Get success message working after save

This commit is contained in:
Brian Read 2024-11-22 15:09:21 +00:00
parent b9b939223b
commit edb245df07
2 changed files with 25 additions and 20 deletions

View File

@ -77,7 +77,7 @@ sub main {
# which DB - this only really works if the initial panel is a PARAMS type panel and not a TABLE # which DB - this only really works if the initial panel is a PARAMS type panel and not a TABLE
my $db = $$${controldb | db | 'cdb'}; #pickup local or global db or Default to config my $db = $$${controldb | db | 'cdb'}; #pickup local or global db or Default to config
<tal:block tal:repeat="dbfield dbfields"> <tal:block tal:repeat="dbfield dbfields">
$$${prefix}_data{${dbfield}} = $db->prop('${dbfield}') || ${dbdefault | ""} || ""; $$${prefix}_data{'${dbfield}'} = $db->prop('${dbfield}') || ${dbdefault | ""} || "";
</tal:block> </tal:block>
#pickup any other contents needed and load them into hash shared with panel #pickup any other contents needed and load them into hash shared with panel
@ -160,7 +160,7 @@ sub do_update {
</tal:block> </tal:block>
if ($ret ne "ok") { if ($ret ne "ok") {
${prefix}_data{trt} = $thispanel; ${prefix}_data{'trt'} = $thispanel;
$c->stash(error => $c->l($ret)); $c->stash(error => $c->l($ret));
$c->stash( $c->stash(
title => $title, title => $title,
@ -177,26 +177,31 @@ sub do_update {
if ($ret ne "ok") { if ($ret ne "ok") {
# return to the panel with error message # return to the panel with error message
$c->stash(error => $c->l($ret)); $c->stash(error => $c->l($ret));
$c->render("${lcPackageName}"); $c->stash(
title => $title,
modul => $modul,
${prefix}_data => \%${prefix}_data
);
$c->render(template => "${lcPackageName}");
} else { } else {
$c->stash( success => $c->l('${panel} panel action was successful')); #A bit bland - edit it in the lex file $c->stash( success => $c->l('${panel} panel action was successful')); #A bit bland - edit it in the lex file
} }
} }
</tal:block> </tal:block>
# and call any signal-events needed # and call any signal-events needed
#TBD
# Setup shared data and call panel # Setup shared data and call panel
$c->stash(
title => $title,
${prefix}_data => \%${prefix}_data
);
if ('${nextpanel | "none"}' eq 'none') { if ('${nextpanel | "none"}' eq 'none') {
$$${prefix}_data{'trt'} = '${firstPanel}'; $$${prefix}_data{'trt'} = '${firstPanel}';
} else { } else {
$$${prefix}_data{'trt'} = '${NextPanel | "none"}'; $$${prefix}_data{'trt'} = '${NextPanel | "none"}';
} }
$c->do_display() $c->stash(
title => $title,
modul => $modul,
${prefix}_data => \%${prefix}_data
);
$c->render( template => "${lcPackageName}" );
} }
} }
@ -275,6 +280,6 @@ sub do_display {
title => $title, title => $title,
${prefix}_data => \%${prefix}_data ${prefix}_data => \%${prefix}_data
); );
$c->render("${lcPackageName}"); $c->render(template => "${lcPackageName}");
} }
1; 1;

View File

@ -16,26 +16,26 @@
<h1><%=$title%></h1> <h1><%=$title%></h1>
% if ( stash('modul') ) { % if ( stash('modul')) {
%= $c->render_to_string(inline => stash('modul') ); %= $c->render_to_string(inline => stash('modul') );
% } % }
%if ($$${prefix}_data->{first}) { %if ($c->stash('first')) {
<br><p> <br><p>
%=$c->render_to_string(inline =>$c->l($$${prefix}_data->{first})) %=$c->render_to_string(inline =>$c->l($c->stash('first')))
</p> </p>
%} elsif ($$${prefix}_data->{success}) { %} elsif ($c->stash('success')) {
<div class='sme-border'> <div class='sme-border'>
<h2> Operation Status Report</h2><p> <h2><%=$c->l('Status Report') %></h2><p>
%= $c->l($$${prefix}_data->{success}); %= $c->l($c->stash('success'));
</p> </p>
</div> </div>
%} elsif ($$${prefix}_data->{error}) { %} elsif ($c->stash('error')) {
<div class='sme-error'> <div class='sme-error'>
<h2> Operation Status Report - error</h2><p> <h2><%=$c->l('Error Status Report') %></h2><p>
%= $c->l($$${prefix}_data->{error}); %= $c->l($c->stash('error'));
</p> </p>
</div> </div>
%} %}