From 17abfad998801837e5be9036e754132c5a424218 Mon Sep 17 00:00:00 2001 From: Kyle Huckins Date: Tue, 26 Feb 2019 18:14:40 +0000 Subject: [PATCH] CAT-206 Update Date performs pcrud - Modify Update Date functionality to perform pcrud update of cataloging_date Signed-off-by: Kyle Huckins Changes to be committed: modified: Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js --- .../js/ui/default/staff/cat/services/marcedit.js | 31 +++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js index 63310ff0e6..83c1e37177 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js +++ b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js @@ -1194,7 +1194,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) $scope.flat_text_marc = $scope.record.toBreaker(); if ($scope.record_type == 'bre') { - $scope.cataloging_date = new Date(rec.cataloging_date()) || new Date(); + $scope.cataloging_date = Date.parse(rec.cataloging_date()) || new Date(); } if ($scope.record_type == 'bre' && !$scope.brandNewRecord) { $scope.bib_source.id = $scope.bibSource = rec.source(); //$scope.Record().source(); @@ -1261,15 +1261,32 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) }; $scope.updateDate = function(cataloging_date) { - if (cataloging_date instanceof Date && !isNaN(cataloging_date)) { - $scope.Record().cataloging_date(new Date(cataloging_date).toISOString()); - } else if (!cataloging_date) { - $scope.Record.cataloging_date(null); - } else { - return; + if (cataloging_date != $scope.Record().cataloging_date()) { + if (cataloging_date instanceof Date && !isNaN(cataloging_date)) { + saveDate($scope.Record().cataloging_date(), cataloging_date); + $scope.Record().cataloging_date(new Date(cataloging_date).toISOString()); + } else if (!cataloging_date) { + saveDate($scope.Record().cataloging_date(), cataloging_date); + $scope.Record().cataloging_date(null); + } else { + return; + } } } + var saveDate = function(orig_date, new_date) { + egCore.pcrud.retrieve( + $scope.record_type, $scope.Record().id() + ).then(function(rec) { + if (new_date) { + rec.cataloging_date(new Date(new_date).toISOString()); + } else { + rec.cataloging_date(null); + } + egCore.pcrud.update(rec); + }); + } + $scope.processRedo = function () { if ($scope.record_redo_stack.length) { $scope.in_redo = true; -- 2.11.0