5 angular.module('egCoreMod')
9 ['$uibModal','$q','egCore','egConfirmDialog','egAlertDialog',
10 function($uibModal , $q , egCore , egConfirmDialog , egAlertDialog) {
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: '
118 cancel_reasons : function() {
119 return service.get_cancel_reasons();
125 service.uncancel_holds = function(hold_ids) {
127 return $uibModal.open({
128 templateUrl : './circ/share/t_uncancel_hold_dialog',
131 ['$scope', '$uibModalInstance',
132 function($scope, $uibModalInstance) {
134 num_holds : hold_ids.length
137 $scope.cancel = function($event) {
138 $uibModalInstance.dismiss();
139 $event.preventDefault();
142 $scope.ok = function() {
144 function uncancel_one() {
145 var hold_id = hold_ids.pop();
147 $uibModalInstance.close();
151 'open-ils.circ', 'open-ils.circ.hold.uncancel',
152 egCore.auth.token(), hold_id
153 ).then(function(resp) {
154 if (evt = egCore.evt.parse(resp)) {
156 'warning.hold.uncancel_failed');
157 console.error('unable to uncancel hold: '
171 service.get_cancel_reasons = function() {
172 if (egCore.env.ahrcc) return $q.when(egCore.env.ahrcc.list);
173 return egCore.pcrud.retrieveAll('ahrcc', {}, {atomic : true})
174 .then(function(list) { return egCore.env.absorbList(list, 'ahrcc').list });
177 // Updates a batch of holds, notifies on each response.
178 // new_values = array of hashes describing values to change,
179 // including the id of the hold to change.
180 // e.g. {id : 1, mint_condition : true}
181 service.update_holds = function(new_values) {
182 return egCore.net.request(
184 'open-ils.circ.hold.update.batch',
185 egCore.auth.token(), null, new_values).then(
187 if (evt = egCore.evt.parse(resp)) {
189 'warning.hold.batch_update');
190 console.error('unable to batch update holds: '
194 'success.hold.batch_update');
200 service.set_copy_quality = function(hold_ids) {
201 if (!hold_ids.length) return $q.when();
202 return $uibModal.open({
203 templateUrl : './circ/share/t_hold_copy_quality_dialog',
206 ['$scope', '$uibModalInstance',
207 function($scope, $uibModalInstance) {
209 function update(val) {
210 var vals = hold_ids.map(function(hold_id) {
211 return {id : hold_id, mint_condition : val}})
212 service.update_holds(vals).finally(function() {
213 $uibModalInstance.close();
216 $scope.good = function() { update(true) }
217 $scope.any = function() { update(false) }
218 $scope.cancel = function() { $uibModalInstance.dismiss() }
224 service.edit_pickup_lib = function(hold_ids) {
225 if (!hold_ids.length) return $q.when();
226 return $uibModal.open({
227 templateUrl : './circ/share/t_hold_edit_pickup_lib',
230 ['$scope', '$uibModalInstance',
231 function($scope, $uibModalInstance) {
232 $scope.cant_be_pickup = function (id) { return !egCore.org.CanHaveUsers(id); };
234 $scope.ok = function() {
235 var vals = hold_ids.map(function(hold_id) {
238 pickup_lib : $scope.args.org_unit.id()
241 service.update_holds(vals).finally(function() {
242 $uibModalInstance.close();
245 $scope.cancel = function() { $uibModalInstance.dismiss() }
251 service.get_sms_carriers = function() {
252 if (egCore.env.csc) return $q.when(egCore.env.csc.list);
253 return egCore.pcrud.retrieveAll('csc', {}, {atomic : true})
254 .then(function(list) { return egCore.env.absorbList(list, 'csc').list });
257 service.edit_notify_prefs = function(hold_ids) {
258 if (!hold_ids.length) return $q.when();
259 return $uibModal.open({
260 templateUrl : './circ/share/t_hold_notification_prefs',
263 ['$scope', '$uibModalInstance', 'sms_carriers',
264 function($scope, $uibModalInstance, sms_carriers) {
266 $scope.sms_carriers = sms_carriers;
267 $scope.num_holds = hold_ids.length;
268 $scope.ok = function() {
270 var vals = hold_ids.map(function(hold_id) {
271 var val = {id : hold_id};
273 ['email', 'phone', 'sms'],
275 var key = type + '_notify';
276 if ($scope.args['update_' + key])
277 val[key] = $scope.args[key];
280 if ($scope.args.update_sms_carrier)
281 val.sms_carrier = $scope.args.sms_carrier.id();
285 service.update_holds(vals).finally(function() {
286 $uibModalInstance.close();
289 $scope.cancel = function() { $uibModalInstance.dismiss() }
293 sms_carriers : service.get_sms_carriers
298 service.edit_dates = function(hold_ids) {
299 if (!hold_ids.length) return $q.when();
301 // collects the fields from the dialog the user wishes to modify
302 function relay_to_update(modal_scope) {
303 var vals = hold_ids.map(function(hold_id) {
304 var val = {id : hold_id};
306 ['thaw_date', 'request_time', 'expire_time', 'shelf_expire_time'],
308 if (modal_scope.args['modify_' + field]) {
309 val[field] = modal_scope.args[field].toISOString();
310 if (field === 'thaw_date') {
311 //If we are setting the thaw_date, freeze the hold.
312 val['frozen'] = true;
321 console.log(JSON.stringify(vals,null,2));
322 return service.update_holds(vals);
325 return $uibModal.open({
326 templateUrl : './circ/share/t_hold_dates',
329 ['$scope', '$uibModalInstance',
330 function($scope, $uibModalInstance) {
331 var today = new Date();
334 request_time : today,
336 shelf_expire_time : today
338 $scope.num_holds = hold_ids.length;
339 $scope.ok = function() {
340 relay_to_update($scope).then($uibModalInstance.close);
342 $scope.cancel = function() { $uibModalInstance.dismiss() }
343 $scope.minDate = new Date();
344 //watch for changes to the hold dates, and perform validations
345 $scope.$watch('args', function(newValue,oldValue,scope) {
346 if (newValue['thaw_date'] && newValue['thaw_date'] < today) {
347 $scope.args['thaw_date'] = today;
348 $scope.args.thaw_date_error = true;
350 if (newValue['thaw_date'] && newValue['thaw_date'] > today) {
351 $scope.args.thaw_date_error = false;
359 service.update_field_with_confirm = function(hold_ids, msg_key, field, value) {
360 if (!hold_ids.length) return $q.when();
362 return egConfirmDialog.open(
363 egCore.strings[msg_key], '', {num_holds : hold_ids.length})
364 .result.then(function() {
366 var vals = hold_ids.map(function(hold_id) {
367 val = {id : hold_id};
371 return service.update_holds(vals);
375 service.suspend_holds = function(hold_ids) {
376 return service.update_field_with_confirm(
377 hold_ids, 'SUSPEND_HOLDS', 'frozen', true);
380 service.activate_holds = function(hold_ids) {
381 return service.update_field_with_confirm(
382 hold_ids, 'ACTIVATE_HOLDS', 'frozen', false);
385 service.set_top_of_queue = function(hold_ids) {
386 return service.update_field_with_confirm(
387 hold_ids, 'SET_TOP_OF_QUEUE', 'cut_in_line', true);
390 service.clear_top_of_queue = function(hold_ids) {
391 return service.update_field_with_confirm(
392 hold_ids, 'CLEAR_TOP_OF_QUEUE', 'cut_in_line', null);
395 service.transfer_to_marked_title = function(hold_ids) {
396 if (!hold_ids.length) return $q.when();
398 var bib_id = egCore.hatch.getLocalItem(
399 'eg.circ.hold.title_transfer_target');
403 return egAlertDialog.open(
404 egCore.strings.NO_HOLD_TRANSFER_TITLE_MARKED).result;
407 return egConfirmDialog.open(
408 egCore.strings.TRANSFER_HOLD_TO_TITLE, '', {
409 num_holds : hold_ids.length,
412 ).result.then(function() {
413 return egCore.net.request(
415 'open-ils.circ.hold.change_title.specific_holds',
416 egCore.auth.token(), bib_id, hold_ids);
420 service.transfer_all_bib_holds_to_marked_title = function(bib_ids) {
421 if (!bib_ids.length) return $q.when();
423 var target_bib_id = egCore.hatch.getLocalItem(
424 'eg.circ.hold.title_transfer_target');
426 if (!target_bib_id) {
428 return egAlertDialog.open(
429 egCore.strings.NO_HOLD_TRANSFER_TITLE_MARKED).result;
432 return egConfirmDialog.open(
433 egCore.strings.TRANSFER_ALL_BIB_HOLDS_TO_TITLE, '', {
434 num_bibs : bib_ids.length,
435 bib_id : target_bib_id
437 ).result.then(function() {
438 return egCore.net.request(
440 'open-ils.circ.hold.change_title',
441 egCore.auth.token(), target_bib_id, bib_ids);
445 // serially retargets each hold
446 service.retarget = function(hold_ids) {
447 if (!hold_ids.length) return $q.when();
448 var deferred = $q.defer();
450 egConfirmDialog.open(
451 egCore.strings.RETARGET_HOLDS, '',
452 {hold_ids : hold_ids.join(',')}
454 ).result.then(function() {
457 var hold_id = hold_ids.pop();
465 'open-ils.circ.hold.reset',
466 egCore.auth.token(), hold_id).finally(do_one);
469 do_one(); // kick it off
472 return deferred.promise;
475 // fleshes orgs, etc. for hold data blobs retrieved from
476 // open-ils.circ.hold.details[.batch].retrieve
477 service.local_flesh = function(hold_data) {
479 hold_data.status_string =
480 egCore.strings['HOLD_STATUS_' + hold_data.status]
483 var hold = hold_data.hold;
484 var volume = hold_data.volume;
485 hold.pickup_lib(egCore.org.get(hold.pickup_lib()));
486 hold.current_shelf_lib(egCore.org.get(hold.current_shelf_lib()));
487 hold_data.id = hold.id();
489 // TODO: LP#1697954 fleshing calls below are deprecated in favor
492 if (hold.requestor() && typeof hold.requestor() != 'object') {
493 console.debug('fetching hold requestor');
494 egCore.pcrud.retrieve('au',hold.requestor()).then(function(u) { hold.requestor(u) });
497 if (hold.cancel_cause() && typeof hold.cancel_cause() != 'object') {
498 console.debug('fetching hold cancel cause');
499 egCore.pcrud.retrieve('ahrcc',hold.cancel_cause()).then(function(c) { hold.cancel_cause(c) });
502 if (hold.usr() && typeof hold.usr() != 'object') {
503 console.debug('fetching hold user');
504 egCore.pcrud.retrieve('au',hold.usr()).then(function(u) { hold.usr(u) });
507 if (hold.sms_carrier() && typeof hold.sms_carrier() != 'object') {
508 console.debug('fetching sms carrier');
509 egCore.pcrud.retrieve('csc',hold.sms_carrier()).then(function(c) { hold.sms_carrier(c) });
512 // current_copy is not always fleshed in the API
513 if (hold.current_copy() && typeof hold.current_copy() != 'object') {
514 hold.current_copy(hold_data.copy);
517 if (hold.current_copy()) {
518 // likewise, current_copy's status isn't fleshed in the API
519 if(hold.current_copy().status() !== null &&
520 typeof hold.current_copy().status() != 'object')
521 egCore.pcrud.retrieve('ccs',hold.current_copy().status()
522 ).then(function(c) { hold.current_copy().status(c) });
524 // current_copy's shelving location position isn't always accessible
525 if (hold.current_copy().location()) {
526 //console.debug('fetching hold copy location order');
528 if (typeof hold.current_copy().location() != 'object') {
529 location_id = hold.current_copy().location();
531 location_id = hold.current_copy().location().id();
535 {location: location_id, org: egCore.auth.user().ws_ou()},
538 ).then(function(orders) {
540 hold_data.hold._copy_location_position = orders[0].position();
542 hold_data.hold._copy_location_position = 999;
547 //Call number affixes are not always fleshed in the API
548 if (hold_data.volume.prefix) {
549 //console.debug('fetching call number prefix');
550 //console.log(hold_data.volume.prefix());
551 egCore.pcrud.retrieve('acnp',hold_data.volume.prefix())
552 .then(function(p) {hold_data.volume.prefix = p.label(); hold_data.volume.prefix_sortkey = p.label_sortkey()});
554 if (hold_data.volume.suffix) {
555 //console.debug('fetching call number suffix');
556 //console.log(hold_data.volume.suffix());
557 egCore.pcrud.retrieve('acns',hold_data.volume.suffix())
558 .then(function(s) {hold_data.volume.suffix = s.label(); hold_data.volume.suffix_sortkey = s.label_sortkey()});
567 * Action handlers for the common Hold grid UI.
568 * These generally scrub the data for valid input then pass the
569 * holds / copies / etc. off to the relevant action in egHolds or egCirc.
571 * Caller must apply a reset_page function, which is called after
572 * most actionis are performed.
574 .factory('egHoldGridActions',
575 ['$window','$location','$timeout','egCore','egHolds','egCirc',
576 function($window , $location , $timeout , egCore , egHolds , egCirc) {
580 service.refresh = function() {
581 console.error('egHoldGridActions.refresh not defined!');
584 service.cancel_hold = function(items) {
585 var hold_ids = items.filter(function(item) {
586 return !item.hold.cancel_time();
587 }).map(function(item) {return item.hold.id()});
589 return egHolds.cancel_holds(hold_ids).then(service.refresh);
592 service.cancel_wide_hold = function(items) {
593 var hold_ids = items.filter(function(item) {
594 return !item.hold.cancel_time;
595 }).map(function(item) {return item.hold.id});
597 return egHolds.cancel_holds(hold_ids).then(service.refresh);
600 service.uncancel_hold = function(items) {
601 var hold_ids = items.filter(function(item) {
602 return item.hold.cancel_time();
603 }).map(function(item) {return item.hold.id()});
605 return egHolds.uncancel_holds(hold_ids).then(service.refresh);
608 service.uncancel_wide_hold = function(items) {
609 var hold_ids = items.filter(function(item) {
610 return item.hold.cancel_time;
611 }).map(function(item) {return item.hold.id});
613 return egHolds.uncancel_holds(hold_ids).then(service.refresh);
616 // jump to circ list for either 1) the targeted copy or
617 // 2) the hold target copy for copy-level holds
618 service.show_recent_circs = function(items) {
619 var focus = items.length == 1;
620 angular.forEach(items, function(item) {
622 var url = egCore.env.basePath +
626 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
631 // jump to circ list for either 1) the targeted copy or
632 // 2) the hold target copy for copy-level holds
633 service.show_recent_circs_wide = function(items) {
634 var focus = items.length == 1;
635 angular.forEach(items, function(item) {
636 if (item.hold.cp_id) {
637 var url = egCore.env.basePath +
641 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
646 service.show_patrons = function(items) {
647 var focus = items.length == 1;
648 angular.forEach(items, function(item) {
649 var url = egCore.env.basePath +
651 item.hold.usr().id() +
653 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
657 service.show_patrons_wide = function(items) {
658 var focus = items.length == 1;
659 angular.forEach(items, function(item) {
660 var url = egCore.env.basePath +
664 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
668 service.show_holds_for_title = function(items) {
669 var focus = items.length == 1;
670 angular.forEach(items, function(item) {
671 var url = '/eg2/staff/catalog/record/' + item.mvr.doc_id() + '/holds';
672 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
676 service.show_holds_for_title_wide = function(items) {
677 var focus = items.length == 1;
678 angular.forEach(items, function(item) {
679 var url = '/eg2/staff/catalog/record/' + item.hold.record_id + '/holds';
680 $timeout(function() { var x = $window.open(url, '_blank'); if (focus) x.focus() });
685 function generic_update(items, action) {
686 if (!items.length) return $q.when();
687 var hold_ids = items.map(function(item) {return item.hold.id()});
688 return egHolds[action](hold_ids).then(service.refresh);
691 function generic_update_wide(items, action) {
692 if (!items.length) return $q.when();
693 var hold_ids = items.map(function(item) {return item.hold.id});
694 return egHolds[action](hold_ids).then(service.refresh);
697 service.set_copy_quality = function(items) {
698 generic_update(items, 'set_copy_quality'); }
699 service.edit_pickup_lib = function(items) {
700 generic_update(items, 'edit_pickup_lib'); }
701 service.edit_notify_prefs = function(items) {
702 generic_update(items, 'edit_notify_prefs'); }
703 service.edit_dates = function(items) {
704 generic_update(items, 'edit_dates'); }
705 service.suspend = function(items) {
706 generic_update(items, 'suspend_holds'); }
707 service.activate = function(items) {
708 generic_update(items, 'activate_holds'); }
709 service.set_top_of_queue = function(items) {
710 generic_update(items, 'set_top_of_queue'); }
711 service.clear_top_of_queue = function(items) {
712 generic_update(items, 'clear_top_of_queue'); }
713 service.transfer_to_marked_title = function(items) {
714 generic_update(items, 'transfer_to_marked_title'); }
716 service.set_copy_quality_wide = function(items) {
717 generic_update_wide(items, 'set_copy_quality'); }
718 service.edit_pickup_lib_wide = function(items) {
719 generic_update_wide(items, 'edit_pickup_lib'); }
720 service.edit_notify_prefs_wide = function(items) {
721 generic_update_wide(items, 'edit_notify_prefs'); }
722 service.edit_dates_wide = function(items) {
723 generic_update_wide(items, 'edit_dates'); }
724 service.suspend_wide = function(items) {
725 generic_update_wide(items, 'suspend_holds'); }
726 service.activate_wide = function(items) {
727 generic_update_wide(items, 'activate_holds'); }
728 service.set_top_of_queue_wide = function(items) {
729 generic_update_wide(items, 'set_top_of_queue'); }
730 service.clear_top_of_queue_wide = function(items) {
731 generic_update_wide(items, 'clear_top_of_queue'); }
732 service.transfer_to_marked_title_wide = function(items) {
733 generic_update_wide(items, 'transfer_to_marked_title'); }
735 service.mark_damaged = function(items) {
736 angular.forEach(items, function(item) {
738 egCirc.mark_damaged({
740 barcode: item.copy.barcode()
741 }).then(service.refresh);
746 service.mark_damaged_wide = function(items) {
747 angular.forEach(items, function(item) {
749 egCirc.mark_damaged({
751 barcode: item.hold.cp_barcode
752 }).then(service.refresh);
757 service.mark_discard = function(items) {
759 .filter(function(item) { return Boolean(item.copy) })
760 .map(function(item) {
761 return {id: item.copy.id(), barcode: item.copy.barcode()}
764 egCirc.mark_discard(copies).then(service.refresh);
767 service.mark_missing = function(items) {
769 .filter(function(item) { return Boolean(item.copy) })
770 .map(function(item) {
771 return {id: item.copy.id(), barcode: item.copy.barcode()}
774 egCirc.mark_missing(copies).then(service.refresh);
777 service.mark_missing_wide = function(items) {
779 .filter(function(item) { return Boolean(item.hold.cp_id) })
780 .map(function(item) { return {id: item.hold.cp_id, barcode: item.hold.cp_barcode}; });
782 egCirc.mark_missing(copies).then(service.refresh);
785 service.mark_discard_wide = function(items) {
787 .filter(function(item) { return Boolean(item.hold.cp_id) })
788 .map(function(item) { return {id: item.hold.cp_id, barcode: item.hold.cp_barcode}; });
790 egCirc.mark_discard(copies).then(service.refresh);
793 service.retarget = function(items) {
794 var hold_ids = items.map(function(item) { return item.hold.id() });
795 egHolds.retarget(hold_ids).then(service.refresh);
798 service.retarget_wide = function(items) {
799 var hold_ids = items.map(function(item) { return item.hold.id });
800 egHolds.retarget(hold_ids).then(service.refresh);
807 * Hold details interface
809 .directive('egHoldDetails', function() {
812 templateUrl : './circ/share/t_hold_details',
815 // if set, called whenever hold details are retrieved. The
816 // argument is the hold blob returned from hold.details.retrieve
821 '$scope','$uibModal','egCore','egHolds','egCirc',
822 function($scope , $uibModal , egCore , egHolds , egCirc) {
825 if (!$scope.holdId) return;
829 'open-ils.circ.hold.details.retrieve.authoritative',
830 egCore.auth.token(), $scope.holdId, {
831 include_current_copy : true,
833 include_cancel_cause : true,
834 include_sms_carrier : true,
835 include_requestor : true
837 ).then(function(hold_data) {
838 egHolds.local_flesh(hold_data);
840 angular.forEach(hold_data,
841 function(val, key) { $scope[key] = val });
843 // fetch + flesh the cancel_cause if needed
844 if ($scope.hold.cancel_time()) {
845 egHolds.get_cancel_reasons().then(function() {
846 // egHolds caches the causes in egEnv
847 $scope.hold.cancel_cause(
848 egCore.env.ahrcc.map[$scope.hold.cancel_cause()]);
852 if ($scope.hold.current_copy()) {
853 egCirc.flesh_copy_location($scope.hold.current_copy());
856 if ($scope.holdRetrieved)
857 $scope.holdRetrieved(hold_data);
862 $scope.show_notify_tab = function() {
863 $scope.detail_tab = 'notify';
864 egCore.pcrud.search('ahn',
865 {hold : $scope.hold.id()},
866 {flesh : 1, flesh_fields : {ahn : ['notify_staff']}},
868 ).then(function(nots) {
869 $scope.hold.notifications(nots);
873 $scope.delete_note = function(note) {
874 egCore.pcrud.remove(note).then(function() {
875 // remove the deleted note from the locally fleshed notes
877 $scope.hold.notes().filter(function(n) {
878 return n.id() != note.id()
884 $scope.new_note = function() {
885 return $uibModal.open({
886 templateUrl : './circ/share/t_hold_note_dialog',
889 ['$scope', '$uibModalInstance',
890 function($scope, $uibModalInstance) {
892 $scope.ok = function() {
893 $uibModalInstance.close($scope.args)
895 $scope.cancel = function($event) {
896 $uibModalInstance.dismiss();
897 $event.preventDefault();
901 }).result.then(function(args) {
902 var note = new egCore.idl.ahrn();
903 note.hold($scope.hold.id());
905 note.slip(args.slip);
907 note.title(args.title);
908 note.body(args.body);
909 return egCore.pcrud.create(note).then(function(n) {
910 $scope.hold.notes().push(n);
915 $scope.new_notification = function() {
916 return $uibModal.open({
917 templateUrl : './circ/share/t_hold_notification_dialog',
920 ['$scope', '$uibModalInstance',
921 function($scope, $uibModalInstance) {
923 $scope.ok = function() {
924 $uibModalInstance.close($scope.args)
926 $scope.cancel = function($event) {
927 $uibModalInstance.dismiss();
928 $event.preventDefault();
932 }).result.then(function(args) {
933 var note = new egCore.idl.ahn();
934 note.hold($scope.hold.id());
935 note.method(args.method);
936 note.note(args.note);
937 note.notify_staff(egCore.auth.user().id());
938 note.notify_time('now');
939 return egCore.pcrud.create(note).then(function(n) {
940 n.notify_staff(egCore.auth.user());
941 $scope.hold.notifications().push(n);
946 $scope.$watch('holdId', function(newVal, oldVal) {
947 if (newVal != oldVal) draw();