From 9035706950cd2520f7019ceb2f09eebf83723a56 Mon Sep 17 00:00:00 2001 From: John Beppu Date: Tue, 3 Feb 2009 16:02:12 -0600 Subject: [PATCH] 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 Signed-off-by: Galen Charlton --- C4/ItemCirculationAlertPreference.pm | 9 +++++- admin/item_circulation_alerts.pl | 18 +++++------ .../admin/item_circulation_alerts.tmpl | 31 +++++++++++++++---- 3 files changed, 42 insertions(+), 16 deletions(-) diff --git a/C4/ItemCirculationAlertPreference.pm b/C4/ItemCirculationAlertPreference.pm index 7ade3dfa47..9659cf6486 100644 --- a/C4/ItemCirculationAlertPreference.pm +++ b/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; diff --git a/admin/item_circulation_alerts.pl b/admin/item_circulation_alerts.pl index f2a9acea2d..cf74f8f86e 100755 --- a/admin/item_circulation_alerts.pl +++ b/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 diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tmpl index 49bf6884a1..e0010ddc09 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tmpl +++ b/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 = ""; $(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(){ - " id="">  + " id=""> @@ -140,7 +159,7 @@ $(function(){ - " id="">  + " id=""> -- 2.39.2