diff --git a/app/app/components/document/document-view.js b/app/app/components/document/document-view.js index 0344d6c2..a72eebd5 100644 --- a/app/app/components/document/document-view.js +++ b/app/app/components/document/document-view.js @@ -30,19 +30,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { toEdit: '', didReceiveAttrs() { - this.get('sectionService').getSpaceBlocks(this.get('folder.id')).then((blocks) => { - if (this.get('isDestroyed') || this.get('isDestroying')) { - return; - } - - this.set('blocks', blocks); - this.set('hasBlocks', blocks.get('length') > 0); - - // to test - blocks.forEach((b) => { - b.set('deleteId', `delete-block-button-${b.id}`); - }); - }); + this.loadBlocks(); }, didRender() { @@ -137,17 +125,30 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { this.send('onHideSectionWizard'); this.set('pageId', ''); - const promise = this.get('onInsertSection')(model); - promise.then((id) => { - if (model.page.pageType === 'section') { - this.set('toEdit', id); + return this.get('onInsertSection')(model); + }, + + loadBlocks() { + this.get('sectionService').getSpaceBlocks(this.get('folder.id')).then((blocks) => { + if (this.get('isDestroyed') || this.get('isDestroying')) { + return; } + + this.set('blocks', blocks); + this.set('hasBlocks', blocks.get('length') > 0); + + blocks.forEach((b) => { + b.set('deleteId', `delete-block-button-${b.id}`); + }); }); }, actions: { onSavePageAsBlock(block) { - this.attrs.onSavePageAsBlock(block); + const promise = this.attrs.onSavePageAsBlock(block); + promise.then(() => { + this.loadBlocks(); + }); }, onCopyPage(pageId, documentId) { @@ -231,7 +232,12 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { this.audit.record("added-section-" + page.contentType); - this.addSection(model); + const promise = this.addSection(model); + promise.then((id) => { + if (model.page.pageType === 'section') { + this.set('toEdit', id); + } + }); }, onInsertBlock(block) { @@ -266,12 +272,18 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { this.audit.record("added-content-block-" + block.get('contentType')); + this.addSection(model); }, - // to test onDeleteBlock(id) { - this.attrs.onDeleteBlock(id); - } + const promise = this.attrs.onDeleteBlock(id); + + promise.then(() => { + this.loadBlocks(); + }); + + return true; + } } }); diff --git a/app/app/pods/document/block/route.js b/app/app/pods/document/block/route.js index 43cdf8a4..30f23f85 100644 --- a/app/app/pods/document/block/route.js +++ b/app/app/pods/document/block/route.js @@ -27,5 +27,13 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { document: self.modelFor('document').document, block: self.get('sectionService').getBlock(params.block_id), }); - } + }, + + activate() { + $('body').addClass('background-color-off-white'); + }, + + deactivate() { + $('body').removeClass('background-color-off-white'); + } }); diff --git a/app/app/pods/document/block/template.hbs b/app/app/pods/document/block/template.hbs index 4bfed5af..952cb08f 100644 --- a/app/app/pods/document/block/template.hbs +++ b/app/app/pods/document/block/template.hbs @@ -1 +1,20 @@ -{{document/block-editor document=model.document folder=model.folder block=model.block onCancel=(action 'onCancel') onAction=(action 'onAction')}} +