From 9ff41d494e268f981db189e1cf01d1df04b37cae Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 1 Mar 2012 13:51:53 -0500 Subject: [PATCH] Copy Location Groups : sort to top option Adds a 'top' flag to copy_location_groups which, when enabled, will cause the location group to sort above the child org units in the org unit selector in the tpac. Signed-off-by: Bill Erickson Signed-off-by: Dan Scott --- Open-ILS/examples/fm_IDL.xml | 1 + Open-ILS/src/sql/Pg/040.schema.asset.sql | 1 + .../XXXX.schema.copy_loc_search_groups.sql | 1 + .../src/templates/opac/parts/org_selector.tt2 | 19 +++++++++++++++++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index c7bb14d5da..94e1aa2524 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -3935,6 +3935,7 @@ SELECT usr, + diff --git a/Open-ILS/src/sql/Pg/040.schema.asset.sql b/Open-ILS/src/sql/Pg/040.schema.asset.sql index 85d58f637d..d98fc75138 100644 --- a/Open-ILS/src/sql/Pg/040.schema.asset.sql +++ b/Open-ILS/src/sql/Pg/040.schema.asset.sql @@ -55,6 +55,7 @@ CREATE TABLE asset.copy_location_group ( name TEXT NOT NULL, -- i18n owner INT NOT NULL REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, pos INT NOT NULL DEFAULT 0, + top BOOL NOT NULL DEFAULT FALSE, opac_visible BOOL NOT NULL DEFAULT TRUE, CONSTRAINT lgroup_once_per_owner UNIQUE (owner,name) ); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.copy_loc_search_groups.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.copy_loc_search_groups.sql index a6dd74a3b6..9e393d9c49 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.copy_loc_search_groups.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.copy_loc_search_groups.sql @@ -7,6 +7,7 @@ CREATE TABLE asset.copy_location_group ( name TEXT NOT NULL, -- i18n owner INT NOT NULL REFERENCES actor.org_unit (id) ON DELETE CASCADE DEFERRABLE INITIALLY DEFERRED, pos INT NOT NULL DEFAULT 0, + top BOOL NOT NULL DEFAULT FALSE, opac_visible BOOL NOT NULL DEFAULT TRUE, CONSTRAINT lgroup_once_per_owner UNIQUE (owner,name) ); diff --git a/Open-ILS/src/templates/opac/parts/org_selector.tt2 b/Open-ILS/src/templates/opac/parts/org_selector.tt2 index a2c222e40f..5b55e900f6 100644 --- a/Open-ILS/src/templates/opac/parts/org_selector.tt2 +++ b/Open-ILS/src/templates/opac/parts/org_selector.tt2 @@ -29,15 +29,30 @@ BLOCK build_org_selector; NEXT UNLESS ctx.is_staff || org_unit.opac_visible == 't'; - IF !loc_grp; + IF !loc_grp; # processing an org unit + + top_loc_groups = []; IF show_loc_groups; + # add the location groups that sort below the child org units FOR grp IN ctx.copy_location_groups.$ou_id.reverse; - node_stack.push({org => org_unit, loc_grp => grp}); + IF grp.top == 't'; + top_loc_groups.push(grp); + ELSE; + node_stack.push({org => org_unit, loc_grp => grp}); + END; END; END; + + # add the child org units FOR child IN org_unit.children.reverse; node_stack.push({org => child}); END; + + # add the location groups that sort to the top + # above the child org units + FOR grp IN top_loc_groups; + node_stack.push({org => org_unit, loc_grp => grp}); + END; END; node_value = ou_id; -- 2.43.2