--- /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 ng-show="subs.length==1" class="modal-title">[% l('Clone Subscription') %]</h4>
+ <h4 ng-show="subs.length>1" class="modal-title">[% l('Clone Subscriptions') %]</h4>
+ </div>
+ <div class="modal-body">
+ <p>[% l('This feature will clone the selected subscriptions and all of their subscription notes, distributions, distribution notes, captions and patterns, streams, and routing list users.') %]</p>
+ <p>[% l('Holdings-related objects, like issuances, items, units, and summaries will not be cloned.') %]</p>
+ <p ng-show="subs.length == 1">[% l('To which bibliographic record should the new subscription be attached?') %]</p>
+ <p ng-show="subs.length > 1">[% l('To which bibliographic record should the new subscriptions be attached?') %]</p>
+ <div class="row">
+ <div class="col-md-1">
+ <input type="radio" name="which_radio_button" id="same_bib"
+ ng-model="args.which_radio_button" value="same_bib">
+ </input>
+ </div>
+ <div class="col-md-11">
+ <label ng-if="subs.length==1" for="same_bib">
+ [% l('Same record as the selected subscription') %]
+ </label>
+ <label ng-if="subs.length>1" for="same_bib">
+ [% l('Same record as the selected subscriptions') %]
+ </label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-1">
+ <input type="radio" name="which_radio_button"
+ ng-model="args.which_radio_button" value="different_bib">
+ </input>
+ </div>
+ <div class="col-md-3">
+ <label for="different_bib">
+ [% l('Record specified by this Bid ID:') %]
+ </label>
+ </div>
+ <div class="col-md-8">
+ <input type="number" class="form-control" min="1"
+ ng-click="args.which_radio_button='different_bib'"
+ ng-model-options="{ debounce: 1000 }"
+ id="different_bib" ng-model="args.bib_id"/>
+ <div ng-show="args.bib_id">{{mvr.title}}</div>
+ <div class="alert alert-warning" ng-show="bibNotFound">
+ [% l('Not Found') %]
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <input
+ ng-disabled="!args.which_radio_button||(args.which_radio_button=='different_bib'&&(!args.bib_id||bibNotFound))"
+ type="submit" class="btn btn-primary" value="[% l('OK') %]"/>
+ <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
+ </div>
+</form>
templateUrl: './serials/t_subscription_manager',
controller:
['$scope','$q','egSerialsCoreSvc','egCore','egGridDataProvider',
- '$uibModal',
+ '$uibModal','ngToast',
function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
- $uibModal) {
+ $uibModal , ngToast ) {
egSerialsCoreSvc.fetch($scope.bibId).then(function() {
$scope.subscriptions = egCore.idl.toTypedHash(egSerialsCoreSvc.subTree);
$scope.distStreamGridDataProvider.refresh();
});
}
}
+ $scope.clone_subscription = function(rows) {
+ if (!rows) { return; }
+ var row = rows[0];
+ $uibModal.open({
+ templateUrl: './serials/t_clone_subscription',
+ controller: 'CloneCtrl',
+ resolve : {
+ subs : function() {
+ return rows;
+ }
+ },
+ windowClass: 'app-modal-window',
+ backdrop: 'static',
+ keyboard: false
+ }).result.then(function(args) {
+ var promises = [];
+ var some_failure = false;
+ var some_success = false;
+ var seen = {};
+ angular.forEach(rows, function(row) {
+ console.log(row);
+ if (!seen[row.id]) {
+ seen[row.id] = 1;
+ promises.push(
+ egCore.net.request(
+ 'open-ils.serial',
+ 'open-ils.serial.subscription.clone',
+ egCore.auth.token(),
+ row.id,
+ args.bib_id
+ ).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);
+ some_failure = true;
+ ngToast.danger(egCore.strings.SERIALS_SUBSCRIPTION_FAIL_CLONE);
+ } else {
+ console.log('success',resp);
+ some_success = true;
+ ngToast.success(egCore.strings.SERIALS_SUBSCRIPTION_SUCCESS_CLONE);
+ }
+ },
+ function(resp) {
+ console.log('failure',resp);
+ some_failure = true;
+ ngToast.danger(egCore.strings.SERIALS_SUBSCRIPTION_FAIL_CLONE);
+ }
+ )
+ );
+ }
+ });
+ $q.all(promises).then(function() {
+ reload();
+ });
+ });
+ }
+
}]
}
})
+.controller('CloneCtrl',
+ ['$scope','$uibModalInstance','egCore','subs',
+function($scope , $uibModalInstance , egCore , subs ) {
+ $scope.args = {};
+ $scope.ok = function(count) { $uibModalInstance.close($scope.args) }
+ $scope.cancel = function () { $uibModalInstance.dismiss() }
+ $scope.subs = subs;
+ $scope.find_bib = function () {
+
+ $scope.bibNotFound = null;
+ $scope.mvr = null;
+ if (!$scope.args.bib_id) return;
+
+ return egCore.net.request(
+ 'open-ils.search',
+ 'open-ils.search.biblio.record.mods_slim.retrieve.authoritative',
+ $scope.args.bib_id
+ ).then(
+ function(resp) { // maybe success
+
+ if (evt = egCore.evt.parse(resp)) {
+ $scope.bibNotFound = $scope.args.bib_id;
+ console.error(evt.toString());
+ return;
+ }
+
+ if (!resp) {
+ $scope.bibNotFound = $scope.args.bib_id;
+ return;
+ }
+
+ $scope.mvr = egCore.idl.toHash(resp);
+ console.log($scope.mvr);
+ },
+ function(resp) { // outright failure
+ console.error(resp);
+ $scope.bibNotFound = $scope.args.bib_id;
+ return;
+ }
+ );
+ }
+ $scope.$watch("args.bib_id", function(newVal, oldVal) {
+ if (newVal && newVal != oldVal) {
+ $scope.find_bib();
+ }
+ });
+}])
+
.controller('RoutingCtrl',
['$scope','$uibModalInstance','egCore','rowInfo','routes',
function($scope , $uibModalInstance , egCore , rowInfo , routes ) {