From: Jason Etheridge Date: Fri, 7 Jul 2017 19:37:54 +0000 (-0400) Subject: webstaff: UI for various serial notes X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fcollab%2Fphasefx%2Fwebstaff-serials-notes;p=working%2FEvergreen.git webstaff: UI for various serial notes These changes add menu options for Subscription Notes, Distribution Notes, and Item Notes to the webstaff serials interface (under Manage Subscriptions and Manage Issues). They spawn dialogs similar to the existing Copy Notes dialog from the Item Editor, and show and allow the editing of existing notes as well as the creation of a new note. I'm not attempting to implement any behavior involving the alert flag. I don't know whether that exists or not. Signed-off-by: Jason Etheridge --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 2309eb0ec0..9faa6abbee 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -4976,7 +4976,7 @@ SELECT usr, - + @@ -4991,6 +4991,20 @@ SELECT usr, + + + + + + + + + + + + + + @@ -5286,7 +5300,7 @@ SELECT usr, - + @@ -5301,7 +5315,22 @@ SELECT usr, - + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/templates/staff/serials/t_notes.tt2 b/Open-ILS/src/templates/staff/serials/t_notes.tt2 new file mode 100644 index 0000000000..06ed074a18 --- /dev/null +++ b/Open-ILS/src/templates/staff/serials/t_notes.tt2 @@ -0,0 +1,103 @@ +
+ + + +
diff --git a/Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2 b/Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2 index 803f443f1f..c104e9f316 100644 --- a/Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2 +++ b/Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2 @@ -118,6 +118,10 @@ label="[% l('Apply Binding Template') %]"> + + + + diff --git a/Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js b/Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js index 9407b633cb..9404be6f78 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js +++ b/Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js @@ -552,6 +552,73 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , }); }); } + $scope.subscription_notes = function(rows) { + return $scope.notes('subscription',rows); + } + $scope.distribution_notes = function(rows) { + return $scope.notes('distribution',rows); + } + $scope.notes = function(note_type,rows) { + if (!rows) { return; } + + function modal(existing_notes) { + $uibModal.open({ + templateUrl: './serials/t_notes', + animation: true, + controller: 'NotesCtrl', + resolve : { + note_type : function() { return note_type; }, + rows : function() { + return rows; + }, + notes : function() { + return existing_notes; + } + }, + windowClass: 'app-modal-window', + backdrop: 'static', + keyboard: false + }).result.then(function(notes) { + console.log('results',notes); + egCore.pcrud.apply(notes).then( + function(a) { console.log('toast here 1',a); }, + function(a) { console.log('toast here 2',a); } + ); + }); + } + + if (rows.length == 1) { + var fm_hint; + var search_hash = {}; + var search_opt = {}; + switch(note_type) { + case 'subscription': + fm_hint = 'ssubn'; + search_hash.subscription = rows[0]['id']; + search_opt.order_by = { ssubn : 'create_date' }; + break; + case 'distribution': + fm_hint = 'sdistn'; + search_hash.distribution = rows[0]['sdist.id']; + search_opt.order_by = { sdistn : 'create_date' }; + break; + case 'item': default: + fm_hint = 'sin'; + search_hash.item = rows[0]['si.id']; + search_opt.order_by = { sin : 'create_date' }; + break; + } + egCore.pcrud.search(fm_hint, search_hash, search_opt, + { atomic : true } + ).then(function(list) { + modal(list); + }); + } else { + // support batch creation of notes across selections, + // but not editing + modal([]); + } + } }] } @@ -799,3 +866,73 @@ function($scope , $uibModalInstance , egCore , rowInfo , routes ) { } }); }]) + +.controller('NotesCtrl', + ['$scope','$uibModalInstance','egCore','note_type','rows','notes', +function($scope , $uibModalInstance , egCore , note_type , rows , notes ) { + $scope.note_type = note_type; + $scope.focusNote = true; + $scope.note = { + creator : egCore.auth.user().id(), + title : '', + value : '', + pub : false, + 'alert' : false, + }; + + $scope.require_initials = false; + egCore.org.settings([ + 'ui.staff.require_initials.copy_notes' + ]).then(function(set) { + $scope.require_initials = Boolean(set['ui.staff.require_initials.copy_notes']); + }); + + $scope.note_list = notes; + + $scope.ok = function(note) { + + var return_notes = []; + if (note.initials) note.value += ' [' + note.initials + ']'; + if ( (typeof note.title != 'undefined' && note.title != '') + || (typeof note.value != 'undefined' && note.value != '')) { + angular.forEach(rows, function (r) { + console.log('r',r); + window.my_r = r; + var n; + switch(note_type) { + case 'subscription': + n = new egCore.idl.ssubn(); + n.subscription(r['id']); + break; + case 'distribution': + n = new egCore.idl.sdistn(); + n.distribution(r['sdist.id']); + break; + case 'item': + default: + n = new egCore.idl.sin(); + n.item(r['si.id']); + } + n.isnew(true); + n.creator(note.creator); + n.pub(note.pub); + n['alert'](note['alert']); + n.title(note.title); + n.value(note.value); + return_notes.push( n ); + }); + } + angular.forEach(notes, function(n) { + if (n.ischanged() || n.isdeleted()) { + return_notes.push( n ); + } + }); + window.return_notes = return_notes; + $uibModalInstance.close(return_notes); + } + + $scope.cancel = function($event) { + $uibModalInstance.dismiss(); + $event.preventDefault(); + } +}]) diff --git a/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js b/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js index 9349ffe38a..627bb2ceee 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js +++ b/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js @@ -406,8 +406,144 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , orderByF return true; }; + $scope.item_notes = function(rows) { + return $scope.notes('item',rows); + } + // TODO - refactor this, it's duplicated in subscription_manager.js + $scope.notes = function(note_type,rows) { + if (!rows) { return; } + + function modal(existing_notes) { + $uibModal.open({ + templateUrl: './serials/t_notes', + animation: true, + controller: 'NotesCtrl', + resolve : { + note_type : function() { return note_type; }, + rows : function() { + return rows; + }, + notes : function() { + return existing_notes; + } + }, + windowClass: 'app-modal-window', + backdrop: 'static', + keyboard: false + }).result.then(function(notes) { + console.log('results',notes); + egCore.pcrud.apply(notes).then( + function(a) { console.log('toast here 1',a); }, + function(a) { console.log('toast here 2',a); } + ); + }); + } + + if (rows.length == 1) { + var fm_hint; + var search_hash = {}; + var search_opt = {}; + switch(note_type) { + case 'subscription': + fm_hint = 'ssubn'; + search_hash.subscription = rows[0]['id']; + search_opt.order_by = { ssubn : 'create_date' }; + break; + case 'distribution': + fm_hint = 'sdistn'; + search_hash.distribution = rows[0]['sdist.id']; + search_opt.order_by = { sdistn : 'create_date' }; + break; + case 'item': default: + fm_hint = 'sin'; + search_hash.item = rows[0]['id']; + search_opt.order_by = { sin : 'create_date' }; + break; + } + egCore.pcrud.search(fm_hint, search_hash, search_opt, + { atomic : true } + ).then(function(list) { + modal(list); + }); + } else { + // support batch creation of notes across selections, + // but not editing + modal([]); + } + } + }] } }) +// TODO - refactor this; it's duplicated in subscription_manager.js +.controller('NotesCtrl', + ['$scope','$uibModalInstance','egCore','note_type','rows','notes', +function($scope , $uibModalInstance , egCore , note_type , rows , notes ) { + $scope.note_type = note_type; + $scope.focusNote = true; + $scope.note = { + creator : egCore.auth.user().id(), + title : '', + value : '', + pub : false, + 'alert' : false, + }; + + $scope.require_initials = false; + egCore.org.settings([ + 'ui.staff.require_initials.copy_notes' + ]).then(function(set) { + $scope.require_initials = Boolean(set['ui.staff.require_initials.copy_notes']); + }); + + $scope.note_list = notes; + + $scope.ok = function(note) { + + var return_notes = []; + if (note.initials) note.value += ' [' + note.initials + ']'; + if ( (typeof note.title != 'undefined' && note.title != '') + || (typeof note.value != 'undefined' && note.value != '')) { + angular.forEach(rows, function (r) { + console.log('r',r); + window.my_r = r; + var n; + switch(note_type) { + case 'subscription': + n = new egCore.idl.ssubn(); + n.subscription(r['id']); + break; + case 'distribution': + n = new egCore.idl.sdistn(); + n.distribution(r['sdist.id']); + break; + case 'item': + default: + n = new egCore.idl.sin(); + n.item(r['id']); + } + n.isnew(true); + n.creator(note.creator); + n.pub(note.pub); + n['alert'](note['alert']); + n.title(note.title); + n.value(note.value); + return_notes.push( n ); + }); + } + angular.forEach(notes, function(n) { + if (n.ischanged() || n.isdeleted()) { + return_notes.push( n ); + } + }); + window.return_notes = return_notes; + $uibModalInstance.close(return_notes); + } + + $scope.cancel = function($event) { + $uibModalInstance.dismiss(); + $event.preventDefault(); + } +}])