Bugzilla – Attachment 166457 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.06 KB, created by
Pedro Amorim
on 2024-05-09 13:54:45 UTC
(
hide
)
Description:
Bug 36751: PoC
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-05-09 13:54:45 UTC
Size:
9.06 KB
patch
obsolete
>From 295a046c48b12264eb7095810eb4b4781d6efd3e Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >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 ) %] >-<h1>[% tx("Modify patron attribute type '{code}'", { code = attribute_type.code }) | html %]</h1> >+<h1>[% tx("Modify patron attribute type '{code}'", { code = attribute_type.code }) | html %]: [% PROCESS model_label_block model_code = attribute_type.get_model %]</h1> > [% ELSE %] >-<h1>New patron attribute type</h1> >+<h1>[% t('New patron attribute type') %]: [% PROCESS model_label_block model_code = attribute_type.get_model %]</h1> > [% END %] > [% IF ( duplicate_code_error ) %] > <div class="dialog message">Could not add patron attribute type "[% duplicate_code_error | html %]" >@@ -106,6 +106,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 +158,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 +231,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 +289,22 @@ > [% 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> >+ <div class="dropdown btn-group"> >+ <button class="btn btn-default dropdown-toggle" type="button" id="new-patron-attr" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> >+ <i class="fa fa-plus"></i> New patron attribute type <span class="caret"></span> >+ </button> >+ <ul class="dropdown-menu" aria-labelledby="new-patron-attr"> >+ <li> >+ <a href="[% script_name | url %]?op=add_attribute_type&model=avc">Authorised value category</a> >+ </li> >+ <li> >+ <a href="[% script_name | url %]?op=add_attribute_type&model=date">Date</a> >+ </li> >+ <li> >+ <a href="[% script_name | url %]?op=add_attribute_type&model=text">Text</a> >+ </li> >+ </ul> >+ </div> > </div> > > <h1>Patron attribute types</h1> >@@ -322,6 +338,7 @@ > <tr> > <th>Code</th> > <th>Description</th> >+ <th>Model</th> > <th>Library limitation</th> > <th>Authorized value category</th> > <th>Mandatory</th> >@@ -334,6 +351,7 @@ > <tr> > <td>[% item.code | html %]</td> > <td>[% item.description | html %]</td> >+ <td>[% PROCESS model_label_block model_code = item.get_model %]</td> > <td> > [% SET libraries = item.library_limits %] > [% IF ( libraries && libraries.count > 0 ) %] >@@ -377,7 +395,7 @@ > [% END %] > </td> > <td class="actions"> >- <a class="btn btn-default btn-xs" href="[% script_name | url %]?op=edit_attribute_type&code=[% item.code | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a> >+ <a class="btn btn-default btn-xs" href="[% script_name | url %]?op=edit_attribute_type&code=[% item.code | uri %]&model=[% item.get_model | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a> > <a class="btn btn-default btn-xs" href="[% script_name | url %]?op=delete_attribute_type&code=[% item.code | uri %]"><i class="fa fa-trash-can"></i> Delete</a> > </td> > </tr> >@@ -464,4 +482,16 @@ > }); > </script> > [% END %] >+ >+[% BLOCK model_label_block %] >+ [% SET switch_model = model_code or model %] >+ [% SWITCH switch_model %] >+ [% CASE 'avc' %] >+ [% t('Authorised value category') %] >+ [% CASE 'date' %] >+ [% t('Date') %] >+ [% CASE 'text' %] >+ [% t('Text') %] >+ [% END %] >+[% END %] > [% INCLUDE 'intranet-bottom.inc' %] >-- >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