mirror of
https://github.com/documize/community.git
synced 2025-07-24 07:39:43 +02:00
Remove group permissions on delete event
This commit is contained in:
parent
1c4a4424e5
commit
359e0e29eb
7 changed files with 236 additions and 142 deletions
|
@ -33,9 +33,11 @@ export default Component.extend(AuthProvider, ModalMixin, {
|
|||
},
|
||||
|
||||
loadGroups() {
|
||||
this.get('groupSvc').getAll().then((groups) => {
|
||||
this.set('groups', groups);
|
||||
});
|
||||
this.get('groupSvc')
|
||||
.getAll()
|
||||
.then(groups => {
|
||||
this.set('groups', groups);
|
||||
});
|
||||
},
|
||||
|
||||
setDefaults() {
|
||||
|
@ -43,54 +45,70 @@ export default Component.extend(AuthProvider, ModalMixin, {
|
|||
},
|
||||
|
||||
loadGroupInfo() {
|
||||
let groupId = this.get('membersGroup.id');
|
||||
let groupId = this.get('membersGroup.id');
|
||||
let searchText = this.get('searchText');
|
||||
|
||||
this.get('groupSvc').getGroupMembers(groupId).then((members) => {
|
||||
this.set('members', members);
|
||||
this.get('groupSvc')
|
||||
.getGroupMembers(groupId)
|
||||
.then(members => {
|
||||
this.set('members', members);
|
||||
|
||||
this.get('userSvc').matchUsers(searchText).then((users) => {
|
||||
users.forEach((user) => {
|
||||
let m = members.findBy('userId', user.get('id'));
|
||||
user.set('isMember', is.not.undefined(m));
|
||||
})
|
||||
this.get('userSvc')
|
||||
.matchUsers(searchText)
|
||||
.then(users => {
|
||||
users.forEach(user => {
|
||||
let m = members.findBy('userId', user.get('id'));
|
||||
user.set('isMember', is.not.undefined(m));
|
||||
});
|
||||
|
||||
if (this.get('showMembers') && members.length === 0) {
|
||||
this.set('showMembers', false);
|
||||
this.set('showUsers', true);
|
||||
}
|
||||
|
||||
this.set('users', users);
|
||||
if (this.get('showMembers') && members.length === 0) {
|
||||
this.set('showMembers', false);
|
||||
this.set('showUsers', true);
|
||||
}
|
||||
|
||||
this.set('users', users);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
onOpenGroupModal() {
|
||||
this.modalOpen("#add-group-modal", {"show": true}, '#new-group-name');
|
||||
this.modalOpen(
|
||||
'#add-group-modal',
|
||||
{ show: true },
|
||||
'#new-group-name'
|
||||
);
|
||||
},
|
||||
|
||||
onAddGroup(e) {
|
||||
e.preventDefault();
|
||||
|
||||
let newGroup = this.get('newGroup');
|
||||
|
||||
|
||||
if (is.empty(newGroup.name)) {
|
||||
$("#new-group-name").addClass("is-invalid").focus();
|
||||
$('#new-group-name')
|
||||
.addClass('is-invalid')
|
||||
.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
this.get('groupSvc').add(newGroup).then(() => {
|
||||
this.loadGroups();
|
||||
});
|
||||
this.get('groupSvc')
|
||||
.add(newGroup)
|
||||
.then(() => {
|
||||
this.loadGroups();
|
||||
});
|
||||
|
||||
this.modalClose("#add-group-modal");
|
||||
this.modalClose('#add-group-modal');
|
||||
this.setDefaults();
|
||||
},
|
||||
|
||||
onShowDeleteModal(groupId) {
|
||||
this.set('deleteGroup', { name: '', id: groupId });
|
||||
this.modalOpen("#delete-group-modal", {"show": true}, '#delete-group-name');
|
||||
this.modalOpen(
|
||||
'#delete-group-modal',
|
||||
{ show: true },
|
||||
'#delete-group-name'
|
||||
);
|
||||
},
|
||||
|
||||
onDeleteGroup(e) {
|
||||
|
@ -99,22 +117,33 @@ export default Component.extend(AuthProvider, ModalMixin, {
|
|||
let deleteGroup = this.get('deleteGroup');
|
||||
let group = this.get('groups').findBy('id', deleteGroup.id);
|
||||
|
||||
if (is.empty(deleteGroup.name) || group.get('name') !== deleteGroup.name) {
|
||||
$("#delete-group-name").addClass("is-invalid").focus();
|
||||
if (
|
||||
is.empty(deleteGroup.name) ||
|
||||
group.get('name') !== deleteGroup.name
|
||||
) {
|
||||
$('#delete-group-name')
|
||||
.addClass('is-invalid')
|
||||
.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
this.get('groupSvc').delete(deleteGroup.id).then(() => {
|
||||
this.loadGroups();
|
||||
});
|
||||
this.get('groupSvc')
|
||||
.delete(deleteGroup.id)
|
||||
.then(() => {
|
||||
this.loadGroups();
|
||||
});
|
||||
|
||||
this.modalClose("#delete-group-modal");
|
||||
this.modalClose('#delete-group-modal');
|
||||
this.set('deleteGroup', { name: '', id: '' });
|
||||
},
|
||||
|
||||
onShowEditModal(groupId) {
|
||||
this.set('editGroup', this.get('groups').findBy('id', groupId));
|
||||
this.modalOpen("#edit-group-modal", {"show": true}, '#edit-group-name');
|
||||
this.modalOpen(
|
||||
'#edit-group-modal',
|
||||
{ show: true },
|
||||
'#edit-group-name'
|
||||
);
|
||||
},
|
||||
|
||||
onEditGroup(e) {
|
||||
|
@ -123,21 +152,29 @@ export default Component.extend(AuthProvider, ModalMixin, {
|
|||
let group = this.get('editGroup');
|
||||
|
||||
if (is.empty(group.get('name'))) {
|
||||
$("#edit-group-name").addClass("is-invalid").focus();
|
||||
$('#edit-group-name')
|
||||
.addClass('is-invalid')
|
||||
.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
this.get('groupSvc').update(group).then(() => {
|
||||
this.load();
|
||||
});
|
||||
this.get('groupSvc')
|
||||
.update(group)
|
||||
.then(() => {
|
||||
this.load();
|
||||
});
|
||||
|
||||
this.modalClose("#edit-group-modal");
|
||||
this.modalClose('#edit-group-modal');
|
||||
this.set('editGroup', null);
|
||||
},
|
||||
|
||||
onShowMembersModal(groupId) {
|
||||
this.set('membersGroup', this.get('groups').findBy('id', groupId));
|
||||
this.modalOpen("#group-members-modal", {"show": true}, '#group-members-search');
|
||||
this.modalOpen(
|
||||
'#group-members-modal',
|
||||
{ show: true },
|
||||
'#group-members-search'
|
||||
);
|
||||
this.set('members', null);
|
||||
this.set('users', null);
|
||||
this.set('showMembers', true);
|
||||
|
@ -146,36 +183,44 @@ export default Component.extend(AuthProvider, ModalMixin, {
|
|||
},
|
||||
|
||||
onSearch() {
|
||||
debounce(this, function() {
|
||||
let searchText = this.get('searchText');
|
||||
this.loadGroupInfo();
|
||||
debounce(
|
||||
this,
|
||||
function() {
|
||||
let searchText = this.get('searchText');
|
||||
this.loadGroupInfo();
|
||||
|
||||
if (is.not.empty(searchText)) {
|
||||
this.set('showMembers', false);
|
||||
this.set('showUsers', true);
|
||||
} else {
|
||||
this.set('showMembers', true);
|
||||
this.set('showUsers', false);
|
||||
}
|
||||
}, 250);
|
||||
if (is.not.empty(searchText)) {
|
||||
this.set('showMembers', false);
|
||||
this.set('showUsers', true);
|
||||
} else {
|
||||
this.set('showMembers', true);
|
||||
this.set('showUsers', false);
|
||||
}
|
||||
},
|
||||
250
|
||||
);
|
||||
},
|
||||
|
||||
onLeaveGroup(userId) {
|
||||
let groupId = this.get('membersGroup.id');
|
||||
|
||||
this.get('groupSvc').leave(groupId, userId).then(() => {
|
||||
this.loadGroupInfo();
|
||||
this.loadGroups();
|
||||
});
|
||||
this.get('groupSvc')
|
||||
.leave(groupId, userId)
|
||||
.then(() => {
|
||||
this.loadGroupInfo();
|
||||
this.loadGroups();
|
||||
});
|
||||
},
|
||||
|
||||
onJoinGroup(userId) {
|
||||
let groupId = this.get('membersGroup.id');
|
||||
|
||||
this.get('groupSvc').join(groupId, userId).then(() => {
|
||||
this.loadGroupInfo();
|
||||
this.loadGroups();
|
||||
});
|
||||
this.get('groupSvc')
|
||||
.join(groupId, userId)
|
||||
.then(() => {
|
||||
this.loadGroupInfo();
|
||||
this.loadGroups();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ var Router = EmberRouter.extend({
|
|||
location: config.locationType
|
||||
});
|
||||
|
||||
export default Router.map(function () {
|
||||
export default Router.map(function() {
|
||||
this.route('folders', {
|
||||
path: '/'
|
||||
});
|
||||
|
@ -25,53 +25,65 @@ export default Router.map(function () {
|
|||
path: 'dashboard'
|
||||
});
|
||||
|
||||
this.route('folder', {
|
||||
path: 's/:folder_id/:folder_slug'
|
||||
}, function() {
|
||||
this.route('category', {
|
||||
path: 'category'
|
||||
})
|
||||
});
|
||||
this.route(
|
||||
'folder',
|
||||
{
|
||||
path: 's/:folder_id/:folder_slug'
|
||||
},
|
||||
function() {
|
||||
this.route('category', {
|
||||
path: 'category'
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
this.route('document', {
|
||||
path: 's/:folder_id/:folder_slug/d/:document_id/:document_slug'
|
||||
}, function () {
|
||||
this.route('section', {
|
||||
path: 'section/:page_id'
|
||||
});
|
||||
this.route('block', {
|
||||
path: 'block/:block_id'
|
||||
});
|
||||
});
|
||||
this.route(
|
||||
'document',
|
||||
{
|
||||
path: 's/:folder_id/:folder_slug/d/:document_id/:document_slug'
|
||||
},
|
||||
function() {
|
||||
this.route('section', {
|
||||
path: 'section/:page_id'
|
||||
});
|
||||
this.route('block', {
|
||||
path: 'block/:block_id'
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
this.route('customize', {
|
||||
path: 'settings'
|
||||
}, function () {
|
||||
this.route('general', {
|
||||
path: 'general'
|
||||
});
|
||||
this.route('groups', {
|
||||
path: 'groups'
|
||||
});
|
||||
this.route('users', {
|
||||
path: 'users'
|
||||
});
|
||||
this.route('folders', {
|
||||
path: 'folders'
|
||||
});
|
||||
this.route('smtp', {
|
||||
path: 'smtp'
|
||||
});
|
||||
this.route('license', {
|
||||
path: 'license'
|
||||
});
|
||||
this.route('auth', {
|
||||
path: 'auth'
|
||||
});
|
||||
this.route('audit', {
|
||||
path: 'audit'
|
||||
});
|
||||
});
|
||||
this.route(
|
||||
'customize',
|
||||
{
|
||||
path: 'settings'
|
||||
},
|
||||
function() {
|
||||
this.route('general', {
|
||||
path: 'general'
|
||||
});
|
||||
this.route('groups', {
|
||||
path: 'groups'
|
||||
});
|
||||
this.route('users', {
|
||||
path: 'users'
|
||||
});
|
||||
this.route('folders', {
|
||||
path: 'folders'
|
||||
});
|
||||
this.route('smtp', {
|
||||
path: 'smtp'
|
||||
});
|
||||
this.route('license', {
|
||||
path: 'license'
|
||||
});
|
||||
this.route('auth', {
|
||||
path: 'auth'
|
||||
});
|
||||
this.route('audit', {
|
||||
path: 'audit'
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
this.route('setup', {
|
||||
path: 'setup'
|
||||
|
@ -81,31 +93,35 @@ export default Router.map(function () {
|
|||
path: 'secure/:token'
|
||||
});
|
||||
|
||||
this.route('auth', {
|
||||
path: 'auth'
|
||||
}, function () {
|
||||
this.route('sso', {
|
||||
path: 'sso/:token'
|
||||
});
|
||||
this.route('keycloak', {
|
||||
path: 'keycloak'
|
||||
});
|
||||
this.route('login', {
|
||||
path: 'login'
|
||||
});
|
||||
this.route('forgot', {
|
||||
path: 'forgot'
|
||||
});
|
||||
this.route('reset', {
|
||||
path: 'reset/:token'
|
||||
});
|
||||
this.route('logout', {
|
||||
path: 'logout'
|
||||
});
|
||||
this.route('share', {
|
||||
path: 'share/:id/:slug/:serial'
|
||||
});
|
||||
});
|
||||
this.route(
|
||||
'auth',
|
||||
{
|
||||
path: 'auth'
|
||||
},
|
||||
function() {
|
||||
this.route('sso', {
|
||||
path: 'sso/:token'
|
||||
});
|
||||
this.route('keycloak', {
|
||||
path: 'keycloak'
|
||||
});
|
||||
this.route('login', {
|
||||
path: 'login'
|
||||
});
|
||||
this.route('forgot', {
|
||||
path: 'forgot'
|
||||
});
|
||||
this.route('reset', {
|
||||
path: 'reset/:token'
|
||||
});
|
||||
this.route('logout', {
|
||||
path: 'logout'
|
||||
});
|
||||
this.route('share', {
|
||||
path: 'share/:id/:slug/:serial'
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
this.route('profile', {
|
||||
path: 'profile'
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<div class="modal-content">
|
||||
<div class="modal-header">Add Group</div>
|
||||
<div class="modal-body">
|
||||
<form onsubmit={{action 'onAddGroup'}}>
|
||||
<form onsubmit= {{action 'onAddGroup'}}>
|
||||
<div class="form-group">
|
||||
<label for="new-group-name">Name</label>
|
||||
{{focus-input id="new-group-name" type="text" class="form-control mousetrap" placeholder="Enter group name" value=newGroup.name}}
|
||||
|
@ -25,7 +25,7 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-success" onclick={{action 'onAddGroup'}}>Add</button>
|
||||
<button type="button" class="btn btn-success" onclick= {{action 'onAddGroup'}}>Add</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -55,8 +55,10 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="margin-top-30"><i>No groups</i></div>
|
||||
{{else}}
|
||||
<div class="margin-top-30">
|
||||
<i>No groups</i>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
|
||||
|
@ -65,7 +67,7 @@
|
|||
<div class="modal-content">
|
||||
<div class="modal-header">Delete Group</div>
|
||||
<div class="modal-body">
|
||||
<form onsubmit={{action 'onDeleteGroup'}}>
|
||||
<form onsubmit= {{action 'onDeleteGroup'}}>
|
||||
<p>Are you sure you want to delete this group?</p>
|
||||
<div class="form-group">
|
||||
<label for="delete-group-name">Please type group name to confirm</label>
|
||||
|
@ -76,7 +78,7 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-danger" onclick={{action 'onDeleteGroup'}}>Delete</button>
|
||||
<button type="button" class="btn btn-danger" onclick= {{action 'onDeleteGroup'}}>Delete</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -87,7 +89,7 @@
|
|||
<div class="modal-content">
|
||||
<div class="modal-header">Edit Group</div>
|
||||
<div class="modal-body">
|
||||
<form onsubmit={{action 'onEditGroup'}}>
|
||||
<form onsubmit= {{action 'onEditGroup'}}>
|
||||
<div class="form-group">
|
||||
<label for="edit-group-name">Name</label>
|
||||
{{input id="edit-group-name" type="text" class="form-control mousetrap" placeholder="Enter group name" value=editGroup.name}}
|
||||
|
@ -101,7 +103,7 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-success" onclick={{action 'onEditGroup'}}>Save</button>
|
||||
<button type="button" class="btn btn-success" onclick= {{action 'onEditGroup'}}>Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue