From b97fae5901c569b687699b39c36941b2f36a3d6f Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 25 Nov 2008 17:42:22 +0000 Subject: [PATCH] plugged in context selector. implemented create git-svn-id: svn://svn.open-ils.org/ILS/trunk@11347 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../global/permission/grp_penalty_threshold.js | 59 +++++++++++++--------- .../global/permission/grp_penalty_threshold.tt2 | 7 ++- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/Open-ILS/web/js/ui/default/conify/global/permission/grp_penalty_threshold.js b/Open-ILS/web/js/ui/default/conify/global/permission/grp_penalty_threshold.js index c8452753be..15480194c9 100644 --- a/Open-ILS/web/js/ui/default/conify/global/permission/grp_penalty_threshold.js +++ b/Open-ILS/web/js/ui/default/conify/global/permission/grp_penalty_threshold.js @@ -25,41 +25,54 @@ var GPT = { }, buildGrid : function() { - var postPenaltyFunc = function() { - openils.PermGrp.fetchGroupTree( + fieldmapper.standardRequest( + ['open-ils.actor', 'open-ils.actor.grp_penalty_threshold.ranged.retrieve'], + { async: true, + params: [openils.User.authtoken, GPT.contextOrg], + oncomplete: GPT._gridComplete + } + ); + }, + + init : function() { + GPT.contextOrg = openils.User.user.ws_ou(); + + var connect = function() { + dojo.connect(GPT.contextOrgSelector, 'onChange', function() { - openils.PermGrp.flatten(); - fieldmapper.standardRequest( - ['open-ils.permacrud', 'open-ils.permacrud.search.pgpt.atomic'], - { async: true, - params: [openils.User.authtoken, {id:{'!=':null}}], - oncomplete: GPT._gridComplete - } - ); + GPT.contextOrg = this.getValue(); + GPT.buildGrid(); } ); }; - GPT.loadCsp(postPenaltyFunc); + new openils.User().buildPermOrgSelector('VIEW_GROUP_PENALTY_THRESHOLD', GPT.contextOrgSelector, null, connect); + + GPT.loadCsp( + function() { + openils.PermGrp.fetchGroupTree( + function() { openils.PermGrp.flatten(); GPT.buildGrid(); } + ); + } + ); }, create : function(args) { + if(!(args.grp && args.org_unit && args.penalty && args.threshold)) + return; - return alert(js2JSON(args)); - - if(!(args.name && args.label)) return; - - var penalty = new pgpt(); - penalty.name(args.name); - penalty.label(args.label); - + var thresh = new pgpt(); + thresh.grp(args.grp); + thresh.org_unit(args.org_unit); + thresh.penalty(args.penalty); + thresh.threshold(args.threshold); fieldmapper.standardRequest( ['open-ils.permacrud', 'open-ils.permacrud.create.pgpt'], { async: true, - params: [openils.User.authtoken, penalty], + params: [openils.User.authtoken, thresh], oncomplete: function(r) { if(new String(openils.Util.readResponse(r)) != '0') - gptBuildGrid(); + GPT.buildGrid(); } } ); @@ -82,7 +95,7 @@ var GPT = { fieldmapper.standardRequest( ['open-ils.permacrud', 'open-ils.permacrud.search.csp.atomic'], { async: true, - params: [openils.User.authtoken, {id:{'!=':null}}], + params: [openils.User.authtoken, {id:{'<':100}}], oncomplete: function(r) { if(list = openils.Util.readResponse(r, false, true)) { list = list.sort( @@ -118,4 +131,4 @@ var GPT = { } }; -openils.Util.addOnLoad(GPT.buildGrid); +openils.Util.addOnLoad(GPT.init); diff --git a/Open-ILS/web/templates/default/conify/global/permission/grp_penalty_threshold.tt2 b/Open-ILS/web/templates/default/conify/global/permission/grp_penalty_threshold.tt2 index 112c9ffde2..b5fc3addf2 100644 --- a/Open-ILS/web/templates/default/conify/global/permission/grp_penalty_threshold.tt2 +++ b/Open-ILS/web/templates/default/conify/global/permission/grp_penalty_threshold.tt2 @@ -14,9 +14,9 @@ - + @@ -44,6 +44,9 @@
-
+Context Org Unit +
-- 2.11.0