1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-21 14:19:43 +02:00
documize/gui/app/components/folder/space-toolbar.js

96 lines
2.1 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 { 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';
import AuthMixin from '../../mixins/auth';
2016-07-07 18:54:16 -07:00
export default Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
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,
pinState : {
isPinned: false,
pinId: '',
2017-10-02 13:48:37 -04:00
newName: ''
},
2017-09-18 13:35:51 +01:00
deleteSpaceName: '',
spaceSettings: computed('permissions', function() {
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);
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
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-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;
},
onStartDocument() {
this.attrs.onStartDocument();
}
2016-10-24 19:20:29 -07:00
}
2016-07-07 18:54:16 -07:00
});