From: Galen Charlton Date: Fri, 11 Dec 2015 03:35:57 +0000 (-0500) Subject: make copy alert suppression editor feature-complete X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bc895ad181a66dd2643f1b27766fffa2647480ee;p=working%2FEvergreen.git make copy alert suppression editor feature-complete Signed-off-by: Galen Charlton Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/templates/staff/admin/local/autoGridEditor/acas.tt2 b/Open-ILS/src/templates/staff/admin/local/autoGridEditor/acas.tt2 new file mode 100644 index 0000000000..301834d7e5 --- /dev/null +++ b/Open-ILS/src/templates/staff/admin/local/autoGridEditor/acas.tt2 @@ -0,0 +1,29 @@ + +
+
+ + + +
+
diff --git a/Open-ILS/web/js/ui/default/staff/admin/local/app.js b/Open-ILS/web/js/ui/default/staff/admin/local/app.js index fcceb0b186..9d0e80234b 100644 --- a/Open-ILS/web/js/ui/default/staff/admin/local/app.js +++ b/Open-ILS/web/js/ui/default/staff/admin/local/app.js @@ -60,7 +60,11 @@ angular.module('egLocalAdmin', $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 @@ -124,6 +128,8 @@ function($scope , $route , $location , egCore , $timeout , egConfirmDialog , $mo $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; @@ -132,9 +138,66 @@ function($scope , $route , $location , egCore , $timeout , egConfirmDialog , $mo }; $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(