WIP collab/gmcharlt/webstaff-sprint3-editor
authorGalen Charlton <gmc@esilibrary.com>
Mon, 23 May 2016 13:49:20 +0000 (09:49 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 23 May 2016 13:49:20 +0000 (09:49 -0400)
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/src/templates/staff/share/t_fm_record_editor.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/admin/server/config/marc_field.js [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/services/fm_record_editor.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..385a4c7
--- /dev/null
@@ -0,0 +1,56 @@
+[%
+  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>
+
+<eg-edit-fm-record
+    idl-class="cmrcfld"
+    mode="update"
+    record-id="245"
+>
+</eg-edit-fm-record>
+
+<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-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/src/templates/staff/share/t_fm_record_editor.tt2 b/Open-ILS/src/templates/staff/share/t_fm_record_editor.tt2
new file mode 100644 (file)
index 0000000..aaa0861
--- /dev/null
@@ -0,0 +1,18 @@
+<div class="eg-edit-fm-record">
+
+    <h1>{{record_label}}</h1>
+  <form role="form" class="form-validated">
+    <div class="form-group row" ng-repeat="field in fields | filter:{virtual:'!true'}">
+      <div class="col-md-3">
+        <label for="rec-{{field.name}}">{{field.label}}</label>
+      </div>
+      <div class="col-md-9">
+        <span  ng-if="field.datatype == 'id' || field.readonly">{{record[field.name]}}</span>
+        <input ng-if="field.datatype == 'text'"
+          ng-model="rec[field.name]"
+          ng-model-options="{ getterSetter : true }">
+        </input>
+      </div>
+    </div>
+  </form>
+</div>
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..2866ab7
--- /dev/null
@@ -0,0 +1,33 @@
+angular.module('egAdminConfig',
+    ['ngRoute','ui.bootstrap','egCoreMod','egUiMod','egGridMod','egFmRecordEditorMod'])
+
+.controller('MarcField',
+       ['$scope','$q','$timeout','$location','$window','egCore','egGridDataProvider',
+function($scope , $q , $timeout , $location , $window , egCore , egGridDataProvider) {
+
+    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();
+        }
+    });
+
+    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'];
+        }
+    }
+}])
diff --git a/Open-ILS/web/js/ui/default/staff/services/fm_record_editor.js b/Open-ILS/web/js/ui/default/staff/services/fm_record_editor.js
new file mode 100644 (file)
index 0000000..3057a2b
--- /dev/null
@@ -0,0 +1,55 @@
+angular.module('egFmRecordEditorMod',
+    ['egCoreMod', 'egUiMod', 'ui.bootstrap'])
+
+.directive('egEditFmRecord', function() {
+    return {
+        restrict : 'AE',
+        transclude : true,
+        scope : {
+            // IDL class hint (e.g. "aou")
+            idlClass : '@',
+
+            // mode: 'create' for creating a new record,
+            //       'update' for editing an existing record
+            mode : '@',
+
+            // record ID to update
+            recordId : '@',
+
+            // reference to handler to run upon saving
+            // record. The handler will be passed the
+            // record ID and a parameter indicating whether
+            // the save did a create or an update. Note that
+            // even if the mode of the egEditFmRecord is
+            // 'create', the onSave handler may still get
+            // 'update' if the user is permitted to create a
+            // record, then update it
+            onSave : '=',
+
+        },
+
+        templateUrl : '/eg/staff/share/t_fm_record_editor',
+
+        controller : [
+                    '$scope','egCore',
+            function($scope , egCore) {
+        
+            $scope.record_label = egCore.idl.classes[$scope.idlClass].label;
+  
+            if ($scope.mode == 'update') {
+                console.debug('retrieve ' + $scope.recordId + ' of ' + $scope.idlClass);
+                egCore.pcrud.retrieve($scope.idlClass, $scope.recordId).then(function(r) { $scope.rec = r });
+            } else {
+                $scope.rec = new egCore.idl[$scope.idlClass]();
+            }
+
+            function get_field_list() {
+                var fields = egCore.idl.classes[$scope.idlClass].fields;
+
+                return fields;
+            }
+
+            $scope.fields = get_field_list();
+        }]
+    };
+})