| 1 | package Yukki::Web::View::Role::Navigation; | ||
| 2 | $Yukki::Web::View::Role::Navigation::VERSION = '0.991_007'; # TRIAL | ||
| 3 | $Yukki::Web::View::Role::Navigation::VERSION = '0.991007'; | ||
| 4 | use v5.24; | ||
| 5 | use Moo::Role; | ||
| 6 | |||
| 7 | use String::Errf qw( errf ); | ||
| 8 | |||
| 9 | # ABSTRACT: Common page navigation tools for views | ||
| 10 | |||
| 11 | |||
| 12 | requires 'standard_menu'; | ||
| 13 | |||
| 14 | |||
| 15 | sub page_navigation { | ||
| 16 | my ($self, $response, $this_action, $vars) = @_; | ||
| 17 | |||
| 18 | for my $menu_item ($self->standard_menu) { | ||
| 19 | next if $this_action eq $menu_item->{action}; | ||
| 20 | |||
| 21 | $response->add_navigation_item([ qw( page page_bottom ) ], { | ||
| 22 | label => $menu_item->{label} // ucfirst $menu_item->{action}, | ||
| 23 | href => errf($menu_item->{href}, $vars // {}), | ||
| 24 | sort => $menu_item->{sort} // 20, | ||
| 25 | }); | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 29 | 1; | ||
| 30 | |||
| 31 | __END__ |