if user discards a new block it should be removed.
This commit is contained in:
committed by
Sebastiaan Janssen
parent
fa4809a288
commit
3f99972ebb
@@ -7,8 +7,8 @@ angular.module("umbraco")
|
||||
vm.tabs = [];
|
||||
|
||||
localizationService.localizeMany([
|
||||
vm.model.liveEditing ? "prompt_discardChanges" : "general_close",
|
||||
vm.model.liveEditing ? "buttons_confirmActionConfirm" : "buttons_submitChanges"
|
||||
vm.model.createFlow ? "general_cancel" : (vm.model.liveEditing ? "prompt_discardChanges" : "general_close"),
|
||||
vm.model.createFlow ? "general_create" : (vm.model.liveEditing ? "buttons_confirmActionConfirm" : "buttons_submitChanges")
|
||||
]).then(function (data) {
|
||||
vm.closeLabel = data[0];
|
||||
vm.submitLabel = data[1];
|
||||
@@ -68,16 +68,16 @@ angular.module("umbraco")
|
||||
// * It would have a 'commit' method to commit the removed errors - which we would call in the formHelper.submitForm when it's successful
|
||||
// * It would have a 'rollback' method to reset the removed errors - which we would call here
|
||||
|
||||
|
||||
if (vm.blockForm.$dirty === true) {
|
||||
localizationService.localizeMany(["prompt_discardChanges", "blockEditor_blockHasChanges"]).then(function (localizations) {
|
||||
if (vm.model.createFlow === true || vm.blockForm.$dirty === true) {
|
||||
var labels = vm.model.createFlow === true ? ["blockEditor_confirmCancelBlockCreationHeadline", "blockEditor_confirmCancelBlockCreationMessage"] : ["prompt_discardChanges", "blockEditor_blockHasChanges"];
|
||||
localizationService.localizeMany(labels).then(function (localizations) {
|
||||
const confirm = {
|
||||
title: localizations[0],
|
||||
view: "default",
|
||||
content: localizations[1],
|
||||
submitButtonLabelKey: "general_discard",
|
||||
submitButtonStyle: "danger",
|
||||
closeButtonLabelKey: "general_cancel",
|
||||
closeButtonLabelKey: "prompt_stay",
|
||||
submit: function () {
|
||||
overlayService.close();
|
||||
vm.model.close(vm.model);
|
||||
@@ -88,11 +88,10 @@ angular.module("umbraco")
|
||||
};
|
||||
overlayService.open(confirm);
|
||||
});
|
||||
|
||||
return;
|
||||
} else {
|
||||
vm.model.close(vm.model);
|
||||
}
|
||||
// TODO: check if content/settings has changed and ask user if they are sure.
|
||||
vm.model.close(vm.model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -326,7 +326,9 @@
|
||||
blockObject.active = true;
|
||||
}
|
||||
|
||||
function editBlock(blockObject, openSettings, blockIndex, parentForm) {
|
||||
function editBlock(blockObject, openSettings, blockIndex, parentForm, options) {
|
||||
|
||||
options = options || {};
|
||||
|
||||
// this must be set
|
||||
if (blockIndex === undefined) {
|
||||
@@ -360,6 +362,7 @@
|
||||
$parentForm: parentForm || vm.propertyForm, // pass in a $parentForm, this maintains the FormController hierarchy with the infinite editing view (if it contains a form)
|
||||
hideContent: blockObject.hideContentInOverlay,
|
||||
openSettings: openSettings === true,
|
||||
createFlow: options.createFlow === true,
|
||||
liveEditing: liveEditing,
|
||||
title: blockObject.label,
|
||||
view: "views/common/infiniteeditors/blockeditor/blockeditor.html",
|
||||
@@ -374,15 +377,17 @@
|
||||
blockObject.active = false;
|
||||
editorService.close();
|
||||
},
|
||||
close: function() {
|
||||
|
||||
if (liveEditing === true) {
|
||||
// revert values when closing in liveediting mode.
|
||||
blockObject.retrieveValuesFrom(blockContentClone, blockSettingsClone);
|
||||
}
|
||||
|
||||
if (wasNotActiveBefore === true) {
|
||||
blockObject.active = false;
|
||||
close: function(blockEditorModel) {
|
||||
if (blockEditorModel.createFlow) {
|
||||
deleteBlock(blockObject);
|
||||
} else {
|
||||
if (liveEditing === true) {
|
||||
// revert values when closing in liveediting mode.
|
||||
blockObject.retrieveValuesFrom(blockContentClone, blockSettingsClone);
|
||||
}
|
||||
if (wasNotActiveBefore === true) {
|
||||
blockObject.active = false;
|
||||
}
|
||||
}
|
||||
editorService.close();
|
||||
}
|
||||
@@ -448,7 +453,7 @@
|
||||
if (inlineEditing === true) {
|
||||
activateBlock(vm.layout[createIndex].$block);
|
||||
} else if (inlineEditing === false && vm.layout[createIndex].$block.hideContentInOverlay !== true) {
|
||||
editBlock(vm.layout[createIndex].$block, false, createIndex, blockPickerModel.$parentForm);
|
||||
editBlock(vm.layout[createIndex].$block, false, createIndex, blockPickerModel.$parentForm, {createFlow: true});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user