webstaff: add admin interface for MARC tag tables
authorGalen Charlton <gmc@esilibrary.com>
Fri, 10 Jun 2016 22:21:31 +0000 (18:21 -0400)
committerMike Rylander <mrylander@gmail.com>
Thu, 18 Aug 2016 19:34:21 +0000 (15:34 -0400)
This is a simple interface using eg-edit-fm-record to start;
more work will be required to better deal with the semantics
for overriding tag definitions at various levels of the OU
hierarchy.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/templates/staff/admin/server/config/marc_field.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/admin/server/t_splash.tt2
Open-ILS/web/js/ui/default/staff/admin/server/config/marc_field.js [new file with mode: 0644]

diff --git a/Open-ILS/src/templates/staff/admin/server/config/marc_field.tt2 b/Open-ILS/src/templates/staff/admin/server/config/marc_field.tt2
new file mode 100644 (file)
index 0000000..3316ab6
--- /dev/null
@@ -0,0 +1,53 @@
+[%
+  WRAPPER "staff/base.tt2";
+  ctx.page_title = l("MARC Tag Tables");
+  ctx.page_app = "egAdminConfig";
+  ctx.page_ctrl = 'MarcField';
+%]
+
+[% BLOCK APP_JS %]
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/grid.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/fm_record_editor.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/admin/server/config/marc_field.js"></script>
+<link rel="stylesheet" href="[% ctx.base_path %]/staff/css/admin.css" />
+[% END %]
+
+<div class="container-fluid" style="text-align:center">
+  <div class="alert alert-info alert-less-pad strong-text-2">
+    [% l('MARC Tag Tables') %]
+  </div>
+</div>
+
+<div class="row">
+  <div class="col-md-2">
+    <div class="form-group">
+      <label>[% l('MARC Record Type') %]</label>
+      <select class="form-control" ng-model="marc_record_type">
+        <option value="biblio">[% l('Bibliographic') %]</option>
+        <option value="authority">[% l('Authority') %]</option>
+        <option value="serial">[% l('Holdings') %]</option>
+      </select>
+    </div>
+  </div>
+</div>
+
+<eg-grid
+    id-field="id"
+    idl-class="cmrcfld"
+    grid-controls="gridControls"
+    features="-multiselect"
+    persist-key="admin.server.config.marc_field">
+
+    <eg-grid-menu-item handler="new_record" label="[% l('New Record') %]"></eg-grid-menu-item>
+    <eg-grid-action handler="edit_record" label="[% l('Edit Record') %]"></eg-grid-action>
+    <eg-grid-action handler="delete_record" label="[% l('Delete Record') %]"></eg-grid-action>
+
+    <eg-grid-field label="[% l('Tag') %]"         path="tag"></eg-grid-field>
+    <eg-grid-field label="[% l('Name') %]"        path="name"></eg-grid-field>
+    <eg-grid-field label="[% l('Description') %]" path="description"></eg-grid-field>
+    <eg-grid-field label="[% l('ID') %]" path='id' required hidden></eg-grid-field>
+    <eg-grid-field path='*' hidden></eg-grid-field>
+</eg-grid>
+
+[% END %]
index 1431942..231dd5c 100644 (file)
@@ -44,6 +44,7 @@
     ,[ l('MARC Search/Facet Classes'), "./admin/server/config/metabib_class" ]
     ,[ l('MARC Search/Facet Field FTS Maps'), "./admin/server/config/metabib_field_ts_map" ]
     ,[ l('MARC Search/Facet Fields'), "./admin/server/config/metabib_field" ]
+    ,[ l('MARC Tag Tables'), "./admin/server/config/marc_field" ]
     ,[ l('Org Unit Proximity Adjustments'), "./admin/server/config/org_unit_proximity_adjustment" ]
     ,[ l('Organization Types'), "./admin/server/legacy/actor/org_unit_type" ]
     ,[ l('Org Unit Setting Types'), "./admin/server/config/org_unit_setting_type" ]
@@ -59,7 +60,7 @@
     ,[ l('Z39.50 Servers'), "./admin/server/config/z3950_source" ]
    ];
 
-   USE table(interfaces, rows=16);
+   USE table(interfaces, rows=17);
 %]
 
 [% FOREACH row = table.rows %]
diff --git a/Open-ILS/web/js/ui/default/staff/admin/server/config/marc_field.js b/Open-ILS/web/js/ui/default/staff/admin/server/config/marc_field.js
new file mode 100644 (file)
index 0000000..fe6f93f
--- /dev/null
@@ -0,0 +1,88 @@
+angular.module('egAdminConfig',
+    ['ngRoute','ui.bootstrap','egCoreMod','egUiMod','egGridMod','egFmRecordEditorMod'])
+
+.controller('MarcField',
+       ['$scope','$q','$timeout','$location','$window','$uibModal','egCore','egGridDataProvider',
+        'egConfirmDialog',
+function($scope , $q , $timeout , $location , $window , $uibModal , egCore , egGridDataProvider ,
+         egConfirmDialog) {
+
+    egCore.startup.go(); // standalone mode requires manual startup
+
+    $scope.marc_record_type = 'biblio';
+    $scope.$watch('marc_record_type', function(newVal, oldVal) {
+        if (newVal != oldVal) {
+            $scope.gridControls.setQuery(generateQuery($scope.marc_record_type));
+            $scope.gridControls.refresh();
+        }
+    });
+
+    $scope.new_record = function() {
+        spawn_editor();
+    }
+
+    $scope.edit_record = function(items) {
+        if (items.length != 1) return;
+        spawn_editor(items[0].id);
+    }
+
+    spawn_editor = function(id) {
+        var templ;
+        if (arguments.length == 1) {
+            templ = '<eg-edit-fm-record idl-class="cmrcfld" mode="update" record-id="id" on-save="ok" on-cancel="cancel"></eg-edit-fm-record>';
+        } else {
+            templ = '<eg-edit-fm-record idl-class="cmrcfld" mode="create" on-save="ok" on-cancel="cancel"></eg-edit-fm-record>';
+        }
+        gridControls = $scope.gridControls;
+        $uibModal.open({
+            template : templ,
+            controller : [
+                        '$scope', '$uibModalInstance',
+                function($scope ,  $uibModalInstance) {
+                    $scope.id = id;
+
+                    $scope.ok = function($event) {
+                        $uibModalInstance.close();
+                        gridControls.refresh();
+                    }
+    
+                    $scope.cancel = function($event) {
+                        $uibModalInstance.dismiss();
+                    }
+                }
+            ]
+        });
+    }
+
+    $scope.delete_record = function(selected) {
+        if (!selected || !selected.length) return;
+
+        egCore.pcrud.retrieve('cmrcfld', selected[0].id).then(function(rec) {
+            egConfirmDialog.open(
+                egCore.strings.EG_CONFIRM_DELETE_RECORD_TITLE,
+                egCore.strings.EG_CONFIRM_DELETE_RECORD_BODY,
+                { id : rec.id() } // TODO replace with selector if available?
+            ).result.then(function() {
+                egCore.pcrud.remove(rec).then(function() {
+                    $scope.gridControls.refresh();
+                });
+            });
+        });
+    }
+
+    function generateQuery(marc_record_type) {
+        return {
+            'id' : { '!=' : null },
+            'marc_record_type' : marc_record_type
+        }
+    }
+
+    $scope.gridControls = {
+        setQuery : function() {
+            return generateQuery($scope.marc_record_type);
+        },
+        setSort : function() {
+            return ['tag'];
+        }
+    }
+}])