diff --git a/app/app/components/document/document-page.js b/app/app/components/document/document-page.js index 1c2e34b6..f5499723 100644 --- a/app/app/components/document/document-page.js +++ b/app/app/components/document/document-page.js @@ -21,9 +21,17 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { didReceiveAttrs() { this._super(...arguments); + if (this.get('isDestroyed') || this.get('isDestroying')) { + return; + } + let page = this.get('page'); this.get('documentService').getPageMeta(page.get('documentId'), page.get('id')).then((meta) => { + if (this.get('isDestroyed') || this.get('isDestroying')) { + return; + } + this.set('meta', meta); if (this.get('toEdit') === this.get('page.id') && this.get('isEditor')) { this.send('onEdit'); diff --git a/app/app/components/document/document-view.js b/app/app/components/document/document-view.js index 565e4f08..b8ef00bc 100644 --- a/app/app/components/document/document-view.js +++ b/app/app/components/document/document-view.js @@ -23,7 +23,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { appMeta: Ember.inject.service(), link: Ember.inject.service(), hasPages: computed.notEmpty('pages'), - newSectionName: '', + newSectionName: 'Section', newSectionNameMissing: computed.empty('newSectionName'), newSectionLocation: '', beforePage: '', @@ -51,13 +51,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { didInsertElement() { this._super(...arguments); - $(".start-section:not(.start-section-empty-state)").hoverIntent({interval: 100, over: function() { - // in - $(this).find('.start-button').velocity("transition.slideDownIn", {duration: 300}); - }, out: function() { - // out - $(this).find('.start-button').velocity("transition.slideUpOut", {duration: 300}); - } }); + this.setupAddWizard(); let self = this; $(".tooltipped").each(function(i, el) { @@ -67,6 +61,8 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { willDestroyElement() { this._super(...arguments); + + $('.start-section:not(.start-section-empty-state)').off('.hoverIntent'); this.destroyTooltips(); }, @@ -105,6 +101,20 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { }); }, + setupAddWizard() { + Ember.run.schedule('afterRender', () => { + $('.start-section:not(.start-section-empty-state)').off('.hoverIntent'); + + $('.start-section:not(.start-section-empty-state)').hoverIntent({interval: 100, over: function() { + // in + $(this).find('.start-button').velocity("transition.slideDownIn", {duration: 300}); + }, out: function() { + // out + $(this).find('.start-button').velocity("transition.slideUpOut", {duration: 300}); + } }); + }); + }, + addSection(model) { // calculate sequence of page (position in document) let sequence = 0; @@ -172,10 +182,10 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { }, onSavePage(page, meta) { + this.set('toEdit', ''); this.attrs.onSavePage(page, meta); }, - // Section wizard related onShowSectionWizard(page) { if (is.undefined(page)) { page = { id: '0' }; @@ -200,7 +210,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { } $("#new-section-wizard").insertAfter(`#add-section-button-${page.id}`); - $("#new-section-wizard").velocity("transition.slideDownIn", {duration: 300, complete: + $("#new-section-wizard").velocity("transition.slideDownIn", { duration: 300, complete: function() { $("#new-section-name").focus(); }}); @@ -209,6 +219,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { onHideSectionWizard() { this.set('newSectionLocation', ''); this.set('beforePage', null); + $("#new-section-wizard").insertAfter('#wizard-placeholder'); $("#new-section-wizard").velocity("transition.slideUpOut", { duration: 300 }); }, @@ -251,6 +262,8 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { } else { this.set('toEdit', ''); } + + this.setupAddWizard(); }); }, @@ -289,12 +302,8 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { const promise = this.addSection(model); promise.then((id) => { this.set('pageId', id); - - // if (model.page.pageType === 'section') { - // this.set('toEdit', id); - // } else { - // this.set('toEdit', ''); - // } + + this.setupAddWizard(); }); }, diff --git a/app/app/components/ui-select.js b/app/app/components/ui-select.js index 6e61bf03..52075dee 100644 --- a/app/app/components/ui-select.js +++ b/app/app/components/ui-select.js @@ -17,7 +17,8 @@ export default Ember.Component.extend({ prompt: null, optionValuePath: 'id', optionLabelPath: 'name', - action: Ember.K, // action to fire on change + action() {}, // action to fire on change + // action: Ember.K, // action to fire on change // shadow the passed-in `selection` to avoid // leaking changes to it via a 2-way binding diff --git a/app/app/pods/document/index/controller.js b/app/app/pods/document/index/controller.js index fd553e12..2830f54b 100644 --- a/app/app/pods/document/index/controller.js +++ b/app/app/pods/document/index/controller.js @@ -113,11 +113,7 @@ export default Ember.Controller.extend(NotifierMixin, { } this.set('model.pages', _.sortBy(pages, "sequence")); - this.transitionToRoute('document.index', - this.get('model.folder.id'), - this.get('model.folder.slug'), - this.get('model.document.id'), - this.get('model.document.slug')); + this.get('target.router').refresh(); }); } else { // page delete followed by re-leveling child pages diff --git a/app/app/templates/components/document/document-view.hbs b/app/app/templates/components/document/document-view.hbs index 32011640..6ac64126 100644 --- a/app/app/templates/components/document/document-view.hbs +++ b/app/app/templates/components/document/document-view.hbs @@ -1,4 +1,5 @@
+ {{#if hasPages}} {{#each pages key="id" as |page index|}} {{#if isEditor}} @@ -47,6 +48,8 @@ {{/if}} {{/if}} +
+
{{input type="text" id="new-section-name" value=newSectionName class=(if newSectionNameMissing 'section-name error-inline' 'section-name') placeholder="Name" autocomplete="off"}} @@ -94,4 +97,5 @@ {{/if}}
+
diff --git a/app/app/templates/components/document/page-heading.hbs b/app/app/templates/components/document/page-heading.hbs index c59c1636..acc191f0 100644 --- a/app/app/templates/components/document/page-heading.hbs +++ b/app/app/templates/components/document/page-heading.hbs @@ -24,7 +24,7 @@

Are you sure you want to delete {{page.title}}?

{{input type="checkbox" id=checkId class="margin-left-20" checked=deleteChildren}} - +

{{/dropdown-dialog}} {{#dropdown-dialog id=publishDialogId target=publishButtonId position="bottom right" button="Publish" color="flat-green" focusOn=blockTitleId onAction=(action 'onSavePageAsBlock')}} diff --git a/app/app/templates/components/document/tab-heading.hbs b/app/app/templates/components/document/tab-heading.hbs index 18e07ff8..3dcb12df 100644 --- a/app/app/templates/components/document/tab-heading.hbs +++ b/app/app/templates/components/document/tab-heading.hbs @@ -37,7 +37,7 @@

Are you sure you want to delete {{page.title}}?

{{input type="checkbox" id=checkId class="margin-left-20" checked=deleteChildren}} - +

{{/dropdown-dialog}} {{#dropdown-dialog id=publishDialogId target=publishButtonId position="bottom right" button="Publish" color="flat-green" focusOn=blockTitleId onAction=(action 'onSavePageAsBlock')}}