projects
/
MojoFacets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
don't redirect to /data/index needlessly
[MojoFacets.git]
/
lib
/
MojoFacets
/
Data.pm
diff --git
a/lib/MojoFacets/Data.pm
b/lib/MojoFacets/Data.pm
index
1b1f0a6
..
c2283b8
100644
(file)
--- a/
lib/MojoFacets/Data.pm
+++ b/
lib/MojoFacets/Data.pm
@@
-130,7
+130,7
@@
sub __stats {
}
if ( $unique ) {
$stats->{$n}->{unique} = 1;
}
if ( $unique ) {
$stats->{$n}->{unique} = 1;
- warn "# $n unique ",dump( $unique );
+
#
warn "# $n unique ",dump( $unique );
}
}
}
}
}
}
@@
-226,7
+226,6
@@
sub load {
$self->_load_path( $path );
$self->session( 'path' => $path );
$self->_load_path( $path );
$self->session( 'path' => $path );
- $self->session( 'modified' => $loaded->{$path}->{modified} );
my $redirect_to = '/data/items';
my $redirect_to = '/data/items';
@@
-254,7
+253,7
@@
sub _loaded {
my $path = $self->session('path') || $self->param('path');
$self->redirect_to('/data/index') unless $path;
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";
my $caller = (caller(1))[3];
if ( $caller =~ m/::edit/ ) {
warn "rebuild stats for $path ignored caller $caller\n";
@@
-268,13
+267,18
@@
sub _loaded {
if ( ! defined $loaded->{$path}->{$name} ) {
warn "$path $name isn't loaded\n";
$self->_load_path( $path );
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}->{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};
}
return $loaded->{$path}->{$name};
}
@@
-529,8
+533,12
@@
sub _data_sorted_by {
sub items {
my $self = shift;
sub items {
my $self = shift;
+ if ( my $show = $self->param('id') ) {
+ $self->param('show', $show);
+ warn "show $show\n";
+ }
+
my $path = $self->session('path');
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;
my @columns = $self->_param_array('columns');
$self->redirect_to('/data/columns') unless @columns;
@@
-741,7
+749,7
@@
sub facet {
}
}
-sub _invalidate_path_column {
+sub _
_
invalidate_path_column {
my ( $path, $name ) = @_;
if ( defined $loaded->{$path}->{sorted}->{$name} ) {
my ( $path, $name ) = @_;
if ( defined $loaded->{$path}->{sorted}->{$name} ) {
@@
-755,6
+763,14
@@
sub _invalidate_path_column {
}
}
}
}
+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;
sub edit {
my $self = shift;
@@
-808,12
+824,11
@@
sub edit {
warn "# change $path $i $old -> $new\n";
$loaded->{$path}->{data}->{items}->[$i]->{$name} = $v;
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
$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);
$new_content = join("\xB6",@$v);
@@
-839,8
+854,7
@@
sub save {
my $self = shift;
my $path = $self->_param_or_session('path');
my $dump_path = $self->_save( $path );
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' );
}
$self->redirect_to( '/data/items' );
}