$self->_load_path( $path );
$self->session( 'path' => $path );
- $self->session( 'modified' => $loaded->{$path}->{modified} );
my $redirect_to = '/data/items';
my $path = $self->session('path') || $self->param('path');
$self->redirect_to('/data/index') unless $path;
- if ( $loaded->{$path}->{modified} > 1 ) {
+ if ( defined $loaded->{$path}->{modified} && $loaded->{$path}->{modified} > 1 ) {
my $caller = (caller(1))[3];
if ( $caller =~ m/::edit/ ) {
warn "rebuild stats for $path ignored caller $caller\n";
if ( ! defined $loaded->{$path}->{$name} ) {
warn "$path $name isn't loaded\n";
$self->_load_path( $path );
- $self->redirect_to('/data/index')
- unless defined $loaded->{$path}->{$name};
if ( ! defined $loaded->{$path}->{stats} ) {
warn "rebuild stats for $path\n";
$loaded->{$path}->{stats} = __stats( $loaded->{$path}->{data}->{items} );
}
+ if ( ! defined $loaded->{$path}->{$name} ) {
+ warn "MISSING $name for $path\n";
+ $self->redirect_to('/data/index')
+ }
}
+
+ $self->session( 'modified' => $loaded->{$path}->{modified} );
+
return $loaded->{$path}->{$name};
}
sub items {
my $self = shift;
+ if ( my $show = $self->param('id') ) {
+ $self->param('show', $show);
+ warn "show $show\n";
+ }
+
my $path = $self->session('path');
- $self->redirect_to('/data/index') unless defined $loaded->{ $path };
my @columns = $self->_param_array('columns');
$self->redirect_to('/data/columns') unless @columns;
}
-sub _invalidate_path_column {
+sub __invalidate_path_column {
my ( $path, $name ) = @_;
if ( defined $loaded->{$path}->{sorted}->{$name} ) {
}
}
+sub __path_modified {
+ my ( $path, $value ) = @_;
+ $value = 1 unless defined $value;
+
+ $loaded->{$path}->{modified} = $value;
+
+ warn "# __path_modified $path $value\n";
+}
sub edit {
my $self = shift;
warn "# change $path $i $old -> $new\n";
$loaded->{$path}->{data}->{items}->[$i]->{$name} = $v;
- _invalidate_path_column( $path, $name );
+ __invalidate_path_column( $path, $name );
$status = 201; # created
# modified = 2 -- force rebuild of stats
- $loaded->{$path}->{modified} = 2;
- $self->session( 'modified' => 2 );
+ __path_modified( $path, 2 );
$new_content = join("\xB6",@$v);
my $self = shift;
my $path = $self->_param_or_session('path');
my $dump_path = $self->_save( $path );
- $loaded->{$path}->{modified} = 0;
- $self->session( 'modified' => 0 );
+ __path_modified( $path, 0 );
$self->redirect_to( '/data/items' );
}