From d047646aff7f5aca23ac2a86422e3c869ea3d405 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 12 Mar 2012 12:22:22 -0400 Subject: [PATCH] TPac: non-inherited org unit visibility Adds support for displaying org units that are children of hidden org units in the tpac org unit selector. A new global flag was added to control this behavior called "opac.org_unit.non_inheritied_visibility" / "Org Units Do Not Inherit Visibility". To avoid confusion / distorted org unit trees, children of hidden org units are left-padded one less for each hidden parent org unit. For example, in the stock org tree, if Sys2 is opac_visible=false (and the global flag is enabled), the tree in the tpac would appear like so: Cons - Sys 1 -- BR1 --- SL1 -- BR2 - BR3 - BR4 Similarly, if CONS was also hidden, the whole tree would be shifted left by 1 pad depth. Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- Open-ILS/src/sql/Pg/950.data.seed-values.sql | 12 +++++ ...X.schema.org_unit_opac_vis_and_sorting.sql | 24 ++++++++++ .../src/templates/opac/parts/org_selector.tt2 | 47 +++++++++++++------ 3 files changed, 69 insertions(+), 14 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_unit_opac_vis_and_sorting.sql diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 6c97858e0d..2d3c8ec59b 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -11541,3 +11541,15 @@ INSERT INTO action_trigger.environment (event_def, path) INSERT INTO actor.toolbar(org,label,layout) VALUES ( 1, 'circ', '["circ_checkout","circ_checkin","toolbarseparator.1","search_opac","copy_status","toolbarseparator.2","patron_search","patron_register","toolbarspacer.3","hotkeys_toggle"]' ), ( 1, 'cat', '["circ_checkin","toolbarseparator.1","search_opac","copy_status","toolbarseparator.2","create_marc","authority_manage","retrieve_last_record","toolbarspacer.3","hotkeys_toggle"]' ); + +INSERT INTO config.global_flag (name, enabled, label) + VALUES ( + 'opac.org_unit.non_inheritied_visibility', + FALSE, + oils_i18n_gettext( + 'opac.org_unit.non_inheritied_visibility', + 'Org Units Do Not Inherit Visibility', + 'cgf', + 'label' + ) + ); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_unit_opac_vis_and_sorting.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_unit_opac_vis_and_sorting.sql new file mode 100644 index 0000000000..115613ab6f --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.org_unit_opac_vis_and_sorting.sql @@ -0,0 +1,24 @@ +BEGIN; + +--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); + +INSERT INTO config.global_flag (name, enabled, label) + VALUES ( + 'opac.org_unit.non_inheritied_visibility', + FALSE, + oils_i18n_gettext( + 'opac.org_unit.non_inheritied_visibility', + 'Org Units Do Not Inherit Visibility', + 'cgf', + 'label' + ) + ); + +COMMIT; + +/* UNDO +BEGIN; +DELETE FROM config.global_flag WHERE name = 'opac.org_unit.non_inheritied_visibility'; +COMMIT; +*/ + diff --git a/Open-ILS/src/templates/opac/parts/org_selector.tt2 b/Open-ILS/src/templates/opac/parts/org_selector.tt2 index fd9c8c0f9f..49775c4da7 100644 --- a/Open-ILS/src/templates/opac/parts/org_selector.tt2 +++ b/Open-ILS/src/templates/opac/parts/org_selector.tt2 @@ -8,6 +8,8 @@ BLOCK build_org_selector; node_stack = [{org => org_unit || ctx.aou_tree}]; + inherited_vis = ctx.get_cgf('opac.org_unit.non_inheritied_visibility').enabled == 'f'; + IF !name; name = 'loc'; IF show_loc_groups; name = 'locg'; END; @@ -30,8 +32,10 @@ BLOCK build_org_selector; css_class = ''; disabled = ''; selected = ''; + visible = org_unit.opac_visible == 't'; - NEXT UNLESS ctx.is_staff || org_unit.opac_visible == 't'; + # org and all children are invisible. + NEXT IF !visible AND inherited_vis AND !ctx.is_staff; IF !loc_grp; # processing an org unit @@ -57,11 +61,15 @@ BLOCK build_org_selector; FOR grp IN top_loc_groups; node_stack.push({org => org_unit, loc_grp => grp}); END; + END; + # This org unit is not publicly visible (though its children may be). + NEXT UNLESS ctx.is_staff OR visible; + node_value = ou_id; - IF loc_grp; node_value = node_value _ ':' _ loc_grp.id; END; IF loc_grp; + node_value = node_value _ ':' _ loc_grp.id; css_class = 'class="loc_grp"'; ELSE; css_class = 'class="org_unit"'; @@ -71,20 +79,31 @@ BLOCK build_org_selector; disabled = 'disabled="disabled"'; ELSIF node_value == value; selected = 'selected="selected"'; - END %] + END; + + pad_depth = org_unit.ou_type.depth; + + # copy loc groups appear as children of the owner (current) org + SET pad_depth = pad_depth + 1 IF loc_grp; + + # for each parent org unit that is hidden, decrease the pad depth by one. + IF !ctx.is_staff; + porg = ctx.get_aou(org_unit.parent_ou); + WHILE porg; + SET pad_depth = pad_depth - 1 IF porg.opac_visible == 'f'; + porg = ctx.get_aou(porg.parent_ou); + END; + END; + + pad_depth = pad_depth * 2; + display_name = loc_grp ? loc_grp.name : org_unit.name; + + %] - [% - END; - %] + + [% END %] [% END %] -- 2.43.2