--- trunk/lib/Frey/DBIC/Designer.pm 2009/01/26 23:37:34 1024
+++ trunk/lib/Frey/DBIC/Designer.pm 2009/01/28 19:54:40 1026
@@ -5,6 +5,7 @@
with 'Frey::Web';
with 'Frey::Config';
with 'Frey::Storage';
+with 'Frey::jQuery';
has dbic_class => (
is => 'rw',
@@ -80,7 +81,8 @@
@columns = @$c if $c;
}
warn "# load $path columns ", $self->dump( @columns );
- @columns = $rs->first->columns unless @columns;
+ my @all_columns = $rs->first->columns;
+ @columns = @all_columns unless @columns;
@columns = grep { $_ ne $self->remove_column } @columns if $self->remove_column;
@@ -103,6 +105,47 @@
$rows .= qq|
$row
\n|;
}
+ $self->add_css(qq|
+ #column-editor {
+ border: 1px solid #888;
+ background: #ffc;
+ position: absolute;
+ top: 1em;
+ right: 1em;
+ }
+ |);
+
+ my @hidden_cols;
+ {
+ my $col;
+ $col->{$_}++ foreach @columns;
+ @hidden_cols = grep { ! $col->{$_} } @all_columns;
+ }
+
+ my $column_editor = qq|
+
+ Visible |
+ | . join("\n", map { qq|
+ $_ |
+ | } @columns )
+ . qq|
+ Hidden |
+ | . join("\n", map { qq|
+ $_ |
+ | } @hidden_cols )
+ . qq|
+
+ |
+ ;
+
+ $self->add_js( 'static/Frey/jQuery/jquery.tablednd_0_5.js' );
+ $self->add_js(q|
+ $(document).ready(function() {
+ // Initialise the table
+ $("#column-editor").tableDnD();
+ });
+ |);
+
my $total = $rs->pager->total_entries;
sub form {
@@ -119,6 +162,7 @@
my $html = qq|
Rows: $total
+ $column_editor