1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 15:49:44 +02:00

add bulk users

This commit is contained in:
sauls8t 2018-03-01 10:58:55 +00:00
parent 7e6d6366da
commit 0b5ed8fd9e
11 changed files with 627 additions and 410 deletions

View file

@ -9,48 +9,41 @@
//
// https://documize.com
import { set } from '@ember/object';
import { inject as service } from '@ember/service';
import Controller from '@ember/controller';
export default Controller.extend({
userService: service('user'),
init() {
this._super(...arguments);
this.newUser = { firstname: "", lastname: "", email: "", active: true };
loadUsers() {
this.get('userService').getComplete().then((users) => {
this.set('model', users);
});
},
actions: {
add(user) {
set(this, 'newUser', user);
return this.get('userService')
.add(this.get('newUser'))
.then((user) => {
this.get('model').pushObject(user);
})
.catch(function (error) {
let msg = error.status === 409 ? 'Unable to add duplicate user' : 'Unable to add user';
this.showNotification(msg);
});
onAddUser(user) {
return this.get('userService').add(user).then((user) => {
this.get('model').pushObject(user);
});
},
onAddUsers(list) {
return this.get('userService').addBulk(list).then(() => {
this.loadUsers();
});
},
onDelete(userId) {
let self = this;
this.get('userService').remove(userId).then(function () {
self.get('userService').getComplete().then(function (users) {
self.set('model', users);
});
this.get('userService').remove(userId).then( () => {
this.loadUsers();
});
},
onSave(user) {
let self = this;
this.get('userService').save(user).then(function () {
self.get('userService').getComplete().then(function (users) {
self.set('model', users);
this.get('userService').save(user).then(() => {
this.get('userService').getComplete().then((users) => {
this.set('model', users);
});
});
},

View file

@ -1,12 +1,8 @@
<div class="row">
<div class="col">
<div class="view-customize">
<h1 class="admin-heading">Users</h1>
<h2 class="sub-heading">Set basic information, passwords and permissions for {{model.length}} users</h2>
</div>
</div>
</div>
{{customize/user-admin
onAddUser=(action 'onAddUser')
onAddUsers=(action 'onAddUsers')}}
{{customize/user-settings add=(action 'add')}}
{{customize/user-admin users=model onDelete=(action "onDelete") onSave=(action "onSave") onPassword=(action "onPassword")}}
{{customize/user-list users=model
onDelete=(action "onDelete")
onSave=(action "onSave")
onPassword=(action "onPassword")}}