Bug 14517 - Private lists browsing broken in translated staff interface
Summary: Private lists browsing broken in translated staff interface
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Lists (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Whiteboard:
Keywords:
Depends on: 14529
Blocks:
  Show dependency treegraph
 
Reported: 2015-07-10 00:51 UTC by Tomás Cohen Arazi
Modified: 2016-12-05 21:22 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Sample broken lists (es-ES) (97.09 KB, image/png)
2015-07-10 00:53 UTC, Tomás Cohen Arazi
Details
Sample working lists (en) (121.83 KB, image/png)
2015-07-10 00:53 UTC, Tomás Cohen Arazi
Details
Bug 14517: List shelves list is broken for translated interfaces (4.43 KB, patch)
2015-07-14 15:32 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 14517: List shelves list is broken for translated interfaces (4.49 KB, patch)
2015-08-12 21:55 UTC, Chris Cormack
Details | Diff | Splinter Review
[PASSED QA] Bug 14517: List shelves list is broken for translated interfaces (4.55 KB, patch)
2015-08-18 16:01 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2015-07-10 00:51:41 UTC
This bug affects (at least) master and 3.20.x.

To reproduce:
- On the staff interface create a private list
- Go to More > Lists ('Your lists' tab)
=> SUCCESS: Your private list is shown.
- Translate the templates to any language like:
  $ cd misc/translator/
  $ perl translate install es-ES
- Enable the translated templates on the sysprefs
- Switch to the translated language
- Go to the lists page (Mas > Listas in es-ES)
=> FAIL: The datatable hangs waiting for the svc/shelves script to return data
Comment 1 Tomás Cohen Arazi 2015-07-10 00:53:17 UTC
Created attachment 40904 [details]
Sample broken lists (es-ES)
Comment 2 Tomás Cohen Arazi 2015-07-10 00:53:50 UTC
Created attachment 40905 [details]
Sample working lists (en)
Comment 3 Jonathan Druart 2015-07-14 15:32:37 UTC Comment hidden (obsolete)
Comment 4 M. Tompsett 2015-07-15 05:22:27 UTC
Comment on attachment 40994 [details] [review]
Bug 14517: List shelves list is broken for translated interfaces

Review of attachment 40994 [details] [review]:
-----------------------------------------------------------------

I fear trying to understand how this works at this late hour.

::: koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt
@@ +29,4 @@
>  }
>  
>  [% BLOCK action_form -%]
> +[%~ SET action_block = '' ~%]

http://template-toolkit.org/docs/manual/Config.html#section_PRE_CHOMP_POST_CHOMP
"To remove all whitespace including any number of newlines, use the '~' character instead.

[% FOREACH user IN userlist %]

   [%~ user ~%]

[% END %]"
--- learned something new. Though this was hard to find in the manual.

@@ +32,5 @@
> +[%~ SET action_block = '' ~%]
> +[%~ IF can_manage_shelf OR can_delete_shelf ~%]
> +    [%~ IF can_manage_shelf ~%]
> +        [%~ action_block =                '<form action="shelves.pl" method="get">' ~%]
> +        [%~ action_block = action_block _ '<input type="hidden" name="shelfnumber" value="' _ shelfnumber  _ '" />' ~%]

http://www.template-toolkit.org/docs/manual/Directives.html#section_SET
"You can concatenate strings together using the ' _ ' operator."
Comment 5 Chris Cormack 2015-08-12 20:06:51 UTC
Can I get a rebase please

Applying: Bug 14517: List shelves list is broken for translated interfaces
fatal: sha1 information is lacking or useless (koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0001 Bug 14517: List shelves list is broken for translated interfaces
Comment 6 Chris Cormack 2015-08-12 21:55:50 UTC Comment hidden (obsolete)
Comment 7 Chris Cormack 2015-08-12 22:00:21 UTC
I just noticed that our To plugin, we just use to do JSON .. In future we could maybe use this? But this is a just a comment. No reason to hold the bug

http://search.cpan.org/~nuffin/Template-Plugin-JSON-0.06/lib/Template/Plugin/JSON.pm
Comment 8 Jonathan Druart 2015-08-18 15:38:11 UTC
(In reply to Chris Cormack from comment #7)
> I just noticed that our To plugin, we just use to do JSON .. In future we
> could maybe use this? But this is a just a comment. No reason to hold the bug
> 
> http://search.cpan.org/~nuffin/Template-Plugin-JSON-0.06/lib/Template/Plugin/
> JSON.pm

The idea was to avoid another dependency.
Comment 9 Kyle M Hall 2015-08-18 16:01:48 UTC
Created attachment 41624 [details] [review]
[PASSED QA] Bug 14517: List shelves list is broken for translated interfaces

The translation script adds quotes ("") around translated string (Edit
for instance).
Which breaks the json structure.

Example:
"dt_action": "<a style=\"cursor:pointer\"><form action='shelves.pl'
method='get'><input class="editshelf" value="Editar" type="submit"
/></form></a>"

Test plan:
1/ On the staff interface create a private list
2/ Go to More > Lists ('Your lists' tab)
3/ Translate the templates to any language like:
  $ cd misc/translator/
  $ perl translate install es-ES
4/ Enable the translated templates on the sysprefs
5/ Switch to the translated language
6/ Go to the lists page (Mas > Listas in es-ES)
The list should be displayed correctly.

Note: There is a limitation. If a translated string contains a simple
quote ('), it will also break the json.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 10 Tomás Cohen Arazi 2015-08-18 16:19:29 UTC
Patches pushed to master.

Great job Jonathan!
Comment 11 Chris Cormack 2015-08-23 06:05:33 UTC
Even though this makes template changes, it stops the templates breaking completely so pushing

Will be in 3.20.3