record-id="detail_hold_record_id"></eg-record-summary>
<eg-hold-details hold-retrieved="set_hold" hold-id="detail_hold_id"></eg-hold-details>
</div>
+
+<!-- catalog view for holds placement -->
+
+<div ng-if="placing_hold">
+ <eg-embed-frame url="catalog_url" handlers="handlers"
+ onchange="handle_page"></eg-embed-frame>
+</div>
--- /dev/null
+<!-- holds are created within the catalog -->
+
+<eg-embed-frame url="catalog_url"
+ handlers="handlers" onchange="handle_page"></eg-embed-frame>
items-provider="gridDataProvider"
persist-key="circ.patron.holds">
+ <eg-grid-menu-item handler="place_hold"
+ label="[% l('Place Hold') %]"></eg-grid-menu-item>
<eg-grid-menu-item handler="detail_view"
label="[% l('Detail View') %]"></eg-grid-menu-item>
}
// xulG catalog handlers
- $scope.handlers = {
- get_barcode_and_settings_async : function(barcode, only_settings) {
- if (!barcode) return $q.reject();
- var deferred = $q.defer();
-
- var barcode_promise = $q.when(barcode);
- if (!only_settings) {
-
- // first verify / locate the barcode
- barcode_promise = egCore.net.request(
- 'open-ils.actor',
- 'open-ils.actor.get_barcodes',
- egCore.auth.token(),
- egCore.auth.user().ws_ou(), 'actor', barcode
- ).then(function(resp) {
-
- if (!resp || egCore.evt.parse(resp) || !resp.length) {
- console.error('user not found: ' + barcode);
- deferred.reject();
- return null;
- }
-
- resp = resp[0];
- return barcode = resp.barcode;
- });
- }
-
- barcode_promise.then(function(barcode) {
- if (!barcode) return;
-
- return egCore.net.request(
- 'open-ils.actor',
- 'open-ils.actor.user.fleshed.retrieve_by_barcode',
- egCore.auth.token(), barcode);
-
- }).then(function(user) {
- if (!user) return null;
-
- if (e = egCore.evt.parse(user)) {
- console.error('user fetch failed : ' + e.toString());
- deferred.reject();
- return null;
- }
-
- // copied more or less directly from XUL menu.js
- var settings = {};
- for(var i = 0; i < user.settings().length; i++) {
- settings[user.settings()[i].name()] =
- JSON2js(user.settings()[i].value());
- }
-
- if(!settings['opac.default_phone'] && user.day_phone())
- settings['opac.default_phone'] = user.day_phone();
- if(!settings['opac.hold_notify'] && settings['opac.hold_notify'] !== '')
- settings['opac.hold_notify'] = 'email:phone';
-
- // Taken from patron/util.js format_name
- // FIXME: I18n
- var patron_name =
- ( user.prefix() ? user.prefix() + ' ' : '') +
- user.family_name() + ', ' +
- user.first_given_name() + ' ' +
- ( user.second_given_name() ? user.second_given_name() + ' ' : '' ) +
- ( user.suffix() ? user.suffix() : '');
-
- deferred.resolve({
- "barcode": barcode,
- "settings" : settings,
- "user_email" : user.email(),
- "patron_name" : patron_name
- });
- });
-
- return deferred.promise;
- }
- }
+ $scope.handlers = { }
// ------------------------------------------------------------------
// Holds
resolve : resolver
});
+ $routeProvider.when('/circ/patron/:id/holds/create', {
+ templateUrl: './circ/patron/t_holds_create',
+ controller: 'PatronHoldsCreateCtrl',
+ resolve : resolver
+ });
+
$routeProvider.when('/circ/patron/:id/holds/:hold_id', {
templateUrl: './circ/patron/t_holds',
controller: 'PatronHoldsCtrl',
$location.path('/circ/patron/' + $scope.patron_id + '/holds');
}
+ $scope.place_hold = function() {
+ $location.path($location.path() + '/create');
+ }
+
// when the detail hold is fetched (and updated), update the bib
// record summary display record id.
$scope.set_hold = function(hold_data) {
}
}])
+
+
+.controller('PatronHoldsCreateCtrl',
+ ['$scope','$routeParams','$location','egCore','patronSvc',
+function($scope , $routeParams , $location , egCore , patronSvc) {
+
+ $scope.handlers = {
+ opac_hold_placed : function() {
+ // FIXME: this isn't getting called.. not sure why
+ patronSvc.fetchUserStats(); // update hold counts
+ }
+ }
+
+ $scope.initTab('holds', $routeParams.id).then(function(isAlert) {
+ if (isAlert) return;
+ // not guarenteed to have a barcode until init fetches the user
+ $scope.handlers.patron_barcode = patronSvc.current.card().barcode();
+ });
+
+ $scope.catalog_url =
+ $location.absUrl().replace(/\/staff.*/, '/opac/advanced');
+
+ $scope.handle_page = function(url) {
+ }
+
+}])
+
+ 'class="eg-embed-frame" style="height:{{height}}px"></iframe>',
controller :
- ['$scope','$window','$location','egCore',
- function($scope , $window , $location , egCore) {
+ ['$scope','$window','$location','$q','egCore',
+ function($scope , $window , $location , $q , egCore) {
// Set the iframe height to just under the window height.
// leave room for the navbar, padding, margins, etc.
// open a user account
new_patron_tab : function(tab_info, usr_info) {
open_tab('/circ/patron/' + usr_info.id + '/checkout');
- }
+ },
+
+ get_barcode_and_settings_async : function(barcode, only_settings) {
+ if (!barcode) return $q.reject();
+ var deferred = $q.defer();
+
+ var barcode_promise = $q.when(barcode);
+ if (!only_settings) {
+
+ // first verify / locate the barcode
+ barcode_promise = egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.get_barcodes',
+ egCore.auth.token(),
+ egCore.auth.user().ws_ou(), 'actor', barcode
+ ).then(function(resp) {
+
+ if (!resp || egCore.evt.parse(resp) || !resp.length) {
+ console.error('user not found: ' + barcode);
+ deferred.reject();
+ return null;
+ }
+
+ resp = resp[0];
+ return barcode = resp.barcode;
+ });
+ }
+
+ barcode_promise.then(function(barcode) {
+ if (!barcode) return;
+
+ return egCore.net.request(
+ 'open-ils.actor',
+ 'open-ils.actor.user.fleshed.retrieve_by_barcode',
+ egCore.auth.token(), barcode);
+
+ }).then(function(user) {
+ if (!user) return null;
+
+ if (e = egCore.evt.parse(user)) {
+ console.error('user fetch failed : ' + e.toString());
+ deferred.reject();
+ return null;
+ }
+
+ // copied more or less directly from XUL menu.js
+ var settings = {};
+ for(var i = 0; i < user.settings().length; i++) {
+ settings[user.settings()[i].name()] =
+ JSON2js(user.settings()[i].value());
+ }
+
+ if(!settings['opac.default_phone'] && user.day_phone())
+ settings['opac.default_phone'] = user.day_phone();
+ if(!settings['opac.hold_notify'] && settings['opac.hold_notify'] !== '')
+ settings['opac.hold_notify'] = 'email:phone';
+
+ // Taken from patron/util.js format_name
+ // FIXME: I18n
+ var patron_name =
+ ( user.prefix() ? user.prefix() + ' ' : '') +
+ user.family_name() + ', ' +
+ user.first_given_name() + ' ' +
+ ( user.second_given_name() ? user.second_given_name() + ' ' : '' ) +
+ ( user.suffix() ? user.suffix() : '');
+
+ deferred.resolve({
+ "barcode": barcode,
+ "settings" : settings,
+ "user_email" : user.email(),
+ "patron_name" : patron_name
+ });
+ });
+
+ return deferred.promise;
+ }
}
if ($scope.handlers) {