From dfdc19aadf28e4384fdc66a19b5a8e5233ffa72d Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Thu, 2 May 2024 11:05:50 +0000 Subject: [PATCH] Bug 36751: PoC This is a PoC only. More work should be done here. Imo, ideally, we'd have a mapping where each 'model' would define what it supports ('repeateable', 'searchable', 'unique identifier', etc). But first would like to know what others think of this. Is this is a good idea? Should we invest more time here. Test plan, k-t-d: 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 --- admin/patron-attr-types.pl | 16 +++- .../en/modules/admin/patron-attr-types.tt | 79 +++++++++++++++---- 2 files changed, 79 insertions(+), 16 deletions(-) diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl index d591383e489..229005b402e 100755 --- a/admin/patron-attr-types.pl +++ b/admin/patron-attr-types.pl @@ -53,7 +53,9 @@ $template->param(script_name => $script_name); my $code = $input->param("code"); my $display_list = 0; -if ($op eq "edit_attribute_type") { +if( $op eq "attribute_type_model" ) { + attribute_type_model($template); +} elsif ($op eq "edit_attribute_type") { edit_attribute_type_form($template, $code); } elsif ($op eq "cud-edit_attribute_type_confirmed") { $display_list = add_update_attribute_type('edit', $template, $code); @@ -81,14 +83,24 @@ output_html_with_http_headers $input, $cookie, $template->output; exit 0; +sub attribute_type_model { + my $template = shift; + + $template->param( + attribute_type_model => 1, + ); +} + sub add_attribute_type_form { my $template = shift; - my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']}); + 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 326d8edc862..3ed77201596 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 @@ -74,6 +74,56 @@
Because the 'ExtendedPatronAttributes` system preference is currently not enabled, extended patron attributes cannot be given to patron records.
Go to the ExtendedPatronAttributes system preference if you wish to enable this feature.
[% END %] +[% IF ( attribute_type_model ) %] + [% WRAPPER module_langing_page %] + [% WRAPPER module_langing_page_content label = t("Select the attribute type model") %] + [% WRAPPER module_langing_page_column %] + [% WRAPPER module_langing_page_item + title = t("Basic") + item_permission = ( CAN_user_catalogue ) + sub_items = [ + { + 'label' => t("Text"), + 'icon_class' => 'fa fa-pencil', + 'link' => script_name _ '?op=add_attribute_type&model=text', + 'permission' => CAN_user_catalogue, + }, + { + 'label' => t("Date"), + 'icon_class' => 'fa fa-calendar', + 'link' => script_name _ '?op=add_attribute_type&model=date', + 'permission' => CAN_user_catalogue, + } + ] + %] + [% END %] + [% END %] + [% WRAPPER module_langing_page_column %] + [% WRAPPER module_langing_page_item + title = t("Choice") + item_permission = ( CAN_user_catalogue ) + sub_items = [ + { + 'label' => t("Authorized value category"), + 'icon_class' => 'fa fa-list', + 'link' => script_name _ '?op=add_attribute_type&model=avc', + 'permission' => CAN_user_catalogue, + } + ] + %] + [% END %] + [% END %] + [% END %] + + [%- SET StaffCataloguingHome = AdditionalContents.get( location => "StaffCataloguingHome", lang => lang, library => logged_in_user.branchcode ) -%] + [%- FOREACH block IN StaffCataloguingHome.content -%] +
+ [%- block.content | $raw -%] +
+ [%- END -%] + [% END %] +[% END %] + [% IF ( attribute_type_form ) %] [% IF ( edit_attribute_type ) %]

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

@@ -106,6 +156,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 +208,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 +281,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.
    -