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 <aleishaamohia@hotmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jesse Weaver 2015-09-02 17:54:04 -06:00 committed by Kyle M Hall
parent 7b5c8cbf07
commit 21e496bd7b
4 changed files with 81 additions and 22 deletions

View File

@ -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();

View File

@ -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);
}

View File

@ -776,6 +776,10 @@ fieldset.action, div.action {
margin-top: 0;
}
fieldset.rows li[aria-disabled="true"] {
color: #999;
}
div.rows+div.rows {
margin-top : .6em;
}

View File

@ -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();
} );
//]]>
</script>
@ -123,6 +131,14 @@ $(document).ready(function() {
[% END %]
<span>Check to display this attribute on a patron's details page in the OPAC.</span>
</li>
<li><label for="opac_editable">Editable in OPAC: </label>
[% IF ( opac_editable_checked ) %]
<input type="checkbox" id="opac_editable" name="opac_editable" checked="checked" />
[% ELSE %]
<input type="checkbox" id="opac_editable" name="opac_editable" />
[% END %]
<span>Check to allow patrons to edit this attribute from their details page in the OPAC. (Requires above, does not work with <a href="/cgi-bin/koha/admin/preferences.pl?op=search&amp;searchfield=PatronSelfRegistrationVerifyByEmail" target="_blank">PatronSelfRegistrationVerifyByEmail</a>.)</span>
</li>
<li><label for="staff_searchable">Searchable: </label>
[% IF ( staff_searchable_checked ) %]
<input type="checkbox" id="staff_searchable" name="staff_searchable" checked="checked" />