Browse Source

bug 323: Item Circulation Alerts UI Fixes

- fixed cross browser issues.  (IE and Safari don't let you say
  someobject.class, presumably because "class" is a keyword that's reserved
  for future versions of JS.  Firefox and Opera allow it.)

- added text to the grid for added clarity.

Signed-off-by: Daniel Sweeney <daniel.sweeney@liblime.com>
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
3.2.x
John Beppu 16 years ago
committed by Galen Charlton
parent
commit
9035706950
  1. 9
      C4/ItemCirculationAlertPreference.pm
  2. 18
      admin/item_circulation_alerts.pl
  3. 31
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tmpl

9
C4/ItemCirculationAlertPreference.pm

@ -349,13 +349,20 @@ sub grid {
my $key = $c->categorycode . "-" . $i->itemtype . "-" . $notification;
$key =~ s/\*/_/g;
my @classes;
my $text = " ";
if ($disabled{$key}) {
push @classes, 'disabled';
$text = "Disabled for $where->{branchcode}";
}
if ($default{$key}) {
push @classes, 'default';
$text = "Disabled for all";
}
push @{$row->{items}}, { class => join(' ', @classes), id => $key };
push @{$row->{items}}, {
class => join(' ', @classes),
id => $key,
text => $text,
};
}
}
return \@grid;

18
admin/item_circulation_alerts.pl

@ -21,7 +21,6 @@ use warnings;
use CGI;
use File::Basename;
use Encode;
use URI::Escape 'uri_escape_utf8';
use JSON;
#use Data::Dump 'pp';
@ -73,7 +72,7 @@ sub show {
my $br = GetBranches;
my $branch = $input->param('branch') || '*';
my @branches = map { utf8($_, 'branchname') } (
my @branches = (
{
branchcode => '*',
branchname => 'Default',
@ -85,10 +84,10 @@ sub show {
}
my $branch_name = exists($br->{$branch}) && $br->{$branch}->{branchname};
my @categories = map { utf8($_, 'description') } (
my @categories = (
C4::Category->all
);
my @item_types = map { utf8($_, 'description'); br($_, 'description') } (
my @item_types = map { br($_, 'description') } (
C4::ItemType->all
);
my $grid_checkout = $preferences->grid({ branchcode => $branch, notification => 'CHECKOUT' });
@ -134,14 +133,14 @@ sub toggle {
my $response = { success => 1 };
my @reasons = $notifications->is_disabled_for($settings);
if (@reasons == 0) {
$response->{class} = '';
$response->{classes} = '';
} else {
my $default_exists = grep { $_->{branchcode} eq '*' } @reasons;
my $non_default_also = grep { $_->{branchcode} ne '*' } @reasons;
my @classes;
push @classes, 'default' if $default_exists;
push @classes, 'disabled' if $non_default_also;
$response->{class} = join(' ', @classes);
$response->{classes} = join(' ', @classes);
}
print $input->header;
print encode_json($response);
@ -195,7 +194,7 @@ Display a branches item circulation alert preferences.
Parameters:
=over 4
=over 2
=item branch
@ -212,11 +211,12 @@ Toggle a preference via AJAX
Parameters:
=over 4
=over 2
=item id
"$categorycode-$item_type-$notification"
The id should be string that can be split on "-" which contains:
"$categorycode-$item_type-$notification".
=item branch

31
koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tmpl

@ -17,6 +17,10 @@ table.grid tbody th {
text-align: right;
}
table.grid tbody td {
font-size: xx-small;
}
table.grid tbody td.info {
background: #fff;
}
@ -43,6 +47,11 @@ table.grid td.default {
var $branch = "<!-- TMPL_VAR NAME="branch" -->";
$(function(){
var blocked = _('Blocked!');
var saving = _('Saving...');
var disabledForAll = _('Disabled for all');
var disabledForCurrent = _('Disabled for') + ' ' + $branch;
$('#branch_selector input:submit').hide();
$('#branch').change(function(){
$('#branch_selector').submit();
@ -52,17 +61,27 @@ $(function(){
var id = this.id;
var td = $(this);
if (td.hasClass('default') && $branch != '*') {
td.html(_('Blocked'));
td.html(blocked);
window.setTimeout(
function(){ td.html(disabledForAll) },
3000
);
} else {
td.html(_('Saving...'));
td.html(saving);
$.ajax({
url : '/cgi-bin/koha/admin/item_circulation_alerts.pl',
type : 'POST',
dataType : 'json',
data : { action: 'toggle', id: id, branch: $branch },
success : function(response){
td.html(' ');
td.attr('class', response.class);
if ($branch == '*' && response.classes.match(/default/)) {
td.html(disabledForAll);
} else if (response.classes.match(/disabled/)) {
td.html(disabledForCurrent);
} else {
td.html(' ');
}
td.attr('class', response.classes);
}
});
}
@ -118,7 +137,7 @@ $(function(){
<tr>
<th><!-- TMPL_VAR NAME="description" --></th>
<!-- TMPL_LOOP NAME="items" -->
<td class="<!-- TMPL_VAR NAME="class" -->" id="<!-- TMPL_VAR NAME="id" -->">&nbsp;</td>
<td class="<!-- TMPL_VAR NAME="class" -->" id="<!-- TMPL_VAR NAME="id" -->"><!-- TMPL_VAR NAME="text" --></td>
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_LOOP -->
@ -140,7 +159,7 @@ $(function(){
<tr>
<th><!-- TMPL_VAR NAME="description" --></th>
<!-- TMPL_LOOP NAME="items" -->
<td class="<!-- TMPL_VAR NAME="class" -->" id="<!-- TMPL_VAR NAME="id" -->">&nbsp;</td>
<td class="<!-- TMPL_VAR NAME="class" -->" id="<!-- TMPL_VAR NAME="id" -->"><!-- TMPL_VAR NAME="text" --></td>
<!-- /TMPL_LOOP -->
</tr>
<!-- /TMPL_LOOP -->

Loading…
Cancel
Save