Bugzilla – Attachment 166061 Details for
Bug 36751
Creating new patron attribute types should start with type choice
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36751: PoC
Bug-36751-PoC.patch (text/plain), 9.07 KB, created by
Pedro Amorim
on 2024-05-02 11:09:30 UTC
(
hide
)
Description:
Bug 36751: PoC
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-05-02 11:09:30 UTC
Size:
9.07 KB
patch
obsolete
>From dfdc19aadf28e4384fdc66a19b5a8e5233ffa72d Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >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 @@ > <div class="dialog message">Because the 'ExtendedPatronAttributes` system preference is currently not enabled, extended patron attributes cannot be given to patron records. <br/>Go to the <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=ExtendedPatronAttributes">ExtendedPatronAttributes</a> system preference if you wish to enable this feature.</div> > [% 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 %] <!-- module_langing_page_column--> >+ [% 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 %] <!-- module_langing_page_column--> >+ [% END %] <!-- module_langing_page_content --> >+ >+ [%- SET StaffCataloguingHome = AdditionalContents.get( location => "StaffCataloguingHome", lang => lang, library => logged_in_user.branchcode ) -%] >+ [%- FOREACH block IN StaffCataloguingHome.content -%] >+ <div class="page-section"> >+ [%- block.content | $raw -%] >+ </div> >+ [%- END -%] >+ [% END %] <!-- module_langing_page --> >+[% END %] >+ > [% IF ( attribute_type_form ) %] > [% IF ( edit_attribute_type ) %] > <h1>[% tx("Modify patron attribute type '{code}'", { code = attribute_type.code }) | html %]</h1> >@@ -106,6 +156,16 @@ > <span class="required">Required</span> > </li> > >+ [% IF attribute_type AND attribute_type.authorised_value_category OR model == "avc" %] >+ <li> >+ <label for="authorised_value_category">Authorized value category: </label> >+ <select name="authorised_value_category" id="authorised_value_category"> >+ <option value=""></option> >+ [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => attribute_type.authorised_value_category ) %] >+ </select> >+ </li> >+ [% END %] >+ > [% IF attribute_type AND attribute_type.repeatable AND NOT can_be_set_to_nonrepeatable %] > <li aria-disabled="true"> > [% ELSE %] >@@ -148,13 +208,12 @@ > <span class="hint">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.</span> > </li> >- <li><label for="is_date">Is a date: </label> >- [% IF attribute_type AND attribute_type.is_date %] >- <input type="checkbox" id="is_date" name="is_date" checked="checked" /> >+ <li> >+ [% IF attribute_type AND attribute_type.is_date OR model == 'date' %] >+ <input hidden type="checkbox" id="is_date" name="is_date" checked="checked" /> > [% ELSE %] >- <input type="checkbox" id="is_date" name="is_date" /> >+ <input hidden type="checkbox" id="is_date" name="is_date" /> > [% END %] >- <span class="hint">If checked, attribute will be a date. Date attributes cannot be repeatable or linked to an authorised value category.</span> > </li> > <li><label for="opac_display">Display in OPAC: </label> > [% IF attribute_type AND attribute_type.opac_display %] >@@ -222,14 +281,6 @@ > <span class="hint">Check to make this attribute copied to the patron's pseudonymized attributes.</span> > </li> > [% END %] >- >- <li><label for="authorised_value_category">Authorized value category: </label> >- <select name="authorised_value_category" id="authorised_value_category"> >- <option value=""></option> >- [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => attribute_type.authorised_value_category ) %] >- </select> >- <div class="hint">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.</div> >- </li> > <li><label for="branches">Library limitation: </label> > <select id="branches" name="branches" multiple size="10"> > <option value="">All libraries</option> >@@ -288,7 +339,7 @@ > [% IF ( display_list ) %] > > <div id="toolbar" class="btn-toolbar"> >- <a class="btn btn-default" id="newrule" href="[% script_name | url %]?op=add_attribute_type"><i class="fa fa-plus"></i> New patron attribute type</a> >+ <a class="btn btn-default" id="newrule" href="[% script_name | url %]?op=attribute_type_model"><i class="fa fa-plus"></i> New patron attribute type</a> > </div> > > <h1>Patron attribute types</h1> >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36751
:
166061
|
166062
|
166457