1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-22 06:39:43 +02:00

move documents new UX

This commit is contained in:
Harvey Kandola 2017-11-22 16:28:17 +00:00
parent bae1245d47
commit aee9345886
14 changed files with 141 additions and 207 deletions

View file

@ -10,11 +10,14 @@
// https://documize.com
import { computed } from '@ember/object';
import { A } from "@ember/array"
import Component from '@ember/component';
export default Component.extend({
showDeleteDialog: false,
selectedDocuments: [],
showMoveDialog: false,
selectedDocuments: A([]),
selectedCaption: 'document',
showAdd: computed('permissions', 'documents', function() {
return this.get('documents.length') === 0 && this.get('permissions.documentAdd');
@ -26,23 +29,50 @@ export default Component.extend({
return this.get('permissions.documentDelete') || this.get('permissions.documentMove');
}),
didReceiveAttrs() {
this._super(...arguments);
let space = this.get('space');
let targets = _.reject(this.get('spaces'), {id: space.get('id')});
this.set('moveOptions', A(targets));
this.set('selectedDocuments', A([]));
},
actions: {
onConfirmDeleteDocuments() {
onShowDeleteDocuments() {
this.set('showDeleteDialog', true);
},
onDeleteDocuments() {
this.set('showDeleteDialog', false);
let list = this.get('selectedDocuments');
// list.forEach(d => {
// let doc = this.get('documents').findBy('id', d);
// doc.set('selected', false);
// });
this.set('selectedDocuments', A([]));
this.set('showDeleteDialog', false);
this.attrs.onDeleteDocument(list);
this.set('selectedDocuments', []);
return true;
},
onShowMoveDocuments() {
this.set('showMoveDialog', true);
},
onMoveDocuments() {
let list = this.get('selectedDocuments');
let spaces = this.get('spaces');
let moveSpaceId = '';
spaces.forEach(space => {
if (space.get('selected')) {
moveSpaceId = space.get('id');
}
});
if (moveSpaceId === '') return false;
this.set('showMoveDialog', false);
this.set('selectedDocuments', A([]));
this.attrs.onMoveDocument(list, moveSpaceId);
return true;
},
@ -59,7 +89,8 @@ export default Component.extend({
list = _.without(list, documentId);
}
this.set('selectedDocuments', list);
this.set('selectedCaption', list.length > 1 ? 'documents' : 'document');
this.set('selectedDocuments', A(list));
}
}
});