From: Galen Charlton Date: Wed, 10 May 2017 21:37:21 +0000 (-0400) Subject: webstaff: add admin interface for managing serial pattern templates X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=96f14437c7ee85492afd445bbef1ed1ca50eb7f5;p=working%2FEvergreen.git webstaff: add admin interface for managing serial pattern templates Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/templates/staff/admin/serials/pattern_template.tt2 b/Open-ILS/src/templates/staff/admin/serials/pattern_template.tt2 new file mode 100644 index 0000000000..aab2258722 --- /dev/null +++ b/Open-ILS/src/templates/staff/admin/serials/pattern_template.tt2 @@ -0,0 +1,44 @@ +[% + WRAPPER "staff/base.tt2"; + ctx.page_title = l("Prediction Pattern Templates"); + ctx.page_app = "egAdminConfig"; + ctx.page_ctrl = 'PatternTemplate'; +%] + +[% BLOCK APP_JS %] + + + + + + + + +[% END %] + +
+
+ [% l('Prediction Templates') %] +
+
+ + + + + + + + + + + + + + + +[% END %] diff --git a/Open-ILS/src/templates/staff/admin/serials/t_splash.tt2 b/Open-ILS/src/templates/staff/admin/serials/t_splash.tt2 index f5060fa6c0..ad9f63f1db 100644 --- a/Open-ILS/src/templates/staff/admin/serials/t_splash.tt2 +++ b/Open-ILS/src/templates/staff/admin/serials/t_splash.tt2 @@ -9,7 +9,8 @@ [% interfaces = [ - [ l('Serial Templates'), "./admin/serials/templates" ] + [ l('Serial Copy Templates'), "./admin/serials/templates" ] + [ l('Pattern Templates'), "./admin/serials/pattern_template" ] ]; USE table(interfaces, cols=3); diff --git a/Open-ILS/web/js/ui/default/staff/admin/serials/pattern_template.js b/Open-ILS/web/js/ui/default/staff/admin/serials/pattern_template.js new file mode 100644 index 0000000000..3b9c5280c5 --- /dev/null +++ b/Open-ILS/web/js/ui/default/staff/admin/serials/pattern_template.js @@ -0,0 +1,111 @@ +angular.module('egAdminConfig', + ['ngRoute','ui.bootstrap','egCoreMod','egUiMod','egGridMod','egFmRecordEditorMod','egSerialsMod','egSerialsAppDep']) + +.controller('PatternTemplate', + ['$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 = ''; + } else { + templ = ''; + } + gridControls = $scope.gridControls; + $uibModal.open({ + template : templ, + controller : [ + '$scope', '$uibModalInstance', + function($scope , $uibModalInstance) { + $scope.id = id; + + $scope.openPatternEditorDialog = function(pred) { + $uibModal.open({ + templateUrl: './serials/t_pattern_editor_dialog', + size: 'lg', + windowClass: 'eg-wide-modal', + backdrop: 'static', + controller: + ['$scope', '$uibModalInstance', function($scope, $uibModalInstance) { + $scope.focusMe = true; + $scope.patternCode = pred.pattern_code; + $scope.ok = function(patternCode) { $uibModalInstance.close(patternCode) } + $scope.cancel = function () { $uibModalInstance.dismiss() } + }] + }).result.then(function (patternCode) { + if (pred.pattern_code !== patternCode) { + pred.pattern_code = patternCode; + } + }); + } + + $scope.customFieldTemplates = { + share_depth : { + template : '' + }, + pattern_code : { + handlers : { + openPatternEditorDialog : $scope.openPatternEditorDialog + }, + template : '' // FIXME i18n + } + } + + $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('spt', 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() { + return { + 'id' : { '!=' : null }, + } + } + + $scope.gridControls = { + setQuery : function() { + return generateQuery(); + }, + setSort : function() { + return ['owning_lib.name','name']; + } + } +}])