[FR] Full page lock screen when another admin is editing an entry #15237
-
Other CMS systems have a full page lock, with a modal that tells admin users when another admin user is actively editing an entry, WordPress example attached. Can this be made possible in Craft CMS, or a hook somehow so that Plugin developers can enable this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Craft doesn’t do this natively because it’s generally safe for two people to be editing the same entry, so long as they’re working on different fields. Craft will show indicators when other authors are on the same entry, with tooltips explaining what they’re doing (#13420), and a notification will appear when the entry has been modified upstream, with a “Reload” button. That said, I just added a JavaScript event for Craft 5.3, which makes it possible to add this feature via a plugin or module: if (Craft::$app->request->getIsCpRequest() && !Craft::$app->request->getAcceptsJson()) {
Craft::$app->view->registerJs(<<<JS
(() => {
const callback = (event) => {
if (event.activity.some(record => record.type === 'edit')) {
const backUrl = Craft.getUrl('entries');
const backIcon = Craft.orientation === 'ltr' ? 'arrow-left' : 'arrow-right';
const modalHtml = `
<div class="modal fitted">
<div class="body">
<p>This entry is being edited by another user.</p>
<a class="btn" href="\${backUrl}" data-icon="\${backIcon}">Go back</a>
</div>
</div>
`;
new Garnish.Modal(modalHtml, {
hideOnEsc: false,
hideOnShadeClick: false,
shadeClass: 'modal-shade dark',
});
Garnish.off(Craft.ElementEditor, 'checkActivity', callback);
}
};
Garnish.on(Craft.ElementEditor, 'checkActivity', callback);
})();
JS);
} With that code in place, edit pages will show an inescapable modal window alerting the user that another user is editing the same entry, the first time that it’s detected that someone is making changes to it. If you want to test that out, you can update to the |
Beta Was this translation helpful? Give feedback.
Craft doesn’t do this natively because it’s generally safe for two people to be editing the same entry, so long as they’re working on different fields. Craft will show indicators when other authors are on the same entry, with tooltips explaining what they’re doing (#13420), and a notification will appear when the entry has been modified upstream, with a “Reload” button.
That said, I just added a JavaScript event for Craft 5.3, which makes it possible to add this feature via a plugin or module: