NAME
Valiant::HTML::Util::Pager - HTML pager component
SYNOPSIS
pager_for $list, +{uri_base => list_uri(+{'todo.status'=>$self->status})}, sub ($self, $pg, $list) {
$pg->window_info,
table +{class=>'table table-striped table-bordered', style=>'margin-bottom:0.5rem'}, [
thead
trow [
th +{scope=>"col"},'Title',
th +{scope=>"col", style=>'width:8em'}, 'Status',
],
tbody { repeat=>$list }, sub ($self, $todo, $i) {
trow [
td a +{ href=>edit_uri([$todo]) }, $todo->title,
td $todo->status,
],
},
tfoot,
td {colspan=>2, style=>'background:white'},
$pg->navigation_line,
],
}, sub ($self, $list) {
div { class=>"alert alert-warning", role=>"alert" },
"There are no tasks to display."
},
DESCRIPTION
Given a model with a pager object, or supplied with a pager object, this component will render a pager for the model. The pager object is expected to be a Data::Page object or something that can be coerced into a Data::Page object.
ATTRIBUTES
This class defines the following attributes.
context
Optional. If provided this is the Catalyst context object. If not provided then the context is expected to be available via the view object.
controller
Optional. If provided this is the Catalyst controller object. If not provided then the controller is expected to be available via the view object.
pager_builder_class
Optional. If provided this is the class used to instantiate the pager builder object.
INHERITED METHODS
This class inherits all methods from Valiant::HTML::Util::TagBuilder and Valiant::HTML::Util::FormTags.
INSTANCE METHODS
The following public instance methods are provided by this class.
pager_for
$pager->pager_for($model, \%options, \&block, \&empty_block);
'\&block' is a coderef that will be called with the following arguments:
'\&empty_block' is called if the pager has no items and is a coderef that will be called with the following arguments:
The options hashref can contain the following keys:
- as
-
Optional. The name of the pager. If not provided the name is derived from the model
- pager
-
Optional. The pager object. If not provided the pager object is derived from the model
- uri_base
-
Optional. The base uri for the pager. If not provided the uri is derived from the either the view or the controller.
- controller
-
Optional. The controller object. If not provided the controller object is derived from $self Used to override if the controller associated with the given model is not the current controller
SEE ALSO
Valiant, Valiant::HTML::PagerBuilder
AUTHOR
See Valiant
COPYRIGHT & LICENSE
See Valiant