Mathijs den Burger pushed to branch feature/CHANNELMGR-1660 at cms-community / hippo-addon-channel-manager
Commits: b4762e73 by Mathijs den Burger at 2018-01-12T10:28:44+01:00 CHANNELMGR-1660 Delete draft before viewing content in the other editor - - - - - 2 changed files: - frontend-ng/src/app/channel/sidePanels/rightSidePanel/contentEditor/contentEditor.service.js - frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContentTools.controller.js Changes: ===================================== 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 @@ -259,22 +259,14 @@ class ContentEditorService { }); } - closeAndDeleteDraft() { - this._deleteDraft(); - this._clear(); - } - - closeAndKeepDraft() { - this._clear(); - } - - _deleteDraft() { + deleteDraft() { if (this.isEditing()) { - this.ContentService.deleteDraft(this.document.id); + return this.ContentService.deleteDraft(this.document.id); } + return this.$q.resolve(); } - _clear() { + close() { delete this.document; delete this.documentType; delete this.documentDirty; ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContentTools.controller.js ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContentTools.controller.js +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContentTools.controller.js @@ -35,50 +35,31 @@ class EditContentToolsCtrl { openContentEditor(mode) { this.mode = mode; - this.EditContentService.stopEditing(); - - // if (!isPromptUnsavedChanges) { - // this._closePanelAndOpenContent(mode); - // return; - // } - // const messageKey = mode === 'view' - // ? 'SAVE_CHANGES_ON_PUBLISH_MESSAGE' - // : 'SAVE_CHANGES_ON_SWITCH_TO_CONTENT_EDITOR_MESSAGE'; - // - // this._dealWithPendingChanges(messageKey, () => { - // if (mode === 'view') { - // this._deleteDraft().finally(() => this._closePanelAndOpenContent(mode)); - // } else { - // this._closePanelAndOpenContent(mode); - // } - // }); } uiCanExit() { + const documentId = this.ContentEditor.getDocument().id; if (this.mode === 'view') { return this.ContentEditor.confirmPendingChanges('SAVE_CHANGES_ON_PUBLISH_MESSAGE') - .then(() => this._openContent()); + .then(() => this.ContentEditor.deleteDraft()) + .then(() => this._viewContent(documentId)); } else if (this.mode === 'edit') { - this._openContent(); + this._editContent(documentId); } - return this.$q.resolve(); + return true; } - _openContent() { - const documentId = this.ContentEditor.getDocument().id; - - this.CmsService.publish('open-content', documentId, this.mode); - - // The CMS automatically unlocks content that is being viewed, so close the visual editor to reflect that. - // It will will unlock the document if needed, so don't delete the draft here. - this.ContentEditor.closeAndKeepDraft(); + _viewContent(documentId) { + this.CmsService.publish('open-content', documentId, 'view'); + this.ContentEditor.close(); + this.CmsService.reportUsageStatistic('CMSChannelsContentPublish'); + } - if (this.mode === 'view') { - this.CmsService.reportUsageStatistic('CMSChannelsContentPublish'); - } else if (this.mode === 'edit') { - this.CmsService.reportUsageStatistic('CMSChannelsContentEditor'); - } + _editContent(documentId) { + this.CmsService.publish('open-content', documentId, 'edit'); + this.ContentEditor.close(); + this.CmsService.reportUsageStatistic('CMSChannelsContentEditor'); } } View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/b4762e7344a2ab1dafc785303ebab5f10d6c1302 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/b4762e7344a2ab1dafc785303ebab5f10d6c1302 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