[Rt-commit] r19919 - rt/3.8/trunk/share/html/Widgets
sartak at bestpractical.com
sartak at bestpractical.com
Fri Jun 5 21:03:50 EDT 2009
Author: sartak
Date: Fri Jun 5 21:03:49 2009
New Revision: 19919
Modified:
rt/3.8/trunk/share/html/Widgets/SelectionBox
Log:
Add a ReadOnly mode for SelectionBox widgets
Modified: rt/3.8/trunk/share/html/Widgets/SelectionBox
==============================================================================
--- rt/3.8/trunk/share/html/Widgets/SelectionBox (original)
+++ rt/3.8/trunk/share/html/Widgets/SelectionBox Fri Jun 5 21:03:49 2009
@@ -108,49 +108,51 @@
}
else {
my $current = $self->{Current} = $ARGS{$self->{Name}.'-Current'};
- ++$self->{Modified};
if ($current && !ref ($current)) {
$current = [$current];
}
- if ($ARGS{add}) {
- my $choosed = $ARGS{$self->{Name}.'-Available'};
- for my $add (ref($choosed) ? @$choosed : $choosed) {
- next if grep { $_ eq $add } @$current;
- push @$current, $add;
- }
- }
-
- if ($ARGS{remove}) {
- my $choosed = $ARGS{$self->{Name}.'-Selected'};
- for my $del (ref($choosed) ? @$choosed : $choosed) {
- @$current = map { $_ eq $del ? () : $_ } @$current;
- }
- }
-
- if ($ARGS{moveup} or $ARGS{movedown}) {
- my $offset = $ARGS{moveup} ? 1 : 0;
- my $choosed = $ARGS{$self->{Name}.'-Selected'};
- $choosed = [$choosed] unless ref ($choosed);
- my $canmove = 0; # not in the cornor
- for my $i ($ARGS{moveup} ? 0..$#{$current} : reverse 0..$#{$current}) {
- if (grep {$_ eq $current->[$i]} @$choosed) {
- if ($canmove) {
- splice (@$current, $i-$offset, 2,
- @{$current}[$i+1-$offset,$i-$offset]);
- }
- }
- else {
- ++$canmove;
- }
- }
- }
+ unless ($self->{ReadOnly}) {
+ ++$self->{Modified};
+ if ($ARGS{add}) {
+ my $choosed = $ARGS{$self->{Name}.'-Available'};
+ for my $add (ref($choosed) ? @$choosed : $choosed) {
+ next if grep { $_ eq $add } @$current;
+ push @$current, $add;
+ }
+ }
+
+ if ($ARGS{remove}) {
+ my $choosed = $ARGS{$self->{Name}.'-Selected'};
+ for my $del (ref($choosed) ? @$choosed : $choosed) {
+ @$current = map { $_ eq $del ? () : $_ } @$current;
+ }
+ }
+
+ if ($ARGS{moveup} or $ARGS{movedown}) {
+ my $offset = $ARGS{moveup} ? 1 : 0;
+ my $choosed = $ARGS{$self->{Name}.'-Selected'};
+ $choosed = [$choosed] unless ref ($choosed);
+ my $canmove = 0; # not in the cornor
+ for my $i ($ARGS{moveup} ? 0..$#{$current} : reverse 0..$#{$current}) {
+ if (grep {$_ eq $current->[$i]} @$choosed) {
+ if ($canmove) {
+ splice (@$current, $i-$offset, 2,
+ @{$current}[$i+1-$offset,$i-$offset]);
+ }
+ }
+ else {
+ ++$canmove;
+ }
+ }
+ }
+
+ if ($ARGS{clear}) {
+ $current = [];
+ }
- if ($ARGS{clear}) {
- $current = [];
+ $self->{Current} = $current;
}
-
- $self->{Current} = $current;
}
@{$self->{Current}} = grep { exists $self->{_item_map}{$_} } @{$self->{Current}};
@@ -195,7 +197,11 @@
<option value="<% $_->[0] %>"><% $_->[1] %></option>
% }
</select>
+
+% unless ($self->{ReadOnly}) {
<input name="add" type="submit" class="button" value=" → " />
+% }
+
<select name="<%$name%>-Selected" id="<%$name%>-Selected" size="<%$size%>" multiple="multiple">
% for (@{$self->{Current}}) {
<option value="<% $_ %>"
@@ -205,6 +211,7 @@
><% $self->{_item_map}{$_} ||'' %></option>
% }
</select>
+% unless ($self->{'ReadOnly'}) {
% unless ($ARGS{'NoArrows'}) {
<input name="moveup" type="submit" class="button" value=" ↑ " />
<input name="movedown" type="submit" class="button" value=" ↓ " />
@@ -213,6 +220,7 @@
% if ($ARGS{'Clear'}) {
<input name="clear" type="submit" class="button" value="<&|/l&>Clear</&>" />
% }
+% }
% my $caption = "";
% unless ($self->{'AutoSave'}) {
More information about the Rt-commit
mailing list