Bugzilla – Attachment 184408 Details for
Bug 40453
Allow newly-added item type translations to be edited
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40453: Allow newly-added item type translations to be edited
Bug-40453-Allow-newly-added-item-type-translations.patch (text/plain), 5.52 KB, created by
Owen Leonard
on 2025-07-18 17:39:30 UTC
(
hide
)
Description:
Bug 40453: Allow newly-added item type translations to be edited
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2025-07-18 17:39:30 UTC
Size:
5.52 KB
patch
obsolete
>From 0122c60e94e7431d43c909d6d5381dffde7edb32 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Fri, 18 Jul 2025 16:45:04 +0000 >Subject: [PATCH] Bug 40453: Allow newly-added item type translations to be > edited > >This patch updates the item type translation page so that newly-added >rows are editable. > >To test you must more than one installed translation. > >- Apply the patch and go to Administration -> Item types. >- Edit an item type and click "Translate into other languages." >- If you already have translations for your installed languages, delete > them. >- Add a new translation. >- In the newly added table row, click the value in the "Language" > column. A dropdown should appear and changing the language should > work. > - Cliking away from the table cell should replace the dropdown with > the language code you selected. >- Click the value in the "Translation" column. The table cell should > become editable. Edit the text and tab out of the field. Your edit > should be saved. >- Reload the page to confirm that everything looks correct. > >Sponsored-by: Athens County Public Libraries >--- > .../prog/en/modules/admin/localization.tt | 43 ++++++++++--------- > 1 file changed, 23 insertions(+), 20 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/localization.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/localization.tt >index e13f64125c6..fcb70962eae 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/localization.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/localization.tt >@@ -149,7 +149,7 @@ > var message; > if ( type == 'success_on_update' ) { > message = $('<div class="alert alert-info"></div>'); >- message.text(_("Entity %s (code %s) for lang %s has correctly been updated with '%s'").format(data.entity, data.code, data.lang, data.translation)); >+ message.text(_("Entity %s (code %s) for lang %s has been updated with '%s'").format(data.entity, data.code, data.lang, data.translation)); > } else if ( type == 'error_on_update' ) { > message = $('<div class="alert alert-warning"></div>'); > if ( data.error_code == 'already_exists' ) { >@@ -252,32 +252,33 @@ > [% END %] > [% END %] > >- $("td.translation").on('focus', function(){ >+ $("body").on('focus', "td.translation", function(){ > $(this).css('background-color', ''); > }); >- $("td.lang").on('click', function(){ >- var td = this; >- var lang = $(td).text(); >- $(td).css('background-color', ''); >- var my_select = $(languages_select).clone(); >- $(my_select).find('option[value="' + lang + '"]').attr('selected', 'selected'); >- $(my_select).on('click', function(e){ >+ $("body").on('click', "td.lang", function(){ >+ var td = $(this); >+ var tr = td.parent(); >+ var id = tr.data('id'); >+ var lang = td.text(); >+ td.css('background-color', ''); >+ var my_select = languages_select.clone(); >+ my_select.find('option[value="' + lang + '"]').attr('selected', 'selected'); >+ my_select.on('click', function(e){ > e.stopPropagation(); > }); >- $(my_select).on('change', function(){ >- var tr = $(this).parent().parent(); >- var id = $(tr).data('id'); >- var lang = $(this).find('option:selected').val(); >- var translation = $(this).text(); >- send_update_request( {id, lang, translation}, td ); >+ var lang; >+ my_select.on('change', function(){ >+ lang = td.find('option:selected').val(); >+ var translation = tr.find("td.translation").text(); >+ send_update_request( {id, lang, translation}, td[0] ); > }); >- $(my_select).on('blur', function(){ >- $(td).html(lang); >+ my_select.on('blur', function(){ >+ td.html(lang); > }); >- $(this).html(my_select); >+ td.html(my_select); > }); > >- $("td.translation").on('blur', function(){ >+ $("body").on('blur', "td.translation", function(){ > var tr = $(this).parent(); > var id = $(tr).data('id'); > var lang = $(tr).find('td.lang').text(); >@@ -311,6 +312,9 @@ > } else { > var new_row = table_dt.row.add( [ success.id, success.entity, success.code, success.lang, success.translation, "<a href=\"#\" class=\"btn btn-default btn-xs delete\"><i class=\"fa fa-trash-can\"></i> Delete</a>" ] ).draw().node(); > $( new_row ).attr("id", "row_id_" + success.id ).data("id", success.id ); >+ /* Is there a better way to target contenteditable cells than by index? */ >+ $( new_row.children[3] ).prop("contenteditable", true).addClass("lang") >+ $( new_row.children[4] ).prop("contenteditable", true).addClass("translation") > show_message({ type: 'success_on_insert', data: success }); > } > }, >@@ -320,7 +324,6 @@ > } > ); > }); >- > }); > </script> > [% END %] >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40453
: 184408