Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editing - Show the previous form when the user cancel current editing #5121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions assets/src/legacy/edition.js
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,16 @@ var lizEdition = function() {
return false;
}

/**
* Sleep function
* @param {number} sleepDuration Duration to wait (milliseconds)
* @returns {Promise}
*/
const editingDelay = sleepDuration => new Promise((resolve, reject) => {
setTimeout(_ => resolve(), sleepDuration)
});


/**
*
*/
Expand Down Expand Up @@ -909,14 +919,23 @@ var lizEdition = function() {
}
});

$('#edition-draw').click(function(){
$('#edition-draw').click(async function(){
// Do nothing if not enabled
if ( $(this).hasClass('disabled') )
return false;
// Deactivate previous edition
if( lizMap.editionPending){
if ( !confirm( lizDict['edition.confirm.cancel'] ) )
// Show editing dock
document.querySelector('li.edition:not(.active) #button-edition')?.click();

// Display a confirmation message
// We need to add a delay in order to show the editing dock
// If not the confirm message is displayed before the editing dock is shown
await editingDelay(10);
if ( !confirm( lizDict['edition.confirm.cancel'] ) ) {
return false;
}

finishEdition();
editionLayer.clear();
}
Expand Down Expand Up @@ -1327,20 +1346,31 @@ var lizEdition = function() {
return internalLaunchEdition(parentInfo, parentFeat.id.split('.').pop());
}


/**
*
* @param {FeatureEditionData} editedFeature
* @param aFid
* @param {Function} aCallback
* @returns {boolean}
*/
function internalLaunchEdition(editedFeature, aFid, aCallback) {
async function internalLaunchEdition(editedFeature, aFid, aCallback) {

// Deactivate previous edition when the feature to edit has no
// relation to the current edited feature
if (lizMap.editionPending) {
if ( !confirm( lizDict['edition.confirm.cancel'] ) )
// Show editing dock
document.querySelector('li.edition:not(.active) #button-edition')?.click();

// Display a confirmation message
// We need to add a delay in order to show the editing dock
// If not the confirm message is displayed before the editing dock is shown
await editingDelay(10);
if ( !confirm( lizDict['edition.confirm.cancel'] ) ) {
return false;
}

// Finish editing
finishEdition();
}

Expand Down
Loading