Initial commit
This commit is contained in:
commit
880e39de2e
511 files changed
+38363
No files matched your search
@@ -0,0 +1,67 @@
|
||||
<md-dialog flex>
|
||||
<form name="permForm" ng-submit="permForm.$valid && ok()">
|
||||
<md-toolbar>
|
||||
<div class="md-toolbar-tools md-portal">
|
||||
<span>{{header}}</span>
|
||||
<span flex></span>
|
||||
<md-button class="md-icon-button" ng-click="cancel()">
|
||||
<md-icon aria-label="Close dialog">close</md-icon>
|
||||
</md-button>
|
||||
</div>
|
||||
</md-toolbar>
|
||||
<md-dialog-content layout-padding flex>
|
||||
<div>
|
||||
<div layout="row">
|
||||
<md-input-container class="md-block" flex-gt-xs ng-if="isNew">
|
||||
<label>Permission Group Unique Name</label>
|
||||
<input ng-model="permission.name" name="name" id="name" required>
|
||||
<div ng-messages="permForm.name.$error" ng-show="permForm.name.$invalid && submitted || permForm.name.$touched">
|
||||
<div ng-message="required">Unique name required</div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
<md-input-container class="md-block" flex-gt-xs>
|
||||
<label>Permission Group Display Name</label>
|
||||
<input ng-model="permission.displayName" name="displayName" id="displayName" required>
|
||||
<div ng-messages="permForm.displayName.$error" ng-show="permForm.displayName.$invalid && submitted || permForm.displayName.$touched">
|
||||
<div ng-message="required">Display name required</div>
|
||||
</div>
|
||||
</md-input-container>
|
||||
</div>
|
||||
<div layout="row" flex>
|
||||
<md-list>
|
||||
<md-list-item>
|
||||
<p flex>Permission Group Enabled</p>
|
||||
<span flex="5"></span>
|
||||
<md-switch md-invert ng-model="permission.enabled" class="md-primary">{{permission.enabled ? 'True' : 'False'}}</md-switch>
|
||||
</md-list-item>
|
||||
</md-list>
|
||||
</div>
|
||||
</div>
|
||||
<div layout="row" flex>
|
||||
<md-tabs md-dynamic-height flex>
|
||||
<md-tab ng-repeat="cat in permissionCategories" label="{{cat.displayName}}">
|
||||
<md-content class="md-padding" flex>
|
||||
<md-list>
|
||||
<md-list-item ng-repeat="perm in cat.permissions">
|
||||
<p>{{perm.displayName}}</p>
|
||||
<span flex="5"></span>
|
||||
<md-switch ng-model="perm.allowed" class="md-primary">{{perm.allowed ? 'Enabled' : 'Disabled'}}</md-switch>
|
||||
</md-list-item>
|
||||
</md-list>
|
||||
</md-content>
|
||||
</md-tab>
|
||||
</md-tabs>
|
||||
</div>
|
||||
<div ng-show="loadingBlock" class="loadingFade"></div>
|
||||
<div class="loadingModal" ng-show="loadingBlock">
|
||||
<md-progress-circular md-mode="indeterminate" md-diameter="80" class="md-hue-2"></md-progress-circular>
|
||||
</div>
|
||||
</md-dialog-content>
|
||||
<md-dialog-actions layout="row" class="modal-footer">
|
||||
<div class="text-danger">{{error}}</div>
|
||||
<md-button id="okButton" type="submit" class="md-raised md-primary" >OK</md-button>
|
||||
<md-button id="cancelButton" class="md-raised md-warn" ng-click="cancel()">Cancel</md-button>
|
||||
</md-dialog-actions>
|
||||
</form>
|
||||
</md-dialog>
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* MODULE DESCRIPTION:
|
||||
*
|
||||
* TODO: Write description here.
|
||||
*/
|
||||
angular.module('portal.common.partials.addPermission', ['ui.router']).controller('AddPermissionCtrl', AddPermissionCtrlController);
|
||||
|
||||
function AddPermissionCtrlController($scope, modalInstance, $state, cache, $mdDialog, permissionObjects,
|
||||
permissionStores, permissionProvider, portalUtils) {
|
||||
|
||||
$scope.header = modalInstance.header;
|
||||
|
||||
$scope.submitted = false;
|
||||
$scope.loadingBlock = false;
|
||||
|
||||
$scope.isNew = modalInstance.permission === undefined ? true : false;
|
||||
|
||||
$scope.permission = $scope.isNew ? new permissionObjects.PermissionGroup() : new permissionObjects.PermissionGroup(modalInstance.permission);
|
||||
|
||||
$scope.valid = false;
|
||||
$scope.permissionCategories = [];
|
||||
|
||||
$scope.mCache = cache.request([new permissionStores.PermissionCategories()]).then(function(){
|
||||
$scope.permissionCategories = $scope.mCache.permissionCategories.data.values;
|
||||
if (!$scope.isNew) {
|
||||
$.each($scope.permission.permissions, function(key, value) {
|
||||
for (var i = 0; i < $scope.permissionCategories.length; i++) {
|
||||
var cat = $scope.permissionCategories[i];
|
||||
if (cat.name !== value.permissionCategory) {
|
||||
continue;
|
||||
}
|
||||
for (var j = 0; j < cat.permissions.length; j++) {
|
||||
var perm = cat.permissions[j];
|
||||
if (value.permissionId === perm.id) {
|
||||
perm.allowed = value.allowed;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}).catch(function(err){
|
||||
portalUtils.toast('Unable to get permission categories: ' + err.message, ['top', 'left'], 2000);
|
||||
});
|
||||
|
||||
/**
|
||||
* OK button handler
|
||||
* @returns {undefined}
|
||||
*/
|
||||
$scope.ok = function () {
|
||||
$scope.loadingBlock = true;
|
||||
var status = $scope.isNew ? 'added': 'edited';
|
||||
$scope.submitted = true;
|
||||
|
||||
$scope.permission.permissions = [];
|
||||
$.each($scope.permissionCategories, function(key, cat) {
|
||||
$.each(cat.permissions, function(key2, perm) {
|
||||
var newPerm = new permissionObjects.PermissionGroupPermission({
|
||||
permissionId: perm.id,
|
||||
permissionGroupId: $scope.permission.id,
|
||||
name: perm.name,
|
||||
displayName: perm.displayName,
|
||||
allowed: perm.allowed === undefined ? false : perm.allowed
|
||||
});
|
||||
$scope.permission.permissions.push(newPerm);
|
||||
});
|
||||
});
|
||||
|
||||
permissionProvider.updatePermissions($scope.isNew, $scope.permission).then(function(results) {
|
||||
$scope.loadingBlock = false;
|
||||
portalUtils.toast('Permission ' + status + ' successfully', ['top', 'left'], 2000);
|
||||
$mdDialog.hide();
|
||||
}).catch(function(err){
|
||||
$scope.loadingBlock = false;
|
||||
$scope.error = err.message;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Cancel button handler.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
$scope.cancel = function () {
|
||||
//Dismiss the modal
|
||||
$mdDialog.cancel();
|
||||
};
|
||||
|
||||
} //end AddPermissionCtrlController function
|
||||
|
||||
})();
|
||||
Reference in new issue
Block a user