Bug 32188: Only show template controls above item form if templates have been defined

The new item templates above the item edit form should only show, when at least one template has been defined.

Test Plan:
1) Browse to the item editor
2) Delete all templates
3) Note the template toolbar is displayed
4) Apply this patch
5) Reload the page, note the toolbar is not displayed
6) Create a new template, note the toolbar is now displayed
7) Delete that template, note the toolbar is no longer displayed

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-11-14 11:07:51 -05:00 committed by Tomas Cohen Arazi
parent 8bbfe0cc94
commit 0441b5ce46
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F

View file

@ -163,60 +163,61 @@
<h2 id="edititem">Edit item #[% itemnumber | html %][% IF ( barcode ) %] / Barcode [% barcode | html %][% END %]</h2>
[% END %]
<div id="item-template-toolbar" class="btn-toolbar">
<div class="btn-group">
<select name="template_id" id="template_id" class="select2" style="width: 20em">
<option value="0" selected="selected">Do not use template</option>
<optgroup label="My templates">
[% FOREACH t IN item_templates.owned %]
[% IF t.id == template_id %]
<option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
[% ELSE %]
<option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
[% END %]
[% END %]
</optgroup>
<optgroup label="Shared templates">
[% FOREACH t IN item_templates.shared %]
[% IF t.id == template_id %]
[% IF CAN_user_editcatalogue_manage_item_editor_templates %]
<option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
[% IF item_templates.owned.count || item_templates.shared.count %]
<div id="item-template-toolbar" class="btn-toolbar">
<div class="btn-group">
<select name="template_id" id="template_id" class="select2" style="width: 20em">
<option value="0" selected="selected">Do not use template</option>
<optgroup label="My templates">
[% FOREACH t IN item_templates.owned %]
[% IF t.id == template_id %]
<option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
[% ELSE %]
<option data-editor="0" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
[% END %]
[% ELSE %]
[% IF CAN_user_editcatalogue_manage_item_editor_templates %]
<option data-editor="1" value="[% t.id | html %]">[% t.name | html %]</option>
[% ELSE %]
<option data-editor="0" value="[% t.id | html %]">[% t.name | html %]</option>
<option data-editor="1" value="[% t.id | html %]">[% t.name | html %][% IF t.is_shared %] (shared)[% END %]</option>
[% END %]
[% END %]
</optgroup>
<optgroup label="Shared templates">
[% FOREACH t IN item_templates.shared %]
[% IF t.id == template_id %]
[% IF CAN_user_editcatalogue_manage_item_editor_templates %]
<option data-editor="1" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
[% ELSE %]
<option data-editor="0" value="[% t.id | html %]" selected="selected">[% t.name | html %]</option>
[% END %]
[% ELSE %]
[% IF CAN_user_editcatalogue_manage_item_editor_templates %]
<option data-editor="1" value="[% t.id | html %]">[% t.name | html %]</option>
[% ELSE %]
<option data-editor="0" value="[% t.id | html %]">[% t.name | html %]</option>
[% END %]
[% END %]
[% END %]
</optgroup>
</select>
</div>
<div class="btn-group">
<button type="submit" id="load_template_submit" name="load_template_submit" value="1"><i class="fa fa-wpforms"></i> Apply template</button>
</div>
<div class="btn-group">
<label for="use_template_for_session">
[% IF use_template_for_session %]
<input type="checkbox" id="use_template_for_session" name="use_template_for_session" checked="checked">
[% ELSE %]
<input type="checkbox" id="use_template_for_session" name="use_template_for_session">
[% END %]
</optgroup>
</select>
</div>
<div class="btn-group">
<button type="submit" id="load_template_submit" name="load_template_submit" value="1"><i class="fa fa-wpforms"></i> Apply template</button>
</div>
<div class="btn-group">
<label for="use_template_for_session">
[% IF use_template_for_session %]
<input type="checkbox" id="use_template_for_session" name="use_template_for_session" checked="checked">
[% ELSE %]
<input type="checkbox" id="use_template_for_session" name="use_template_for_session">
[% END %]
For session</label>
</div>
For session</label>
</div>
<div class="btn-group">
<button type="submit" id="unload_template_submit" name="unload_template_submit" value="1"><i class="fa fa-eraser"></i> Clear template</button>
</div>
<div class="btn-group">
<button type="submit" id="unload_template_submit" name="unload_template_submit" value="1"><i class="fa fa-eraser"></i> Clear template</button>
</div>
<div class="btn-group">
<button type="submit" id="delete_template_submit" name="delete_template_submit" value="1" disabled><i class="fa fa-trash"></i> Delete template</button>
<div class="btn-group">
<button type="submit" id="delete_template_submit" name="delete_template_submit" value="1" disabled><i class="fa fa-trash"></i> Delete template</button>
</div>
</div>
</div>
[% END %]
<fieldset class="rows">
[% PROCESS subfields_for_item subfields => subfields %]