From f365d3b40ba3361521bdf48be29d84c8c0a0f4f1 Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Wed, 2 Sep 2015 17:54:04 -0600 Subject: [PATCH] Bug 13757: Add the option to set patron attributes editable in the OPAC Note: this is a squashed version of the original patchset, because it was needed This patch adds an opac_editable property of borrower attribute types that can be set in the interface. I'm removing work on OPAC and will refactor it, keeping the author attribution. Test plan: 1. Repeat the following with a new and existing borrower attribute type: 2. Verify that "Editable in OPAC" can only be checked if "Display in OPAC" is checked. 3. Verify that this new property is correctly saved. Signed-off-by: Aleisha Signed-off-by: Tomas Cohen Arazi --- C4/Members/AttributeTypes.pm | 58 ++++++++++++++++------ admin/patron-attr-types.pl | 25 +++++++--- koha-tmpl/intranet-tmpl/prog/css/staff-global.css | 4 ++ .../prog/en/modules/admin/patron-attr-types.tt | 16 ++++++ 4 files changed, 81 insertions(+), 22 deletions(-) diff --git a/C4/Members/AttributeTypes.pm b/C4/Members/AttributeTypes.pm index d4927db..77ba96c 100644 --- a/C4/Members/AttributeTypes.pm +++ b/C4/Members/AttributeTypes.pm @@ -37,6 +37,7 @@ C4::Members::AttributeTypes - mananage extended patron attribute types $attr_type->repeatable($repeatable); $attr_type->unique_id($unique_id); $attr_type->opac_display($opac_display); + $attr_type->opac_editable($opac_editable); $attr_type->staff_searchable($staff_searchable); $attr_type->authorised_value_category($authorised_value_category); $attr_type->store(); @@ -122,6 +123,7 @@ sub new { $self->{'repeatable'} = 0; $self->{'unique_id'} = 0; $self->{'opac_display'} = 0; + $self->{'opac_editable'} = 0; $self->{'staff_searchable'} = 0; $self->{'display_checkout'} = 0; $self->{'authorised_value_category'} = ''; @@ -163,6 +165,7 @@ sub fetch { $self->{'repeatable'} = $row->{'repeatable'}; $self->{'unique_id'} = $row->{'unique_id'}; $self->{'opac_display'} = $row->{'opac_display'}; + $self->{'opac_editable'} = $row->{'opac_editable'}; $self->{'staff_searchable'} = $row->{'staff_searchable'}; $self->{'display_checkout'} = $row->{'display_checkout'}; $self->{'authorised_value_category'} = $row->{'authorised_value_category'}; @@ -203,6 +206,7 @@ sub store { repeatable = ?, unique_id = ?, opac_display = ?, + opac_editable = ?, staff_searchable = ?, authorised_value_category = ?, display_checkout = ?, @@ -211,22 +215,33 @@ sub store { WHERE code = ?"); } else { $sth = $dbh->prepare_cached("INSERT INTO borrower_attribute_types - (description, repeatable, unique_id, opac_display, - staff_searchable, authorised_value_category, display_checkout, category_code, class, code) - VALUES (?, ?, ?, ?, - ?, ?, ?, ?, ?, ?)"); + ( description, + repeatable, + unique_id, + opac_display, + opac_editable, + staff_searchable, + authorised_value_category, + display_checkout, + category_code, + class, + code + ) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); } + $sth->execute( - $self->{description}, - $self->{repeatable}, - $self->{unique_id}, - $self->{opac_display}, - $self->{staff_searchable}, - $self->{authorised_value_category}, - $self->{display_checkout}, - $self->{category_code} || undef, - $self->{class}, - $self->{code}, + $self->{'description'}, + $self->{'repeatable'}, + $self->{'unique_id'}, + $self->{'opac_display'}, + $self->{'opac_editable'}, + $self->{'staff_searchable'} || 0, + $self->{'authorised_value_category'}, + $self->{'display_checkout'}, + $self->{'category_code'} || undef, + $self->{'class'}, + $self->{'code'} ); if ( defined $$self{branches} ) { @@ -335,6 +350,21 @@ sub opac_display { @_ ? $self->{'opac_display'} = ((shift) ? 1 : 0) : $self->{'opac_display'}; } +=head2 opac_editable + + my $opac_editable = $attr_type->opac_editable(); + $attr_type->opac_editable($opac_editable); + +Accessor. The C<$opac_editable> argument +is interpreted as a Perl boolean. + +=cut + +sub opac_editable { + my $self = shift; + @_ ? $self->{'opac_editable'} = ((shift) ? 1 : 0) : $self->{'opac_editable'}; +} + =head2 staff_searchable my $staff_searchable = $attr_type->staff_searchable(); diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl index 74e075c..178bf37 100755 --- a/admin/patron-attr-types.pl +++ b/admin/patron-attr-types.pl @@ -40,14 +40,15 @@ our $input = new CGI; my $op = $input->param('op') || ''; -our ($template, $loggedinuser, $cookie) - = get_template_and_user({template_name => "admin/patron-attr-types.tt", - query => $input, - type => "intranet", - authnotrequired => 0, - flagsrequired => {parameters => 'parameters_remaining_permissions'}, - debug => 1, - }); +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { template_name => "admin/patron-attr-types.tt", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => { parameters => 'parameters_remaining_permissions' } + } +); + $template->param(script_name => $script_name); @@ -118,6 +119,9 @@ sub error_add_attribute_type_form { if ($input->param('opac_display')) { $template->param(opac_display_checked => 1); } + if ($input->param('opac_editable')) { + $template->param(opac_editable_checked => 1); + } if ($input->param('staff_searchable')) { $template->param(staff_searchable_checked => 1); } @@ -162,6 +166,8 @@ sub add_update_attribute_type { my $opac_display = $input->param('opac_display'); $attr_type->opac_display($opac_display); + my $opac_editable = $input->param('opac_editable'); + $attr_type->opac_editable($opac_editable); my $staff_searchable = $input->param('staff_searchable'); $attr_type->staff_searchable($staff_searchable); my $authorised_value_category = $input->param('authorised_value_category'); @@ -242,6 +248,9 @@ sub edit_attribute_type_form { if ($attr_type->opac_display()) { $template->param(opac_display_checked => 1); } + if ($attr_type->opac_editable()) { + $template->param(opac_editable_checked => 1); + } if ($attr_type->staff_searchable()) { $template->param(staff_searchable_checked => 1); } diff --git a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css index f423dba..95fc105 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/css/staff-global.css @@ -701,6 +701,10 @@ fieldset.action, div.action { width: auto; } +fieldset.rows li[aria-disabled="true"] { + color: #999; +} + div.rows+div.rows { margin-top : .6em; } 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 6fb7c97..b855e1e 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 @@ -20,6 +20,14 @@ $(document).ready(function() { if ( $("#branches option:selected").length < 1 ) { $("#branches option:first").attr("selected", "selected"); } + + $("#opac_display").change( function() { + if ( this.checked ) { + $("#opac_editable").removeAttr('disabled').parent().removeAttr('aria-disabled'); + } else { + $("#opac_editable").attr('disabled', true).parent().attr('aria-disabled', 'true'); + } + } ).change(); } ); //]]> @@ -123,6 +131,14 @@ $(document).ready(function() { [% END %] Check to display this attribute on a patron's details page in the OPAC. +
  • + [% IF ( opac_editable_checked ) %] + + [% ELSE %] + + [% END %] + Check to allow patrons to edit this attribute from their details page in the OPAC. (Requires above, does not work with PatronSelfRegistrationVerifyByEmail.) +
  • [% IF ( staff_searchable_checked ) %] -- 2.7.4