Bug 22659: Add save and continue button to additional-contents.tt

To test:
1. Apply patch and restart everything
2. Go to Tools > News and create some new additional content.
3. Notice a Save and continue button
4. Try saving and contining.
5. Make sure if you are using the CodeMirror editor that you are still in the CodeMirror editor
6. Try 2 - 5 again but with the wysiwyg editor, make sure when you save and continue you remain in the wysiwyg editor.
7. If you are saving and contining from News make sure you remain in News, when you are saving and contining from HTML customizations make sure you remain there.
8. Turn on the NewsLog system preference
9. With the NewsLog on make sure your content is being logged correctly when you sabe and continue.

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Lucas Gass 2022-02-03 22:31:19 +00:00 committed by Tomas Cohen Arazi
parent 9de92e07e6
commit e88ee0fc5e
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 30 additions and 1 deletions

View File

@ -171,6 +171,12 @@
<div id="toolbar" class="btn-toolbar">
<div class="btn-group">
<button class="btn btn-default" id="submit_form"><i class="fa fa-save"></i> Save</button>
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a id="saveandcontinue" href="#">Save and continue editing</a></li>
</ul>
</div>
[% IF category == 'news' %]
<a class="btn btn-default cancel" href="/cgi-bin/koha/tools/additional-contents.pl"><i class="fa fa-remove"></i> Cancel</a>
@ -184,6 +190,8 @@
<input type="hidden" name="category" value="[% category | html %]" />
<input type="hidden" name="code" value="[% additional_content.code | html %]" />
<input type="hidden" name="idnew" value="[% additional_content.idnew | html %]" />
<input type="hidden" id="redirect" name="redirect" value="" />
<input type="hidden" id="editmode" name="editmode" value="[% editmode | html %]" />
<fieldset class="rows">
<ol>
<li>
@ -453,6 +461,13 @@
[% INCLUDE 'calendar.inc' %]
[% Asset.js("js/tools-menu.js") | $raw %]
[% Asset.js("lib/hc-sticky.js") | $raw %]
<script>
$("#saveandcontinue").on("click",function(e){
e.preventDefault();
$("#redirect").val("just_save");
$("#submit_form").click();
});
</script>
[% IF additional_contents.count %]
[% INCLUDE 'datatables.inc' %]
<script>

View File

@ -40,12 +40,17 @@ my $op = $cgi->param('op') || 'list';
my $id = $cgi->param('id');
my $category = $cgi->param('category') || 'news';
my $wysiwyg;
my $redirect = $cgi->param('redirect');
my $editmode;
if( $cgi->param('editmode') ){
$wysiwyg = $cgi->param('editmode') eq "wysiwyg" ? 1 : 0;
} else {
$wysiwyg = C4::Context->preference("AdditionalContentsEditor") eq "tinymce" ? 1 : 0;
}
$editmode = $wysiwyg eq 1 ? "wysiwyg" : "text";
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
template_name => "tools/additional-contents.tt",
@ -136,6 +141,7 @@ elsif ( $op eq 'add_validate' ) {
);
$updated = $additional_content->_result->get_dirty_columns;
$additional_content->store;
$id = $additional_content->idnew;
};
if ($@) {
$success = 0;
@ -170,6 +176,7 @@ elsif ( $op eq 'add_validate' ) {
? 'News_' . $additional_content->idnew
: $location . '_' . $additional_content->idnew;
$additional_content->code($code)->store;
$id = $additional_content->idnew;
}
};
if ($@) {
@ -183,7 +190,13 @@ elsif ( $op eq 'add_validate' ) {
}
}
$op = 'list';
if( $redirect eq "just_save" ){
print $cgi->redirect("/cgi-bin/koha/tools/additional-contents.pl?op=add_form&id=$id&editmode=$editmode&redirect=done");
exit;
} else {
$op = 'list';
}
}
elsif ( $op eq 'delete_confirmed' ) {
my @ids = $cgi->multi_param('ids');
@ -252,6 +265,7 @@ $template->param(
op => $op,
category => $category,
wysiwyg => $wysiwyg,
editmode => $editmode,
languages => \@languages,
);