Umbraco 10 - Overriding directive template
a
Hey folks. I have a specific case where the Client wants us to display a custom message on the propertyEditor when user is not part of a specific group Following this tutorial https://umbraco.com/blog/mvp-blog-beyond-umbraco-2-hooking-angularjs-again/ managed to add our own logic behind the umbPropertyEditorDirective. On the screenshot it's possible to see that we are trying to hijack the template with our custom template. What we tried so far: We tried to add editor: { view: "~App_Plugins/path/to/html"} (This didnt work) We also tried what you can see on the screenshot => This approach only works if we remove the async methods, which is not possible since we need to know the user group before changing the template. We tried to hook up a custom controller on the propertyEditor using the ng-controller="MyController" but this also didn't work I'm out of Ideas, can anyone help? https://cdn.discordapp.com/attachments/1228292017021386795/1228292017738747924/image.png?ex=662b8315&is=66190e15&hm=e8c8c190bf70bc6d9318ba0c927849d4bfc961f19aa91f57935e0cb75cf1d9c2&
j
@arthurnassar what message does the client want to display on the property editor? What are they trying to achieve
a
Essentially what the client wants is that Shared properties cannot be edited by certain profiles... Let's suppose the user does not have the languageEditor group, then he wont be able to edit the shared properties (in this case it would be Identifier) So what is currently happening is that All users can edit the shared properties and they can edit it by clicking the edit button. What we want to do is to replace this popup with one that shows a message that the user cannot edit this shared property just like the second screenshot https://cdn.discordapp.com/attachments/1228292017021386795/1228317175249633390/image.png?ex=662b9a83&is=66192583&hm=dcd20ea4ce6d6bfc54262ee5e32635b0e5dcdd533006e4999048842deed31dbc& https://cdn.discordapp.com/attachments/1228292017021386795/1228317175614541824/image.png?ex=662b9a83&is=66192583&hm=546985f6d8a73ae7b772e9ef927d9eaaa0402f77dd958b746533713cbf14c924&
Currently the approach of using the $provide.decorator works fine if we dont use the async calls... But the issue is that we need to do async calls because we need to get the user groups to check whether we should override the template or not.
@JigitalCharlie just to showcase... this is the code that we used to force the editor property override. As you can see it works properly bu it removes the capability of checking the user groups https://cdn.discordapp.com/attachments/1228292017021386795/1228318291144212501/image.png?ex=662b9b8d&is=6619268d&hm=53ab004f817876e9f05f70389a12d581b86a4ed52db6ebcdf59e40895c0c59bf&
One thing to add... I know that from Umbraco 10 onwards this feature is already supported through allowed languages on the users. But this specific client has a custom implementation (that was introduced before Umbraco 10) and he does not want to change it. So essentially what I'm looking for is a way to "hijack" the propertyEditors and add a custom implementation
j
@arthurnassar the reason i ask, because having started my own business now and dealing with these sort of problems, what tends to be better is to a different solution. In this case, upgrading to Umbraco 10, will probably be easier and cheaper than trying to impliment this functionality and then having to upgrade at a later point 🙂
a
They are on Umbraco 10... but they dont want to update this old approach
But I managed to make it work by adding a decorator that hijacks the propertyEditor controller and add custom stuff to the $scope ... Still not sure if this is the best approach tho but it seems to work fine https://cdn.discordapp.com/attachments/1228292017021386795/1228375814211633223/image.png?ex=662bd120&is=66195c20&hm=f80871a8dfe369e592a6df5e15da4cd691f37c87f851a9b4bfa875685f66f62d&
12 Views