1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-23 07:09:43 +02:00

per space templates

This commit is contained in:
Harvey Kandola 2017-08-17 09:37:33 +01:00
parent 574139ae21
commit 558d90d2ba
10 changed files with 73 additions and 36 deletions

View file

@ -12,14 +12,13 @@
import Ember from 'ember';
import NotifierMixin from '../../mixins/notifier';
const {
computed,
} = Ember;
export default Ember.Component.extend(NotifierMixin, {
localStorage: Ember.inject.service(),
appMeta: Ember.inject.service(),
templateService: Ember.inject.service('template'),
canEditTemplate: "",
importedDocuments: [],
savedTemplates: [],
@ -27,27 +26,14 @@ export default Ember.Component.extend(NotifierMixin, {
newDocumentName: 'New Document',
newDocumentNameMissing: computed.empty('newDocumentName'),
init() {
this._super(...arguments);
this.get('templateService').getSavedTemplates().then((saved) => {
let emptyTemplate = {
id: "0",
title: "Empty",
description: "An empty canvas for your words",
layout: "doc",
locked: true
};
saved.unshiftObject(emptyTemplate);
this.set('savedTemplates', saved);
});
},
didInsertElement() {
this.setupImport();
},
didReceiveAttrs() {
this.setupTemplates();
},
willDestroyElement() {
if (is.not.null(this.get('drop'))) {
this.get('drop').destroy();
@ -55,6 +41,21 @@ export default Ember.Component.extend(NotifierMixin, {
}
},
setupTemplates() {
let templates = this.get('templates');
let emptyTemplate = {
id: "0",
title: "Empty",
description: "An empty canvas for your words",
layout: "doc",
locked: true
};
templates.unshiftObject(emptyTemplate);
this.set('savedTemplates', templates);
},
setupImport() {
// already done init?
if (is.not.null(this.get('drop'))) {
@ -151,4 +152,3 @@ export default Ember.Component.extend(NotifierMixin, {
},
}
});