From 50d2addfca502d9414e880126736c889dd5b8008 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 18 Jun 2010 20:19:44 +0200 Subject: [PATCH] added overwrite checkbox to code console Newly generated code will always be saved, but modifications won't witout user explicitly clicking on checkbox or renaming description. --- lib/MojoFacets/Data.pm | 12 +++++++++--- templates/data/items/table.html.ep | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/MojoFacets/Data.pm b/lib/MojoFacets/Data.pm index b8b7786..291f6fa 100644 --- a/lib/MojoFacets/Data.pm +++ b/lib/MojoFacets/Data.pm @@ -605,6 +605,7 @@ sub items { } } + my $code_path = $self->app->home->rel_dir('public') . "/code"; if ( $commit ) { warn "# commit on ", $#$filtered + 1, " items:\n$code\n"; foreach ( 0 .. $#$filtered ) { @@ -614,9 +615,13 @@ sub items { } if ( my $description = $self->param('code_description') ) { my $depends = $self->param('code_depends') || die "no code_depends?"; - my $path = $self->app->home->rel_dir('public') . "/code/$depends.$description.pl"; - write_file $path, $code; - warn "code $path ", -s $path, " bytes saved\n"; + my $path = "$code_path/$depends.$description.pl"; + if ( -e $path && ! $self->param('overwrite') ) { + warn "# code $path not saved\n"; + } else { + write_file $path, $code; + warn "code $path ", -s $path, " bytes saved\n"; + } } $code = ''; } @@ -662,6 +667,7 @@ sub items { code_description => $self->param('code_description') || join(',', grep { defined $cols_changed->{$_} && $cols_changed->{$_} == 2 } @columns ), + code_path => $code_path, ); } diff --git a/templates/data/items/table.html.ep b/templates/data/items/table.html.ep index 1699ca7..d3b99c1 100644 --- a/templates/data/items/table.html.ep +++ b/templates/data/items/table.html.ep @@ -79,6 +79,10 @@ filter % if ( $code_depends ) { <%= $code_depends %>..pl +% my $path = "$code_path/$code_depends.$code_description.pl"; +% if ( -e $path ) { + +% } % } -- 2.20.1