LP#1673857: admin interfaces for copy tag types and copy tags
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 30 Mar 2017 21:08:19 +0000 (17:08 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 24 Jul 2017 15:29:08 +0000 (11:29 -0400)
This patch adds standard administration interfaces to manage
copy tag types (Server Administration) and copy tags (Local
Administration)

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Josh Stompro <stomproj@larl.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/admin/local/asset/copy_tag.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/admin/local/t_splash.tt2
Open-ILS/src/templates/staff/admin/server/config/copy_tag_type.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/admin/server/t_splash.tt2
Open-ILS/web/js/ui/default/staff/admin/local/asset/copy_tag.js [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/admin/server/config/copy_tag_type.js [new file with mode: 0644]

diff --git a/Open-ILS/src/templates/staff/admin/local/asset/copy_tag.tt2 b/Open-ILS/src/templates/staff/admin/local/asset/copy_tag.tt2
new file mode 100644 (file)
index 0000000..82d93bc
--- /dev/null
@@ -0,0 +1,50 @@
+[%
+  WRAPPER "staff/base.tt2";
+  ctx.page_title = l("Copy Tags");
+  ctx.page_app = "egAdminConfig";
+  ctx.page_ctrl = 'CopyTag';
+%]
+
+[% 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/local/asset/copy_tag.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('Copy Tags') %]
+  </div>
+</div>
+
+<div class="row">
+  <div class="col-md-4">
+    <div class="form-group">
+      <label>[% l('Filter by Owning Library:') %]</label>
+      <eg-org-selector selected="context_org" onchange="org_changed"></eg-org-selector>
+    </div>
+  </div>
+</div>
+
+<eg-grid
+    id-field="id"
+    idl-class="acpt"
+    grid-controls="gridControls"
+    features="-multiselect"
+    persist-key="admin.server.asset.copy_tag">
+
+    <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('Owner') %]" flesher="orgById" path="owner.name"></eg-grid-field>
+    <eg-grid-field label="[% l('Tag Type') %]"  path="tag_type.label"></eg-grid-field>
+    <eg-grid-field label="[% l('Label') %]" path="label"></eg-grid-field>
+    <eg-grid-field label="[% l('Is OPAC Visible?') %]" path="pub"></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 22878a1..cdcccb7 100644 (file)
@@ -20,6 +20,7 @@
     ,[ l('Copy Location Groups'), "./admin/local/asset/copy_location_group" ]
     ,[ l('Copy Location Order'), "./admin/local/asset/copy_location_order" ]
     ,[ l('Copy Locations Editor'), "./admin/local/asset/copy_locations" ]
+    ,[ l('Copy Tags'), "./admin/local/asset/copy_tag" ]
     ,[ l('Field Documentation'), "./admin/local/config/idl_field_doc" ]
     ,[ l('Group Penalty Thresholds'), "./admin/local/permission/grp_penalty_threshold" ]
     ,[ l('Hold Policies'), "./admin/local/config/hold_matrix_matchpoint" ]
diff --git a/Open-ILS/src/templates/staff/admin/server/config/copy_tag_type.tt2 b/Open-ILS/src/templates/staff/admin/server/config/copy_tag_type.tt2
new file mode 100644 (file)
index 0000000..676083d
--- /dev/null
@@ -0,0 +1,38 @@
+[%
+  WRAPPER "staff/base.tt2";
+  ctx.page_title = l("Copy Tag Types");
+  ctx.page_app = "egAdminConfig";
+  ctx.page_ctrl = 'CopyTagType';
+%]
+
+[% 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/copy_tag_type.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('Copy Tag Types') %]
+  </div>
+</div>
+
+<eg-grid
+    id-field="code"
+    idl-class="cctt"
+    grid-controls="gridControls"
+    features="-multiselect"
+    persist-key="admin.server.config.copy_tag_type">
+
+    <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('Code') %]"  path="code"></eg-grid-field>
+    <eg-grid-field label="[% l('Label') %]" path="label"></eg-grid-field>
+    <eg-grid-field label="[% l('Owner') %]" flesher="orgById" path="owner.name"></eg-grid-field>
+</eg-grid>
+
+[% END %]
index 5d8bf43..36faae3 100644 (file)
@@ -26,6 +26,7 @@
     ,[ l('Circulation Modifiers'), "./admin/server/config/circ_modifier" ]
     ,[ l('Circulation Recurring Fine Rules'), "./admin/server/config/rule_recurring_fine" ]
     ,[ l('Copy Statuses'), "./admin/server/legacy/config/copy_status" ]
+    ,[ l('Copy Tag Types'), "./admin/server/config/copy_tag_type" ]
     ,[ l('Custom Org Unit Trees'), "./admin/server/actor/org_unit_custom_tree" ]
     ,[ l('Floating Groups'), "./admin/server/config/floating_groups" ]
     ,[ l('Global Flags'), "./admin/server/config/global_flag" ]
diff --git a/Open-ILS/web/js/ui/default/staff/admin/local/asset/copy_tag.js b/Open-ILS/web/js/ui/default/staff/admin/local/asset/copy_tag.js
new file mode 100644 (file)
index 0000000..3d9ca2c
--- /dev/null
@@ -0,0 +1,90 @@
+angular.module('egAdminConfig',
+    ['ngRoute','ui.bootstrap','egCoreMod','egUiMod','egGridMod','egFmRecordEditorMod'])
+
+.controller('CopyTag',
+       ['$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.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="acpt" mode="update" record-id="id" on-save="ok" on-cancel="cancel"></eg-edit-fm-record>';
+        } else {
+            templ = '<eg-edit-fm-record idl-class="acpt" 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('acpt', 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() }
+            ).result.then(function() {
+                egCore.pcrud.remove(rec).then(function() {
+                    $scope.gridControls.refresh();
+                });
+            });
+        });
+    }
+
+    function generateQuery(orgId) {
+
+        // because the orgId is coming from a selector,
+        // it should always have a value unless the selector
+        // hasn't been fully initialized yet, in which case
+        // we want to abort to avoid fetching anything.
+        if (!orgId) return;
+
+        return {
+            'id' : { '!=' : null },
+            'owner' : egCore.org.descendants(orgId, true)
+        };
+    }
+    $scope.gridControls = {
+        setQuery : function() { return generateQuery(); },
+        setSort : function() {
+            return ['owner.name', 'label'];
+        }
+    }
+
+    $scope.org_changed = function(org) {
+        $scope.gridControls.setQuery(generateQuery(org.id()));
+        $scope.gridControls.refresh();
+    }
+
+}])
diff --git a/Open-ILS/web/js/ui/default/staff/admin/server/config/copy_tag_type.js b/Open-ILS/web/js/ui/default/staff/admin/server/config/copy_tag_type.js
new file mode 100644 (file)
index 0000000..5d367eb
--- /dev/null
@@ -0,0 +1,73 @@
+angular.module('egAdminConfig',
+    ['ngRoute','ui.bootstrap','egCoreMod','egUiMod','egGridMod','egFmRecordEditorMod'])
+
+.controller('CopyTagType',
+       ['$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.new_record = function() {
+        spawn_editor();
+    }
+
+    $scope.edit_record = function(items) {
+        if (items.length != 1) return;
+        spawn_editor(items[0].code);
+    }
+
+    spawn_editor = function(code) {
+        var templ;
+        if (arguments.length == 1) {
+            templ = '<eg-edit-fm-record idl-class="cctt" mode="update" record-id="code" on-save="ok" on-cancel="cancel"></eg-edit-fm-record>';
+        } else {
+            templ = '<eg-edit-fm-record idl-class="cctt" 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.code = code;
+
+                    $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('cctt', selected[0].code).then(function(rec) {
+            egConfirmDialog.open(
+                egCore.strings.EG_CONFIRM_DELETE_RECORD_TITLE,
+                egCore.strings.EG_CONFIRM_DELETE_RECORD_BODY,
+                { code : rec.code() }
+            ).result.then(function() {
+                egCore.pcrud.remove(rec).then(function() {
+                    $scope.gridControls.refresh();
+                });
+            });
+        });
+    }
+
+    $scope.gridControls = {
+        setQuery : function() {
+            return { 'code' : { '!=' : null } };
+        },
+        setSort : function() {
+            return ['code'];
+        }
+    }
+}])