how to validate in assets dam properties? | Community
Skip to main content
amangoyal15
Level 3
January 3, 2017

how to validate in assets dam properties?

  • January 3, 2017
  • 3 replies
  • 4617 views

I need to validate in asset dam properties.

I took reference from https://helpx.adobe.com/experience-manager/using/creating-touchui-validate.html 

 

Code Snippet - 

$(document).on("click", ".aem-assets-admin-properties-submit", function (e) {

        e.stopPropagation();
        e.preventDefault();
      ddlOrderValue = $("#ddlChar option:selected").val();

    if(typeof ddlOrderValue == "string" && typeof primaryBVTag == "string" && typeof primarySLTag == "string"){
          var ddlOrderValueCheck  = ddlOrderValue.substring(ddlOrderValue.lastIndexOf("/")+1);
          var primaryBVTagCheck  = primaryBVTag.substring(primaryBVTag.lastIndexOf("/")+1);
          var primarySLTagCheck  = primarySLTag.substring(primarySLTag.lastIndexOf("/")+1);
      }


        if( (($('#setcontentownerid').hasClass("hide")) == false ) && (ddlOrderValueCheck == '') || ( primaryBVTagCheck == '' &&  primarySLTagCheck == '') ||             ((ddlOrderValueCheck != primaryBVTagCheck) && (ddlOrderValueCheck != primarySLTagCheck)) ) {
                alert("Check your Inputs");
              ns.ui.helpers.prompt({
                title: Granite.I18n.get("Invalid Input"),
                message: "Please Enter valid Inputs",
                actions: [{
                    id: "CANCEL",
                    text: "CANCEL",
                    className: "coral-Button"
                }],
            callback: function (actionId) {
                if (actionId === "CANCEL") {
                }
            }
        });

        }else{
            alert("else");

                createNewTags($(".data-fields.active form")).done(function(){
                var form = $('.data-fields.active form');
                alert("else aem-submit -createNewTags");
                handleResponse(form, submitForm(form));
            }).fail(function(response){
                var modal = $('#aem-assets-metadataedit-error');
                var body = Granite.I18n.get('Unable to create new tags. Check for access privileges to create tags.');
                modal.find(".coral-Modal-body").html('<p>' + body + '</p>');
                modal.modal("show");
            });
            alert("end of else");
          }

    }); 


// -----------------------------------------------------------------------------------------------------------------------   
    function createNewTags (form) {
        return $.when.apply(null, form.find('[data-metatype="tags"].coral-PathBrowser+ul.coral-TagList input[type="hidden"][name]').map(function() {
            var el = this;

            if (el.value.indexOf(":") >= 0) return;

            var tenantId = $(".foundation-form.mode-edit").attr("tenant-id");
            el.value = tenantId ? ("mac:" + tenantId + "/default/" + el.previousElementSibling.textContent ) : el.previousElementSibling.textContent;
            return createSingleTag(el.value).then(function(tag) {
                // Fix tag name in select element
                var tenantId = $(".foundation-form.mode-edit").attr("tenant-id");
                if (!tenantId) {
                    // Fix tag name in select element
                    el.value = tag;
                }
            });
        }));
    }

I am getting error because of ns.ui.helper.prompt({     });  , error in browser console is -

Uncaught TypeError: Cannot read property 'ui' of undefined
    at HTMLButtonElement.<anonymous> (clientlib-assetspropertiesdialog.js:287)
    at HTMLDocument.dispatch (jquery.js:4665)
    at HTMLDocument.elemData.handle (jquery.js:4333)

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

kautuk_sahni
Community Manager
Community Manager
January 4, 2017

Hi

Moving this post to AEM "Assets" topic so that contextual experts can help you.

~kautuk

Kautuk Sahni
smacdonald2008
Level 10
December 15, 2017

The article you mentioned is about how to validate fields in a component dialog.  Has nothing to do with Assets.

Adobe Employee
December 15, 2017

Can you make sure "ns" is defined? Or can you share the complete code?

edubey
Level 10
December 15, 2017

please mention aem version