From: Bill Erickson Date: Tue, 15 Jul 2014 16:01:05 +0000 (-0400) Subject: patron edit; plug in editor xulG handlers X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8bcc2fd98455bca789d6393c6cef7bda23b2d4d8;p=working%2FEvergreen.git patron edit; plug in editor xulG handlers Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/templates/staff/circ/patron/index.tt2 b/Open-ILS/src/templates/staff/circ/patron/index.tt2 index 82b62832ea..4f38659163 100644 --- a/Open-ILS/src/templates/staff/circ/patron/index.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/index.tt2 @@ -9,6 +9,7 @@ + [% INCLUDE 'staff/circ/share/circ_strings.tt2' %] diff --git a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 index 02e2e0a5ca..379444ad61 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_edit.tt2 @@ -1,6 +1,3 @@ -
-
-
[% l('EDIT Development Pending') %]
-
-
+ + diff --git a/Open-ILS/web/js/ui/default/actor/user/register.js b/Open-ILS/web/js/ui/default/actor/user/register.js index fe5f0c9f59..6100a9b2b9 100644 --- a/Open-ILS/web/js/ui/default/actor/user/register.js +++ b/Open-ILS/web/js/ui/default/actor/user/register.js @@ -2010,6 +2010,7 @@ function uEditFinishSave(newPatron, doClone) { if(xulG && typeof xulG.spawn_editor == 'function' && !patron.isnew() ) { window.xulG.spawn_editor({ses:openils.User.authtoken,clone:cloneUser}); + return; uEditRefresh(); } else { diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index 20f1f9664a..b1505280cc 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -226,7 +226,8 @@ function($q , $timeout , $location , egCore, egUser , $locale) { // shortcut to force-reload the current primary service.refreshPrimary = function() { - return service.setPrimary(null, service.current, true); + if (!service.current) return $q.when(); + return service.setPrimary(service.current.id(), null, true); } // sets the primary display user, fetching data as necessary. @@ -1111,9 +1112,23 @@ function($scope , $q , $routeParams, egCore , $modal , patronSvc) { * Link to patron edit UI */ .controller('PatronEditCtrl', - ['$scope','$routeParams','egCore', -function($scope, $routeParams, egCore) { + ['$scope','$routeParams','$location','egCore','patronSvc', +function($scope, $routeParams, $location , egCore , patronSvc) { $scope.initTab('edit', $routeParams.id); + + var url = $location.absUrl().replace(/\/staff.*/, '/actor/user/register'); + + // since we don't store auth cookies, pass the ses via URL + url += '?ses=' + egCore.auth.token(); + url += '&usr=' + encodeURIComponent($routeParams.id); + + $scope.funcs = { + on_save : function() { + patronSvc.refreshPrimary(); + } + } + + $scope.patron_edit_url = url; }]) /** diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/register.js b/Open-ILS/web/js/ui/default/staff/circ/patron/register.js index 0550be565e..a74b023cae 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/register.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/register.js @@ -66,6 +66,7 @@ function($scope , $routeParams , $location , $filter , egCore) { url += '&clone=' + encodeURIComponent($routeParams.clone_id); } + // pass the reg URL into the scope, thus into the $scope.reg_url = url; }]) diff --git a/Open-ILS/web/js/ui/default/staff/services/env.js b/Open-ILS/web/js/ui/default/staff/services/env.js index b8ddd7b159..fb1e120c34 100644 --- a/Open-ILS/web/js/ui/default/staff/services/env.js +++ b/Open-ILS/web/js/ui/default/staff/services/env.js @@ -1,9 +1,22 @@ /** * Core Service - egEnv * - * Manages startup data loading. All registered loaders run - * simultaneously. When all promises are resolved, the promise - * returned by egEnv.load() is resolved. + * Manages startup data loading and data caching. + * All registered loaders run * simultaneously. When all promises + * are resolved, the promise * returned by egEnv.load() is resolved. + * + * There are two main uses cases for egEnv: + * + * 1. When loading a variety of objects on page load, having them + * loaded with egEnv ensures that the load will happen in parallel + * and that it will complete before egStartup completes, which is + * generally before page controllers run. + * + * 2. When loading generic IDL data across different services, + * having them all stash the data in egEnv means they each have + * an agreed-upon cache mechanism. + * + * It's also a good place to stash other environmental tidbits... * * Generic and class-based loaders are supported. * @@ -41,6 +54,14 @@ function($q, $window , egAuth, egPCRUD, egIDL) { loaders : [] }; + + // from the current index page + // Currently defaults to /eg/staff for all pages. + // Use $location.path() to jump around within an app. + // Use egEnv.basePath to create URLs to new apps. + service.basePath = + $window.document.getElementsByTagName('base')[0].getAttribute('href'); + /* returns a promise, loads all of the specified classes */ service.load = function() { // always assume the user is logged in diff --git a/Open-ILS/web/js/ui/default/staff/services/lframe.js b/Open-ILS/web/js/ui/default/staff/services/lframe.js index 053cb453f8..26adcdd19a 100644 --- a/Open-ILS/web/js/ui/default/staff/services/lframe.js +++ b/Open-ILS/web/js/ui/default/staff/services/lframe.js @@ -8,20 +8,34 @@ angular.module('egCoreMod') restrict : 'AE', replace : true, scope : { - url : '=' + // URL to load in the legacy iframe + url : '=', + + // optional hash of functions which augment or override + // the stock xulG functions defined below. + handlers : '=' }, template : '', controller : - ['$scope','$window','$location', - function($scope , $window , $location) { + ['$scope','$window','$location','egCore', + function($scope , $window , $location , egCore) { // Set the iframe height to just under the window height. // leave room for the navbar, padding, margins, etc. $scope.height = $window.outerHeight - 250; + // $location has functions for modifying paths and search, + // but they all assume you are staying within the angular + // app, which we are not. Build the URLs by hand. + function open_tab(path) { + var url = 'https://' + $window.location.hostname + + egCore.env.basePath + path; + console.debug('egLegacyFrame opening tab ' + url); + $window.open(url, '_blank').focus(); + } // define our own xulG functions to be inserted into the // iframe. NOTE: window-level functions are bad. Though @@ -31,17 +45,51 @@ angular.module('egCoreMod') // for porting dojo, etc. apps to angular apps and should // eventually go away. $window.egLegacyFrameLoader = function(iframe) { + + // tell the iframe'd window its inside the staff client + iframe.contentWindow.IAMXUL = true; + + // also tell it it's inside the browser client, which + // may be needed in a few special cases. + iframe.contentWindow.IAMBROWSER = true; + + // define a few commonly used stock xulG handlers. iframe.contentWindow.xulG = { - // patron search spawn_search : function(search) { - $window.open( - $location.path('/circ/patron/search'). - search({search : js2JSON(search)}).absUrl(), - '_blank' - ).focus(); - } + open_tab('/circ/patron/search?search=' + + encodeURIComponent(js2JSON(search))); + }, + + // edit an existing user + spawn_editor : function(info) { + if (info.usr) { + open_tab('/circ/patron/register/edit/' + info.usr); + + } else if (info.clone) { + // FIXME: The save-and-clone operation in the + // patron editor results in this action. + // For some reason, this specific function results + // in a new browser window opening instead of a + // browser tab. Possibly this is caused by the + // fact that the action occurs as a result of a + // button click instead of an href. *shrug*. + // It's obnoxious. + open_tab('/circ/patron/register/clone/' + info.clone); + } + }, + + // open a user account + new_patron_tab : function(tab_info, usr_info) { + open_tab('/circ/patron/' + usr_info.id + '/checkout'); + } + } + + if ($scope.handlers) { + angular.forEach($scope.handlers, function(val, key) { + iframe.contentWindow.xulG[key] = val; + }); } } }]