cobuild-angular-stack
Version:
Base stack angular sass jade gulp
87 lines (77 loc) • 2.21 kB
JavaScript
(function (module) {
'use strict';
module.controller('AdminAccountsController', AdminAccountsController);
AdminAccountsController.$inject = ['$rootScope', '$scope', 'Utils', 'UtilData', 'AdminAccount', 'toastr', '$uibModal', 'lodash'];
function AdminAccountsController($rootScope, $scope, Utils, UtilData, AdminAccount, toastr, $uibModal, lodash) {
$scope.isLoad = true;
$scope.error = function(err) {
$scope.isLoad = false;
}
$scope.getAdminAccounts = function() {
AdminAccount.find().$promise.then(function(accounts) {
$scope.accounts = accounts;
$scope.isLoad = false;
},$scope.error).catch($scope.error);
}
$scope.getRole = function(role) {
var type = "Sin permisos";
switch(role) {
case "sales-read":
type = "VENTAS (LECTURA)";
break;
case "admin":
type = "ADMINISTRADOR";
break;
case "sales":
type = "VENTAS";
break;
case "partner-read":
type = "PARTNERSHIP (LECTURA)";
break;
case "partner":
type = "PARTNERSHIP";
break;
case "customer-service":
type = "ATENCIÓN A CLIENTES";
break;
case "customer-service-read":
type = "ATENCIÓN A CLIENTES (LECTURA)";
break;
case "analitic":
type = "ANÁLISIS LECTURA";
break;
}
return type;
}
$scope.editAccount = function(account) {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'partials/admin.settings.account.edit.html',
controller: 'AdminAccountsEditController',
resolve: {
account: account
}
});
modalInstance.result.then(function() {
$scope.getAdminAccounts();
})
}
$scope.createAccount = function() {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'partials/admin.settings.account.edit.html',
controller: 'AdminAccountsEditController',
resolve: {
account: {
username: "",
role: ""
}
}
});
modalInstance.result.then(function() {
$scope.getAdminAccounts();
})
}
$scope.getAdminAccounts();
};
})(angular.module('uniko.admin.settings.accounts'));