RapidApp
view release on metacpan or search on metacpan
t/02_rapiddbic_opts1.t view on Meta::CPAN
use strict;
use warnings;
use FindBin '$Bin';
use lib "$Bin/var/testapps/TestRA-ChinookDemo/lib";
use Path::Class qw(file dir);
use RapidApp::Test::EnvUtil;
BEGIN { $ENV{TMPDIR} or RapidApp::Test::EnvUtil::set_tmpdir_env() }
BEGIN {
package TestApp1::Model::DB;
use Moose;
extends 'TestRA::ChinookDemo::Model::DB';
$INC{'TestApp1/Model/DB.pm'} = __FILE__;
1;
}
BEGIN {
package TestApp1;
use Moose;
use Catalyst::Runtime 5.80;
use RapidApp;
use Catalyst qw/RapidApp::RapidDbic/;
extends 'Catalyst';
our $VERSION = '0.01';
__PACKAGE__->config(
name => 'TestApp1',
# ------
# This RapidDbic config was been copied verbatim from RA::ChinookDemo (02_rapiddbic_basics)
# https://github.com/IntelliTree/RA-ChinookDemo/blob/02_rapiddbic_basics/lib/RA/ChinookDemo.pm
# ------
'Plugin::RapidApp::RapidDbic' => {
# Only required option:
dbic_models => ['DB'],
configs => { # Model Configs
DB => { # Configs for the model 'DB'
grid_params => {
'*defaults' => { # Defaults for all Sources
updatable_colspec => ['*'],
creatable_colspec => ['*'],
destroyable_relspec => ['*']
}, # ('*defaults')
Album => {
include_colspec => ['*','artistid.name']
},
Genre => {
# Leave persist_immediately on without the add form
# (inserts blank/default rows immediately):
use_add_form => 0,
# No delete confirmations:
confirm_on_destroy => 0
},
Invoice => {
# Delete invoice_lines with invoice (cascade):
destroyable_relspec => ['*','invoice_lines']
},
InvoiceLine => {
# join all columns of all relationships (first-level):
include_colspec => ['*','*.*'],
updatable_colspec => [
'invoiceid','unitprice',
'invoiceid.billing*'
],
},
MediaType => {
# Use the grid itself to set new row values:
use_add_form => 0, #<-- also disables autoload_added_record
persist_immediately => {
create => 0,
update => 1,
destroy => 1
},
# No delete confirmations:
confirm_on_destroy => 0
},
Track => {
include_colspec => ['*','albumid.artistid.*'],
# Don't persist anything immediately:
persist_immediately => {
# 'create => 0' changes these defaults:
# use_add_form => '0' (normally 'tab')
# autoload_added_record => 0 (normally '1')
create => 0,
update => 0,
destroy => 0
},
# Use the add form in a window:
use_add_form => 'window'
},
}, # (grid_params)
TableSpecs => {
Album => {
display_column => 'title'
},
Artist => {
display_column => 'name'
},
Employee => {
# Use virtual column 'full_name' as the display column:
display_column => 'full_name'
},
Genre => {
display_column => 'name',
auto_editor_type => 'combo'
},
MediaType => {
display_column => 'name',
auto_editor_type => 'combo'
},
Track => {
columns => {
bytes => {
renderer => 'Ext.util.Format.fileSize'
},
( run in 1.223 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )