Arthur Bogaart pushed to branch feature/CC-CHANNELMGR-1480 at cms-community / hippo-addon-channel-manager
Commits: 67bc6477 by Arthur Bogaart at 2017-10-23T10:49:06+02:00 CHANNELMGR-1480 Simplify rightSidePanel logic for switching between edit&create - - - - - 2 changed files: - frontend-ng/src/app/channel/sidePanels/rightSidePanel/rightSidePanel.controller.js - frontend-ng/src/app/channel/sidePanels/rightSidePanel/rightSidePanel.html Changes: ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/rightSidePanel.controller.js ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/rightSidePanel.controller.js +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/rightSidePanel.controller.js @@ -44,16 +44,7 @@ class RightSidePanelCtrl { SidePanelService.initialize('right', $element.find('.right-side-panel'), // onOpen - (type, options) => { - if (type === 'edit') { - this._openEditContent(options); - } else if (type === 'create') { - this._openCreateContent(options); - } else { - throw new Error(`Failed to open rightside panel component with type ${type}`); - } - this._onOpen(); - }, + (type, options) => this._onOpen(type, options), // onClose () => this._onClose()); } @@ -63,36 +54,24 @@ class RightSidePanelCtrl { this.lastSavedWidth = this.localStorageService.get('rightSidePanelWidth') || '440px'; } - _openEditContent(documentId) { - if (this.documentId === documentId) { - return; - } - - this.beforeStateChange().then(() => { - this._resetState(); - if (documentId) { - this.documentId = documentId; - this.editing = true; - } else { - this.createContent = true; - } - }); + _openEditContent(options) { + this.editing = true; + this.options = options; } _openCreateContent(options) { - this._resetState(); + this.creating = true; this.options = options; - this.create = true; this.title = this.$translate.instant('NEW_CONTENT'); } onBeforeStateChange(callback) { this.beforeStateChange = callback; } + _resetState() { - delete this.documentId; delete this.editing; - delete this.create; + delete this.creating; delete this.options; this._resetBeforeStateChange(); } @@ -105,10 +84,21 @@ class RightSidePanelCtrl { return this.SidePanelService.isOpen('right'); } - _onOpen() { - this.$element.addClass('sidepanel-open'); - this.$element.css('width', this.lastSavedWidth); - this.$element.css('max-width', this.lastSavedWidth); + _onOpen(type, options) { + this.beforeStateChange().then(() => { + this._resetState(); + if (type === 'edit') { + this._openEditContent(options); + } else if (type === 'create') { + this._openCreateContent(options); + } else { + throw new Error(`Failed to open rightside panel component with type ${type}`); + } + + this.$element.addClass('sidepanel-open'); + this.$element.css('width', this.lastSavedWidth); + this.$element.css('max-width', this.lastSavedWidth); + }); } _onClose() { ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/rightSidePanel.html ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/rightSidePanel.html +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/rightSidePanel.html @@ -25,12 +25,12 @@ ng-if="!RightSidePanelCtrl.isFullWidth"> </resize-handle> <hippo-edit-content ng-if="RightSidePanelCtrl.editing" flex layout="column" - requested-document="RightSidePanelCtrl.documentId" + requested-document="RightSidePanelCtrl.options" on-full-width="RightSidePanelCtrl.setFullWidth(state)" on-close="RightSidePanelCtrl.closePanel()" on-before-state-change="RightSidePanelCtrl.onBeforeStateChange(callback)"> </hippo-edit-content> - <hippo-create-content ng-if="RightSidePanelCtrl.create" + <hippo-create-content ng-if="RightSidePanelCtrl.creating" [options]="RightSidePanelCtrl.options" (on-close)="RightSidePanelCtrl.closePanel()" (on-continue)="angular.noop()"> View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/67bc64775c50fae712b230623c5f3587ee06a924 --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/67bc64775c50fae712b230623c5f3587ee06a924 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