Bug 29828

Summary: If no content is added to default, but a translation, news/additional content entries don't show in list
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: ToolsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: major    
Priority: P5 - low CC: arthur.suzuki, david, eb, jonathan.druart, lucas, m.de.rooy, martin.renvoize, mik, sally.healey, tomascohen, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29778
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00 22.05 21.11
Bug Depends on: 24387    
Bug Blocks:    
Attachments: Bug 29828: Prevent additional content to be created without default
Bug 29828: Prevent additional content to be created without default
Bug 29828: Prevent additional content to be created without default
Bug 29828: Prevent additional content to be created without default

Description Katrin Fischer 2022-01-08 21:16:36 UTC
To test:

Add a new news or HTML customization entry, fill in the title for one or more languages.
Leave content empty.
Save.

The entry hasn't been saved. There is no error and nothing visible in the logs.
Comment 1 Katrin Fischer 2022-01-08 21:27:01 UTC
I think I got it now - the problem is a little different, but bad.

Updated step by step:

1) Add a new html customization or news entry
2) Fill in the title for default, leave content empty
3) Fill in title and content for English
4) Save
5) Verify the new entry doesn't show in the list of entries
6) Run 
   select idnew, category, code, location, title, lang from additional_contents order by code, lang;
7) Verify your entry is in the database
Comment 2 Jonathan Druart 2022-01-10 09:19:30 UTC
Created attachment 129239 [details] [review]
Bug 29828: Prevent additional content to be created without default

When creating or editing an additional content, the form is submitted if
only the title of the 'default' tab is filled in.
We should submit the form only if both title and content exist.

Test plan:
Create a new content using text editor (codemirror)
Confirm that the form is submitted only if title and content from the
default tab are not empty
Try again with wysiwyg (tinymce)
Comment 3 Katrin Fischer 2022-01-10 09:40:00 UTC
Hi Joubu, I am not sure that fixes the problem. 

The problem is translations again, because if there is no default entry, the entry won't show in the list at all. This will just force you to enter a default text.

I think it should work without, in case you want to add content only for a specific language, as you could do that with news before too.
Comment 4 Katrin Fischer 2022-01-16 22:49:15 UTC
(In reply to Katrin Fischer from comment #3)
> Hi Joubu, I am not sure that fixes the problem. 
> 
> The problem is translations again, because if there is no default entry, the
> entry won't show in the list at all. This will just force you to enter a
> default text.
> 
> I think it should work without, in case you want to add content only for a
> specific language, as you could do that with news before too.

Can you please have another look?
Comment 5 Jonathan Druart 2022-05-18 09:48:46 UTC
Sorry for the delay.

I think we need to go with this patch, for a solution that can be backportable. It will fix "invisible" entries.

On bug 24387 we (I) assumed that a default must exist. If we want to change this behavior it must be done on its own bug report I'd say, it may introduce side-effects. Here we need something easy that can be backported.
Comment 6 Jonathan Druart 2022-05-18 09:51:22 UTC
Created attachment 135097 [details] [review]
Bug 29828: Prevent additional content to be created without default

When creating or editing an additional content, the form is submitted if
only the title of the 'default' tab is filled in.
We should submit the form only if both title and content exist.

Test plan:
Create a new content using text editor (codemirror)
Confirm that the form is submitted only if title and content from the
default tab are not empty
Try again with wysiwyg (tinymce)
Comment 7 David Nind 2022-05-18 18:16:47 UTC
Created attachment 135162 [details] [review]
Bug 29828: Prevent additional content to be created without default

When creating or editing an additional content, the form is submitted if
only the title of the 'default' tab is filled in.
We should submit the form only if both title and content exist.

Test plan:
Create a new content using text editor (codemirror)
Confirm that the form is submitted only if title and content from the
default tab are not empty
Try again with wysiwyg (tinymce)

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 David Nind 2022-05-18 18:52:29 UTC
Testing notes (koha-testing-docker):

- When testing, I was getting some "flaky" behaviour with new news items not displaying.

- In the end, I emptied the additional_contents table (truncate additional_contents;) and started again.

- I think the issue was the difference between the date on my computer (we are NZST - so date was 19 May 2022) compared with koha-testing-docker (UTC time 18 May 2022): news wasn't displaying in the OPAC and staff interface as the date of the news item was in the future (that is, the publication date had not yet been reached).
Comment 9 Marcel de Rooy 2022-05-19 06:22:59 UTC
QAing
Comment 10 Marcel de Rooy 2022-05-19 06:32:33 UTC
This adds a new string. Which kind of blocks it for 22.05
Comment 11 Marcel de Rooy 2022-05-19 06:35:12 UTC
Created attachment 135191 [details] [review]
Bug 29828: Prevent additional content to be created without default

When creating or editing an additional content, the form is submitted if
only the title of the 'default' tab is filled in.
We should submit the form only if both title and content exist.

Test plan:
Create a new content using text editor (codemirror)
Confirm that the form is submitted only if title and content from the
default tab are not empty
Try again with wysiwyg (tinymce)

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 12 Marcel de Rooy 2022-05-19 06:35:37 UTC
@RM: Includes string changes
Comment 13 Elaine Bradtke 2022-05-19 16:53:53 UTC
(In reply to David Nind from comment #8)
> Testing notes (koha-testing-docker):
> 
> - When testing, I was getting some "flaky" behaviour with new news items not
> displaying.
> 
> - In the end, I emptied the additional_contents table (truncate
> additional_contents;) and started again.
> 
> - I think the issue was the difference between the date on my computer (we
> are NZST - so date was 19 May 2022) compared with koha-testing-docker (UTC
> time 18 May 2022): news wasn't displaying in the OPAC and staff interface as
> the date of the news item was in the future (that is, the publication date
> had not yet been reached).

I have seen the same flaky behaviour.  I'm eight hours behind the catalogue I maintain, so there are times when they're on a different date.  Good to know this is a potential problem.
Comment 14 Tomás Cohen Arazi 2022-05-31 12:00:08 UTC
Pushed to master for 22.11, thanks!
Comment 15 Lucas Gass 2022-06-01 18:39:28 UTC
Pushed to 22.05.x for 22.05.01, thanks all!
Comment 16 Arthur Suzuki 2022-06-03 12:33:33 UTC
pushed to 21.11.x for 21.11.07, thx!
Comment 17 Victor Grousset/tuxayo 2022-06-25 21:41:31 UTC
Missing dependencies for 21.05.x, it shouldn't be affected, no backport.