There is JavaScript on the new Pages page which is supposed to check to see whether the view includes the tabs, i.e. on the edit page. The script needs to be more specific about what DOM elements to look for before it tries to grab information about the tab.
Created attachment 140919 [details] [review] Bug 31609: JavaScript error on Additional contents main page This patch makes a minor modification to the JavaScript on the Additional contents page to prevent an error when there are no tabs present on the page. The JS needs an additional check so that it doesn't run when there are no tabs. To test you should have more than one language installed. - Before the patch, you would see a JavaScript error in the console: "Uncaught TypeError: can't access property "hash", firstTab[0] is undefined." - Apply the patch and go to Tools -> Additional contents. - With the patch applied there should be no error on the additional contents main page. - Try creating or editing additional contents entries to confirm that the interface still works correctly.
Failed QA because after applying the patch and go to go Tools > Additional contents: - error no longer appears when language is English - switch to another language installed: the error message reappears. Steps to reproduce (tested using KTD): 1. Install another language: koha-translate --install fr-CA 2. Add an additional contents entry. 3. Replicate the error as per the test plan. 4. Apply the patch - leave language as English, flush_memcached, restart_all, clear browser cache. 5. From the home page, go to Tools > Additional contents - there should be no error in the browser console. 6. Switch language to Français. 7. The error message is back! (Note that it doesn't happen when you switch back to English.)
I think the issue is that you have to run the translate "update" command first, to rebuild the other language strings based on the patch's modified template. Then run the "install" command. Could you try again?
Created attachment 140975 [details] [review] Bug 31609: JavaScript error on Additional contents main page This patch makes a minor modification to the JavaScript on the Additional contents page to prevent an error when there are no tabs present on the page. The JS needs an additional check so that it doesn't run when there are no tabs. To test you should have more than one language installed. - Before the patch, you would see a JavaScript error in the console: "Uncaught TypeError: can't access property "hash", firstTab[0] is undefined." - Apply the patch and go to Tools -> Additional contents. - With the patch applied there should be no error on the additional contents main page. - Try creating or editing additional contents entries to confirm that the interface still works correctly. Signed-off-by: David Nind <david@davidnind.com>
(In reply to Owen Leonard from comment #3) > I think the issue is that you have to run the translate "update" command > first, to rebuild the other language strings based on the patch's modified > template. Then run the "install" command. Thanks Owen! That made things work.
The error is still present on the list view of Tools/Pages Uncaught TypeError: firstTab[0] is undefined <anonymous> https://master.rijkskoha.nl:28443/cgi-bin/koha/tools/additional-contents.pl?category=pages:1132 jQuery 13 Template code: let firstTab = $("#tabs a:first"); firstTab.tab("show"); initTinyMce( firstTab[0].hash ); There should probably be a check on firstTab first :) The <div id="tabs" class="toptabs"> belongs to the detail page and not to the list view on the main page.
The above proves that it was not trivial :)
(In reply to Marcel de Rooy from comment #6) > The error is still present on the list view of Tools/Pages I don't see this. Could you please look again?
(In reply to Owen Leonard from comment #8) > (In reply to Marcel de Rooy from comment #6) > > The error is still present on the list view of Tools/Pages > > I don't see this. Could you please look again? You need to hit Tools/Pages. The JS error is on the main page. Not the detail one.
I can see the JavaScript error as dscribed on Tools > News: Uncaught TypeError: firstTab[0] is undefined <anonymous> http://localhost:8081/cgi-bin/koha/tools/additional-contents.pl?category=news:1653 jQuery 13
With this patch, all 3, Pages, News and HTML customizations on longer show the error.
Created attachment 142574 [details] [review] Bug 31609: JavaScript error on Additional contents main page This patch makes a minor modification to the JavaScript on the Additional contents page to prevent an error when there are no tabs present on the page. The JS needs an additional check so that it doesn't run when there are no tabs. To test you should have more than one language installed. - Before the patch, you would see a JavaScript error in the console: "Uncaught TypeError: can't access property "hash", firstTab[0] is undefined." - Apply the patch and go to Tools -> Additional contents. - With the patch applied there should be no error on the additional contents main page. - Try creating or editing additional contents entries to confirm that the interface still works correctly. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Confirming that I do not see the error either anymore.
Created attachment 142599 [details] [review] Bug 31609: JavaScript error on Additional contents main page This patch makes a minor modification to the JavaScript on the Additional contents page to prevent an error when there are no tabs present on the page. The JS needs an additional check so that it doesn't run when there are no tabs. To test you should have more than one language installed. - Before the patch, you would see a JavaScript error in the console: "Uncaught TypeError: can't access property "hash", firstTab[0] is undefined." - Apply the patch and go to Tools -> Additional contents. - With the patch applied there should be no error on the additional contents main page. - Try creating or editing additional contents entries to confirm that the interface still works correctly. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Pushed to master for 22.11. Nice work everyone, thanks!
Backported to 22.05.x for upcoming 22.05.08
patch relies on initTinyMce function, which I can't find defined in 21.11. Won't apply as is.