Expand my Community achievements bar.

Need to block user input in pathbrowser

Avatar

Level 3

Hi,

In my dialog I have put a pathbrowser field (granite/ui/components/foundation/form/pathbrowser). But I want to block the user from manually entering the path in the field and only choosing the path via the path finder. Is there some property that can be used for this ?

5 Replies

Avatar

Level 10

Here is the doc for this Granite Type: 

https://docs.adobe.com/docs/es/aem/6-1/develop/extending/granite/granite-reference.html#Form Inputs - Pathbrowser

I am not aware of it supporting this functionality - that is blocking a user from selecting a path. After all - this is the purpose of this widget.

Avatar

Level 3

I want to select the path only through the path finder by browsing through the node structure in the repository like /content/geometrixx, I don't want the user to enter the path manually by typing the path (e.g. https://www.google.com).

Avatar

Level 10

Ok - i was not 100% clear in that - you want them to only be able to select the path - not paste it into the control. You need to extend that - see the code posted by nupurj17891248.

Avatar

Community Advisor

Hey Ankush,

I once encountered the same scenario where I didn't want author to enter any input , only allowing him to select the path, I created the javascript for that which I included in "cq.authoring.dialog" clientlib category.

Here is the javascript code sample that can help you :

$(document).on("dialog-ready", function() {    var pathReadonly = function() {        setTimeout(function() {            $(".path-readonly").find(".js-coral-pathbrowser-input").each(function() {                $(this).attr("readonly", "readonly");            });        }, 250);    }    pathReadonly();
});

Add the property "class" with value "path-readonly"  to the dialog node of resourceType ''granite/ui/components/foundation/form/pathbrowser"  and it should work.

Hope this helps!

 

Thanks,

Nupur

Avatar

Level 1

Hi Nupur,

I tried the above approach and getting the below console error, and after this, i am not able to access the authoring dialog. ( even close the dialog or enter any filed values ) can you please help ?

Uncaught TypeError: Cannot read property 'unifySpacing' of undefined

    at transformTo (http://localhost:4502/libs/cq/gui/components/authoring/editors/clientlibs/core.js:20430:29)

    at Object.<anonymous> (http://localhost:4502/libs/cq/gui/components/authoring/editors/clientlibs/core.js:20516:21)

    at Object.<anonymous> (http://localhost:4502/etc.clientlibs/clientlibs/granite/jquery.js:3411:33)

    at fire (http://localhost:4502/etc.clientlibs/clientlibs/granite/jquery.js:3232:31)

    at Object.fireWith [as resolveWith] (http://localhost:4502/etc.clientlibs/clientlibs/granite/jquery.js:3362:7)

    at Object.<anonymous> (http://localhost:4502/etc.clientlibs/clientlibs/granite/jquery.js:3418:41)

    at fire (http://localhost:4502/etc.clientlibs/clientlibs/granite/jquery.js:3232:31)

    at Object.fireWith [as resolveWith] (http://localhost:4502/etc.clientlibs/clientlibs/granite/jquery.js:3362:7)

    at Object.deferred.(anonymous function) [as resolve] (http://localhost:4502/etc.clientlibs/clientlibs/granite/jquery.js:3461:36)

    at HTMLScriptElement.<anonymous> (http://localhost:4502/etc.clientlibs/granite/ui/components/coral/foundation/clientlibs/foundation.js...)