Merge pull request #7140 from lasniscinote/gl_SCI_10004

(fix) Add warning for unsaved changes when leaving Task workflow editmode (Canvas view) [SCI-10004]
This commit is contained in:
ajugo 2024-03-04 10:45:18 +01:00 committed by GitHub
commit 9299cb7a52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -545,6 +545,35 @@ function bindTouchDropdowns(selector) {
});
}
function handleAnchorClick(event) {
event.preventDefault();
// check if the clicked element is an anchor tag with an href
if (event.target.tagName === 'A' && event.target.href) {
const targetUrl = event.target.href;
const alertText = $("#update-canvas").attr("data-unsaved-work-text");
const exit = confirm(alertText);
if (exit) {
// remove unload listeners and navigate to location
$(window).off("beforeunload");
$(document).off("page:before-change");
window.location.href = targetUrl;
}
}
};
// listen to clicks on links in navigator and leftMenuContainer
$(document).ready(function() {
const navigatorEl = $('.sci--layout-navigation-navigator');
const leftMenuContainerEl = $('.sci--layout--left-menu-container');
navigatorEl.on('click', 'a', handleAnchorClick);
leftMenuContainerEl.on('click', 'a', handleAnchorClick);
});
function bindEditModeCloseWindow() {
var alertText = $("#update-canvas").attr("data-unsaved-work-text");