Bug 35044: Admin: New additional fields 'repeatable' field

There is now a new 'repeatable' checkbox when configuring
(adding or editing) an additional field for a specific table.
It is also displayed in a column in the additional fields panel
for a given tablename.

MARC fields are not allowed to be repeatable.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Pedro Amorim 2023-10-13 10:00:22 +00:00 committed by Katrin Fischer
parent 53a50118ae
commit e4ce13c945
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
2 changed files with 22 additions and 1 deletions

View file

@ -53,6 +53,7 @@ if ( $op eq 'cud-add' ) {
my $marcfield = $input->param('marcfield') // q{}; my $marcfield = $input->param('marcfield') // q{};
my $marcfield_mode = $input->param('marcfield_mode') // 'get'; my $marcfield_mode = $input->param('marcfield_mode') // 'get';
my $searchable = $input->param('searchable') ? 1 : 0; my $searchable = $input->param('searchable') ? 1 : 0;
my $repeatable = $input->param('repeatable') ? 1 : 0;
if ( $field_id and $name ) { if ( $field_id and $name ) {
my $updated = 0; my $updated = 0;
my $set_fields = { my $set_fields = {
@ -60,6 +61,7 @@ if ( $op eq 'cud-add' ) {
marcfield => $marcfield, marcfield => $marcfield,
marcfield_mode => $marcfield_mode, marcfield_mode => $marcfield_mode,
searchable => $searchable, searchable => $searchable,
repeatable => $repeatable,
}; };
$set_fields->{authorised_value_category} = $authorised_value_category if $authorised_value_category; $set_fields->{authorised_value_category} = $authorised_value_category if $authorised_value_category;
@ -80,6 +82,7 @@ if ( $op eq 'cud-add' ) {
marcfield => $marcfield, marcfield => $marcfield,
marcfield_mode => $marcfield_mode, marcfield_mode => $marcfield_mode,
searchable => $searchable, searchable => $searchable,
repeatable => $repeatable,
}; };
$set_fields->{authorised_value_category} = $authorised_value_category if $authorised_value_category; $set_fields->{authorised_value_category} = $authorised_value_category if $authorised_value_category;
@ -137,4 +140,4 @@ $template->param(
messages => \@messages, messages => \@messages,
); );
output_html_with_http_headers $input, $cookie, $template->output; output_html_with_http_headers $input, $cookie, $template->output;

View file

@ -156,6 +156,7 @@
[% IF show_searchable %] [% IF show_searchable %]
<th>Searchable</th> <th>Searchable</th>
[% END %] [% END %]
<th>Repeatable</th>
<th class="noExport">Actions</th> <th class="noExport">Actions</th>
</tr> </tr>
</thead> </thead>
@ -178,6 +179,9 @@
[% IF field.searchable %]Yes[% ELSE %]No[% END %] [% IF field.searchable %]Yes[% ELSE %]No[% END %]
</td> </td>
[% END %] [% END %]
<td>
[% IF field.repeatable %]Yes[% ELSE %]No[% END %]
</td>
<td class="actions"> <td class="actions">
<a class="btn btn-default btn-xs" href="?op=add_form&amp;field_id=[% field.id | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a> <a class="btn btn-default btn-xs" href="?op=add_form&amp;field_id=[% field.id | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a>
<a class="confirmdelete btn btn-default btn-xs" href="?op=delete&amp;field_id=[% field.id | uri %]&amp;tablename=[% tablename | uri %]"><i class="fa fa-trash-can"></i> Delete</a> <a class="confirmdelete btn btn-default btn-xs" href="?op=delete&amp;field_id=[% field.id | uri %]&amp;tablename=[% tablename | uri %]"><i class="fa fa-trash-can"></i> Delete</a>
@ -212,6 +216,14 @@
[% PROCESS options_for_authorised_value_categories authorised_value_categories = AuthorisedValues.GetCategories({selected => field.authorised_value_category}) %] [% PROCESS options_for_authorised_value_categories authorised_value_categories = AuthorisedValues.GetCategories({selected => field.authorised_value_category}) %]
</select> </select>
</li> </li>
<li>
<label for="repeatable">Repeatable: </label>
[% IF field.repeatable %]
<input type="checkbox" name="repeatable" id="repeatable" checked="checked" />
[% ELSE %]
<input type="checkbox" name="repeatable" id="repeatable" />
[% END %]
</li>
[% IF show_marcfield %] [% IF show_marcfield %]
<li> <li>
<label for="marcfield">MARC field: </label> <label for="marcfield">MARC field: </label>
@ -299,6 +311,12 @@
alert(_("You cannot select an authorised value category and a MARC field") ); alert(_("You cannot select an authorised value category and a MARC field") );
return false; return false;
} }
} $("#repeatable").prop('checked') == true
if ( $("#marcfield").length && $("#repeatable").length) {
if ( $("#marcfield").val().length > 0 && $("#repeatable").prop('checked') == true ) {
alert(_("You cannot set a MARC field as repeatable") );
return false;
}
} }
return true; return true;
}); });