1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-23 15:19:42 +02:00
This commit is contained in:
Harvey Kandola 2016-10-24 19:20:29 -07:00
parent 7db618dea0
commit 4a17acce11
19 changed files with 322 additions and 203 deletions

View file

@ -0,0 +1,74 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
import TooltipMixin from '../../mixins/tooltip';
const {
inject: { service }
} = Ember;
export default Ember.Component.extend(TooltipMixin, {
link: service(),
hasSections: false,
hasAttachments: false,
linkName: '',
keywords: '',
selection: null,
init() {
this._super(...arguments);
let self = this;
let documentId = this.get('document.id');
let pageId = this.get('page.id');
this.get('link').getCandidates(documentId, pageId).then(function (candidates) {
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);
});
},
didRender() {
this.addTooltip(document.getElementById("content-linker-button"));
},
willDestroyElement() {
this.destroyTooltips();
},
actions: {
setSelection(i) {
this.set('selection', i);
let candidates = this.get('candidates');
candidates.pages.forEach(c => {
Ember.set(c, 'selected', c.id === i.id);
});
candidates.attachments.forEach(c => {
Ember.set(c, 'selected', c.id === i.id);
});
},
onInsertLink() {
let selection = this.get('selection');
if (is.null(selection)) {
return;
}
return this.get('onInsertLink')(selection);
}
}
});