mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
delete docs moved to new UX
This commit is contained in:
parent
9cbee80f51
commit
bae1245d47
13 changed files with 199 additions and 89 deletions
|
@ -10,7 +10,6 @@
|
|||
// https://documize.com
|
||||
|
||||
import { computed } from '@ember/object';
|
||||
|
||||
import { notEmpty } from '@ember/object/computed';
|
||||
import { inject as service } from '@ember/service';
|
||||
import Component from '@ember/component';
|
||||
|
|
|
@ -10,18 +10,43 @@
|
|||
// https://documize.com
|
||||
|
||||
import { computed } from '@ember/object';
|
||||
|
||||
import Component from '@ember/component';
|
||||
|
||||
export default Component.extend({
|
||||
showDeleteDialog: false,
|
||||
selectedDocuments: [],
|
||||
|
||||
showAdd: computed('permissions', 'documents', function() {
|
||||
return this.get('documents.length') === 0 && this.get('permissions.documentAdd');
|
||||
}),
|
||||
showLockout: computed('permissions', 'documents', function() {
|
||||
return this.get('documents.length') === 0 && !this.get('permissions.documentAdd');
|
||||
}),
|
||||
hasDocumentActions: computed('permissions', function() {
|
||||
return this.get('permissions.documentDelete') || this.get('permissions.documentMove');
|
||||
}),
|
||||
|
||||
actions: {
|
||||
onConfirmDeleteDocuments() {
|
||||
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.attrs.onDeleteDocument(list);
|
||||
|
||||
this.set('selectedDocuments', []);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
selectDocument(documentId) {
|
||||
let doc = this.get('documents').findBy('id', documentId);
|
||||
let list = this.get('selectedDocuments');
|
||||
|
|
|
@ -19,8 +19,8 @@ import TooltipMixin from '../../mixins/tooltip';
|
|||
|
||||
export default Component.extend(NotifierMixin, TooltipMixin, {
|
||||
folderService: service('folder'),
|
||||
folderName: '',
|
||||
hasNameError: empty('folderName'),
|
||||
spaceName: '',
|
||||
hasNameError: empty('spaceName'),
|
||||
editMode: false,
|
||||
|
||||
keyUp(e) {
|
||||
|
@ -31,7 +31,7 @@ export default Component.extend(NotifierMixin, TooltipMixin, {
|
|||
|
||||
actions: {
|
||||
toggleEdit() {
|
||||
this.set('folderName', this.get('folder.name'));
|
||||
this.set('spaceName', this.get('space.name'));
|
||||
this.set('editMode', true);
|
||||
|
||||
schedule('afterRender', () => {
|
||||
|
@ -44,11 +44,8 @@ export default Component.extend(NotifierMixin, TooltipMixin, {
|
|||
return;
|
||||
}
|
||||
|
||||
this.set('folder.name', this.get('folderName'));
|
||||
|
||||
this.get('folderService').save(this.get('folder'));
|
||||
this.showNotification('Saved');
|
||||
|
||||
this.set('space.name', this.get('spaceName'));
|
||||
this.get('folderService').save(this.get('space'));
|
||||
this.set('editMode', false);
|
||||
},
|
||||
|
||||
|
|
|
@ -42,12 +42,6 @@ export default Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
let folder = this.get('folder');
|
||||
let targets = _.reject(this.get('folders'), {id: folder.get('id')});
|
||||
|
||||
this.get('pinned').isSpacePinned(folder.get('id')).then((pinId) => {
|
||||
this.set('pinState.pinId', pinId);
|
||||
this.set('pinState.isPinned', pinId !== '');
|
||||
this.set('pinState.newName', folder.get('name'));
|
||||
});
|
||||
|
||||
this.set('movedFolderOptions', targets);
|
||||
},
|
||||
|
||||
|
@ -74,41 +68,6 @@ export default Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
},
|
||||
|
||||
actions: {
|
||||
onUnpin() {
|
||||
this.get('pinned').unpinItem(this.get('pinState.pinId')).then(() => {
|
||||
this.set('pinState.isPinned', false);
|
||||
this.set('pinState.pinId', '');
|
||||
this.eventBus.publish('pinChange');
|
||||
this.renderTooltips();
|
||||
});
|
||||
},
|
||||
|
||||
onPin() {
|
||||
let pin = {
|
||||
pin: this.get('pinState.newName'),
|
||||
documentId: '',
|
||||
folderId: this.get('folder.id')
|
||||
};
|
||||
|
||||
if (is.empty(pin.pin)) {
|
||||
$('#pin-space-name').addClass('error').focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
this.get('pinned').pinItem(pin).then((pin) => {
|
||||
this.set('pinState.isPinned', true);
|
||||
this.set('pinState.pinId', pin.get('id'));
|
||||
this.eventBus.publish('pinChange');
|
||||
this.renderTooltips();
|
||||
});
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
deleteDocuments() {
|
||||
this.attrs.onDeleteDocument();
|
||||
},
|
||||
|
||||
setMoveFolder(folderId) {
|
||||
this.set('moveFolderId', folderId);
|
||||
|
||||
|
|
|
@ -99,8 +99,7 @@ export default Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
this.send("showNotification", "Moved");
|
||||
},
|
||||
|
||||
onDeleteDocument() {
|
||||
let documents = this.get('selectedDocuments');
|
||||
onDeleteDocument(documents) {
|
||||
let self = this;
|
||||
let promises = [];
|
||||
|
||||
|
@ -113,10 +112,9 @@ export default Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
documents.forEach(function (document) {
|
||||
document.set('selected', false);
|
||||
});
|
||||
this.set('documents', documents);
|
||||
|
||||
this.set('documents', documents);
|
||||
this.set('selectedDocuments', []);
|
||||
this.send("showNotification", "Deleted");
|
||||
this.attrs.onRefresh();
|
||||
});
|
||||
},
|
||||
|
|
62
gui/app/components/ui/ui-confirm-dialog.js
Normal file
62
gui/app/components/ui/ui-confirm-dialog.js
Normal file
|
@ -0,0 +1,62 @@
|
|||
// 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 Component from '@ember/component';
|
||||
import stringUtil from '../../utils/string';
|
||||
|
||||
export default Component.extend({
|
||||
contentId: '',
|
||||
cancelCaption: 'Cancel',
|
||||
confirmCaption: 'OK',
|
||||
title: 'Confirm',
|
||||
show: false,
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
this.set("contentId", 'confirm-modal-' + stringUtil.makeId(10));
|
||||
},
|
||||
|
||||
didUpdateAttrs() {
|
||||
this._super(...arguments);
|
||||
let modalId = '#' + this.get('contentId');
|
||||
|
||||
if (this.get('show')) {
|
||||
$(modalId).modal({});
|
||||
$(modalId).modal('show');
|
||||
let self = this;
|
||||
$(modalId).on('hidden.bs.modal', function(e) { // eslint-disable-line no-unused-vars
|
||||
self.set('show', false);
|
||||
$(modalId).modal('dispose');
|
||||
});
|
||||
} else {
|
||||
$(modalId).modal('hide');
|
||||
$(modalId).modal('dispose');
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
onCancel() {
|
||||
$('#' + this.get('contentId')).modal('dispose');
|
||||
},
|
||||
|
||||
onAction(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (this.get('onAction') === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.attrs.onAction()) {
|
||||
this.set('show', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue