# Copyright (c) 2007-2009 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: Table.bunit,v 1.13 2009/12/17 13:56:40 nagler Exp $ Widget({ setup_render => sub { req()->put(task_id => Bivio::Agent::TaskId->PRODUCTS); model('ProductList', {parent_id => 'REPTILES'}) unless req()->unsafe_get('Model.ProductList'); return; }, new_params => sub { my($case, $params) = @_; if (@$params == 1) { $case->put(_expect_args => $params->[0]); return [ProductList => ['Product.product_id', 'Product.name'], @$params]; } else { return [ProductList => @$params]; } }, check_return => sub { my($case, $actual, $expect) = @_; my($expect_args) = $case->unsafe_get('_expect_args'); return defined($expect->[0]) ? $expect : [_t($expect_args)]; }, }); [ map(([$_] => undef), {}, {cellpadding => 2}, {cellspacing => 3}, {width => '100%'}, {border => 1}, ), map({ my($left, $right) = @$_; ([$left] => _t($right)); } [{align => 'n'}, {class => 'b_align_n'}], [{expand => 1}, {width => '95%', class => 'b_align_left'}], [{title => 'Reptiles'}, {title => qq{\n
Reptiles
\n}, class => 'b_align_left'}], ), [{class => 'reptiles'}] => _chomp(<<'EOF'),
Product ID Product Name
RP-LI-02 Iguana
RP-SN-01 Rattlesnake
EOF [{class => 'reptiles', before_row => class('HTMLWidget.String')->new('FOO', 0)}] => _chomp(<<'EOF'),
Product ID Product Name
FOO
RP-LI-02 Iguana
FOO
RP-SN-01 Rattlesnake
EOF [[ { column_widget => class('HTMLWidget.Join')->new([' ']), column_data_class => 'ping', }, {field => 'Product.name', column_data_class => 'zing'} ], {class => 'reptiles', show_headings => 0}] => _chomp(<<'EOF'),
  Iguana
  Rattlesnake
EOF ]; sub _chomp { my($x) = @_; chomp($x); return $x; } sub _t { my($exp) = @_; my($x) = _chomp(<<'EOF'); title=NOP
Product ID Product Name This column sorted in ascending order
dot
RP-LI-02 Iguana
RP-SN-01 Rattlesnake
EOF $exp ||= {}; while (my($k, $v) = each(%$exp)) { $x =~ s/(?<=\b$k=)("?)[^"\s>]+("?)/$1$v$2/; } $x =~ s/ \w+="?NOP"?//g; $x =~ s/ title=//g; return $x; }