--- /dev/null
+<form ng-submit="ok(args)" role="form">
+ <div class="modal-header">
+ <button type="button" class="close" ng-click="cancel()"
+ aria-hidden="true">×</button>
+ <h4 class="modal-title">[% l('Link MFHD') %]</h4>
+ </div>
+ <div class="modal-body">
+ <div ng-repeat="legacy in legacies">
+ <div uib-tooltip="[% l('Record ID [_1]', '{{legacy.mvr.doc_id}}') %]" tooltip-placement="left">
+ <a target="_blank" href="/eg/staff/cat/catalog/record/{{legacy.mvr.doc_id}}">{{legacy.mvr.title}}</a>
+ </div>
+ <div>
+ {{legacy.mvr.physical_description}}
+ </div>
+ <div ng-repeat="svr in legacy.svrs" uib-tooltip="{{svr|json}}" tooltip-placement="left">
+ <input type="radio" name="which_mfhd" ng-model="args.which_mfhd" ng-value="svr.sre_id" id="{{svr.sre_id}}">
+ <label for="{{svr.sre_id}}">
+ {{svr.location}}
+ </label>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <div class="pull-left">
+ <label>[% l('Summary Display') %]</label>
+ <select ng-model="args.summary_method">
+ <option value="add_to_sre" selected>[% l('Both') %]</option>
+ <option value="merge_with_sre">[% l('Merge') %]</option>
+ <option value="use_sre_only">[% l('MFHD Only') %]</option>
+ <option value="use_sdist_only">[% l('None') %]</option>
+ </select>
+ </div>
+ <input type="submit" class="btn btn-primary" value="[% l('OK') %]" ng-disabled="!args.which_mfhd"/>
+ <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
+ </div>
+</form>
var some_success = false;
var seen = {};
angular.forEach(rows, function(row) {
- console.log(row);
+ //console.log(row);
if (!seen[row.id]) {
seen[row.id] = 1;
promises.push(
});
});
}
+ $scope.link_mfhd = function(rows) {
+ if (!rows) { return; }
+ var row = rows[0];
+ if (!row['sdist.id']) { return; }
+ $uibModal.open({
+ templateUrl: './serials/t_link_mfhd',
+ controller: 'LinkMFHDCtrl',
+ resolve : {
+ row : function() {
+ return rows[0];
+ },
+ bibId : function() {
+ return $scope.bibId;
+ }
+ },
+ windowClass: 'app-modal-window',
+ backdrop: 'static',
+ keyboard: false
+ }).result.then(function(args) {
+ console.log('modal done', args);
+ egCore.pcrud.search('sdist', {
+ id: rows[0]['sdist.id']
+ }, {}, { atomic : true }
+ ).then(function(resp){
+ var evt = egCore.evt.parse(resp);
+ if (evt) { // any way to just throw or return this to the error handler?
+ console.log('failure',resp);
+ ngToast.danger(egCore.strings.SERIALS_DISTRIBUTION_FAIL_LINK_MFHD);
+ }
+ var sdist = resp[0];
+ sdist.ischanged(true);
+ sdist.summary_method( args.summary_method );
+ sdist.record_entry( args.which_mfhd );
+ egCore.pcrud.apply(sdist).then(
+ function(resp) { // maybe success
+ console.log('apply',resp);
+ var evt = egCore.evt.parse(resp);
+ if (evt) { // any way to just throw or return this to the error handler?
+ console.log('failure',resp);
+ ngToast.danger(egCore.strings.SERIALS_DISTRIBUTION_FAIL_LINK_MFHD);
+ } else {
+ console.log('success',resp);
+ ngToast.success(egCore.strings.SERIALS_DISTRIBUTION_SUCCESS_LINK_MFHD);
+ reload();
+ }
+ },
+ function(resp) {
+ console.log('failure',resp);
+ ngToast.danger(egCore.strings.SERIALS_DISTRIBUTION_FAIL_LINK_MFHD);
+ }
+ );
+ });
+ });
+ }
}]
}
})
+.controller('LinkMFHDCtrl',
+ ['$scope','$q','$uibModalInstance','egCore','row','bibId',
+function($scope , $q , $uibModalInstance , egCore , row , bibId ) {
+ console.log('row',row);
+ console.log('bibId',bibId);
+ $scope.args = {
+ summary_method: row['sdist.summary_method'] || 'add_to_sre',
+ };
+ if (row['sdist.record_entry']) {
+ $scope.args.which_mfhd = row['sdist.record_entry'].id;
+ }
+ $scope.ok = function(count) { $uibModalInstance.close($scope.args) }
+ $scope.cancel = function () { $uibModalInstance.dismiss() }
+ $scope.legacies = {};
+ egCore.pcrud.search('sre', {
+ record: bibId, owning_lib : row['owning_lib.id'], active: 't', deleted: 'f'
+ }, {}, { atomic : true }
+ ).then(
+ function(resp) { // maybe success
+ var evt; if (evt = egCore.evt.parse(resp)) { console.error(evt.toString()); return; }
+ if (!resp) { return; }
+
+ var promises = [];
+ var seen = {};
+
+ angular.forEach(resp, function(sre) {
+ console.log('sre',sre);
+ if (!seen[sre.record()]) {
+ seen[sre.record()] = 1;
+ $scope.legacies[sre.record()] = { mvr: null, svrs: [] };
+ promises.push(
+ egCore.net.request(
+ 'open-ils.search',
+ 'open-ils.search.biblio.record.mods_slim.retrieve.authoritative',
+ sre.record()
+ ).then(function(resp2) {
+ var evt; if (evt = egCore.evt.parse(resp2)) { console.error(evt.toString()); return; }
+ if (!resp2) { return; }
+ $scope.legacies[sre.record()].mvr = egCore.idl.toHash(resp2);
+ })
+ );
+ promises.push(
+ egCore.net.request(
+ 'open-ils.search',
+ 'open-ils.search.serial.record.bib.retrieve',
+ sre.record(),
+ row['owning_lib.id']
+ ).then(function(resp2) {
+ angular.forEach(resp2,function(r) {
+ if (r.sre_id() > 0) {
+ console.log('svr',egCore.idl.toHash(r));
+ $scope.legacies[sre.record()].svrs.push( egCore.idl.toHash(r) );
+ }
+ });
+ })
+ );
+ }
+ if (typeof $scope.legacies[sre.record()].sres == 'undefined') {
+ $scope.legacies[sre.record()].sres = {};
+ }
+ $scope.legacies[sre.record()].sres[sre.id()] = egCore.idl.toHash(sre);
+ });
+
+ $q.all(promises).then(function(){
+ console.log('done',$scope.legacies);
+ });
+ },
+ function(resp) { // outright failure
+ console.error('failure',resp);
+ }
+ )
+}])
+
.controller('CloneCtrl',
['$scope','$uibModalInstance','egCore','subs',
function($scope , $uibModalInstance , egCore , subs ) {
}
$scope.mvr = egCore.idl.toHash(resp);
- console.log($scope.mvr);
+ //console.log($scope.mvr);
},
function(resp) { // outright failure
console.error(resp);