From: Bill Erickson Date: Mon, 12 Mar 2012 16:22:22 +0000 (-0400) Subject: TPac: non-inherited org unit visibility X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3f130f8da6ea736ad2bc9ac37c95d0a5819796bd;p=working%2FEvergreen.git 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 --- 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 94e7626f84..84d71df7cd 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -11372,3 +11372,16 @@ INSERT INTO config.org_unit_setting_type 'integer' ); + +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 02c24489b6..ed845a9b98 100644 --- a/Open-ILS/src/templates/opac/parts/org_selector.tt2 +++ b/Open-ILS/src/templates/opac/parts/org_selector.tt2 @@ -5,6 +5,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; @@ -27,8 +29,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 @@ -54,11 +58,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"'; @@ -68,20 +76,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 %]