From 8a873d036bad33ab5007640ac805b53315617823 Mon Sep 17 00:00:00 2001
From: Alex Buckley <alexbuckley@catalyst.net.nz>
Date: Wed, 17 Aug 2022 20:20:12 +0000
Subject: [PATCH] Bug 30418: Template and JavaScript changes

Sponsored-by: Catalyst IT, New Zealand
---
 .../prog/en/includes/permissions.inc          |  5 +++++
 .../prog/en/modules/virtualshelves/shelves.tt | 19 ++++++++++++++++++-
 .../bootstrap/en/modules/opac-shelves.tt      | 11 +++++++++++
 3 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc
index a8bfd89e02a..48b0cc5c4ee 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc
@@ -726,6 +726,11 @@
             Edit public lists (Name, settings, and permissions, but not explicitly contents)
         </span>
         <span class="permissioncode">([% name | html %])</span>
+    [%- CASE 'edit_public_list_contents' -%]
+        <span class="sub_permission edit_public_list_contents_subpermission">
+            Edit public lists contents
+        </span>
+        <span class="permissioncode">([% name | html %])</span>
     [%- CASE 'upload_general_files' -%]
         <span class="sub_permission upload_general_files_subpermission">
             Upload any file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
index 605a074f5e2..8dd3e486158 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt
@@ -47,10 +47,18 @@
                 <option value="3" selected="selected">Staff only</option>
             [% ELSE %]
                 <option value="3">Staff only</option>
-                [% END %]
+            [% END %]
+
+            [% IF shelf.allow_change_from_permitted_staff %]
+                <option value="4" selected="selected">Permitted staff only</option>
+            [% ELSE %]
+                <option value="4">Permitted staff only</option>
+            [% END %]
+
         </select>
         &emsp; <span id="anyone_remark" style="display:none;color:red;">The Anyone permission has no actual effect while this list is strictly private.</span>
         &emsp; <span id="staff_remark" style="display:none;color:red;">The Staff only permission has no actual effect while this list is strictly private.</span>
+        &emsp; <span id="permitted_staff_remark" style="display:none;color:red;">The Permitted staff only permission has no actual effect while this list is strictly private.</span>
     </li>
 [% END %]
 </head>
@@ -912,6 +920,7 @@
             if( perms < 2 ) {
                 $("#anyone_remark").hide();
                 $("#staff_remark").hide();
+                $("#permitted_staff_remark").hide();
             } else if( public==0 ) {
                 // If we move to Private (without shares), show Anyone remark
                 // Note: the number of shares is not tested real-time
@@ -919,17 +928,25 @@
                     if( perms== 2) {
                         $("#anyone_remark").show();
                         $("#staff_remark").hide();
+                        $("#permitted_staff_remark").hide();
                     } else if ( perms==3 ) {
                         $("#anyone_remark").hide();
                         $("#staff_remark").show();
+                        $("#permitted_staff_remark").hide();
+                    } else if ( perms==4 ) {
+                        $("#anyone_remark").hide();
+                        $("#staff_remark").hide();
+                        $("#permitted_staff_remark").show();
                     }
                 [% ELSE %]
                     $("#anyone_remark").hide();
                     $("#staff_remark").hide();
+                    $("#permitted_staff_remark").hide();
                 [% END %]
             } else { // public==1
                 $("#anyone_remark").hide();
                 $("#staff_remark").hide();
+                $("#permitted_staff_remark").hide();
             }
         }
         [% IF op == 'view' %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt
index 058ea4a180e..3b6f355cffb 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt
@@ -51,10 +51,12 @@
             [% IF shelf.allow_change_from_others %]<option value="2" selected="selected">Anyone seeing this list</option>[% ELSE %]<option value="2">Anyone seeing this list</option>[% END %]
 
             [% IF staffuser == 1 %][% IF shelf.allow_change_from_staff %]<option value="3" selected="selected">Staff only</option>[% ELSE %]<option value="3">Staff only</option>[% END %][% END %]
+            [% IF permitteduser == 1 %][% shelf.allow_change_from_permitted_staff %]<option value="4" selected="selected">Permitted staff only</option>[% ELSE %]<option value="4">Permitted staff only</option>[% END %'[% END %]
 
         </select>
         &emsp; <span id="anyone_remark" style="display:none;color:red;">The "Anyone" permission has no actual effect while this list is strictly private.</span>
         &emsp; <span id="staff_remark" style="display:none;color:red;">The "Staff only" permission has no actual effect while this list is strictly private.</span>
+         &emsp; <span id="permitted_staff_remark" style="display:none;color:red;">The "Permitted staff only" permission has no actual effect while this list is strictly private.</span>
     </li>
 [% END %]
 
@@ -1097,6 +1099,7 @@ function AdjustRemark() {
     if( perms < 2 ) {
         $("#anyone_remark").hide();
         $("#staff_remark").hide();
+        $("#permitted_staff_remark").hide();
     } else if( public==0 ) {
         // If we move to Private (without shares), show Anyone remark
         // Note: the number of shares is not tested real-time
@@ -1104,17 +1107,25 @@ function AdjustRemark() {
             if ( perms==2 ) {
                 $("#anyone_remark").show();
                 $("#staff_remark").hide();
+                $("#permitted_staff_remark").hide();
             } else if ( perms==3 ) {
                 $("#anyone_remark").hide();
                 $("#staff_remark").show();
+                $("#permitted_staff_remark").hide();
+            } else if ( perms==4 ) {
+                $("#anyone_remark").hide();
+                $("#staff_remark").hide();
+                $("#permitted_staff_remark").show();
             }
         [% ELSE %]
             $("#anyone_remark").hide();
             $("#staff_remark").hide();
+            $("#permitted_staff_remark").hide();
         [% END %]
     } else { // public==1
         $("#anyone_remark").hide();
         $("#staff_remark").hide();
+        $("#permitted_staff_remark").hide();
     }
 }
 </script>
-- 
2.30.2