--- /dev/null
+<!-- use <form> so we get submit-on-enter for free -->
+<form class="form-validated" novalidate name="form" ng-submit="ok(record)">
+ <div>
+ <div class="modal-header">
+ <button type="button" class="close"
+ ng-click="cancel()" aria-hidden="true">×</button>
+ <h4 ng-if="creating" class="modal-title">[% l('Create copy alert suppression rule') %]</h4>
+ <h4 ng-if="!creating" class="modal-title">[% l('Update copy alert suppression rule') %]</h4>
+ </div>
+ <div class="modal-body">
+ <div class="form-group">
+ <label for="copy-alert-type-selector">[% l('Alert Type') %]</label>
+ <select id="copy-alert-type-selector" class="form-control"
+ ng-model="record.alert_type"
+ ng-options="at.id() as at.name() for at in ccat">
+ </select>
+ </div>
+ <div class="form-group">
+ <label for="select-org-unit">[% l('Org Unit') %]</label>
+ <eg-org-selector selected="record.org"></eg-org-selector>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <input type="submit" ng-disabled="form.$invalid"
+ class="btn btn-primary" value="[% l('Save') %]"/>
+ <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
+ </div>
+ </div> <!-- modal-content -->
+</form>
$routeProvider.when('/admin/local/actor/copy_alert_suppress', {
templateUrl: './admin/local/t_grid_editor',
controller: 'AutoGridEditorCtl',
- fmBase: 'acas'
+ fmBase: 'acas',
+ createEditPrefetch: {
+ ccat : { active: 't' }
+ },
+ createEditOrgExpand: ['org']
});
// Conify page handler
$scope.funcs = {};
$scope.baseFmClass = $route.current.$$route.fmBase;
+ $scope.createEditPrefetch = $route.current.$$route.createEditPrefetch || {};
+ $scope.createEditOrgExpand = $route.current.$$route.createEditOrgExpand || [];
$scope.gridControls = {
setQuery : function(q) {
if (q) query = q;
};
$scope.gridControls.setQuery({id : {'!=' : null}});
+ function openCreateEditDialog(id) {
+ return $modal.open({
+ templateUrl : './admin/local/autoGridEditor/' + $scope.baseFmClass,
+ scope : $scope,
+ controller :
+ ['$scope', '$modalInstance', function($scope, $modalInstance) {
+ $scope.creating = id ? false : true;
+ angular.forEach($scope.$parent.createEditPrefetch, function(where, fmClass) {
+ egCore.pcrud.search(
+ fmClass, where, {},
+ {atomic : true, authoritative : true}
+ ).then(function(vals) {
+ $scope[fmClass] = vals;
+ });
+ });
+ if ($scope.creating) {
+ $scope.record = {};
+ } else {
+ egCore.pcrud.retrieve($scope.baseFmClass, id).then(function(to_edit) {
+ $scope.record = egCore.idl.toHash(to_edit);
+ angular.forEach($scope.createEditOrgExpand, function(ou_field) {
+ $scope.record[ou_field] = egCore.org.get($scope.record[ou_field]);
+ });
+ });
+ }
+ $scope.ok = function(record) { $modalInstance.close(record) };
+ $scope.cancel = function () { $modalInstance.dismiss() }
+ }]
+ });
+ }
+
$scope.createHandler = function() {
+ openCreateEditDialog().result.then(function(record) {
+ var newRec = new egCore.idl[$scope.baseFmClass]();
+ angular.forEach(record, function(val, key) {
+ if (typeof(val) === 'object') {
+ newRec[key](val.id());
+ } else {
+ newRec[key](val);
+ }
+ });
+ return egCore.pcrud.create(newRec);
+ }).then(function(){
+ $scope.gridControls.refresh();
+ });
};
$scope.editHandler = function(items) {
+ openCreateEditDialog(items[0].id).result.then(function(record) {
+ var editedRec = new egCore.idl[$scope.baseFmClass]();
+ angular.forEach(record, function(val, key) {
+ if (typeof(val) === 'object') {
+ editedRec[key](val.id());
+ } else {
+ editedRec[key](val);
+ }
+ });
+ return egCore.pcrud.update(editedRec);
+ }).then(function(){
+ $scope.gridControls.refresh();
+ });
};
$scope.deleteHandler = function(items) {
egConfirmDialog.open(