5 angular.module('egCoreMod')
9 ['$uibModal','$q','egCore','egConfirmDialog','egAlertDialog','egWorkLog',
10 function($uibModal , $q , egCore , egConfirmDialog , egAlertDialog , egWorkLog) {
14 service.fetch_wide_holds = function(restrictions, order_by, limit, offset) {
15 return egCore.net.request(
17 'open-ils.circ.hold.wide_hash.stream',
19 restrictions, order_by, limit, offset
23 service.fetch_holds = function(hold_ids) {
24 var deferred = $q.defer();
26 // Fetch hold details in batches for better UI responsiveness.
30 function one_batch() {
31 var ids = hold_ids.slice(index, index + batch_size)
32 .filter(function(id) {return Boolean(id)}) // avoid nulls
34 console.debug('egHolds.fetch_holds => ' + ids);
44 'open-ils.circ.hold.details.batch.retrieve.authoritative',
45 egCore.auth.token(), ids, {
46 include_current_copy : true,
48 include_cancel_cause : true,
49 include_sms_carrier : true,
50 include_requestor : true
54 one_batch, // kick off the next batch
57 var hold = hold_data.hold;
58 hold_data.id = hold.id();
59 service.local_flesh(hold_data);
60 deferred.notify(hold_data);
65 one_batch(); // kick it off
66 return deferred.promise;
70 service.cancel_holds = function(hold_ids) {
72 return $uibModal.open({
73 templateUrl : './circ/share/t_cancel_hold_dialog',
76 ['$scope', '$uibModalInstance', 'cancel_reasons',
77 function($scope, $uibModalInstance, cancel_reasons) {
80 cancel_reasons : cancel_reasons,
81 num_holds : hold_ids.length
84 $scope.cancel = function($event) {
85 $uibModalInstance.dismiss();
86 $event.preventDefault();
89 $scope.ok = function() {
91 function cancel_one() {
92 var hold_id = hold_ids.pop();
94 $uibModalInstance.close();
98 'open-ils.circ', 'open-ils.circ.hold.cancel',
99 egCore.auth.token(), hold_id,
100 $scope.args.cancel_reason,
102 ).then(function(resp) {
103 if (evt = egCore.evt.parse(resp)) {
105 'warning.hold.cancel_failed');
106 console.error('unable to cancel hold: '
110 'open-ils.circ', 'open-ils.circ.hold.details.retrieve',
111 egCore.auth.token(), hold_id, {
112 'suppress_notices': true,
113 'suppress_transits': true,
114 'suppress_mvr' : true,
116 }).then(function(details) {
117 //console.log('details', details);
119 egCore.strings.EG_WORK_LOG_CANCELED_HOLD
121 'action' : 'canceled_hold',
122 'method' : 'open-ils.circ.hold.cancel',
124 'patron_id' : details.hold.usr().id(),
125 'user' : details.patron_last,
126 'item' : details.copy ? details.copy.barcode() : null,
127 'item_id' : details.copy ? details.copy.id() : null
141 cancel_reasons : function() {
142 return service.get_cancel_reasons().then(function(reasons) {
143 // only display reasons for manually canceling holds
144 return reasons.filter(function(r) {
145 return 't' === r.manual();
153 service.uncancel_holds = function(hold_ids) {
155 return $uibModal.open({
156 templateUrl : './circ/share/t_uncancel_hold_dialog',
159 ['$scope', '$uibModalInstance',
160 function($scope, $uibModalInstance) {
162 num_holds : hold_ids.length
165 $scope.cancel = function($event) {
166 $uibModalInstance.dismiss();
167 $event.preventDefault();
170 $scope.ok = function() {
172 function uncancel_one() {
173 var hold_id = hold_ids.pop();
175 $uibModalInstance.close();
179 'open-ils.circ', 'open-ils.circ.hold.uncancel',
180 egCore.auth.token(), hold_id
181 ).then(function(resp) {
182 if (evt = egCore.evt.parse(resp)) {
184 'warning.hold.uncancel_failed');
185 console.error('unable to uncancel hold: '
199 service.get_cancel_reasons = function() {
200 if (egCore.env.ahrcc) return $q.when(egCore.env.ahrcc.list);
201 return egCore.pcrud.retrieveAll('ahrcc', {}, {atomic : true})
202 .then(function(list) { return egCore.env.absorbList(list, 'ahrcc').list });
205 // Updates a batch of holds, notifies on each response.
206 // new_values = array of hashes describing values to change,
207 // including the id of the hold to change.
208 // e.g. {id : 1, mint_condition : true}
209 service.update_holds = function(new_values) {
210 return egCore.net.request(
212 'open-ils.circ.hold.update.batch',
213 egCore.auth.token(), null, new_values).then(
215 if (evt = egCore.evt.parse(resp)) {
217 'warning.hold.batch_update');
218 console.error('unable to batch update holds: '
222 'success.hold.batch_update');
228 service.set_copy_quality = function(hold_ids) {
229 if (!hold_ids.length) return $q.when();
230 return $uibModal.open({
231 templateUrl : './circ/share/t_hold_copy_quality_dialog',
234 ['$scope', '$uibModalInstance',
235 function($scope, $uibModalInstance) {
237 function update(val) {
238 var vals = hold_ids.map(function(hold_id) {
239 return {id : hold_id, mint_condition : val}})
240 service.update_holds(vals).finally(function() {
241 $uibModalInstance.close();
244 $scope.good = function() { update(true) }
245 $scope.any = function() { update(false) }
246 $scope.cancel = function() { $uibModalInstance.dismiss() }
252 service.edit_pickup_lib = function(hold_ids) {
253 if (!hold_ids.length) return $q.when();
254 return $uibModal.open({
255 templateUrl : './circ/share/t_hold_edit_pickup_lib',
258 ['$scope', '$uibModalInstance',
259 function($scope, $uibModalInstance) {
260 $scope.cant_be_pickup = function (id) { return !egCore.org.CanHaveUsers(id); };
262 $scope.ok = function() {
263 var vals = hold_ids.map(function(hold_id) {
266 pickup_lib : $scope.args.org_unit.id()
269 service.update_holds(vals).finally(function() {
270 $uibModalInstance.close();
273 $scope.cancel = function() { $uibModalInstance.dismiss() }
279 service.get_sms_carriers = function() {
280 if (egCore.env.csc) return $q.when(egCore.env.csc.list);
281 return egCore.pcrud.retrieveAll('csc', {}, {atomic : true})
282 .then(function(list) { return egCore.env.absorbList(list, 'csc').list });
285 service.edit_notify_prefs = function(hold_ids) {
286 if (!hold_ids.length) return $q.when();
287 return $uibModal.open({
288 templateUrl : './circ/share/t_hold_notification_prefs',
291 ['$scope', '$uibModalInstance', 'sms_carriers',
292 function($scope, $uibModalInstance, sms_carriers) {
294 $scope.sms_carriers = sms_carriers;
295 $scope.num_holds = hold_ids.length;
296 $scope.ok = function() {
298 var vals = hold_ids.map(function(hold_id) {
299 var val = {id : hold_id};
301 ['email', 'phone', 'sms'],
303 var key = type + '_notify';
304 if ($scope.args['update_' + key])
305 val[key] = $scope.args[key];
308 if ($scope.args.update_sms_carrier)
309 val.sms_carrier = $scope.args.sms_carrier.id();
313 service.update_holds(vals).finally(function() {
314 $uibModalInstance.close();
317 $scope.cancel = function() { $uibModalInstance.dismiss() }
321 sms_carriers : service.get_sms_carriers
326 service.edit_dates = function(hold_ids) {
327 if (!hold_ids.length) return $q.when();
329 // collects the fields from the dialog the user wishes to modify
330 function relay_to_update(modal_scope) {
331 var vals = hold_ids.map(function(hold_id) {
332 var val = {id : hold_id};
334 ['thaw_date', 'request_time', 'expire_time', 'shelf_expire_time'],
336 if (modal_scope.args['modify_' + field]) {
337 val[field] = modal_scope.args[field].toISOString();
338 if (field === 'thaw_date') {
339 //If we are setting the thaw_date, freeze the hold.
340 val['frozen'] = true;
349 console.log(JSON.stringify(vals,null,2));
350 return service.update_holds(vals);
353 return $uibModal.open({
354 templateUrl : './circ/share/t_hold_dates',
357 ['$scope', '$uibModalInstance',
358 function($scope, $uibModalInstance) {
359 var today = new Date();
362 request_time : today,
364 shelf_expire_time : today
366 $scope.num_holds = hold_ids.length;
367 $scope.ok = function() {
368 relay_to_update($scope).then($uibModalInstance.close);
370 $scope.cancel = function() { $uibModalInstance.dismiss() }
371 $scope.minDate = new Date();
372 //watch for changes to the hold dates, and perform validations
373 $scope.$watch('args', function(newValue,oldValue,scope) {
374 if (newValue['thaw_date'] && newValue['thaw_date'] < today) {
375 $scope.args['thaw_date'] = today;
376 $scope.args.thaw_date_error = true;
378 if (newValue['thaw_date'] && newValue['thaw_date'] > today) {
379 $scope.args.thaw_date_error = false;
387 service.update_field_with_confirm = function(hold_ids, msg_key, field, value) {
388 if (!hold_ids.length) return $q.when();
390 return egConfirmDialog.open(
391 egCore.strings[msg_key], '', {num_holds : hold_ids.length})
392 .result.then(function() {
394 var vals = hold_ids.map(function(hold_id) {
395 val = {id : hold_id};
399 return service.update_holds(vals);
403 service.suspend_holds = function(hold_ids) {
404 return service.update_field_with_confirm(
405 hold_ids, 'SUSPEND_HOLDS', 'frozen', true);
408 service.activate_holds = function(hold_ids) {
409 return service.update_field_with_confirm(
410 hold_ids, 'ACTIVATE_HOLDS', 'frozen', false);
413 service.set_top_of_queue = function(hold_ids) {
414 return service.update_field_with_confirm(
415 hold_ids, 'SET_TOP_OF_QUEUE', 'cut_in_line', true);
418 service.clear_top_of_queue = function(hold_ids) {
419 return service.update_field_with_confirm(
420 hold_ids, 'CLEAR_TOP_OF_QUEUE', 'cut_in_line', null);
423 service.transfer_to_marked_title = function(hold_ids) {
424 if (!hold_ids.length) return $q.when();
426 var bib_id = egCore.hatch.getLocalItem(
427 'eg.circ.hold.title_transfer_target');
431 return egAlertDialog.open(
432 egCore.strings.NO_HOLD_TRANSFER_TITLE_MARKED).result;
435 return egConfirmDialog.open(
436 egCore.strings.TRANSFER_HOLD_TO_TITLE, '', {
437 num_holds : hold_ids.length,
440 ).result.then(function() {
441 return egCore.net.request(
443 'open-ils.circ.hold.change_title.specific_holds',
444 egCore.auth.token(), bib_id, hold_ids);
448 service.transfer_all_bib_holds_to_marked_title = function(bib_ids) {
449 if (!bib_ids.length) return $q.when();
451 var target_bib_id = egCore.hatch.getLocalItem(
452 'eg.circ.hold.title_transfer_target');
454 if (!target_bib_id) {
456 return egAlertDialog.open(
457 egCore.strings.NO_HOLD_TRANSFER_TITLE_MARKED).result;
460 return egConfirmDialog.open(
461 egCore.strings.TRANSFER_ALL_BIB_HOLDS_TO_TITLE, '', {
462 num_bibs : bib_ids.length,
463 bib_id : target_bib_id
465 ).result.then(function() {
466 return egCore.net.request(
468 'open-ils.circ.hold.change_title',
469 egCore.auth.token(), target_bib_id, bib_ids);
473 // serially retargets each hold
474 service.retarget = function(hold_ids) {
475 if (!hold_ids.length) return $q.when();
476 var deferred = $q.defer();
478 egConfirmDialog.open(
479 egCore.strings.RETARGET_HOLDS, '',
480 {hold_ids : hold_ids.join(',')}
482 ).result.then(function() {
485 var hold_id = hold_ids.pop();
493 'open-ils.circ.hold.reset',
494 egCore.auth.token(), hold_id).finally(do_one);
497 do_one(); // kick it off
500 return deferred.promise;
503 // fleshes orgs, etc. for hold data blobs retrieved from
504 // open-ils.circ.hold.details[.batch].retrieve
505 service.local_flesh = function(hold_data) {
507 hold_data.status_string =
508 egCore.strings['HOLD_STATUS_' + hold_data.status]
511 var hold = hold_data.hold;
512 var volume = hold_data.volume;
513 hold.pickup_lib(egCore.org.get(hold.pickup_lib()));
514 hold.current_shelf_lib(egCore.org.get(hold.current_shelf_lib()));
515 hold_data.id = hold.id();
517 // TODO: LP#1697954 fleshing calls below are deprecated in favor
520 if (hold.requestor() && typeof hold.requestor() != 'object') {
521 console.debug('fetching hold requestor');
522 egCore.pcrud.retrieve('au',hold.requestor()).then(function(u) { hold.requestor(u) });
525 if (hold.canceled_by() && typeof hold.canceled_by() != 'object') {
526 console.debug('fetching hold canceled_by');
527 egCore.pcrud.retrieve('au',hold.canceled_by()).then(function(u) { hold.canceled_by(u) });
530 if (hold.cancel_cause() && typeof hold.cancel_cause() != 'object') {
531 console.debug('fetching hold cancel cause');
532 egCore.pcrud.retrieve('ahrcc',hold.cancel_cause()).then(function(c) { hold.cancel_cause(c) });
535 if (hold.usr() && typeof hold.usr() != 'object') {
536 console.debug('fetching hold user');
537 egCore.pcrud.retrieve('au',hold.usr()).then(function(u) { hold.usr(u) });
540 if (hold.sms_carrier() && typeof hold.sms_carrier() != 'object') {
541 console.debug('fetching sms carrier');
542 egCore.pcrud.retrieve('csc',hold.sms_carrier()).then(function(c) { hold.sms_carrier(c) });
545 // current_copy is not always fleshed in the API
546 if (hold.current_copy() && typeof hold.current_copy() != 'object') {
547 hold.current_copy(hold_data.copy);
550 if (hold.current_copy()) {
551 // likewise, current_copy's status isn't fleshed in the API
552 if(hold.current_copy().status() !== null &&
553 typeof hold.current_copy().status() != 'object')
554 egCore.pcrud.retrieve('ccs',hold.current_copy().status()
555 ).then(function(c) { hold.current_copy().status(c) });
557 // current_copy's shelving location position isn't always accessible
558 if (hold.current_copy().location()) {
559 //console.debug('fetching hold copy location order');
561 if (typeof hold.current_copy().location() != 'object') {
562 location_id = hold.current_copy().location();
564 location_id = hold.current_copy().location().id();
568 {location: location_id, org: egCore.auth.user().ws_ou()},
571 ).then(function(orders) {
573 hold_data.hold._copy_location_position = orders[0].position();
575 hold_data.hold._copy_location_position = 999;
580 //Call number affixes are not always fleshed in the API
581 if (hold_data.volume.prefix) {
582 //console.debug('fetching call number prefix');
583 //console.log(hold_data.volume.prefix());
584 egCore.pcrud.retrieve('acnp',hold_data.volume.prefix())
585 .then(function(p) {hold_data.volume.prefix = p.label(); hold_data.volume.prefix_sortkey = p.label_sortkey()});
587 if (hold_data.volume.suffix) {
588 //console.debug('fetching call number suffix');
589 //console.log(hold_data.volume.suffix());
590 egCore.pcrud.retrieve('acns',hold_data.volume.suffix())
591 .then(function(s) {hold_data.volume.suffix = s.label(); hold_data.volume.suffix_sortkey = s.label_sortkey()});
600 * Action handlers for the common Hold grid UI.
601 * These generally scrub the data for valid input then pass the
602 * holds / copies / etc. off to the relevant action in egHolds or egCirc.
604 * Caller must apply a reset_page function, which is called after
605 * most actionis are performed.
607 .factory('egHoldGridActions',
608 ['$window','$location','$timeout','egCore','egHolds','egCirc',
609 function($window , $location , $timeout , egCore , egHolds , egCirc) {
613 service.refresh = function() {
614 console.error('egHoldGridActions.refresh not defined!');
617 service.cancel_hold = function(items) {
618 var hold_ids = items.filter(function(item) {
619 return !item.hold.cancel_time();
620 }).map(function(item) {return item.hold.id()});
622 return egHolds.cancel_holds(hold_ids).then(service.refresh);
625 service.cancel_hold_wide = function(items) {
626 var hold_ids = items.filter(function(item) {
627 return !item.hold.cancel_time;
628 }).map(function(item) {return item.hold.id});
630 return egHolds.cancel_holds(hold_ids).then(service.refresh);
633 service.uncancel_hold = function(items) {
634 var hold_ids = items.filter(function(item) {
635 return item.hold.cancel_time();
636 }).map(function(item) {return item.hold.id()});
638 return egHolds.uncancel_holds(hold_ids).then(service.refresh);
641 service.uncancel_hold_wide = function(items) {
642 var hold_ids = items.filter(function(item) {
643 return item.hold.cancel_time;
644 }).map(function(item) {return item.hold.id});
646 return egHolds.uncancel_holds(hold_ids).then(service.refresh);
649 // jump to circ list for either 1) the targeted copy or
650 // 2) the hold target copy for copy-level holds
651 service.show_recent_circs = function(items) {
652 var focus = items.length == 1;
653 angular.forEach(items, function(item) {
655 var url = egCore.env.basePath +
659 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
664 // jump to circ list for either 1) the targeted copy or
665 // 2) the hold target copy for copy-level holds
666 service.show_recent_circs_wide = function(items) {
667 var focus = items.length == 1;
668 angular.forEach(items, function(item) {
669 if (item.hold.cp_id) {
670 var url = egCore.env.basePath +
674 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
679 service.show_patrons = function(items) {
680 var focus = items.length == 1;
681 angular.forEach(items, function(item) {
682 var url = egCore.env.basePath +
684 item.hold.usr().id() +
686 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
690 service.show_patrons_wide = function(items) {
691 var focus = items.length == 1;
692 angular.forEach(items, function(item) {
693 var url = egCore.env.basePath +
697 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
701 service.show_holds_for_title = function(items) {
702 var focus = items.length == 1;
703 angular.forEach(items, function(item) {
704 var url = '/eg2/staff/catalog/record/' + item.mvr.doc_id() + '/holds';
705 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
709 service.show_holds_for_title_wide = function(items) {
710 var focus = items.length == 1;
711 angular.forEach(items, function(item) {
712 var url = '/eg2/staff/catalog/record/' + item.hold.record_id + '/holds';
713 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
718 function generic_update(items, action) {
719 if (!items.length) return $q.when();
720 var hold_ids = items.map(function(item) {return item.hold.id()});
721 return egHolds[action](hold_ids).then(service.refresh);
724 function generic_update_wide(items, action) {
725 if (!items.length) return $q.when();
726 var hold_ids = items.map(function(item) {return item.hold.id});
727 return egHolds[action](hold_ids).then(service.refresh);
730 service.set_copy_quality = function(items) {
731 generic_update(items, 'set_copy_quality'); }
732 service.edit_pickup_lib = function(items) {
733 generic_update(items, 'edit_pickup_lib'); }
734 service.edit_notify_prefs = function(items) {
735 generic_update(items, 'edit_notify_prefs'); }
736 service.edit_dates = function(items) {
737 generic_update(items, 'edit_dates'); }
738 service.suspend = function(items) {
739 generic_update(items, 'suspend_holds'); }
740 service.activate = function(items) {
741 generic_update(items, 'activate_holds'); }
742 service.set_top_of_queue = function(items) {
743 generic_update(items, 'set_top_of_queue'); }
744 service.clear_top_of_queue = function(items) {
745 generic_update(items, 'clear_top_of_queue'); }
746 service.transfer_to_marked_title = function(items) {
747 generic_update(items, 'transfer_to_marked_title'); }
749 service.set_copy_quality_wide = function(items) {
750 generic_update_wide(items, 'set_copy_quality'); }
751 service.edit_pickup_lib_wide = function(items) {
752 generic_update_wide(items, 'edit_pickup_lib'); }
753 service.edit_notify_prefs_wide = function(items) {
754 generic_update_wide(items, 'edit_notify_prefs'); }
755 service.edit_dates_wide = function(items) {
756 generic_update_wide(items, 'edit_dates'); }
757 service.suspend_wide = function(items) {
758 generic_update_wide(items, 'suspend_holds'); }
759 service.activate_wide = function(items) {
760 generic_update_wide(items, 'activate_holds'); }
761 service.set_top_of_queue_wide = function(items) {
762 generic_update_wide(items, 'set_top_of_queue'); }
763 service.clear_top_of_queue_wide = function(items) {
764 generic_update_wide(items, 'clear_top_of_queue'); }
765 service.transfer_to_marked_title_wide = function(items) {
766 generic_update_wide(items, 'transfer_to_marked_title'); }
768 service.mark_damaged = function(items) {
769 angular.forEach(items, function(item) {
771 egCirc.mark_damaged({
773 barcode: item.copy.barcode()
774 }).then(service.refresh);
779 service.mark_damaged_wide = function(items) {
780 angular.forEach(items, function(item) {
782 egCirc.mark_damaged({
784 barcode: item.hold.cp_barcode
785 }).then(service.refresh);
790 service.mark_discard = function(items) {
792 .filter(function(item) { return Boolean(item.copy) })
793 .map(function(item) {
794 return {id: item.copy.id(), barcode: item.copy.barcode()}
797 egCirc.mark_discard(copies).then(service.refresh);
800 service.mark_missing = function(items) {
802 .filter(function(item) { return Boolean(item.copy) })
803 .map(function(item) {
804 return {id: item.copy.id(), barcode: item.copy.barcode()}
807 egCirc.mark_missing(copies).then(service.refresh);
810 service.mark_missing_wide = function(items) {
812 .filter(function(item) { return Boolean(item.hold.cp_id) })
813 .map(function(item) { return {id: item.hold.cp_id, barcode: item.hold.cp_barcode}; });
815 egCirc.mark_missing(copies).then(service.refresh);
818 service.mark_discard_wide = function(items) {
820 .filter(function(item) { return Boolean(item.hold.cp_id) })
821 .map(function(item) { return {id: item.hold.cp_id, barcode: item.hold.cp_barcode}; });
823 egCirc.mark_discard(copies).then(service.refresh);
826 service.retarget = function(items) {
827 var hold_ids = items.map(function(item) { return item.hold.id() });
828 egHolds.retarget(hold_ids).then(service.refresh);
831 service.retarget_wide = function(items) {
832 var hold_ids = items.map(function(item) { return item.hold.id });
833 egHolds.retarget(hold_ids).then(service.refresh);
840 * Hold details interface
842 .directive('egHoldDetails', function() {
845 templateUrl : './circ/share/t_hold_details',
848 // if set, called whenever hold details are retrieved. The
849 // argument is the hold blob returned from hold.details.retrieve
854 '$scope','$uibModal','egCore','egHolds','egCirc',
855 function($scope , $uibModal , egCore , egHolds , egCirc) {
858 if (!$scope.holdId) return;
862 'open-ils.circ.hold.details.retrieve.authoritative',
863 egCore.auth.token(), $scope.holdId, {
864 include_current_copy : true,
866 include_cancel_cause : true,
867 include_sms_carrier : true,
868 include_requestor : true
870 ).then(function(hold_data) {
871 egHolds.local_flesh(hold_data);
873 angular.forEach(hold_data,
874 function(val, key) { $scope[key] = val });
876 // fetch + flesh the cancel_cause if needed
877 if ($scope.hold.cancel_cause() && typeof $scope.hold.cancel_cause() != 'object') {
878 egHolds.get_cancel_reasons().then(function() {
879 // egHolds caches the causes in egEnv
880 $scope.hold.cancel_cause(
881 egCore.env.ahrcc.map[$scope.hold.cancel_cause()]);
885 if ($scope.hold.current_copy()) {
886 egCirc.flesh_copy_location($scope.hold.current_copy());
889 if ($scope.holdRetrieved)
890 $scope.holdRetrieved(hold_data);
895 $scope.show_notify_tab = function() {
896 $scope.detail_tab = 'notify';
897 egCore.pcrud.search('ahn',
898 {hold : $scope.hold.id()},
899 {flesh : 1, flesh_fields : {ahn : ['notify_staff']}},
901 ).then(function(nots) {
902 $scope.hold.notifications(nots);
906 $scope.delete_note = function(note) {
907 egCore.pcrud.remove(note).then(function() {
908 // remove the deleted note from the locally fleshed notes
910 $scope.hold.notes().filter(function(n) {
911 return n.id() != note.id()
917 $scope.new_note = function() {
918 return $uibModal.open({
919 templateUrl : './circ/share/t_hold_note_dialog',
922 ['$scope', '$uibModalInstance',
923 function($scope, $uibModalInstance) {
925 $scope.ok = function() {
926 $uibModalInstance.close($scope.args)
928 $scope.cancel = function($event) {
929 $uibModalInstance.dismiss();
930 $event.preventDefault();
934 }).result.then(function(args) {
935 var note = new egCore.idl.ahrn();
936 note.hold($scope.hold.id());
938 note.slip(args.slip);
940 note.title(args.title);
941 note.body(args.body);
942 return egCore.pcrud.create(note).then(function(n) {
943 $scope.hold.notes().push(n);
948 $scope.new_notification = function() {
949 return $uibModal.open({
950 templateUrl : './circ/share/t_hold_notification_dialog',
953 ['$scope', '$uibModalInstance',
954 function($scope, $uibModalInstance) {
956 $scope.ok = function() {
957 $uibModalInstance.close($scope.args)
959 $scope.cancel = function($event) {
960 $uibModalInstance.dismiss();
961 $event.preventDefault();
965 }).result.then(function(args) {
966 var note = new egCore.idl.ahn();
967 note.hold($scope.hold.id());
968 note.method(args.method);
969 note.note(args.note);
970 note.notify_staff(egCore.auth.user().id());
971 note.notify_time('now');
972 return egCore.pcrud.create(note).then(function(n) {
973 n.notify_staff(egCore.auth.user());
974 $scope.hold.notifications().push(n);
979 $scope.$watch('holdId', function(newVal, oldVal) {
980 if (newVal != oldVal) draw();