Author: spadkins
Date: Wed Jul 18 11:15:18 2007
New Revision: 9761
Modified:
p5ee/trunk/App-Widget/lib/App/Widget/DataTable2.pm
Log:
add {deletable}, {copyable}, and {addable} options for the {editable} option.
remove the extraneous commit()s
Modified: p5ee/trunk/App-Widget/lib/App/Widget/DataTable2.pm
==============================================================================
--- p5ee/trunk/App-Widget/lib/App/Widget/DataTable2.pm (original)
+++ p5ee/trunk/App-Widget/lib/App/Widget/DataTable2.pm Wed Jul 18 11:15:18 2007
@@ -537,7 +537,6 @@
$self->set("add_data", $add_data);
}
- $rep->commit();
&App::sub_exit() if ($App::trace);
}
@@ -583,7 +582,6 @@
$self->set("row_selected", $row_selected);
}
- $rep->commit();
&App::sub_exit() if ($App::trace);
}
@@ -755,6 +753,12 @@
$sortable = $self->{sortable} || 0;
$filterable = $self->{filterable} || 0;
$editable = $self->{editable} || 0;
+ my $deletable = $self->{deletable};
+ my $copyable = $self->{copyable};
+ my $addable = $self->{addable};
+ $deletable = 1 if (!defined $deletable);
+ $copyable = 1 if (!defined $copyable);
+ $addable = 1 if (!defined $addable);
$numbered = $self->{numbered} || 1;
$column_selectable = $self->{column_selectable} || 1;
$row_selectable = $self->{row_selectable} || (($mode eq "edit") ? 1
: 0);
@@ -773,11 +777,14 @@
if ($mode eq "edit") {
if ($rowactions) {
- $rowactions = [ @$rowactions, "copy", "delete" ];
+ $rowactions = [ @$rowactions ];
}
else {
- $rowactions = [ "copy", "delete" ];
+ $rowactions = [];
}
+ push(@$rowactions, "copy") if ($copyable);
+ push(@$rowactions, "delete") if ($deletable);
+
if ($rowactiondefs) {
$rowactiondefs = { %$rowactiondefs };
}
@@ -946,36 +953,38 @@
bevel => 2,
)->html();
$html .= "</td>\n";
- $html .= "<td>\n";
- $html .= $context->widget("$name-add",
- class => "App::Widget::ImageButton",
- image_script => 'App/app-button',
- #volatile => 1,
- label => 'Add Rows',
- height => 17,
- width => 85,
- bevel => 2,
- )->html();
- $html .= "</td>\n";
- $html .= "<td>\n";
- $html .= $context->widget("$name-rows_to_add",
- class => "App::Widget::Select",
- values => ["1","2","3","4","5","6","7","8","9","10",
-
"11","12","13","14","15","16","17","18","19","20",
- ],
- )->html();
- $html .= "</td>\n";
- $html .= "<td>\n";
- $html .= $context->widget("$name-cancel_add",
- class => "App::Widget::ImageButton",
- image_script => 'App/app-button',
- #volatile => 1,
- label => 'Cancel Adds',
- height => 17,
- width => 85,
- bevel => 2,
- )->html();
- $html .= "</td>\n";
+ if ($addable) {
+ $html .= "<td>\n";
+ $html .= $context->widget("$name-add",
+ class => "App::Widget::ImageButton",
+ image_script => 'App/app-button',
+ #volatile => 1,
+ label => 'Add Rows',
+ height => 17,
+ width => 85,
+ bevel => 2,
+ )->html();
+ $html .= "</td>\n";
+ $html .= "<td>\n";
+ $html .= $context->widget("$name-rows_to_add",
+ class => "App::Widget::Select",
+ values =>
["1","2","3","4","5","6","7","8","9","10",
+
"11","12","13","14","15","16","17","18","19","20",
+ ],
+ )->html();
+ $html .= "</td>\n";
+ $html .= "<td>\n";
+ $html .= $context->widget("$name-cancel_add",
+ class => "App::Widget::ImageButton",
+ image_script => 'App/app-button',
+ #volatile => 1,
+ label => 'Cancel Adds',
+ height => 17,
+ width => 85,
+ bevel => 2,
+ )->html();
+ $html .= "</td>\n";
+ }
#$html .= "<td>\n";
#$html .= $context->widget("$name-confirm",
# class => "App::Widget::RadioButtonSet",