您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

groupusersadd.controller.js 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /**
  2. * Created by robin on 11/6/15.
  3. */
  4. angular.module('luticate')
  5. .controller('GroupUsersAddController', ['$scope', 'luticateAuthUsers', 'data', '$q', 'dialogs', 'luticateAuthGroups',
  6. function($scope, luticateAuthUsers, data, $q, dialogs, luticateAuthGroups) {
  7. $scope.selectedUsers = [];
  8. $scope.group = data;
  9. $scope.userPicker = {
  10. columns: [
  11. {
  12. name: "Username",
  13. width: 3,
  14. getValue: function (item) {
  15. return item.Username;
  16. }
  17. }, {
  18. name: "Email",
  19. width: 3,
  20. getValue: function (item) {
  21. return item.Email;
  22. }
  23. }, {
  24. name: "Firstname",
  25. width: 3,
  26. getValue: function (item) {
  27. return item.Firstname;
  28. }
  29. }, {
  30. name: "Lastname",
  31. width: 3,
  32. getValue: function (item) {
  33. return item.Lastname;
  34. }
  35. }
  36. ],
  37. canAdd: 'LU_USER_ADD',
  38. canDel: 'LU_USER_DEL',
  39. canEdit: 'LU_USER_EDIT',
  40. getLoadPagePromise: function (page, perPage, query, promise) {
  41. return luticateAuthUsers.getAll({page: page, perPage: perPage, query: query}, promise);
  42. },
  43. getItemText: function(item)
  44. {
  45. return item.Username;
  46. }
  47. };
  48. $scope.addUser = function(defer)
  49. {
  50. if ($scope.userPicker.pickedItems.length == 0) {
  51. defer.resolve();
  52. return;
  53. }
  54. var promiseAddUser = {
  55. id: "promiseAddUser",
  56. loaderGroups: ["modal"]
  57. };
  58. var user = $scope.userPicker.pickedItems[0];
  59. luticateAuthGroups.usersAdd({
  60. group_id: $scope.group.Id,
  61. user_id: user.Id
  62. }, promiseAddUser).then(function(data)
  63. {
  64. $scope.userPicker.pickedItems.splice(0, 1);
  65. $scope.addUser(defer);
  66. }, function(error)
  67. {
  68. defer.reject(error);
  69. });
  70. };
  71. $scope.submitForm = function()
  72. {
  73. var defer = $q.defer();
  74. $scope.addUser(defer);
  75. return defer.promise;
  76. };
  77. }]);