1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-21 06:09:42 +02:00
documize/app/app/components/document/document-toolbar.js

71 lines
1.6 KiB
JavaScript
Raw Normal View History

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: [],
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: {
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-07-08 16:08:23 -07:00
}
});