1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- /**
- * Created by robin on 11/6/15.
- */
-
- angular.module('luticate')
- .controller('GroupUsersAddController', ['$scope', 'luticateAuthUsers', 'data', '$q', 'dialogs', 'luticateAuthGroups',
- function($scope, luticateAuthUsers, data, $q, dialogs, luticateAuthGroups) {
- $scope.selectedUsers = [];
- $scope.group = data;
- $scope.userPicker = {
- columns: [
- {
- name: "Username",
- width: 3,
- getValue: function (item) {
- return item.Username;
- }
- }, {
- name: "Email",
- width: 3,
- getValue: function (item) {
- return item.Email;
- }
- }, {
- name: "Firstname",
- width: 3,
- getValue: function (item) {
- return item.Firstname;
- }
- }, {
- name: "Lastname",
- width: 3,
- getValue: function (item) {
- return item.Lastname;
- }
- }
- ],
-
- canAdd: 'LU_USER_ADD',
-
- canDel: 'LU_USER_DEL',
-
- canEdit: 'LU_USER_EDIT',
-
- getLoadPagePromise: function (page, perPage, query, promise) {
- return luticateAuthUsers.getAll({page: page, perPage: perPage, query: query}, promise);
- },
-
- getItemText: function(item)
- {
- return item.Username;
- }
- };
-
- $scope.addUser = function(defer)
- {
- if ($scope.userPicker.pickedItems.length == 0) {
- defer.resolve();
- return;
- }
-
- var promiseAddUser = {
- id: "promiseAddUser",
- loaderGroups: ["modal"]
- };
-
- var user = $scope.userPicker.pickedItems[0];
- luticateAuthGroups.usersAdd({
- group_id: $scope.group.Id,
- user_id: user.Id
- }, promiseAddUser).then(function(data)
- {
- $scope.userPicker.pickedItems.splice(0, 1);
- $scope.addUser(defer);
- }, function(error)
- {
- defer.reject(error);
- });
- };
-
- $scope.submitForm = function()
- {
- var defer = $q.defer();
-
- $scope.addUser(defer);
-
- return defer.promise;
- };
- }]);
|