CallBackery

 view release on metacpan or  search on metacpan

lib/CallBackery/GuiPlugin/AbstractAction.pm  view on Meta::CPAN


has screenCfg => sub {
    my $self = shift;
    $self->__fixActionCfg;
    return {
        type    => 'action',
        options => $self->screenOpts,
        action  => $self->actionCfg,
    }
};

# if no user is assigned, all access checks are positive, this allows to explore the
# modules full capabilities during startup
has 'user'=> sub ($self) {
    my $mockUser = bless {}, 'MockUser';
    unless (defined &MockUser::may) {
        *MockUser::may = sub ($mockSelf, $right) {
            # $self->log->debug("MockUser::may($right) -> true");
            return 1;
        };
    }
    unless (defined &MockUser::mayAny) {
        *MockUser::mayAny = sub ($mockSelf, $right) {
            # $self->log->debug("MockUser::may($right) -> true");
            return 1;
        };
    }
    unless (defined &MockUser::userId) {
        *MockUser::userId = sub ($mockSelf) {
            return '__MockUser__';
        };
    }
    unless (defined &MockUser::userInfo) {
        *MockUser::userInfo = sub ($mockSelf) {
            return {};
        };
    }
    unless (defined &MockUser::controller) {
        *MockUser::controller = sub ($mockSelf) {
            return undef;
        };
    }
    return $mockUser;
};

=head2 screenOpts

Returns a hash of options for the screen Options

=cut

has screenOpts => sub {
    {
    }
};

=head2 actionCfg

Returns a list of action buttons to place at the top of the form.

For C<download> and C<display> actions the gui is blocked by a modal busy
indicator while the download is being prepared (for at most 3 seconds).
Actions which take a long time to produce their data can switch this off by
setting C<noBusyIndicator> to true, keeping the gui usable while they run:

 {
     label         => trm('Create Report'),
     action        => 'download',
     key           => 'createReport',
     noBusyIndicator => true,
     actionHandler => sub { ... },
 }

=cut

has actionCfg => sub {
   [];
};

=head2 actionCfgMap

Lookup table for action plugins.

NOTE: Unique keys are not checked for popup plugins as they don't have
      action handlers.
      This allows multiple popup actions using the same plugin instance.
      In this case an additional cfg parameter C<testingIdPostfix> must be
      used to make the QoxdooObjectIds unique used from frontend testing.

=cut

has actionCfgMap => sub {
    my $self = shift;
    my %map;
    for my $row (@{$self->actionCfg}){
        next unless $row->{action} =~ /^(submit|upload|download|display|autoSubmit|save)/;
        next unless $row->{key};
        my $key = $row->{key};
        die mkerror(4646, "Duplicate action key $key") if exists $map{$key};
        $map{$key} = $row;
    }
    return \%map;
};


=head1 METHODS

All the methods of L<CallBackery::GuiPlugin::Abstract> plus:

=cut

=head2 massageConfig

Function to integrate the plugin configuration recursively into the main config
hash.

=cut

sub massageConfig {
    my $self = shift;
    my $cfg = shift;



( run in 1.153 second using v1.01-cache-2.11-cpan-302cb4679cc )