From: Mike Rylander Date: Mon, 30 Mar 2015 18:14:20 +0000 (-0400) Subject: webstaff: Fixed field editor! X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ab705c3b38301f197c40a63ee2d4255f1b5f13f4;p=evergreen%2Fmasslnc.git webstaff: Fixed field editor! Signed-off-by: Mike Rylander Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 b/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 index 958e823214..153fa0fb10 100644 --- a/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 +++ b/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 @@ -4,10 +4,101 @@ -
+
{{calculated_record_type}}
+
+
+ + + + + + +
+
+ + + + + + +
+
+ + + + + + +
+
+ + + + + + +
+
+ + + + + +
+
+ + + + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + + + +
+
+ + + + + + +
+
+ + + + + + +
+
+ + + + +
+
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 d779857e6e..729ca7ecd5 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 @@ -128,38 +128,40 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) return { transclude: true, restrict: 'E', - template: '
'+ - ''+ - ''+ - '
, + template: '
'+ + '
'+ + '
'+ + '
', scope: { record: "=", fixedField: "@" }, replace: true, controller : ['$scope', '$element', 'egTagTable', function ( $scope , $element , egTagTable) { $($element).children().css({ display : 'none' }); - $scope.rtype = $scope.record.recordType(); $scope.me = null; - egTagTable.fetchFFPosTable( $scope.rtype ).then(function (ff_list) { - ff_list.forEach( function (ff) { - if (!$scope.me && ff.tag != '006') { // we're going to ignore 006 for now... - if (ff.fixed_field == $scope.fixedField && ff.rec_type == $scope.rtype) { - $($element).children().css({ display : 'block' }); - $scope.me = ff; - } - } - }); - }).then(function () { - if ($scope.me) { - var input = $('#' + $scope.fixedField + '_ff_input'); - input.attr('maxlength', $scope.me.length) - input.val($scope.record.getFixedField($scope.me.fixed_field); - input.on('keypress', function(e) { - $scope.record.setFixedField($scope.me.fixed_field, input.val()); + $scope.$watch('record.ready', function (newVal, oldVal) { + if (newVal && newVal != oldVal) { + $scope.rtype = $scope.record.recordType(); + egTagTable.fetchFFPosTable( $scope.rtype ).then(function (ff_list) { // This does not work when fetching from hatch... + angular.forEach(ff_list, function (ff) { + if (!$scope.me) { + if (ff.fixed_field == $scope.fixedField && ff.rec_type == $scope.rtype) { + $scope.me = ff; + $($element).children().css({ display : 'inline' }); + + var input = $($element).find('input'); + input.attr('maxlength', $scope.me.length); + input.val($scope.record.extractFixedField($scope.me.fixed_field)); + input.on('keyup', function(e) { + $scope.record.setFixedField($scope.me.fixed_field, input.val()); + $scope.$parent.$digest(); + }); + } + } + }); }); } }); - } ] } @@ -711,6 +713,8 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) }).then(function(){ return egTagTable.fetchFFPosTable($scope.calculated_record_type) + }).then(function(){ + return egTagTable.fetchFFValueTable($scope.calculated_record_type) }).then(setCaret); } @@ -731,7 +735,6 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) } if ($scope.record_undo_stack.length != $scope.save_stack_depth) { - console.log('should get a listener... does not'); $scope.dirtyFlag = true; } else { $scope.dirtyFlag = false; diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js b/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js index 5d3202dd06..739081667c 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js +++ b/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js @@ -53,26 +53,52 @@ function($q, egCore, egAuth) { service.fetchFFPosTable = function(rtype) { var deferred = $q.defer(); - if (service.ff_pos_map[rtype]) { - deferred.resolve(service.ff_pos_map[rtype]); - return deferred.promise; - } + var hatch_pos_key = 'FFPosTable_'+rtype; + + egCore.hatch.getItem(hatch_pos_key).then(function(cached_table) { + if (cached_table) { + service.ff_pos_map[rtype] = cached_table; + deferred.resolve(cached_table); - egCore.net.request( // First, get the list of FFs (minus 006) - 'open-ils.fielder', - 'open-ils.fielder.cmfpm.atomic', - { query : { tag : { '!=' : '006' } } } - ).then(function (data) { - service.ff_pos_map[rtype] = data; - }).then(function() { // Then, get the value maps - return egCore.net.request( - 'open-ils.cat', - 'open-ils.cat.biblio.fixed_field_values.by_rec_type', - rtype - ); - }).then(function (data) { - service.ff_value_map[rtype] = data; - deferred.resolve(service.ff_pos_map[rtype]); + } else { + + egCore.net.request( // First, get the list of FFs (minus 006) + 'open-ils.fielder', + 'open-ils.fielder.cmfpm.atomic', + { query : { tag : { '!=' : '006' } } } + ).then(function (data) { + service.ff_pos_map[rtype] = data; + egCore.hatch.setItem(hatch_pos_key, data); + deferred.resolve(data); + }); + } + }); + + return deferred.promise; + }; + + service.fetchFFValueTable = function(rtype) { + var deferred = $q.defer(); + + var hatch_value_key = 'FFValueTable_'+rtype; + + egCore.hatch.getItem(hatch_value_key).then(function(cached_table) { + if (cached_table) { + service.ff_value_map[rtype] = cached_table; + deferred.resolve(cached_table); + + } else { + + egCore.net.request( + 'open-ils.cat', + 'open-ils.cat.biblio.fixed_field_values.by_rec_type', + rtype + ).then(function (data) { + service.ff_value_map[rtype] = data; + deferred.resolve(data); + egCore.hatch.setItem(hatch_value_key, data); + }); + } }); return deferred.promise; diff --git a/Open-ILS/web/js/ui/default/staff/marcrecord.js b/Open-ILS/web/js/ui/default/staff/marcrecord.js index 7cc42b3463..58b54d25be 100644 --- a/Open-ILS/web/js/ui/default/staff/marcrecord.js +++ b/Open-ILS/web/js/ui/default/staff/marcrecord.js @@ -476,39 +476,49 @@ var MARC21 = { var rtype = this.recordType(); - var val; - + var done = false; if (MARC21.Record._ff_pos[field].ldr && _l) { if (MARC21.Record._ff_pos[field].ldr[rtype]) { // It's in the leader - val = value.substr(0, MARC21.Record._ff_pos[field].ldr[rtype].len); + if (value.length > MARC21.Record._ff_pos[field].ldr[rtype].len) + value = value.substr(0, MARC21.Record._ff_pos[field].ldr[rtype].len); + while (value.length < MARC21.Record._ff_pos[field].ldr[rtype].len) + value += MARC21.Record._ff_pos[field].ldr[rtype].def; this.leader = _l.substring(0, MARC21.Record._ff_pos[field].ldr[rtype].start) + - val + + value + _l.substring( MARC21.Record._ff_pos[field].ldr[rtype].start + MARC21.Record._ff_pos[field].ldr[rtype].len ); + done = true; } } else if (MARC21.Record._ff_pos[field]._8 && _8) { if (MARC21.Record._ff_pos[field]._8[rtype]) { // Nope, it's in the 008 - val = value.substr(0, MARC21.Record._ff_pos[field]._8[rtype].len); + if (value.length > MARC21.Record._ff_pos[field]._8[rtype].len) + value = value.substr(0, MARC21.Record._ff_pos[field]._8[rtype].len); + while (value.length < MARC21.Record._ff_pos[field]._8[rtype].len) + value += MARC21.Record._ff_pos[field]._8[rtype].def; this.field('008').update( _8.substring(0, MARC21.Record._ff_pos[field]._8[rtype].start) + - val + + value + _8.substring( MARC21.Record._ff_pos[field]._8[rtype].start + MARC21.Record._ff_pos[field]._8[rtype].len ) ); + done = true; } } - if (!val && MARC21.Record._ff_pos[field]._6 && _6) { + if (!done && MARC21.Record._ff_pos[field]._6 && _6) { if (MARC21.Record._ff_pos[field]._6[rtype]) { // ok, maybe the 006? - val = value.substr(0, MARC21.Record._ff_pos[field]._6[rtype].len); + if (value.length > MARC21.Record._ff_pos[field]._6[rtype].len) + value = value.substr(0, MARC21.Record._ff_pos[field]._6[rtype].len); + while (value.length < MARC21.Record._ff_pos[field]._6[rtype].len) + value += MARC21.Record._ff_pos[field]._6[rtype].def; this.field('006').update( _6.substring(0, MARC21.Record._ff_pos[field]._6[rtype].start) + - val + + value + _6.substring( MARC21.Record._ff_pos[field]._6[rtype].start + MARC21.Record._ff_pos[field]._6[rtype].len @@ -517,7 +527,7 @@ var MARC21 = { } } - return val; + return value; } this.ready = false;