mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
category permission admin, re-vamped view layout
This commit is contained in:
parent
0c152c219f
commit
3f31d6d15e
48 changed files with 753 additions and 373 deletions
|
@ -11,25 +11,59 @@
|
|||
|
||||
import Ember from 'ember';
|
||||
import NotifierMixin from '../../mixins/notifier';
|
||||
import TooltipMixin from '../../mixins/tooltip';
|
||||
|
||||
const {
|
||||
inject: { service }
|
||||
} = Ember;
|
||||
|
||||
export default Ember.Component.extend(NotifierMixin, {
|
||||
folderService: service('folder'),
|
||||
export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
||||
userService: service('user'),
|
||||
categoryService: service('category'),
|
||||
appMeta: service(),
|
||||
store: service(),
|
||||
newCategory: '',
|
||||
drop: null,
|
||||
users: [],
|
||||
|
||||
didReceiveAttrs() {
|
||||
this.load();
|
||||
},
|
||||
|
||||
didRender() {
|
||||
// this.addTooltip(this.$(".action"));
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
let drop = this.get('drop');
|
||||
|
||||
if (is.not.null(drop)) {
|
||||
drop.destroy();
|
||||
}
|
||||
},
|
||||
|
||||
load() {
|
||||
// get categories
|
||||
this.get('categoryService').getAll(this.get('folder.id')).then((c) => {
|
||||
this.set('category', c);
|
||||
|
||||
// get users that this space admin user can see
|
||||
this.get('userService').getAll().then((users) => {
|
||||
// set up Everyone user
|
||||
let u = {
|
||||
orgId: this.get('folder.orgId'),
|
||||
folderId: this.get('folder.id'),
|
||||
userId: '',
|
||||
firstname: 'Everyone',
|
||||
lastname: '',
|
||||
};
|
||||
|
||||
let data = this.get('store').normalize('user', u)
|
||||
users.pushObject(this.get('store').push(data));
|
||||
|
||||
users = users.sortBy('firstname', 'lastname');
|
||||
this.set('users', users);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -76,7 +110,7 @@ export default Ember.Component.extend(NotifierMixin, {
|
|||
this.setEdit(id, true);
|
||||
},
|
||||
|
||||
onCancel(id) {
|
||||
onEditCancel(id) {
|
||||
this.setEdit(id, false);
|
||||
this.load();
|
||||
},
|
||||
|
@ -94,6 +128,69 @@ export default Ember.Component.extend(NotifierMixin, {
|
|||
this.get('categoryService').save(cat).then(() => {
|
||||
this.load();
|
||||
});
|
||||
},
|
||||
|
||||
onShowAccessPicker(catId) {
|
||||
let users = this.get('users');
|
||||
let category = this.get('category').findBy('id', catId);
|
||||
|
||||
this.get('categoryService').getViewers(category.get('id')).then((viewers) => {
|
||||
// mark those users as selected that have already been given permission
|
||||
// to see the current category;
|
||||
console.log(viewers);
|
||||
|
||||
users.forEach((user) => {
|
||||
let selected = viewers.isAny('id', user.get('id'));
|
||||
user.set('selected', selected);
|
||||
});
|
||||
|
||||
this.set('categoryUsers', users);
|
||||
this.set('currentCategory', category);
|
||||
|
||||
$(".category-access-dialog").css("display", "block");
|
||||
|
||||
let drop = new Drop({
|
||||
target: $("#category-access-button-" + catId)[0],
|
||||
content: $(".category-access-dialog")[0],
|
||||
classes: 'drop-theme-basic',
|
||||
position: "bottom right",
|
||||
openOn: "always",
|
||||
tetherOptions: {
|
||||
offset: "5px 0",
|
||||
targetOffset: "10px 0"
|
||||
},
|
||||
remove: false
|
||||
});
|
||||
|
||||
this.set('drop', drop);
|
||||
});
|
||||
},
|
||||
|
||||
onGrantCancel() {
|
||||
let drop = this.get('drop');
|
||||
drop.close();
|
||||
},
|
||||
|
||||
onGrantAccess() {
|
||||
let category = this.get('currentCategory');
|
||||
let users = this.get('categoryUsers').filterBy('selected', true);
|
||||
let viewers = [];
|
||||
|
||||
users.forEach((user) => {
|
||||
let v = {
|
||||
orgId: this.get('folder.orgId'),
|
||||
folderId: this.get('folder.id'),
|
||||
categoryId: category.get('id'),
|
||||
userId: user.get('id')
|
||||
};
|
||||
|
||||
viewers.push(v);
|
||||
});
|
||||
|
||||
this.get('categoryService').setViewers(category.get('id'), viewers).then( () => {});
|
||||
|
||||
let drop = this.get('drop');
|
||||
drop.close();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -60,6 +60,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
if (this.get('permissions.documentMove')) {
|
||||
this.addTooltip(document.getElementById("move-documents-button"));
|
||||
}
|
||||
|
||||
if (this.get('permissions.documentDelete')) {
|
||||
this.addTooltip(document.getElementById("delete-documents-button"));
|
||||
}
|
||||
|
@ -67,11 +68,13 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, AuthMixin, {
|
|||
if (this.get('permissions.spaceOwner')) {
|
||||
this.addTooltip(document.getElementById("space-delete-button"));
|
||||
}
|
||||
|
||||
if (this.get('permissions.spaceManage')) {
|
||||
this.addTooltip(document.getElementById("space-settings-button"));
|
||||
}
|
||||
if (this.get('session.authenticated')) {
|
||||
this.addTooltip(document.getElementById("space-unpin-button"));
|
||||
|
||||
if (this.get('pinState.isPinned')) {
|
||||
this.addTooltip(document.getElementById("space-unpin-button"));
|
||||
} else {
|
||||
this.addTooltip(document.getElementById("space-pin-button"));
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ export default Ember.Component.extend(NotifierMixin, {
|
|||
documentMove: false,
|
||||
documentCopy: false,
|
||||
documentTemplate: false
|
||||
};
|
||||
};
|
||||
|
||||
let data = this.get('store').normalize('space-permission', u)
|
||||
folderPermissions.pushObject(this.get('store').push(data));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue