Bug 24606: (QA follow-up) Set existing sharing setting when updating existing template

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Kyle Hall 2022-10-17 09:35:13 -04:00 committed by Tomas Cohen Arazi
parent 4037e6ceca
commit 0e1a3efb75
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 6 additions and 3 deletions

View file

@ -273,12 +273,12 @@
<option value="0" selected="selected">Save as new template</option>
<optgroup label="Update existing template">
[% FOREACH t IN item_templates.owned %]
<option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
<option data-editor="1" data-shared="[% t.is_shared %]" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
[% END %]
[% IF CAN_user_editcatalogue_manage_item_editor_templates && item_templates.shared.count %]
<optgroup label="Update shared template">
[% FOREACH t IN item_templates.shared %]
<option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
<option data-editor="1" data-shared="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
[% END %]
</optgroup>
[% END %]

View file

@ -93,10 +93,13 @@ $(document).ready(function(){
});
$("#template_id").change(); // Trigger to enable delete button if patron's template is in use
$("#replace_template_id").on("change", function() {
if ( $(this).find(":selected").val() > 0 ) {
let selected = $(this).find(":selected");
if ( selected.val() > 0 ) {
$("#template_name_block").hide();
$("#template_is_shared").prop("checked", selected.data("shared"));
} else {
$("#template_name_block").show();
$("#template_is_shared").prop("checked", false);
}
});