Browse Source

Bug 29113: Hide code for additional contents and generate it

additional_contents.code is used to group DB rows together. Each row
represent one content in a given language, and the code is used to know
they are translation of the lang='default' one.

It's not really useful for the end user and we could hide it and
generate it.

Test plan:
Create/Edit/Delete additional contents (news and HTML customizations)
and confirm that they are correctly grouped together.
You need several languages installed to test this patch correctly.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.11/bug30761
Jonathan Druart 2 years ago
parent
commit
264ac5fd2d
  1. 12
      koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt
  2. 15
      tools/additional-contents.pl

12
koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt

@ -178,20 +178,10 @@
<form id="add_additional_content" method="post" action="/cgi-bin/koha/tools/additional-contents.pl" class="validate">
<input type="hidden" name="op" value="add_validate" />
<input type="hidden" name="id" value="[% additional_content.idnew | html %]" />
<input type="hidden" name="category" value="[% category | html %]" />
<input type="hidden" name="code" value="[% additional_content.code | html %]" />
<fieldset class="rows">
<ol>
<li>
[% IF additional_content %]
<span class="label">Code:</span> [% additional_content.code | html %]
<input type="hidden" id="code" name="code" value="[% additional_content.code | html %]" />
[% ELSE %]
<label for="code" class="required">Code:</label>
<input type="text" id="code" name="code" size="20" maxlength="20" value="" required="required"/>
<span class="required">Required</span>
[% END %]
</li>
<li>
<label for="location">Display location:</label>
<select id="location" name="location">

15
tools/additional-contents.pl

@ -107,7 +107,7 @@ elsif ( $op eq 'add_validate' ) {
my $number = $cgi->param('number');
my $success = 1;
for my $lang ( @lang ) {
for my $lang ( sort {$a ne 'default'} @lang ) { # Process 'default' first
my $title = shift @title;
my $content = shift @content;
my $additional_content = Koha::AdditionalContents->find(
@ -161,7 +161,7 @@ elsif ( $op eq 'add_validate' ) {
my $additional_content = Koha::AdditionalContent->new(
{
category => $category,
code => $code,
code => $code || 'tmp_code',
location => $location,
branchcode => $branchcode,
title => $title,
@ -173,7 +173,16 @@ elsif ( $op eq 'add_validate' ) {
borrowernumber => $borrowernumber,
}
)->store;
eval { $additional_content->store; };
eval {
$additional_content->store;
unless ($code) {
$additional_content->discard_changes;
$code = $category eq 'news'
? 'News_' . $additional_content->idnew
: $location . '_' . $additional_content->idnew;
$additional_content->code($code)->store;
}
};
if ($@) {
$success = 0;
push @messages, { type => 'error', code => 'error_on_insert' };

Loading…
Cancel
Save