mirror of
https://github.com/documize/community.git
synced 2025-07-25 08:09:43 +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
|
@ -17,7 +17,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
|||
documentService: Ember.inject.service('document'),
|
||||
appMeta: Ember.inject.service(),
|
||||
drop: null,
|
||||
emptyState: Ember.computed.empty('files'),
|
||||
hasAttachments: Ember.computed.notEmpty('files'),
|
||||
deleteAttachment: {
|
||||
id: "",
|
||||
name: "",
|
||||
|
@ -104,7 +104,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
|
|||
target: $(".delete-attachment-" + id)[0],
|
||||
content: $(".delete-attachment-dialog")[0],
|
||||
classes: 'drop-theme-basic',
|
||||
position: "bottom left",
|
||||
position: "bottom right",
|
||||
openOn: "always",
|
||||
tetherOptions: {
|
||||
offset: "5px 0",
|
|
@ -31,38 +31,31 @@ export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
|
|||
name: "",
|
||||
description: ""
|
||||
},
|
||||
tab: '',
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
if (is.empty(this.get('tab')) || is.undefined(this.get('tab'))) {
|
||||
this.set('tab', 'index');
|
||||
}
|
||||
},
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
|
||||
|
||||
this.set('saveTemplate.name', this.get('document.name'));
|
||||
this.set('saveTemplate.description', this.get('document.excerpt'));
|
||||
|
||||
|
||||
this.set('pinState.pinId', this.get('pinned').isDocumentPinned(this.get('document.id')));
|
||||
this.set('pinState.isPinned', this.get('pinState.pinId') !== '');
|
||||
this.set('pinState.newName', this.get('document.name').substring(0,3).toUpperCase());
|
||||
this.set('pinState.newName', this.get('document.name'));
|
||||
},
|
||||
|
||||
didRender() {
|
||||
this.destroyTooltips();
|
||||
|
||||
if (this.get('permissions.documentEdit')) {
|
||||
this.addTooltip(document.getElementById("document-activity-button"));
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
onChangeTab(tab) {
|
||||
this.set('tab', tab);
|
||||
},
|
||||
|
||||
onTagChange(tags) {
|
||||
let doc = this.get('document');
|
||||
doc.set('tags', tags);
|
||||
this.get('documentService').save(doc);
|
||||
},
|
||||
|
||||
onMenuOpen() {
|
||||
this.set('menuOpen', !this.get('menuOpen'));
|
||||
},
|
||||
|
@ -78,15 +71,15 @@ export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
|
|||
|
||||
onPageSequenceChange(changes) {
|
||||
this.get('onPageSequenceChange')(changes);
|
||||
},
|
||||
},
|
||||
|
||||
onPageLevelChange(changes) {
|
||||
this.get('onPageLevelChange')(changes);
|
||||
},
|
||||
},
|
||||
|
||||
onGotoPage(id) {
|
||||
this.get('onGotoPage')(id);
|
||||
},
|
||||
},
|
||||
|
||||
onUnpin() {
|
||||
this.get('pinned').unpinItem(this.get('pinState.pinId')).then(() => {
|
||||
|
@ -136,12 +129,15 @@ export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
|
|||
|
||||
return true;
|
||||
},
|
||||
|
||||
|
||||
onLayoutChange(layout) {
|
||||
let doc = this.get('document');
|
||||
doc.set('layout', layout);
|
||||
this.get('documentService').save(doc);
|
||||
|
||||
|
||||
if (this.get('permissions.documentEdit')) {
|
||||
this.get('documentService').save(doc);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -76,7 +76,7 @@ export default Ember.Component.extend(TooltipMixin, {
|
|||
let permissions = this.get('permissions');
|
||||
|
||||
return permissions.get('documentDelete') || permissions.get('documentCopy') ||
|
||||
permissions.get('documentMove') || permissions.get('documentTemplate');;
|
||||
permissions.get('documentMove') || permissions.get('documentTemplate');
|
||||
}),
|
||||
|
||||
didRender() {
|
||||
|
|
34
gui/app/components/document/space-category.js
Normal file
34
gui/app/components/document/space-category.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
// 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 Ember from 'ember';
|
||||
import TooltipMixin from '../../mixins/tooltip';
|
||||
import NotifierMixin from '../../mixins/notifier';
|
||||
|
||||
export default Ember.Component.extend(TooltipMixin, NotifierMixin, {
|
||||
documentService: Ember.inject.service('document'),
|
||||
sectionService: Ember.inject.service('section'),
|
||||
sessionService: Ember.inject.service('session'),
|
||||
appMeta: Ember.inject.service(),
|
||||
userService: Ember.inject.service('user'),
|
||||
localStorage: Ember.inject.service(),
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
},
|
||||
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
},
|
||||
|
||||
actions: {
|
||||
}
|
||||
});
|
|
@ -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));
|
||||
|
|
23
gui/app/components/ui/ui-list-picker.js
Normal file
23
gui/app/components/ui/ui-list-picker.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
// 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 Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
nameField: 'category',
|
||||
items: [],
|
||||
|
||||
actions: {
|
||||
onToggle(item) {
|
||||
Ember.set(item, 'selected', !item.get('selected'));
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue