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
|
|
|
|
|
2017-11-16 13:28:05 +00:00
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import Component from '@ember/component';
|
|
|
|
import { inject as service } from '@ember/service';
|
2016-07-07 18:54:16 -07:00
|
|
|
import NotifierMixin from '../../mixins/notifier';
|
|
|
|
import TooltipMixin from '../../mixins/tooltip';
|
2017-03-21 13:05:10 +00:00
|
|
|
import AuthMixin from '../../mixins/auth';
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2017-11-16 13:28:05 +00:00
|
|
|
export default Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
2017-09-18 13:02:15 +01:00
|
|
|
folderService: service('folder'),
|
|
|
|
session: service(),
|
|
|
|
appMeta: service(),
|
|
|
|
pinned: service(),
|
2016-10-06 14:13:02 -07:00
|
|
|
showToolbar: false,
|
2016-10-24 19:20:29 -07:00
|
|
|
folder: {},
|
|
|
|
busy: false,
|
|
|
|
moveFolderId: "",
|
2016-10-07 10:42:20 -07:00
|
|
|
drop: null,
|
2017-09-18 13:02:15 +01:00
|
|
|
pinState : {
|
|
|
|
isPinned: false,
|
|
|
|
pinId: '',
|
2017-10-02 13:48:37 -04:00
|
|
|
newName: ''
|
2017-09-18 13:02:15 +01:00
|
|
|
},
|
2017-09-18 13:35:51 +01:00
|
|
|
deleteSpaceName: '',
|
2017-11-16 13:28:05 +00:00
|
|
|
spaceSettings: computed('permissions', function() {
|
2017-10-10 16:02:46 -04:00
|
|
|
return this.get('permissions.spaceOwner') || this.get('permissions.spaceManage');
|
|
|
|
}),
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-10-24 19:20:29 -07:00
|
|
|
didReceiveAttrs() {
|
2017-09-25 14:37:11 +01:00
|
|
|
this._super(...arguments);
|
|
|
|
|
2017-09-18 13:02:15 +01:00
|
|
|
let folder = this.get('folder');
|
2017-10-02 13:48:37 -04:00
|
|
|
let targets = _.reject(this.get('folders'), {id: folder.get('id')});
|
|
|
|
|
2016-10-24 19:20:29 -07:00
|
|
|
this.set('movedFolderOptions', targets);
|
|
|
|
},
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-10-16 17:27:52 -07:00
|
|
|
didRender() {
|
2017-09-25 14:37:11 +01:00
|
|
|
this._super(...arguments);
|
2017-09-20 08:28:41 +01:00
|
|
|
this.renderTooltips();
|
|
|
|
},
|
|
|
|
|
|
|
|
renderTooltips() {
|
|
|
|
this.destroyTooltips();
|
2016-10-16 17:27:52 -07:00
|
|
|
},
|
|
|
|
|
2016-10-24 19:20:29 -07:00
|
|
|
willDestroyElement() {
|
2017-09-25 14:37:11 +01:00
|
|
|
this._super(...arguments);
|
|
|
|
|
2017-10-02 13:48:37 -04:00
|
|
|
if (this.get('isDestroyed') || this.get('isDestroying')) return;
|
2017-09-20 08:28:41 +01:00
|
|
|
|
2016-10-07 10:42:20 -07:00
|
|
|
if (is.not.null(this.get('drop'))) {
|
|
|
|
this.get('drop').destroy();
|
|
|
|
this.set('drop', null);
|
|
|
|
}
|
|
|
|
|
2016-10-24 19:20:29 -07:00
|
|
|
this.destroyTooltips();
|
|
|
|
},
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-10-24 19:20:29 -07:00
|
|
|
actions: {
|
|
|
|
setMoveFolder(folderId) {
|
|
|
|
this.set('moveFolderId', folderId);
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-10-24 19:20:29 -07:00
|
|
|
let folders = this.get('folders');
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-10-24 19:20:29 -07:00
|
|
|
folders.forEach(folder => {
|
|
|
|
folder.set('selected', folder.id === folderId);
|
|
|
|
});
|
|
|
|
},
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-10-24 19:20:29 -07:00
|
|
|
moveDocuments() {
|
|
|
|
if (this.get("moveFolderId") === "") {
|
|
|
|
return false;
|
|
|
|
}
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-10-24 19:20:29 -07:00
|
|
|
this.attrs.onMoveDocument(this.get('moveFolderId'));
|
2016-07-07 18:54:16 -07:00
|
|
|
|
2016-11-21 19:27:18 -08:00
|
|
|
return true;
|
2017-09-25 19:14:33 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
onStartDocument() {
|
|
|
|
this.attrs.onStartDocument();
|
2016-11-22 10:05:32 -08:00
|
|
|
}
|
2016-10-24 19:20:29 -07:00
|
|
|
}
|
2016-07-07 18:54:16 -07:00
|
|
|
});
|