| 1 | package Gapp::Meta::Widget::Native::Trait::AssistantPage; | ||
| 2 | { | ||
| 3 | $Gapp::Meta::Widget::Native::Trait::AssistantPage::VERSION = '0.60'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use Moose::Role; | ||
| 7 | use MooseX::SemiAffordanceAccessor; | ||
| 8 | use MooseX::LazyRequire; | ||
| 9 | |||
| 10 | |||
| 11 | has 'page_title' => ( | ||
| 12 | is => 'rw', | ||
| 13 | isa => 'Str', | ||
| 14 | default => '', | ||
| 15 | ); | ||
| 16 | |||
| 17 | has 'page_type' => ( | ||
| 18 | is => 'rw', | ||
| 19 | isa => 'Str', | ||
| 20 | default => '', | ||
| 21 | lazy_required => 1, | ||
| 22 | ); | ||
| 23 | |||
| 24 | has 'page_icon' => ( | ||
| 25 | is => 'rw', | ||
| 26 | isa => 'Str', | ||
| 27 | default => '', | ||
| 28 | ); | ||
| 29 | |||
| 30 | has 'page_num' => ( | ||
| 31 | is => 'rw', | ||
| 32 | isa => 'Int|Undef', | ||
| 33 | ); | ||
| 34 | |||
| 35 | # the validator function is valled to determine if the page is complete | ||
| 36 | # the code-ref should return true for complete, false for not | ||
| 37 | has 'validator' => ( | ||
| 38 | is => 'rw', | ||
| 39 | isa => 'Maybe[CodeRef]', | ||
| 40 | ); | ||
| 41 | |||
| 42 | # call validate to validate the page | ||
| 43 | sub validate { | ||
| 44 | my ( $self ) = shift; | ||
| 45 | return if ! $self->validator; | ||
| 46 | |||
| 47 | my $valid = $self->validator->( $self ); | ||
| 48 | |||
| 49 | if ( ! $self->parent ) { | ||
| 50 | warn qq[could not mark page ($self) as complete: ] . | ||
| 51 | qq[you must add this page to an assistant first]; | ||
| 52 | return $valid; | ||
| 53 | } | ||
| 54 | |||
| 55 | $self->parent->gobject->set_page_complete( $self->gobject, $valid ); | ||
| 56 | return $valid; | ||
| 57 | } | ||
| 58 | |||
| 59 | |||
| 60 | |||
| 61 | package Gapp::Meta::Widget::Custom::Trait::AssistantPage; | ||
| 62 | { | ||
| 63 | $Gapp::Meta::Widget::Custom::Trait::AssistantPage::VERSION = '0.60'; | ||
| 64 | } | ||
| 65 | sub register_implementation { 'Gapp::Meta::Widget::Native::Trait::AssistantPage' }; | ||
| 66 | |||
| 67 | |||
| 68 | 1; |