=> 'destroy' ) if (defined $self->destroy_handler);
$self->add_listener( write => RapidApp::JSONFunc->new( raw => 1, func =>
'function(store, action, result, res, rs) { store.reload(); }'
b JsonStore {
my $self = shift;
return {
%{ $self->content },
xtype => 'jsonstore'
} if ($self->store_use_xtype);
return RapidApp::JSONFunc->new(
func => 'new Ext.data.JsonS
se_params};
if (defined $encoded) {
my $decoded = $self->json->decode($encoded) or die "Failed to decode base_params JSON";
foreach my $k (keys %$decoded) {
$params->{$k} = $decod
{'username'}, $c->req->params->{'password'});
$c->stash->{current_view} = 'RapidApp::JSON';
$c->stash->{json} = $self->do_login($c,$user,$pass) ?
{ success => 1, msg => $user . ' logged in.'
gin => 0' has been set
## -----
## This code block generates the 'resultset_attr' json in perl instead of
## in ExtJS (Ext.encode) so we can reach in and prevent the character seq
in_name = $conf->{open_url_multi_rs_join_name};
my $personality = $join_name;
my $attr_json = do {
my $attr = clone($rel_data->{attrs});
$attr->{join} ||= [];
push @
attr->{join}[0]; }
my $json = encode_json_ascii($attr);
$json =~ s/\{\[/\{ \[/g;
$json =~ s/\]\}/\] \}/g;
$json
};
## -----
$conf
params} = $self->json->encode($params);
my $items = $self->$orig(@_) || [];
push @$items, {
text => 'Save Search',
iconCls => 'ra-icon-save-as',
handler => RapidApp::JSONFunc->new( raw =>
f->json->encode($save_cnf) . '); }'
)
};
if ($self->c->req->params->{search_id}) {
push @$items, {
text => 'Delete Search',
iconCls => 'ra-icon-delete',
handler => RapidApp::JSONFun
# Merge in params, even though the request is already underway:
my $search_params = try{$self->json->decode($Search->get_column('params'))} || {};
# TODO: this is now duplicated in the /view Req
r' };
use RapidApp::Util qw(:all);
require Module::Runtime;
require Catalyst::Utils;
use JSON qw(decode_json);
# Controller for loading a saved search in CoreSchema via ID
sub load :Chained :PathP
=> $data->{title},
tabIconCls => $data->{iconcls}
};
my $params = $data->{params} ? decode_json($data->{params}) : {};
my @not_allowed_params = qw(search_id quick_search quick_search_cols qu
lumn('state_data');
return if (!$state_data || $state_data eq '{}');
my $search_data = $self->json->decode($state_data) or die usererr "Error deserializing grid_state";
$self->apply_to_all_column
$first_val;
$first_val = $value_list[0]->[0] if (defined $value_list[0]);
my $mapjs = encode_json(\%val_to_disp);
my $js = 'function(v){' .
'var val_map = ' . $mapjs . ';' .
'if(typeof val
::Writer::XLSX;
use RapidApp::Spreadsheet::ExcelTableWriter;
use RapidApp::Util qw(:all);
require JSON;
require Text::CSV;
use DateTime;
sub BUILD {}
before 'BUILD' => sub {
my $self = shift;
$se
'Download As...',
hideOnClick => \0,
iconCls => 'ra-icon-document-save',
menu => RapidApp::JSONFunc->new( func => 'new Ext.ux.RapidApp.AppTab.AppGrid2.ExcelExportMenu',
parm => {
url =>
tsv', renderer => 'export_render_tsv' },
{ mime => 'application/json', file_ext => '.json', renderer => 'export_render_json' },
{ mime => $xlsx_mime, file_ext => '.xlsx',
lf->json->encode({
$cdta->{self} => $val,
$rev_rel => $val,
});
}
}
}
# ---
%{$c->req->params} = ( %$p, base_params => $self->json->en
ext or return undef;
my $lk_enc = $c->req->params->{rs_lock_keys} or return undef;
try{$self->json->decode($lk_enc)}
}
before 'store_init_onrequest' => sub {
my $self = shift;
if(my $lock_k
converts [[ 'foo' ]] into \[ 'foo' ] and is needed because the later cannot
## be expressed in JSON. This allows the client to send a literal col name
if(ref($attr->{select}) eq 'ARRAY') {
my
Ref values mean literal SQL which should be evaluated at the time. New feature in
# RapidApp::JSON::MixedEncoder supports CodeRef values, which call them at encode time. This
# lets us set the
_record_pk' => $pk_val }
# }
# },$loadCfg);
#
# my $href = '#loadcfg:data=' . uri_escape(encode_json($loadCfg));
# my $onclick = 'return Ext.ux.RapidApp.InlineLinkHandler.apply(this,arguments);';
#
lf->AppDV->get_column($name) or return '';
$self->FieldCmp->{$Column->name} = $self->AppDV->json->encode($Column->get_field_config);
return '<div class="' . $Column->name . '">{' .
_column($name) or return '';
$self->AppDV->FieldCmp->{$Column->name} = $self->AppDV->json->encode($Column->get_field_config);
return $self->div_edit_field($Column->name,$display);
_column($name) or return '';
$self->AppDV->FieldCmp->{$Column->name} = $self->AppDV->json->encode($Column->get_field_config);
return $self->div_bigfield($Column->name,$display);
es) . '">' . $html_out . '</div>';
}
sub xtemplate {
my $self = shift;
return RapidApp::JSONFunc->new(
#func => 'new Ext.XTemplate',
func => 'Ext.ux.RapidApp.newXTemplate',
parm
lf = shift;
return {
compiled => \1,
disableFormats => \1,
renderField => RapidApp::JSONFunc->new( raw => 1, func =>
'function(name,values,renderer) {' .
#'var record = { d
y $cnf = {
url => $self->suburl('printview'),
params => $params
};
my $json = $self->json->encode($cnf);
return {
xtype => 'button',
text => 'Print View',
ic
bodyStyle => 'border: 1px solid #D0D0D0;',
baseParams => {
resultset_condition => $self->json->encode({ 'me.' . $cond_data->{foreign} => $Row->get_column($cond_data->{self}) })
},
sto
1,
fields => $fields,
store => $self->getStore_func,
nameWidth => 250,
sm => RapidApp::JSONFunc->new( func => 'new Ext.grid.RowSelectionModel', parm => {
listeners => {
# Disable row
hat disableSelection doesn't work in propertygrid with 'source')
beforerowselect => RapidApp::JSONFunc->new( raw => 1, func => 'function() { return false; }' )
}
}),
plugins => [ 'titlecoll
the
message to the user.
See RapidApp::Sugar for the "die usererr" syntax.
See RapidApp::View::JSON for the logic this module ties into.
=cut
# Note that this is considered text, unless it is an
esponse {
my ($self, $c)= @_;
$c->stash->{exception} = $self;
$c->forward('View::RapidApp::JSON');
}
sub stringify { (shift)->userMessage }
# This method exists because 'overload' doesn't do
efined $self->focusField);
return $data;
}
sub customprompt_json {
my $self = shift;
return RapidApp::JSON::MixedEncoder::encode_json($self->customprompt_data);
}
sub writeResponse {
my ($self,
elf->customprompt_json);
#$c->response->status(500);
my $rct= $c->stash->{requestContentType};
if ($rct eq 'text/x-rapidapp-form-response' || $rct eq 'JSON') {
$c->stash->{json}= { success => \
0 };
$c->view('RapidApp::JSON')->process($c);
}
else {
unless (length($c->response->body) > 0) {
$c->response->content_type('text/plain; charset=utf-8');
$c->response->body("More user inpu
is is returned by the C<content()> method of the Module class,
and is automatically serialized as JSON and returned to the client by the Module dispatch
system. Thus, it is possible to easily override
-Authenticated' => 0);
if ($self->auto_prompt && $self->c->stash->{requestContentType} ne 'JSON') {
my $authPath= $self->auth_module_path;
my $authModule;
defined $authPath && lengt
p::View::Printview' => 'View::RapidApp::Printview' ],
['RapidApp::View::JSON' => 'View::RapidApp::JSON' ],
['RapidApp::View::Template' => 'View::RapidApp::Template'
rn) eq 'HASH' &&
defined $warn->{msg}
);
$c->res->header( 'X-RapidApp-Warning' => encode_json_ascii($warn) );
}
around 'finalize_error' => sub {
my ($orig, $c, @args) = @_;
if($c->is_ra
t);
my $tp = $c->request->header('X-RapidApp-RequestContentType') or return 0;
return $tp eq 'JSON' ? 1 : 0;
}
# Some some housework on the config for normalization/consistency:
sub _normalize_ca
me::HiRes qw(gettimeofday tv_interval);
use LWP::UserAgent;
use HTTP::Request::Common;
use JSON qw(decode_json);
use Try::Tiny;
# shorthand aliases:
sub lreq { (shift)->last_request }
sub lres { (shi
has 'ajax_request_headers', is => 'ro', default => sub {{
'X-RapidApp-RequestContentType' => 'JSON',
'X-RapidApp-VERSION' => $RapidApp::VERSION,
'X-Requested-With' => '
f it was generated by the
# RapidApp/ExtJS JavaScript client/browser to a JSON-encoded
# resource. Decodes and returns the JSON as perl ref
sub ajax_post_decode {
my ($self, $url, $params) = @_;
m
};
if (not defined $id and $self->c->req->params->{orig_params}) {
my $orig_params = $self->json->decode($self->c->req->params->{orig_params});
$id = $orig_params->{$self->record_pk};
}