use Reaction::UI::WidgetClass;
class ActionForm, which {
+ fragment widget [ qw/header field_list buttons footer/ ]
+ => {id => sub { $_{viewport}->location } };
- #implements fragment widget {
- # arg form_id => $_{viewport}->location;
- #};
+ fragment field_list [field => over func('viewport','ordered_fields')];
+ fragment field [ 'viewport' ];
- implements fragment field_list {
- render field => over $_{viewport}->ordered_fields;
- };
+ #move button logic here
+ fragment buttons [ string {"DUMMY"} ],
+ { message => sub{ $_{viewport}->can('message') ? $_{viewport}->message : "" },
+ ok_label => func(viewport => 'ok_label'),
+ close_label => func(viewport => 'close_label'),
+ apply_label => func(viewport => 'apply_label'),
+ };
- implements fragment field {
- render 'viewport';
- };
+ fragment header [ string {"DUMMY"} ];
+ fragment footer [ string {"DUMMY"} ];
+ implements fragment ok_button_fragment {
+ if (grep { $_ eq 'ok' } $_{viewport}->accept_events) {
+ arg 'event_id' => event_id 'ok';
+ arg 'label' => $_{viewport}->ok_label;
+ render 'ok_button';
+ }
+ };
+
+ implements fragment apply_button_fragment {
+ if (grep { $_ eq 'apply' } $_{viewport}->accept_events) {
+ arg 'event_id' => event_id 'apply';
+ arg 'label' => $_{viewport}->apply_label;
+ render 'apply_button';
+ }
+ };
+
+ implements fragment cancel_button_fragment {
+ if (grep { $_ eq 'cancel' } $_{viewport}->accept_events) {
+ arg 'event_id' => event_id 'cancel';
+ arg 'label' => $_{viewport}->cancel_label;
+ render 'cancel_button';
+ }
+ };
+
};
1;
class ChooseMany is 'Reaction::UI::Widget::Field', which {
- implements fragment action_buttons {
- foreach my $event (
- qw(add_all_values do_add_values do_remove_values remove_all_values)
- ) {
- arg "event_id_${event}" => event_id $event;
- }
- };
+ fragment field [qw/available_values action_buttons selected_values current_values/];
- implements fragment current_values {
- render hidden_value => over $_{viewport}->current_value_choices;
- };
+ fragment current_values [ hidden_value => over func('viewport', 'current_value_choices') ];
+ fragment hidden_value [ string { $_->{value} } ];
- implements fragment selected_values {
- arg event_id_remove_values => event_id 'remove_values';
- render value_option => over $_{viewport}->current_value_choices;
- };
+ fragment available_values [ option => over func('viewport', 'available_value_choices') ];
+ fragment selected_values [ option => over func('viewport', 'current_value_choices') ];
+ fragment option [string {"DUMMY"}], { v_value => sub {$_->{value}}, v_name => sub {$_->{name}} };
+ fragment action_buttons [ string {"DUMMY"} ];
+ implements fragment available_values {
+ arg event_id_add_values => event_id 'add_values';
+ render value_option => over $_{viewport}->available_value_choices;
+ };
+
+ implements fragment value_option {
+ arg option_name => $_->{name};
+ arg option_value => $_->{value};
+ };
+
+ implements fragment hidden_value {
+ arg hidden_value => $_->{value};
+ };
+
};
1;
class ChooseOne is 'Reaction::UI::Widget::Field', which {
- implements fragment option_is_required {
- if ($_{viewport}->attribute->is_required) {
- render 'options_is_required_yes';
- } else {
- render 'options_is_required_no';
- }
- };
-
- implements fragment option_list {
- render option => over $_{viewport}->value_choices;
- };
+ fragment field [ option => over func('viewport', 'value_choices') ],
+ { is_required => sub{ $_{viewport}->attribute->is_required } };
+
+ fragment option [string {"DUMMY"}],
+ {
+ v_value => sub { $_->{value} },
+ v_name => sub { $_->{name} },
+ is_selected => sub { $_{viewport}->is_current_value($_->{value}) },
+ };
+ implements fragment option {
+ arg option_name => $_->{name};
+ arg option_value => $_->{value};
+ };
+
+ implements fragment option_is_selected {
+ if ($_{viewport}->is_current_value($_->{value})) {
+ render 'option_is_selected_yes';
+ } else {
+ render 'option_is_selected_no';
+ }
+ };
+
};
1;
class HiddenArray is 'Reaction::UI::Widget::Field', which {
- implements fragment hidden_list {
- render hidden_field => over $_{viewport}->value;
- };
+ fragment field [ item => over func('viewport', 'value') ];
+ fragment item [ string { $_ } ];
+ implements fragment hidden_field {
+ arg field_value => $_;
+ };
+
};
1;
};
implements fragment header_action_cell {
- arg col_count => $_{viewport}->object_action_count;
- };
-
- implements fragment page_list {
- render numbered_page_fragment
- => over [ $_{pager_obj}->first_page .. $_{pager_obj}->last_page ];
- };
-
- implements fragment numbered_page_fragment {
- arg page_uri => event_uri { page => $_ };
- arg page_number => $_;
- if ($_{pager_obj}->current_page == $_) {
- render 'numbered_page_this_page';
- } else {
- render 'numbered_page';
- }
- };
-
- implements fragment first_page {
- arg page_uri => event_uri { page => $_{pager_obj}->first_page };
- arg page_name => 'First';
- render 'named_page';
- };
-
- implements fragment last_page {
- arg page_uri => event_uri { page => $_{pager_obj}->last_page };
- arg page_name => 'Last';
- render 'named_page';
- };
-
- implements fragment next_page {
- arg page_name => 'Next';
- if (my $page = $_{pager_obj}->next_page) {
- arg page_uri => event_uri { page => $page };
- render 'named_page';
- } else {
- render 'named_page_no_page';
- }
+ arg 'col_count' => $_{viewport}->object_action_count;
};
+ implements fragment previous_page {
+ arg page_name => 'Previous';
+ if (my $page = $_{pager_obj}->previous_page) {
+ arg page_uri => event_uri { page => $page };
+ render 'named_page';
+ } else {
+ render 'named_page_no_page';
+ }
+ };
+
};
1;