-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from documize/content-links
Content links
- Loading branch information
Showing
54 changed files
with
2,489 additions
and
977 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
{ | ||
"predef": [ | ||
"server", | ||
"document", | ||
"window", | ||
"-Promise", | ||
"moment", | ||
"$", | ||
"_", | ||
"is", | ||
"Mousetrap", | ||
"CodeMirror", | ||
"Intercom", | ||
"Materialize", | ||
"tinymce", | ||
"Tether", | ||
"Tooltip", | ||
"Drop", | ||
"Dropzone", | ||
"dragula", | ||
"datetimepicker", | ||
"Waypoint" | ||
], | ||
"browser": true, | ||
"boss": true, | ||
"curly": true, | ||
"debug": false, | ||
"devel": true, | ||
"eqeqeq": true, | ||
"evil": true, | ||
"forin": false, | ||
"immed": false, | ||
"laxbreak": false, | ||
"newcap": true, | ||
"noarg": true, | ||
"noempty": false, | ||
"nonew": false, | ||
"nomen": false, | ||
"onevar": false, | ||
"plusplus": false, | ||
"regexp": false, | ||
"undef": true, | ||
"sub": true, | ||
"strict": false, | ||
"white": false, | ||
"eqnull": true, | ||
"esnext": true, | ||
"unused": true | ||
"predef": [ | ||
"server", | ||
"document", | ||
"window", | ||
"-Promise", | ||
"moment", | ||
"$", | ||
"_", | ||
"is", | ||
"Mousetrap", | ||
"CodeMirror", | ||
"Intercom", | ||
"Materialize", | ||
"tinymce", | ||
"Tether", | ||
"Tooltip", | ||
"Drop", | ||
"Dropzone", | ||
"dragula", | ||
"datetimepicker", | ||
"Waypoint" | ||
], | ||
"browser": true, | ||
"boss": true, | ||
"curly": true, | ||
"debug": false, | ||
"devel": true, | ||
"eqeqeq": true, | ||
"evil": true, | ||
"forin": false, | ||
"immed": false, | ||
"laxbreak": false, | ||
"newcap": true, | ||
"noarg": true, | ||
"noempty": false, | ||
"nonew": false, | ||
"nomen": false, | ||
"onevar": false, | ||
"plusplus": false, | ||
"regexp": false, | ||
"undef": true, | ||
"sub": true, | ||
"strict": false, | ||
"white": false, | ||
"eqnull": true, | ||
"esnext": true, | ||
"unused": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// 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(), | ||
linkName: '', | ||
keywords: '', | ||
selection: null, | ||
matches: { | ||
documents: [], | ||
pages: [], | ||
attachments: [] | ||
}, | ||
tabs: [ | ||
{ label: 'Section', selected: true }, | ||
{ label: 'Attachment', selected: false }, | ||
{ label: 'Search', selected: false } | ||
], | ||
|
||
showSections: Ember.computed('tabs.@each.selected', function () { | ||
return this.get('tabs').findBy('label', 'Section').selected; | ||
}), | ||
showAttachments: Ember.computed('tabs.@each.selected', function () { | ||
return this.get('tabs').findBy('label', 'Attachment').selected; | ||
}), | ||
showSearch: Ember.computed('tabs.@each.selected', function () { | ||
return this.get('tabs').findBy('label', 'Search').selected; | ||
}), | ||
hasMatches: Ember.computed('matches', function () { | ||
let m = this.get('matches'); | ||
return m.documents.length || m.pages.length || m.attachments.length; | ||
}), | ||
|
||
init() { | ||
this._super(...arguments); | ||
let self = this; | ||
|
||
let folderId = this.get('folder.id'); | ||
let documentId = this.get('document.id'); | ||
let pageId = this.get('page.id'); | ||
|
||
this.get('link').getCandidates(folderId, 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")); | ||
this.addTooltip(document.getElementById("content-counter-button")); | ||
}, | ||
|
||
willDestroyElement() { | ||
this.destroyTooltips(); | ||
}, | ||
|
||
onKeywordChange: function () { | ||
Ember.run.debounce(this, this.fetch, 750); | ||
}.observes('keywords'), | ||
|
||
fetch() { | ||
let keywords = this.get('keywords'); | ||
let self = this; | ||
|
||
if (_.isEmpty(keywords)) { | ||
this.set('matches', { documents: [], pages: [], attachments: [] }); | ||
return; | ||
} | ||
|
||
this.get('link').searchCandidates(keywords).then(function (matches) { | ||
self.set('matches', matches); | ||
}); | ||
}, | ||
|
||
actions: { | ||
setSelection(i) { | ||
let candidates = this.get('candidates'); | ||
let matches = this.get('matches'); | ||
|
||
this.set('selection', i); | ||
|
||
candidates.pages.forEach(c => { | ||
Ember.set(c, 'selected', c.id === i.id); | ||
}); | ||
|
||
candidates.attachments.forEach(c => { | ||
Ember.set(c, 'selected', c.id === i.id); | ||
}); | ||
|
||
matches.documents.forEach(c => { | ||
Ember.set(c, 'selected', c.id === i.id); | ||
}); | ||
|
||
matches.pages.forEach(c => { | ||
Ember.set(c, 'selected', c.id === i.id); | ||
}); | ||
|
||
matches.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); | ||
}, | ||
|
||
onTabSelect(tabs) { | ||
this.set('tabs', tabs); | ||
} | ||
} | ||
}); |
Oops, something went wrong.