<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/grid.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/user.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/lframe.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/services/billing.js"></script>
<script src="[% ctx.media_prefix %]/js/ui/default/staff/circ/services/circ.js"></script>
[% INCLUDE 'staff/circ/share/circ_strings.tt2' %]
-<div class="row pad-vert">
- <div class="col-md-10 col-md-offset-1">
- <div class="alert alert-warning">[% l('EDIT Development Pending') %]</div>
- </div>
-</div>
+<!-- insert the patron registration UI -->
+<eg-legacy-frame url="patron_edit_url" handlers="funcs"></eg-legacy-frame>
if(xulG && typeof xulG.spawn_editor == 'function' && !patron.isnew() ) {
window.xulG.spawn_editor({ses:openils.User.authtoken,clone:cloneUser});
+ return;
uEditRefresh();
} else {
// 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.
* 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;
}])
/**
url += '&clone=' + encodeURIComponent($routeParams.clone_id);
}
+ // pass the reg URL into the scope, thus into the
$scope.reg_url = url;
}])
/**
* 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.
*
loaders : []
};
+
+ // <base href="<basePath>"/> 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
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 : '<iframe src="{{url}}" onload="egLegacyFrameLoader(this)" '
+ 'class="eg-legacy-frame" style="height:{{height}}px"></iframe>',
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
// 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;
+ });
}
}
}]