start on a config editor for config.copy_alert_types
authorGalen Charlton <gmc@esilibrary.com>
Thu, 10 Dec 2015 23:17:24 +0000 (18:17 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 3 Nov 2017 20:01:31 +0000 (16:01 -0400)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/admin/local/index.tt2
Open-ILS/src/templates/staff/admin/local/t_grid_editor.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/admin/local/app.js

index 02d604f..6200f6e 100644 (file)
@@ -7,8 +7,14 @@
 
 [% BLOCK APP_JS %]
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/eframe.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/grid.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/admin/local/app.js"></script>
 <link rel="stylesheet" href="[% ctx.base_path %]/staff/css/admin.css" />
+<script>
+angular.module('egCoreMod').run(['egStrings', function(s) {
+  s.REMOVE_ITEM_CONFIRM = '[% l('Delete rows?') %]';
+}]);
+</script
 [% END %]
 
 <div ng-view></div>
diff --git a/Open-ILS/src/templates/staff/admin/local/t_grid_editor.tt2 b/Open-ILS/src/templates/staff/admin/local/t_grid_editor.tt2
new file mode 100644 (file)
index 0000000..54f3da0
--- /dev/null
@@ -0,0 +1,12 @@
+<eg-grid
+  id-field="id"
+  idl-class="{{baseFmClass}}"
+  features="-multisort,-multiselect"
+  grid-controls="gridControls"
+  auto-fields="true"
+  persist-key="admin.local.config.grideditor.{{baseFmClass}}">
+
+  <eg-grid-menu-item label="[% l('Create') %]" handler="createHandler"></eg-grid-menu-item>
+  <eg-grid-action handler="editHandler" label="[% l('Edit') %]"></eg-grid-action>
+  <eg-grid-action handler="deleteHandler" label="[% l('Delete') %]"></eg-grid-action>
+</eg-grid>
index afceb4d..016beb9 100644 (file)
@@ -1,5 +1,5 @@
 angular.module('egLocalAdmin',
-    ['ngRoute', 'ui.bootstrap', 'egCoreMod','egUiMod'])
+    ['ngRoute', 'ui.bootstrap', 'egCoreMod','egUiMod','egGridMod'])
 
 .config(['$routeProvider','$locationProvider','$compileProvider', 
  function($routeProvider , $locationProvider , $compileProvider) {
@@ -51,6 +51,12 @@ angular.module('egLocalAdmin',
         resolve : resolver
     });
 
+    $routeProvider.when('/admin/local/config/copy_alert_types', {
+        templateUrl: './admin/local/t_grid_editor',
+        controller: 'AutoGridEditorCtl',
+        fmBase: 'ccat'
+    });
+
     // Conify page handler
     $routeProvider.when('/admin/local/:schema/:page', {
         template: eframe_template,
@@ -105,3 +111,41 @@ function($scope , $location , egCore , $timeout) {
     $scope.local_admin_url = $location.absUrl().replace(/\/.*/, url);
 }])
 
+.controller('AutoGridEditorCtl',
+       ['$scope','$route','$location','egCore','$timeout','egConfirmDialog','$modal',
+function($scope , $route , $location , egCore , $timeout , egConfirmDialog , $modal) {
+
+    $scope.funcs = {};
+
+    $scope.baseFmClass = $route.current.$$route.fmBase;
+    $scope.gridControls = {
+        setQuery : function(q) {
+            if (q) query = q;
+            return query;
+        }
+    };
+    $scope.gridControls.setQuery({id : {'!=' : null}});
+
+    $scope.createHandler = function() {
+    };
+    $scope.editHandler = function(items) {
+    };
+    $scope.deleteHandler = function(items) {
+        egConfirmDialog.open(
+            egCore.strings.REMOVE_ITEM_CONFIRM,
+            '',
+            {}
+        ).result.then(function() {
+            var ids = items.map(function(s){ return s.id });
+            egCore.pcrud.search(
+                $scope.baseFmClass, {id : ids}, {},
+                {atomic : true, authoritative : true}
+            ).then(function(to_delete) {
+                return egCore.pcrud.remove(to_delete);
+            }).then(function() {
+                $scope.gridControls.refresh();
+            });
+        });
+    };
+}])
+