Bug 14517: List shelves list is broken for translated interfaces
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 14 Jul 2015 15:26:36 +0000 (16:26 +0100)
committerTomas Cohen Arazi <tomascohen@unc.edu.ar>
Tue, 18 Aug 2015 16:18:21 +0000 (13:18 -0300)
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>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt

index 01ceb8a..646b3b4 100644 (file)
@@ -1,4 +1,5 @@
 [% USE KohaDates %]
+[% USE To %]
 {
     "sEcho": [% sEcho %],
     "iTotalRecords": [% iTotalRecords %],
 }
 
 [% BLOCK action_form -%]
-    [%- IF can_manage_shelf OR can_delete_shelf-%]
-[% IF can_manage_shelf %]<form action='shelves.pl' method='get'><input type='hidden' name='shelfnumber' value='[% shelfnumber %]' /><input type='hidden' name='op' value='modif' /><input type='submit' class='editshelf' value='Edit' /></form>[% END %][% IF can_manage_shelf OR can_delete_shelf %]<form action='shelves.pl' method='post'><input type='hidden' name='shelfoff' value='[% shelfoff %]' /><input type='hidden' name='shelves' value='1' /><input type='hidden' name='DEL-[% shelfnumber %]' value='1' /><input type='hidden' name='CONFIRM-[% shelfnumber %]' value='1' />[% IF type == 1 %]<input type='hidden' name='display' value='privateshelves' />[% ELSE %]<input type='hidden' name='display' value='publicshelves' />[% END %]<input type='submit' class='deleteshelf' onclick='return confirmDelete(MSG_CONFIRM_DELETE_LIST)' value='Delete' /></form>[% END %]
-    [%- ELSE -%]
-        None
-    [%- END -%]
-[%- END %]
+[%~ 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  _ '" />' ~%]
+        [%~ action_block = action_block _ '<input type="hidden" name="op" value="modif" />' ~%]
+        [%~ action_block = action_block _ '<input type="submit" class="editshelf" value="Edit" />' ~%]
+        [%~ action_block = action_block _ '</form>' ~%]
+    [%~ END ~%]
+    [%~ IF can_manage_shelf OR can_delete_shelf ~%]
+        [%~ action_block = action_block _ '<form action="shelves.pl" method="post">' ~%]
+        [%~ action_block = action_block _ '<input type="hidden" name="shelfoff" value="' _ shelfoff _ '" />' ~%]
+        [%~ action_block = action_block _ '<input type="hidden" name="shelves" value="1" />' ~%]
+        [%~ action_block = action_block _ '<input type="hidden" name="DEL-' _ shelfnumber _ '" value="1" />' ~%]
+        [%~ action_block = action_block _ '<input type="hidden" name="CONFIRM-' _ shelfnumber _ '" value="1" />' ~%]
+        [%~ IF type == 1 ~%]
+            [%~ action_block = action_block _ '<input type="hidden" name="display" value="privateshelves" />' ~%]
+        [%~ ELSE ~%]
+            [%~ action_block = action_block _ '<input type="hidden" name="display" value="publicshelves" />' ~%]
+        [%~ END ~%]
+        [%~ action_block = action_block _ '<input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST)" value="Delete" />' ~%]
+        [%~ action_block = action_block _ '</form>' ~%]
+    [%~ END ~%]
+[%~ ELSE ~%]
+    [%~ SET action_block = 'None' ~%]
+[%~ END ~%]
+[%~ To.json(action_block) ~%]
+[%~ END ~%]