From 6605f5aff402f071b5e75a7d8cb6ef93af372115 Mon Sep 17 00:00:00 2001 From: Kyle Huckins Date: Thu, 12 Dec 2019 21:57:34 +0000 Subject: [PATCH] View Course Information on the Item Record - Users with the MANAGE_RESERVES permission who are opted into the course module can view a new Course Info tab on the item record. - Course Info tab displays a list of all courses(with link to the Admin Course Page) item is associated with, and a list of all instructors associated with those courses. - Improvements to open-ils.circ.course_users.retrieve. Signed-off-by: Kyle Huckins Changes to be committed: modified: Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm new file: Open-ILS/src/templates/staff/cat/item/t_course_pane.tt2 modified: Open-ILS/src/templates/staff/cat/item/t_view.tt2 modified: Open-ILS/web/js/ui/default/staff/cat/item/app.js --- .../src/perlmods/lib/OpenILS/Application/Circ.pm | 7 +- .../src/templates/staff/cat/item/t_course_pane.tt2 | 72 +++++++++++++++++++++ Open-ILS/src/templates/staff/cat/item/t_view.tt2 | 3 + Open-ILS/web/js/ui/default/staff/cat/item/app.js | 74 ++++++++++++++++++++-- 4 files changed, 151 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/src/templates/staff/cat/item/t_course_pane.tt2 diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm index 83fc2f3b9f..198d3d8e97 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm @@ -1168,7 +1168,7 @@ sub fetch_course_users { unless ($self->api_name =~ /\.staff/) and $e->allowed('MANAGE_RESERVES'); - $users->{list} = $e->search_asset_course_module_course_users($filter); + $users->{list} = $e->search_asset_course_module_course_users($filter, {order_by => {acmcu => 'course'}}); for my $course_user (@{$users->{list}}) { my $patron = {}; $patron->{id} = $course_user->id; @@ -1182,10 +1182,15 @@ sub fetch_course_users { my $final_user = {}; $final_user->{id} = $user->{id}; $final_user->{usr_role} = $user->{usr_role}; + $final_user->{patron_id} = $user->{patron_data}->id; $final_user->{first_given_name} = $user->{patron_data}->first_given_name; + $final_user->{second_given_name} = $user->{patron_data}->second_given_name; $final_user->{family_name} = $user->{patron_data}->family_name; $final_user->{pref_first_given_name} = $user->{patron_data}->pref_first_given_name; $final_user->{pref_family_name} = $user->{patron_data}->pref_family_name; + $final_user->{pref_second_given_name} = $user->{patron_data}->pref_second_given_name; + $final_user->{pref_suffix} = $user->{patron_data}->pref_suffix; + $final_user->{pref_prefix} = $user->{patron_data}->pref_prefix; push @$targets, $final_user; } diff --git a/Open-ILS/src/templates/staff/cat/item/t_course_pane.tt2 b/Open-ILS/src/templates/staff/cat/item/t_course_pane.tt2 new file mode 100644 index 0000000000..befa04abe9 --- /dev/null +++ b/Open-ILS/src/templates/staff/cat/item/t_course_pane.tt2 @@ -0,0 +1,72 @@ +
+
+ [% l('You do not have sufficient permissions to view this page') %] +
+
+ +
+
+
+ [% l('No Associated Courses') %] +
+
+
+
+
+ [% l('Associated Courses') %] +
+
+ + +
+ +
+
+ [% l('No Associated Instructors') %] +
+
+
+
+
+ [% l('Associated Instructors') %] +
+
+ +
+
+ + + {{instructor.pref_family_name}}, + + + {{instructor.family_name}}, + + + {{instructor.pref_first_given_name}} + + + {{instructor.first_given_name}} + + + {{instructor.pref_second_given_name}} + + + {{instructor.second_given_name}} + + +
+
+
+ {{key.course}} + ({{key.role}}) +
+
+
+
+
+
+
diff --git a/Open-ILS/src/templates/staff/cat/item/t_view.tt2 b/Open-ILS/src/templates/staff/cat/item/t_view.tt2 index 1859865675..bf9eaa4817 100644 --- a/Open-ILS/src/templates/staff/cat/item/t_view.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/t_view.tt2 @@ -23,6 +23,9 @@
  • [% l('Triggered Events') %]
  • +
  • + [% l('Course Info') %] +
  • diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/app.js index 614db62ecf..28167a07ef 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js @@ -744,21 +744,21 @@ function($scope , $q , $window , $location , $timeout , egCore , egNet , egGridD * Detail view -- shows one copy */ .controller('ViewCtrl', - ['$scope','$q','$location','$routeParams','$timeout','$window','egCore','egItem','egBilling','egCirc', -function($scope , $q , $location , $routeParams , $timeout , $window , egCore , itemSvc , egBilling , egCirc) { + ['$scope','$q','egGridDataProvider','$location','$routeParams','$timeout','$window','egCore','egItem','egBilling','egCirc', +function($scope , $q , egGridDataProvider , $location , $routeParams , $timeout , $window , egCore , itemSvc , egBilling , egCirc) { var copyId = $routeParams.id; $scope.args.copyId = copyId; $scope.tab = $routeParams.tab || 'summary'; $scope.context.page = 'detail'; $scope.summaryRecord = null; - + $scope.courseModulesOptIn = fetchCourseOptIn(); + $scope.has_course_perms = fetchCoursePerms(); $scope.edit = false; if ($scope.tab == 'edit') { $scope.tab = 'summary'; $scope.edit = true; } - // use the cached record info if (itemSvc.copy) { $scope.copy_alert_count = itemSvc.copy.copy_alerts().filter(function(aca) { @@ -965,6 +965,27 @@ console.debug($scope.copy_alert_count); }); } + // Check for Course Modules Opt-In to enable Course Info tab + function fetchCourseOptIn() { + return egCore.org.settings( + 'circ.course_materials_opt_in' + ).then(function(set) { + $scope.courseModulesOptIn = set['circ.course_materials_opt_in']; + + return $scope.courseModulesOptIn; + }); + } + + function fetchCoursePerms() { + return egCore.perm.hasPermAt('MANAGE RESERVES', true).then(function(orgIds) { + if(orgIds.indexOf(egCore.auth.user().ws_ou()) != -1){ + $scope.has_course_perms = true; + + return $scope.has_course_perms; + } + }); + } + $scope.addBilling = function(circ) { egBilling.showBillDialog({ xact_id : circ.id(), @@ -1139,6 +1160,47 @@ console.debug($scope.copy_alert_count); }) } + function loadCourseInfo() { + delete $scope.courses; + delete $scope.instructors; + delete $scope.course_ids; + delete $scope.instructors_exist; + if (!copyId) return; + $scope.course_ids = []; + $scope.courses = []; + $scope.instructors = {}; + + egCore.pcrud.search('acmcm', { + item: copyId + }, { + flesh: 3, + flesh_fields: { + acmcm: ['course'] + }, order_by: {acmc : 'id desc'} + }).then(null, null, function(material) { + + $scope.courses.push(material.course()); + egCore.net.request( + 'open-ils.circ', + 'open-ils.circ.course_users.retrieve', + material.course().id() + ).then(null, null, function(instructors) { + angular.forEach(instructors, function(instructor) { + var patron_id = instructor.patron_id.toString(); + if (!$scope.instructors[patron_id]) { + $scope.instructors[patron_id] = instructor; + $scope.instructors_exist = true; + $scope.instructors[patron_id]._linked_course = []; + } + $scope.instructors[patron_id]._linked_course.push({ + role: instructor.usr_role, + course: material.course().name() + }); + }); + }); + }); + } + // we don't need all data on all tabs, so fetch what's needed when needed. function loadTabData() { @@ -1161,6 +1223,10 @@ console.debug($scope.copy_alert_count); loadMostRecentTransit(); break; + case 'course': + loadCourseInfo(); + break; + case 'triggered_events': var url = $location.absUrl().replace(/\/staff.*/, '/actor/user/event_log'); url += '?copy_id=' + encodeURIComponent(copyId); -- 2.11.0