mirror of
https://github.com/documize/community.git
synced 2025-07-24 07:39:43 +02:00
new UX for category management
This commit is contained in:
parent
1c08a7fbcf
commit
1f0fc844a8
29 changed files with 287 additions and 397 deletions
|
@ -10,7 +10,6 @@
|
|||
// https://documize.com
|
||||
|
||||
import Component from '@ember/component';
|
||||
|
||||
import { inject as service } from '@ember/service';
|
||||
import NotifierMixin from '../../mixins/notifier';
|
||||
import TooltipMixin from '../../mixins/tooltip';
|
||||
|
@ -22,19 +21,20 @@ export default Component.extend(NotifierMixin, TooltipMixin, DropdownMixin, {
|
|||
appMeta: service(),
|
||||
store: service(),
|
||||
newCategory: '',
|
||||
deleteId: '',
|
||||
dropdown: null,
|
||||
users: [],
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.renderTooltips();
|
||||
this.load();
|
||||
},
|
||||
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.destroyDropdown();
|
||||
this.removeTooltips();
|
||||
},
|
||||
|
||||
load() {
|
||||
|
@ -88,15 +88,17 @@ export default Component.extend(NotifierMixin, TooltipMixin, DropdownMixin, {
|
|||
},
|
||||
|
||||
actions: {
|
||||
onAdd() {
|
||||
onAdd(e) {
|
||||
e.preventDefault();
|
||||
|
||||
let cat = this.get('newCategory');
|
||||
|
||||
if (cat === '') {
|
||||
$('#new-category-name').addClass('error').focus();
|
||||
$('#new-category-name').addClass('is-invalid').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
$('#new-category-name').removeClass('error').focus();
|
||||
$('#new-category-name').removeClass('is-invalid').focus();
|
||||
this.set('newCategory', '');
|
||||
|
||||
let c = {
|
||||
|
@ -109,8 +111,19 @@ export default Component.extend(NotifierMixin, TooltipMixin, DropdownMixin, {
|
|||
});
|
||||
},
|
||||
|
||||
onDelete(id) {
|
||||
this.get('categoryService').delete(id).then(() => {
|
||||
onShowDelete(id) {
|
||||
let cat = this.get('category').findBy('id', id);
|
||||
this.set('deleteId', cat.get('id'));
|
||||
|
||||
$('#category-delete-modal').modal('dispose');
|
||||
$('#category-delete-modal').modal({show: true});
|
||||
},
|
||||
|
||||
onDelete() {
|
||||
$('#category-delete-modal').modal('hide');
|
||||
$('#category-delete-modal').modal('dispose');
|
||||
|
||||
this.get('categoryService').delete(this.get('deleteId')).then(() => {
|
||||
this.load();
|
||||
});
|
||||
},
|
||||
|
@ -127,12 +140,12 @@ export default Component.extend(NotifierMixin, TooltipMixin, DropdownMixin, {
|
|||
onSave(id) {
|
||||
let cat = this.setEdit(id, true);
|
||||
if (cat.get('category') === '') {
|
||||
$('#edit-category-' + cat.get('id')).addClass('error').focus();
|
||||
return;
|
||||
$('#edit-category-' + cat.get('id')).addClass('is-invalid').focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
cat = this.setEdit(id, false);
|
||||
$('#edit-category-' + cat.get('id')).removeClass('error');
|
||||
$('#edit-category-' + cat.get('id')).removeClass('is-invalid');
|
||||
|
||||
this.get('categoryService').save(cat).then(() => {
|
||||
this.load();
|
||||
|
@ -140,7 +153,8 @@ export default Component.extend(NotifierMixin, TooltipMixin, DropdownMixin, {
|
|||
},
|
||||
|
||||
onShowAccessPicker(catId) {
|
||||
this.closeDropdown();
|
||||
this.set('showCategoryAccess', true);
|
||||
|
||||
let users = this.get('users');
|
||||
let category = this.get('category').findBy('id', catId);
|
||||
|
||||
|
@ -155,26 +169,12 @@ export default Component.extend(NotifierMixin, TooltipMixin, DropdownMixin, {
|
|||
|
||||
this.set('categoryUsers', users);
|
||||
this.set('currentCategory', category);
|
||||
|
||||
$(".category-access-dialog").css("display", "block");
|
||||
|
||||
let dropOptions = Object.assign(this.get('dropDefaults'), {
|
||||
target: $("#category-access-button-" + catId)[0],
|
||||
content: $(".category-access-dialog")[0],
|
||||
classes: 'drop-theme-basic',
|
||||
position: "bottom right",
|
||||
remove: false});
|
||||
|
||||
let drop = new Drop(dropOptions);
|
||||
this.set('dropdown', drop);
|
||||
});
|
||||
},
|
||||
|
||||
onGrantCancel() {
|
||||
this.closeDropdown();
|
||||
},
|
||||
|
||||
onGrantAccess() {
|
||||
this.set('showCategoryAccess', false);
|
||||
|
||||
let folder = this.get('folder');
|
||||
let category = this.get('currentCategory');
|
||||
let users = this.get('categoryUsers').filterBy('selected', true);
|
||||
|
@ -196,8 +196,6 @@ export default Component.extend(NotifierMixin, TooltipMixin, DropdownMixin, {
|
|||
this.get('categoryService').setViewers(folder.get('id'), category.get('id'), viewers).then(() => {
|
||||
this.load();
|
||||
});
|
||||
|
||||
this.closeDropdown();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue