use SL::DB::Chart;
use Exporter qw(import);
-use Data::Dumper;
-our @EXPORT = qw(chart_picker chart);
+our @EXPORT_OK = qw(chart_picker chart);
use Carp;
+use Data::Dumper;
+use SL::Presenter::EscapedText qw(escape is_escaped);
+use SL::Presenter::Tag qw(input_tag name_to_id html_tag);
sub chart {
- my ($self, $chart, %params) = @_;
+ my ($chart, %params) = @_;
$params{display} ||= 'inline';
croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
my $text = join '', (
- $params{no_link} ? '' : '<a href="am.pl?action=edit_account&id=' . $self->escape($chart->id) . '">',
- $self->escape($chart->accno),
+ $params{no_link} ? '' : '<a href="am.pl?action=edit_account&id=' . escape($chart->id) . '">',
+ escape($chart->accno),
$params{no_link} ? '' : '</a>',
);
- return $self->escaped_text($text);
+ is_escaped($text);
}
sub chart_picker {
- my ($self, $name, $value, %params) = @_;
+ my ($name, $value, %params) = @_;
$value = SL::DB::Manager::Chart->find_by(id => $value) if $value && !ref $value;
- my $id = delete($params{id}) || $self->name_to_id($name);
+ my $id = delete($params{id}) || name_to_id($name);
my $fat_set_item = delete $params{fat_set_item};
my @classes = $params{class} ? ($params{class}) : ();
push @classes, 'chartpicker_fat_set_item' if $fat_set_item;
my $ret =
- $self->input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id) .
- join('', map { $params{$_} ? $self->input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(type category choose booked)) .
- $self->input_tag("", (ref $value && $value->can('displayable_name')) ? $value->displayable_name : '', id => "${id}_name", %params);
+ input_tag($name, (ref $value && $value->can('id') ? $value->id : ''), class => "@classes", type => 'hidden', id => $id) .
+ join('', map { $params{$_} ? input_tag("", delete $params{$_}, id => "${id}_${_}", type => 'hidden') : '' } qw(type category choose booked)) .
+ input_tag("", (ref $value && $value->can('displayable_name')) ? $value->displayable_name : '', id => "${id}_name", %params);
$::request->layout->add_javascripts('autocomplete_chart.js');
$::request->presenter->need_reinit_widgets($id);
- $self->html_tag('span', $ret, class => 'chart_picker');
+ html_tag('span', $ret, class => 'chart_picker');
}
+sub picker { goto &chart_picker }
+
1;
__END__
# Create an html link for editing/opening a chart
my $object = SL::DB::Manager::Chart->get_first;
- my $html = SL::Presenter->get->chart($object, display => 'inline');
+ my $html = SL::Presenter::Chart::chart($object, display => 'inline');
see also L<SL::Presenter>
rendering. If you write a standard controller that only calls C<render> once, it
will just work. In case the header is generated in a different render call
(multiple blocks, ajax, old C<bin/mozilla> style controllers) you need to
-include C<js/autocomplete_part.js> yourself.
+include C<js/autocomplete_chart.js> yourself.
=back