Rockerby / Umbraco.BackOfficeEditorView

https://marketplace.umbraco.com/package/arjo.umbracobackofficeeditorview
Mozilla Public License 2.0
7 stars 5 forks source link

Can this auto lock turned on automatically when I click the page on the left side tree node? #13

Open caps424 opened 1 week ago

caps424 commented 1 week ago

Instead of clicking a lock icon every time, it would be handy to enable lock mode when I click the page from tree node on the left side.

This below is what I am doing for now but would be great to find out proper way to do that rather than this hack below.

    eventsService.on('editorState.changed', function (e, v) {
        setTimeout(function () {
            document.getElementById("boev_lock-icon-wrapper").click()
        }, 1500)
    });
Rockerby commented 1 week ago

Hey @caps424 - thanks for using the package and raising your feedback.

Sounds like this could be a good feature. I would suspect the best way to do this would be to have it as a configurable option to allow people to turn it on / off as they see fit.

caps424 commented 1 week ago

Hi @Rockerby,

Thanks very much for your reply I didn't really expect to see that fast.

In the meantime I changed my code like below to check if this page is already locked or not. Hope this will help you out to make this great plugin better.

    eventsService.on('editorState.changed', function (e, v) {

        let interval = setInterval(callback, 500);
        function callback() {
            if (document.querySelector("#boev_lock-icon-wrapper") != null) {
                clearInterval(interval);
                setTimeout(function () {
                    if (!document.querySelector("#boev_lock-icon-wrapper").classList.contains("active")) {
                        document.querySelector("#boev_lock-icon-wrapper").click();
                    }
                }, 1500);
            }
        }
    });
Rockerby commented 1 week ago

Awesome, thanks for sharing your code! The plugin does a call to the server to get the initial status of a page when you view it. My thinking was to multi-purpose that call and set it to lock if the setting is set to do so and the page isn't already locked.

caps424 commented 1 week ago

I think the auto lock should unlock the page when user leave the page so other users can edit the page afterward. This is just my suggestion so you probably have a better option than I thought.

Many thanks!

Sonny