From 44489c666f1a7105ea7c22810133759e7c45f024 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 25 Jan 2016 18:34:54 -0500 Subject: [PATCH] webstaff: implement import/export of copy templates Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- .../src/templates/staff/cat/volcopy/t_attr_edit.tt2 | 11 +++++++++-- Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 b/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 index 9753d5370c..09e87d234c 100644 --- a/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 +++ b/Open-ILS/src/templates/staff/cat/volcopy/t_attr_edit.tt2 @@ -19,8 +19,15 @@
- - + + [% l('Import') %] + + +
diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js index 9bdec0beba..cfd974a268 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js @@ -1624,9 +1624,24 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore , } $scope.templates = {}; + $scope.imported_templates = { data : '' }; $scope.template_name = ''; $scope.template_name_list = []; - + + $scope.$watch('imported_templates.data', function(newVal, oldVal) { + if (newVal && newVal != oldVal) { + try { + var newTemplates = JSON.parse(newVal); + if (!Object.keys(newTemplates).length) return; + $scope.templates = newTemplates; + $scope.template_name_list = Object.keys(newTemplates); + $scope.template_name = ''; + } catch (E) { + console.log('tried to import an invalid copy template file'); + } + } + }); + $scope.tracker = function (x,f) { if (x) return x[f]() }; $scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') }; $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); }; -- 2.11.0