2016-07-07 18:54:16 -07:00
|
|
|
// 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 NotifierMixin from '../../mixins/notifier';
|
|
|
|
import TooltipMixin from '../../mixins/tooltip';
|
|
|
|
|
|
|
|
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
2016-07-08 16:08:23 -07:00
|
|
|
appMeta: Ember.inject.service(),
|
|
|
|
userService: Ember.inject.service('user'),
|
|
|
|
localStorage: Ember.inject.service(),
|
|
|
|
drop: null,
|
|
|
|
users: [],
|
2016-11-08 16:10:19 -08:00
|
|
|
menuOpen: false,
|
2016-07-08 16:08:23 -07:00
|
|
|
saveTemplate: {
|
|
|
|
name: "",
|
|
|
|
description: ""
|
|
|
|
},
|
2016-07-07 18:54:16 -07:00
|
|
|
|
|
|
|
didReceiveAttrs() {
|
|
|
|
this.set('saveTemplate.name', this.get('document.name'));
|
|
|
|
this.set('saveTemplate.description', this.get('document.excerpt'));
|
|
|
|
},
|
|
|
|
|
2016-07-08 16:08:23 -07:00
|
|
|
willDestroyElement() {
|
|
|
|
this.destroyTooltips();
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2016-11-08 16:10:19 -08:00
|
|
|
onMenuOpen() {
|
|
|
|
this.set('menuOpen', !this.get('menuOpen'));
|
|
|
|
},
|
|
|
|
|
2016-07-07 18:54:16 -07:00
|
|
|
deleteDocument() {
|
|
|
|
this.attrs.onDocumentDelete();
|
2016-07-08 16:08:23 -07:00
|
|
|
},
|
2016-07-07 18:54:16 -07:00
|
|
|
|
|
|
|
printDocument() {
|
|
|
|
window.print();
|
2016-07-08 16:08:23 -07:00
|
|
|
},
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-07-08 16:08:23 -07:00
|
|
|
saveTemplate() {
|
|
|
|
var name = this.get('saveTemplate.name');
|
|
|
|
var excerpt = this.get('saveTemplate.description');
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-07-08 16:08:23 -07:00
|
|
|
if (is.empty(name)) {
|
|
|
|
$("#new-template-name").addClass("error").focus();
|
|
|
|
return false;
|
|
|
|
}
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-07-08 16:08:23 -07:00
|
|
|
if (is.empty(excerpt)) {
|
|
|
|
$("#new-template-desc").addClass("error").focus();
|
|
|
|
return false;
|
|
|
|
}
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-07-08 16:08:23 -07:00
|
|
|
this.showNotification('Template saved');
|
|
|
|
this.attrs.onSaveTemplate(name, excerpt);
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-07-08 16:08:23 -07:00
|
|
|
return true;
|
2016-11-08 16:10:19 -08:00
|
|
|
}
|
2016-07-08 16:08:23 -07:00
|
|
|
}
|
2016-10-05 15:44:44 -07:00
|
|
|
});
|