| 1 | package Yukki::Web::View::Attachment; | ||
| 2 | $Yukki::Web::View::Attachment::VERSION = '0.991_007'; # TRIAL | ||
| 3 | $Yukki::Web::View::Attachment::VERSION = '0.991007'; | ||
| 4 | use v5.24; | ||
| 5 | use utf8; | ||
| 6 | use Moo; | ||
| 7 | |||
| 8 | use Type::Utils; | ||
| 9 | |||
| 10 | use namespace::clean; | ||
| 11 | |||
| 12 | extends 'Yukki::Web::View'; | ||
| 13 | |||
| 14 | # ABSTRACT: View for attachment forms | ||
| 15 | |||
| 16 | |||
| 17 | has rename_template => ( | ||
| 18 | is => 'ro', | ||
| 19 | isa => class_type('Template::Pure'), | ||
| 20 | lazy => 1, | ||
| 21 | builder => '_build_rename_template', | ||
| 22 | ); | ||
| 23 | |||
| 24 | sub _build_rename_template { | ||
| 25 | shift->prepare_template( | ||
| 26 | template => 'attachment/rename.html', | ||
| 27 | directives => [ | ||
| 28 | '#yukkiname' => 'page', | ||
| 29 | '#yukkiname_new@value' => 'page', | ||
| 30 | ], | ||
| 31 | ); | ||
| 32 | } | ||
| 33 | |||
| 34 | has remove_template => ( | ||
| 35 | is => 'ro', | ||
| 36 | isa => class_type('Template::Pure'), | ||
| 37 | lazy => 1, | ||
| 38 | builder => '_build_remove_template', | ||
| 39 | ); | ||
| 40 | |||
| 41 | sub _build_remove_template { | ||
| 42 | shift->prepare_template( | ||
| 43 | template => 'attachment/remove.html', | ||
| 44 | directives => [ | ||
| 45 | '.yukkiname' => 'page', | ||
| 46 | '#cancel_remove@href' => 'return_link', | ||
| 47 | ], | ||
| 48 | ); | ||
| 49 | } | ||
| 50 | |||
| 51 | |||
| 52 | sub rename { | ||
| 53 | my ($self, $ctx, $vars) = @_; | ||
| 54 | my $file = $vars->{file}; | ||
| 55 | |||
| 56 | $ctx->response->page_title($vars->{title}); | ||
| 57 | |||
| 58 | return $self->render_page( | ||
| 59 | template => $self->rename_template, | ||
| 60 | context => $ctx, | ||
| 61 | vars => $vars, | ||
| 62 | ); | ||
| 63 | } | ||
| 64 | |||
| 65 | |||
| 66 | sub remove { | ||
| 67 | my ($self, $ctx, $vars) = @_; | ||
| 68 | my $file = $vars->{file}; | ||
| 69 | |||
| 70 | $ctx->response->page_title($vars->{title}); | ||
| 71 | |||
| 72 | return $self->render_page( | ||
| 73 | template => $self->remove_template, | ||
| 74 | context => $ctx, | ||
| 75 | vars => $vars, | ||
| 76 | ); | ||
| 77 | } | ||
| 78 | |||
| 79 | 1; | ||
| 80 | |||
| 81 | __END__ |