Mathijs den Burger pushed to branch feature/CHANNELMGR-1660 at cms-community / hippo-addon-channel-manager
Commits: 3d2e3c4b by Mathijs den Burger at 2018-01-12T14:41:10+01:00 CHANNELMGR-1660 Fix savePendingChanges (missing DialogService) $timeout is not used anymore, so remove it. - - - - - beeee5de by Mathijs den Burger at 2018-01-12T15:11:24+01:00 CHANNELMGR-1660 Confirm pending changes when exiting edit-content - - - - - 3 changed files: - frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/contentEditor.controller.js - frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/contentEditor.service.js - frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContentMain.controller.js Changes: ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/contentEditor.controller.js ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/contentEditor.controller.js +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/contentEditor.controller.js @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 Hippo B.V. (http://www.onehippo.com) + * Copyright 2018 Hippo B.V. (http://www.onehippo.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,10 +40,6 @@ class ContentEditorCtrl { getError() { return this.ContentEditor.getError(); } - - uiCanExit() { - return this.ContentEditor.confirmPendingChanges('SAVE_CHANGES_ON_BLUR_MESSAGE'); - } } export default ContentEditorCtrl; ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/contentEditor.service.js ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/contentEditor.service.js +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/contentEditor.service.js @@ -55,14 +55,14 @@ const ERROR_MAP = { }; class ContentEditorService { - constructor($q, $timeout, $translate, CmsService, ContentService, FeedbackService, FieldService) { + constructor($q, $translate, CmsService, ContentService, DialogService, FeedbackService, FieldService) { 'ngInject'; this.$q = $q; - this.$timeout = $timeout; this.$translate = $translate; this.CmsService = CmsService; this.ContentService = ContentService; + this.DialogService = DialogService; this.FeedbackService = FeedbackService; this.FieldService = FieldService; } @@ -228,13 +228,20 @@ class ContentEditorService { }); } + /** + * Possible return values: + * - resolved promise with value 'true' when changes have been saved + * - resolved promise with value 'false' when changes have been discarded + * - rejected promise when user canceled + */ confirmPendingChanges(messageKey) { return this._confirmSaveOrDiscardChanges(messageKey) .then((action) => { if (action === 'SAVE') { - return this._saveDraft(); + return this._saveDraft() + .then(() => true); // let caller know that changes have been saved } - return this.$q.resolve(); + return this.$q.resolve(false); // let caller know that changes have not been saved }); } ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContentMain.controller.js ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContentMain.controller.js +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContentMain.controller.js @@ -54,6 +54,17 @@ class EditContentMainCtrl { }); } + uiCanExit() { + return this.ContentEditor.confirmPendingChanges('SAVE_CHANGES_ON_BLUR_MESSAGE') + .then((saved) => { + if (saved) { + this.HippoIframeService.reload(); + } + return this.ContentEditor.deleteDraft() + .then(() => this.ContentEditor.close()); + }); + } + closeButtonLabel() { return this.isDocumentDirty() ? this.cancelLabel : this.closeLabel; } View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/8535a28c764f2e615eb2c3ef16fffcf077713235...beeee5de6143dedea2eed1970b5f5556244294df --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/compare/8535a28c764f2e615eb2c3ef16fffcf077713235...beeee5de6143dedea2eed1970b5f5556244294df You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn