2017-09-21 15:48:00 +01: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
|
|
|
|
|
2018-06-15 14:25:05 +01:00
|
|
|
import { A } from '@ember/array';
|
2018-12-21 17:39:09 +00:00
|
|
|
import { computed } from '@ember/object';
|
2018-12-26 18:13:00 +00:00
|
|
|
import { notEmpty } from '@ember/object/computed';
|
2017-11-16 13:28:05 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2018-06-15 14:25:05 +01:00
|
|
|
import Modals from '../../mixins/modal';
|
2018-03-15 17:11:53 +00:00
|
|
|
import Component from '@ember/component';
|
2017-09-21 15:48:00 +01:00
|
|
|
|
2018-12-06 14:10:00 +00:00
|
|
|
export default Component.extend(Modals, {
|
2018-06-15 14:25:05 +01:00
|
|
|
documentService: service('document'),
|
2017-11-16 13:28:05 +00:00
|
|
|
sessionService: service('session'),
|
2018-06-15 14:25:05 +01:00
|
|
|
categoryService: service('category'),
|
2018-06-25 19:43:29 +01:00
|
|
|
router: service(),
|
2018-12-21 17:39:09 +00:00
|
|
|
selectedCategories: A([]),
|
|
|
|
tagz: A([]),
|
2018-12-26 18:13:00 +00:00
|
|
|
userChanges: notEmpty('contributorMsg'),
|
2018-12-21 17:39:09 +00:00
|
|
|
unassigned: computed('selectedCategories', 'tagz', function() {
|
|
|
|
return this.get('selectedCategories').length === 0 && this.get('tagz').length === 0;
|
|
|
|
}),
|
2018-01-22 10:31:03 +00:00
|
|
|
|
2017-09-21 15:48:00 +01:00
|
|
|
didReceiveAttrs() {
|
|
|
|
this._super(...arguments);
|
2018-06-15 14:25:05 +01:00
|
|
|
this.load();
|
2017-09-22 17:23:14 +01:00
|
|
|
},
|
|
|
|
|
2018-06-15 14:25:05 +01:00
|
|
|
load() {
|
|
|
|
this.get('categoryService').getDocumentCategories(this.get('document.id')).then((selected) => {
|
|
|
|
this.set('selectedCategories', selected);
|
|
|
|
});
|
2017-12-05 10:46:53 +00:00
|
|
|
|
2018-06-15 14:25:05 +01:00
|
|
|
let tagz = [];
|
|
|
|
if (!_.isUndefined(this.get('document.tags')) && this.get('document.tags').length > 1) {
|
|
|
|
let tags = this.get('document.tags').split('#');
|
2017-12-05 10:46:53 +00:00
|
|
|
_.each(tags, function(tag) {
|
2018-06-15 14:25:05 +01:00
|
|
|
if (tag.length > 0) {
|
|
|
|
tagz.pushObject(tag);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2018-01-22 10:31:03 +00:00
|
|
|
|
2018-06-15 14:25:05 +01:00
|
|
|
this.set('tagz', A(tagz));
|
|
|
|
},
|
2017-12-05 10:46:53 +00:00
|
|
|
|
2018-06-15 14:25:05 +01:00
|
|
|
actions: {
|
2019-05-29 11:09:19 +01:00
|
|
|
onEdit() {
|
|
|
|
if (!this.get('permissions.documentEdit')) return;
|
|
|
|
|
|
|
|
this.get('router').transitionTo('document.settings');
|
|
|
|
},
|
|
|
|
|
2018-06-25 19:43:29 +01:00
|
|
|
onEditCategory() {
|
2018-12-21 18:03:35 +00:00
|
|
|
if (!this.get('permissions.documentEdit')) return;
|
2018-06-25 19:43:29 +01:00
|
|
|
|
2018-12-21 18:03:35 +00:00
|
|
|
this.get('router').transitionTo('document.settings', {queryParams: {tab: 'category'}});
|
2018-01-22 10:31:03 +00:00
|
|
|
}
|
2017-12-05 10:46:53 +00:00
|
|
|
}
|
2017-09-21 15:48:00 +01:00
|
|
|
});
|