From 295a046c48b12264eb7095810eb4b4781d6efd3e Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 9 May 2024 13:46:29 +0000 Subject: [PATCH] Bug 36751: PoC New PoC removing the intermediary screen and adding dropdown choices instead. This also now adds the 'model' column in the UI table. I would prefer to go deeper and update the database schema but I feel that might be too much for now. Test plan, remains the same but dropdown choices instead of new UI screen: Visit patron attribute types at: http://localhost:8081/cgi-bin/koha/admin/patron-attr-types.pl Click "New patron attribute type" Notice you are now presented with choices in regards to the model of the attribute type: "Text", "Date" or "Authorized value category Notice if you pick "Date", you're unable to pick an authorized value category Notice if you pick "Authorised value category", you're unable to pick if its a date or not --- Koha/Patron/Attribute/Type.pm | 12 ++++ admin/patron-attr-types.pl | 2 + .../en/modules/admin/patron-attr-types.tt | 64 ++++++++++++++----- 3 files changed, 61 insertions(+), 17 deletions(-) diff --git a/Koha/Patron/Attribute/Type.pm b/Koha/Patron/Attribute/Type.pm index 772cad3c43..4eb09f4108 100644 --- a/Koha/Patron/Attribute/Type.pm +++ b/Koha/Patron/Attribute/Type.pm @@ -115,6 +115,18 @@ sub check_unique_ids { } +=head3 get_model + Return the name of the model of this attribute type + +=cut + +sub get_model { + my ($self) = @_; + + return 'date' if $self->is_date; + return 'avc' if $self->authorised_value_category; + return 'text'; +} =head3 _type diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl index d591383e48..be9f75c861 100755 --- a/admin/patron-attr-types.pl +++ b/admin/patron-attr-types.pl @@ -84,11 +84,13 @@ exit 0; sub add_attribute_type_form { my $template = shift; + my $model = $input->param('model'); my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']}); $template->param( attribute_type_form => 1, confirm_op => 'cud-add_attribute_type_confirmed', categories => $patron_categories, + model => $model ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt index 6c87a2fe0c..7cb98425af 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt @@ -76,9 +76,9 @@ [% IF ( attribute_type_form ) %] [% IF ( edit_attribute_type ) %] -

[% tx("Modify patron attribute type '{code}'", { code = attribute_type.code }) | html %]

+

[% tx("Modify patron attribute type '{code}'", { code = attribute_type.code }) | html %]: [% PROCESS model_label_block model_code = attribute_type.get_model %]

[% ELSE %] -

New patron attribute type

+

[% t('New patron attribute type') %]: [% PROCESS model_label_block model_code = attribute_type.get_model %]

[% END %] [% IF ( duplicate_code_error ) %]
Could not add patron attribute type "[% duplicate_code_error | html %]" @@ -106,6 +106,16 @@ Required + [% IF attribute_type AND attribute_type.authorised_value_category OR model == "avc" %] +
  • + + +
  • + [% END %] + [% IF attribute_type AND attribute_type.repeatable AND NOT can_be_set_to_nonrepeatable %]
  • [% ELSE %] @@ -148,13 +158,12 @@ If checked, attribute will be a unique identifier. If a value is given to a patron record, the same value cannot be given to a different record.
  • -
  • - [% IF attribute_type AND attribute_type.is_date %] - +
  • + [% IF attribute_type AND attribute_type.is_date OR model == 'date' %] + [% ELSE %] - + [% END %] - If checked, attribute will be a date. Date attributes cannot be repeatable or linked to an authorised value category.
  • [% IF attribute_type AND attribute_type.opac_display %] @@ -222,14 +231,6 @@ Check to make this attribute copied to the patron's pseudonymized attributes.
  • [% END %] - -
  • - -
    If one is selected, the patron record input page will only allow values to be chosen from the authorized value list. However, an authorized value list is not enforced during batch patron import.
    -