Catalyst-Plugin-AutoCRUD

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

  * Friendly error page if Javascript is disabled in the client browser (report by malcolm)
  * Fix exists bug in Metadata.pm (thanks to abraxxa)
  * Better support for Result Class names with underscores (report by abraxxa)

 -- Oliver Gorwits <oliver.gorwits@oucs.ox.ac.uk>  Fri, 22 Aug 2008 13:00:54 +0100

libcatalystx-listframework-builder (0.25) UNRELEASED; urgency=low

  * Grid expands to show rows until it needs a scrollbar
  * Delete column uses tooltip for text
  * Fix for form's combobox (related) search to be case insensitive
  * Nuke all the c.base usage in favour of c.uri_for
  * Change all component namespace into LFB::
    Your DBIC Model's config *must* change from Model::DBIC to Model::LFB::DBIC
  * Config var for ExtJS lib location changed from javascript to extjs2
    Your App config *must* change from using "javascript" to "extjs2"
  * Application is now relocateable and useable as a plugin (see POD for details)

 -- Oliver Gorwits <oliver.gorwits@oucs.ox.ac.uk>  Tue, 19 Aug 2008 14:40:05 +0100

libcatalystx-listframework-builder (0.24) UNRELEASED; urgency=low

lib/Catalyst/Plugin/AutoCRUD/Model/StorageEngine/DBIC/CRUD.pm  view on Meta::CPAN


            next COL;
        }

        # else is foreign key
        my $link = $c->stash->{cpac}->{m}->t->{ $ci->extra('ref_table') };

        # some kind of update to an existing relation
        if (!exists $params->{'checkbox.' . $col}) {
            # someone is messing with the AJAX (tests?)
            next COL if !defined $params->{'combobox.' . $col};

            # user has blanked the field to remove the relation
            if (!length $params->{'combobox.' . $col}) {
                $self_row->set_column($_ => undef)
                    for @{$ci->extra('fields')};
                delete $proxy_updates->{$col};
            }

            # user has cleared or not updated the field
            next COL if $params->{'combobox.' . $col} !~ m/\000/;

            # update to new related record
            # we find the target and pass in the row object to DBIC
            my $finder = _extract_ID($params->{'combobox.' . $col});
            my $found_row = $c->model( $link->extra('model') )->find($finder, {key => 'primary'})
                or $self_row->throw_exception("autocrud: failed to find row for $col");
            $self_row->set_inflated_columns({$col => $found_row});
            delete $proxy_updates->{$col};

            next COL;
        }

        # else new related record to be created
        delete $proxy_updates->{$col};

lib/Catalyst/Plugin/AutoCRUD/Model/StorageEngine/DBIC/CRUD.pm  view on Meta::CPAN

                    if $fci->data_type and $fci->data_type eq 'boolean';

                # skip auto-inc cols unless they contain data
                next unless exists $params->{"$col.$fcol"}
                    and ($params->{"$col.$fcol"} or not $fci->is_auto_increment);

                $new_related->{$fcol} = $params->{"$col.$fcol"};
            }
            # any foreign keys (belongs_to) in the related record
            # we find the target and pass the row object to DBIC
            elsif (exists $params->{"combobox.$col.$fcol"}) {
                next unless length $params->{"combobox.$col.$fcol"};

                my $finder = _extract_ID($params->{"combobox.$col.$fcol"});
                my $link_link = $c->stash->{cpac}->{m}->t->{ $fci->extra('ref_table') };
                $new_related->{$fcol} = 
                    $c->model( $link_link->extra('model') )->find($finder, {key => 'primary'})
                    or $self_row->throw_exception("autocrud: failed to find row for $fcol");
            }
        }

        my $new_col = $c->model( $link->extra('model') )->create($new_related)
            or $self_row->throw_exception("autocrud: failed to create row for $col");
        $self_row->set_inflated_columns({$col => $new_col});

lib/Catalyst/Plugin/AutoCRUD/templates/extjs2/javascript/grid/columns.tt  view on Meta::CPAN

                                            "table_go.png" ) %]'
        }).render(document.body, id);
    }

    // text added to FK combo list to hint for the full-text-search option
    var fk_combo_comment = ' (all matches)';

    // create reusable renderer
    Ext.util.Format.comboRenderer = function(combo, table, field, url) {
        return function(value,metadata,record,rowindex,colindex,store) {
            // choose what to render from the combobox store's data
            if (rowindex === 0) {
                var rec = combo.findRecord(combo.valueField, value);
                var retval = rec ? rec.get(combo.displayField) : value;
                return (retval.indexOf(fk_combo_comment) !== -1) ? value : retval;
            }

            if (value) {
                // create an id, attached to a span, and hang a button off it
                var id = Ext.id();
                // if the related table is "hidden" we are not passed field,

lib/Catalyst/Plugin/AutoCRUD/templates/extjs2/javascript/grid/columns.tt  view on Meta::CPAN

        { name: 'dbid' }, { name: 'stringified' }
    ]);

    // create the combo instances
    [% FOREACH col IN cpac.tc.cols %]
      [% NEXT UNLESS cpac.tm.f.$col.is_foreign_key OR cpac.tm.f.$col.extra('is_reverse') %]
      [% NEXT IF cpac.tm.f.$col.extra('masked_by') %]
      var fk_combo_[% col | replace('\'', '\\\'') %] = new Ext.form.ComboBox ({
          valueField: 'dbid'
          ,displayField: 'stringified'
          ,hiddenName: 'combobox.[% col | replace('\'', '\\\'') %]'
          ,hiddenId: 'fk_combo_[% col | replace('\'', '\\\'') %]'
          ,loadingText: 'Searching...'
          ,forceSelection: true
          ,selectOnFocus: true
          ,typeAhead: false
          ,pageSize: 10
          ,triggerAction: 'all'
          ,lazyRender: true
          ,listClass: 'x-combo-list-small'
          ,lastQuery: ''

lib/Catalyst/Plugin/AutoCRUD/templates/extjs2/javascript/update/tabs.tt  view on Meta::CPAN

                  [%= IF NOT meta.f.$field.is_nullable
                        AND (NOT meta.f.$field.default_value.defined OR meta.f.$field.default_value) %]
                    ,allowBlank: false
                  [% END %]

                  [%= IF meta.f.$field.is_foreign_key %]
                    ,xtype: 'combo'
                    ,displayField: 'stringified'
                    ,valueField: 'dbid'
                    [% IF orig_col == '' %]
                    ,hiddenName: 'combobox.[% field | replace('\'', '\\\'') %]'
                    [% ELSE %]
                    ,hiddenName: 'combobox.[% orig_col %].[% field | replace('\'', '\\\'') %]'
                    [% END %]
                    ,loadingText: 'Searching...'
                    ,forceSelection: true
                    ,selectOnFocus: true
                    ,typeAhead: false
                    ,pageSize: 5
                    ,triggerAction: 'all'
                    ,store: new Ext.data.JsonStore ({
                        url: '[% c.uri_for(
                            c.controller('AutoCRUD::DisplayEngine::ExtJS2').action_for('list_stringified'),

t/33-ajax-update.t  view on Meta::CPAN

            'total' => 1
};

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/create', {}, {success => '0'}, 'add row, no data');
$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/update', {}, {success => '0'}, 'update row, no data');
$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/list', {'cpac_filter.title' => 'Greatest Hits'}, $default_album_page, 'check data');

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/create', {
    'cpac__id' => "id\0005",
    id => 5,
    'combobox.artist_id' => 3,
    title     => 'Greatest Hits',
    recorded  => '2002-05-21',
}, {success => '0'}, 'add row, dupe data');
$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/list', {'cpac_filter.title' => 'Greatest Hits'}, $default_album_page, 'check data');

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/create', {
    'combobox.artist_id' => "id\0001",
    recorded  => '2002-05-21',
}, {success => '0'}, 'add row, duff data');

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/create', {
    'combobox.artist_id' => "id\0001",
    title     => 'Testing Hits',
}, {success => '1'}, 'add minimal row');
$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/list', {'cpac_filter.title' => 'Testing Hits'}, $testing_album_page, 'check data');

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/update', {
    cpac__id => "id\0005",
    id => "5",
    'combobox.artist_id' => "id\0003",
    foobar  => '2002-05-21',
}, {success => '1'}, 'edit row cols, extra data ignored');
$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/list', {'cpac_filter.title' => 'Greatest Hits'}, $default_album_page, 'check data');

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/update', {
    cpac__id => "id\0005",
    id => "5",
    'combobox.artist_id' => "id\0003",
    title     => 'Greatest Hits 2',
    recorded  => '2002-05-21',
}, {success => '1'}, 'edit row cols');

$default_album_page->{rows}->[0]->{cpac__display_name} = 'Greatest Hits 2';
$default_album_page->{rows}->[0]->{title} = 'Greatest Hits 2';
$default_album_page->{rows}->[0]->{artist_id} = 'Adam Smith';
$default_album_page->{rows}->[0]->{recorded} = '2002-05-21';
$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/list', {'cpac_filter.title' => 'Greatest Hits 2'}, $default_album_page, 'check data');

SKIP : {
    skip 'cannot test FK constraints with SQLite', 6;

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/update', {
    cpac__id => "id\0005",
    id => "5",
    'combobox.artist_id' => "id\0009",
    title     => 'Greatest Hits 2',
    recorded  => '2002-05-21',
}, {success => '0'}, 'edit row fks, duff data');

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/update', {
    'combobox.artist_id' => "id\0001",
    title     => 'Greatest Hits 2',
    recorded  => '2002-05-21',
}, {success => '1'}, 'edit row fks');

} # SKIP

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/update', {
    cpac__id => "id\0005",
    id => "5",
    'checkbox.artist_id' => 'on',
    'combobox.artist_id' => "id\0003",
    title     => 'Greatest Hits 2',
    recorded  => '2002-05-21',
}, {success => '0'}, 'edit row add fwd related, duff data');
$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/list', {'cpac_filter.title' => 'Greatest Hits 2'}, $default_album_page, 'check data');

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/update', {
    cpac__id => "id\0005",
    id => "5",
    'checkbox.artist_id' => 'on',
    'artist_id.forename' => 'Bob',
    'artist_id.surname' => 'Thornton',
    'combobox.artist_id' => "id\0003",
    title     => 'Greatest Hits 2',
    recorded  => '2002-05-21',
}, {success => '1'}, 'edit row add fwd related');

$default_album_page->{rows}->[0]->{artist_id} = 'Bob Thornton';
$default_album_page->{rows}->[0]->{cpac__pk_for_artist_id} = [{ tag => 'input', type => 'hidden', name => 'cpac_filter.id', value => 4}];
$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/list', {'cpac_filter.title' => 'Greatest Hits 2'}, $default_album_page, 'check data');
$mech->ajax_ok('/site/default/schema/dbic/source/artist/extjs2/list', {'cpac_filter.surname' => 'Thornton'}, $new_artist_page, 'check data');

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/create', {
    'artist.forename' => 'Charlie',
    'artist.surname' => 'Thornton',
    'checkbox.artist_id' => 'on',
    'combobox.artist_id' => "id\0003",
}, {success => '0'}, 'add row, duff data, with related');
$mech->ajax_ok('/site/default/schema/dbic/source/artist/extjs2/list', {'cpac_filter.forename' => 'Charlie'}, {total => 0, rows => []}, 'check data');

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/create', {
    'checkbox.artist_id' => 'on',
    'artist_id.surname' => 'Thornton',
    'combobox.artist_id' => "id\0001",
    title     => 'Testing Hits 2',
    recorded  => '2002-05-21',
}, {success => '0'}, 'add row, with related, duff data');
$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/list', {'cpac_filter.title' => 'Testing Hits 2'}, {total => 0, rows => []}, 'check data');
$mech->ajax_ok('/site/default/schema/dbic/source/artist/extjs2/list', {'cpac_filter.surname' => 'Thornton'}, $new_artist_page, 'check data');

$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/create', {
    'checkbox.artist_id' => 'on',
    'artist_id.forename' => 'Charlie',
    'artist_id.surname' => 'Thornton',
    'combobox.artist_id' => "id\0001",
    title     => 'Testing Hits 2',
}, {success => '1'}, 'add row, with related');
$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/list', {'cpac_filter.title' => 'Testing Hits 2'}, $new_album_page, 'check data');
$mech->ajax_ok('/site/default/schema/dbic/source/artist/extjs2/list', {'cpac_filter.forename' => 'Charlie'}, $second_artist_page, 'check data');

$mech->ajax_ok('/site/default/schema/dbic/source/track/extjs2/create', {
    title => 'Track Title',
    'combobox.album_id' => '',
    'checkbox.album_id' => 'on',
    'album_id.recorded' => '1999-05-21',
    'combobox.copyright_id' => '',
    'checkbox.copyright_id' => 'on',
    'rights owner' => 'Label D',
}, {success => '0'}, 'add row, with 2x related, one duff');
$mech->ajax_ok('/site/default/schema/dbic/source/track/extjs2/list', {'cpac_filter.title' => 'Track Title'}, {total => 0, rows => []}, 'check data');
$mech->ajax_ok('/site/default/schema/dbic/source/copyright/extjs2/list', {'cpac_filter.rights owner' => 'Label D'}, {total => 0, rows => []}, 'check data');
$mech->ajax_ok('/site/default/schema/dbic/source/album/extjs2/list', {'cpac_filter.recorded' => '1999-05-21'}, {total => 0, rows => []}, 'check data');

$mech->ajax_ok('/site/default/schema/dbic/source/track/extjs2/create', {
    'parent_album.title' => 'Testing Hits 3',
    'checkbox.parent_album' => 'on',
    'checkbox.copyright_id' => 'on',
    'combobox.parent_album.artist_id' => "id\0003",
    'copyright_id.rights owner' => 'Label D',
    title => 'Track Title',
}, {success => '1'}, 'add row, with 2x related');

$mech->ajax_ok('/site/default/schema/dbic/source/track/extjs2/list', {'cpac_filter.title' => 'Track Title'}, {
            'rows' => [
                        {
                          'cpac__id' => "id\00014",
                          'length' => '',
                          'sales' => '',



( run in 0.882 second using v1.01-cache-2.11-cpan-39bf76dae61 )