Bug 37398: Make date and date time fields have date picker by default

To test:
1. APPLY PATCH, restart_all
2. Pick a framework, I choose BKS in k-t-d
3. Make sure that a few date and datetime fields are exposed in the editor.
4. On additem.tt a date picker should be instantiated on the date or datetime fields.
5. Make sure the date pickers work on each field.
6. If it is a datetime field you should have the option to add hours and minutes. ( datelastseen )
7. Edit the framework and remove the dateaccessioned.pl plugin from any of these date fields.
8. Even without the dateaccessioned.pl plugin a date picker should be present on the field.
9. Add the dateaccessioned.pl plugin to a non date/datetime field.
10. Make sure the dateaccessioned.pl plugin works properly on the non date/datetime field.
11. Mark one of the date/datetime fields as mandatory, make sure it still acts as mandatory.
12. Hide date/datetime from the editor, make sure it hides properly.

+----------------------+-------------+
| COLUMN_NAME          | COLUMN_TYPE |
+----------------------+-------------+
| dateaccessioned      | date        |
| replacementpricedate | date        |
| datelastborrowed     | date        |
| datelastseen         | datetime    |
| onloan               | date        |
+----------------------+-------------+

Signed-off-by: Phil Ringnalda <phil@chetcolibrary.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Lucas Gass 2024-09-12 16:06:18 +00:00 committed by Katrin Fischer
parent a5fe02e614
commit aa4ee79f6e
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 26 additions and 1 deletions

View File

@ -147,6 +147,14 @@ sub generate_subfield_form {
}
}
if ($subfield->{kohafield} =~ /items\.(replacementpricedate|dateaccessioned|datelastborrowed|onloan)/) {
$subfield_data{datetype} = 'date';
}
if ($subfield->{kohafield} =~ /items\.(datelastseen|damaged_on|itemlost_on|withdrawn_on|deleted_on)/) {
$subfield_data{datetype} = 'datetime';
}
$subfield_data{visibility} = "display:none;"
if ( ( $subfield->{hidden} > 4 ) || ( $subfield->{hidden} <= -4 ) );
@ -315,7 +323,20 @@ sub generate_subfield_form {
authtypecode => $subfield->{authtypecode},
};
}
elsif ( $subfield_data{datetype} eq 'date' ) {
$subfield_data{marc_value} = {
type => 'date_field',
id => $subfield_data{id},
value => $value,
}
}
elsif ( $subfield_data{datetype} eq 'datetime' ) {
$subfield_data{marc_value} = {
type => 'datetime_field',
id => $subfield_data{id},
value => $value,
}
}
# it's a plugin field
elsif ( $subfield->{value_builder} ) { # plugin
require Koha::FrameworkPlugin;

View File

@ -166,6 +166,10 @@
[% ELSE %]
<textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" rows="5" cols="64" >[% mv.value | html %]</textarea>
[% END %]
[% ELSIF ( mv.type == 'date_field' ) %]
<input type="text" id="[% mv.id | html %]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %] flatpickr" value="[% mv.value | html %]" class="flatpickr" />
[% ELSIF ( mv.type == 'datetime_field' ) %]
<input type="text" id="[% mv.id | html %]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %] flatpickr" value="[% mv.value | html %]" data-flatpickr-enable-time="true" />
[% END %]
[% IF subfield.kohafield == 'items.more_subfields_xml' %]