diff --git a/gui/app/components/document/content-linker.js b/gui/app/components/document/content-linker.js index 43d217db..53ff9e08 100644 --- a/gui/app/components/document/content-linker.js +++ b/gui/app/components/document/content-linker.js @@ -10,7 +10,7 @@ // https://documize.com import { debounce } from '@ember/runloop'; -import { computed, set, observer } from '@ember/object'; +import { computed, set } from '@ember/object'; import { inject as service } from '@ember/service'; import stringUtil from '../../utils/string'; import ModalMixin from '../../mixins/modal'; @@ -35,7 +35,19 @@ export default Component.extend(ModalMixin, { }), modalId: computed('page', function() { return '#content-linker-modal-' + this.get('page.id'); }), showModal: false, - onToggle: observer('showModal', function() { + + init() { + this._super(...arguments); + this.matches = { + documents: [], + pages: [], + attachments: [] + }; + }, + + didReceiveAttrs() { + this._super(...arguments); + let modalId = this.get('modalId'); if (!this.get('showModal')) { @@ -52,18 +64,20 @@ export default Component.extend(ModalMixin, { self.set('candidates', candidates); self.set('hasSections', is.not.null(candidates.pages) && candidates.pages.length); self.set('hasAttachments', is.not.null(candidates.attachments) && candidates.attachments.length); + + if (!self.get('hasSections') && !self.get('hasAttachments')) { + self.set('tab1Selected', false); + self.set('tab2Selected', false); + self.set('tab3Selected', true); + self.set('tab4Selected', false); + } }); this.modalOpen(modalId, {show: true}); - }), - init() { - this._super(...arguments); - this.matches = { - documents: [], - pages: [], - attachments: [] - }; + this.modalOnHide(modalId, () => { + this.set('showModal', false); + }); }, didRender() { @@ -74,13 +88,10 @@ export default Component.extend(ModalMixin, { willDestroyElement() { this._super(...arguments); + this.set('showModal', false); this.modalClose(this.get('modalId')); }, - onKeywordChange: observer('keywords', function() { - debounce(this, this.fetch, 750); - }), - fetch() { let keywords = this.get('keywords'); let self = this; @@ -96,6 +107,10 @@ export default Component.extend(ModalMixin, { }, actions: { + onSearch() { + debounce(this, this.fetch, 750); + }, + setSelection(i) { let candidates = this.get('candidates'); let matches = this.get('matches'); diff --git a/gui/app/components/document/view-content.js b/gui/app/components/document/view-content.js index 748c486f..9cb8623f 100644 --- a/gui/app/components/document/view-content.js +++ b/gui/app/components/document/view-content.js @@ -37,6 +37,7 @@ export default Component.extend(Notifier, { didReceiveAttrs() { this._super(...arguments); + this.set('showLikes', this.get('folder.allowLikes') && this.get('document.isLive')); }, @@ -44,6 +45,10 @@ export default Component.extend(Notifier, { this._super(...arguments); this.jumpToSection(this.get('currentPageId')); + }, + + didRender() { + this._super(...arguments); this.contentLinkHandler(); }, diff --git a/gui/app/components/section/base-editor-inline.js b/gui/app/components/section/base-editor-inline.js index 72a21f7d..60a16863 100644 --- a/gui/app/components/section/base-editor-inline.js +++ b/gui/app/components/section/base-editor-inline.js @@ -60,6 +60,7 @@ export default Component.extend(ModalMixin, { willDestroyElement() { this._super(...arguments); + this.set('showLinkModal', false); let mousetrap = this.get('mousetrap'); if (is.not.null(mousetrap)) { diff --git a/gui/app/templates/components/document/content-linker.hbs b/gui/app/templates/components/document/content-linker.hbs index 3d61a58e..d7a496f1 100644 --- a/gui/app/templates/components/document/content-linker.hbs +++ b/gui/app/templates/components/document/content-linker.hbs @@ -46,7 +46,7 @@