2017-02-27 17:07:49 +00: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
|
|
|
|
|
2017-11-16 13:28:05 +00:00
|
|
|
import { empty } from '@ember/object/computed';
|
|
|
|
import { inject as service } from '@ember/service';
|
2018-06-15 14:25:05 +01:00
|
|
|
import Notifier from '../../mixins/notifier';
|
2017-11-16 13:28:05 +00:00
|
|
|
import Component from '@ember/component';
|
2017-02-27 17:07:49 +00:00
|
|
|
|
2018-06-15 14:25:05 +01:00
|
|
|
export default Component.extend(Notifier, {
|
|
|
|
documentSvc: service('document'),
|
2017-02-27 17:07:49 +00:00
|
|
|
docName: '',
|
|
|
|
docExcerpt: '',
|
2017-11-16 13:28:05 +00:00
|
|
|
hasNameError: empty('docName'),
|
2017-02-27 17:07:49 +00:00
|
|
|
|
2018-06-15 14:25:05 +01:00
|
|
|
didReceiveAttrs() {
|
|
|
|
this._super(...arguments);
|
2017-03-22 10:24:30 +00:00
|
|
|
|
2018-06-15 14:25:05 +01:00
|
|
|
this.set('docName', this.get('document.name'));
|
|
|
|
this.set('docExcerpt', this.get('document.excerpt'));
|
|
|
|
},
|
2017-02-27 17:07:49 +00:00
|
|
|
|
2018-06-15 14:25:05 +01:00
|
|
|
actions: {
|
2017-03-22 10:24:30 +00:00
|
|
|
onSave() {
|
2018-06-07 14:23:54 +01:00
|
|
|
if (this.get('hasNameError')) return;
|
2018-06-25 19:39:32 +01:00
|
|
|
if (!this.get('permissions.documentEdit')) return;
|
2018-06-15 14:25:05 +01:00
|
|
|
|
2018-12-23 16:06:15 +00:00
|
|
|
this.set('document.name', this.get('docName').trim());
|
2018-06-07 14:23:54 +01:00
|
|
|
this.set('document.excerpt', this.get('docExcerpt').trim());
|
2018-06-15 14:25:05 +01:00
|
|
|
|
2018-01-22 10:31:03 +00:00
|
|
|
let cb = this.get('onSaveDocument');
|
|
|
|
cb(this.get('document'));
|
2017-02-27 17:07:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|