Bug 21091 - Move add item template JavaScript to a separate file
Summary: Move add item template JavaScript to a separate file
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Owen Leonard
QA Contact: Josef Moravec
URL:
Keywords:
Depends on:
Blocks: 28689
  Show dependency treegraph
 
Reported: 2018-07-19 14:21 UTC by Owen Leonard
Modified: 2021-07-08 13:57 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 21091: Move add item template JavaScript to a separate file (14.17 KB, patch)
2018-07-19 14:49 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 21091: Move add item template JavaScript to a separate file (14.09 KB, patch)
2018-08-16 07:55 UTC, Claire Gravely
Details | Diff | Splinter Review
Bug 21091: Move add item template JavaScript to a separate file (14.87 KB, patch)
2018-11-28 18:24 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 21091: Move add item template JavaScript to a separate file (14.98 KB, patch)
2018-11-28 18:34 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 21091: Move add item template JavaScript to a separate file (14.95 KB, patch)
2019-02-15 21:59 UTC, José-Mario Monteiro-Santos
Details | Diff | Splinter Review
Bug 22015: Add missing USE raw statement (882 bytes, patch)
2019-02-22 10:39 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 21091: Add missing USE raw statement (828 bytes, patch)
2019-02-22 10:40 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 21091: Move add item template JavaScript to a separate file (14.89 KB, patch)
2019-02-25 15:31 UTC, Josef Moravec
Details | Diff | Splinter Review
Bug 21091: Add missing USE raw statement (883 bytes, patch)
2019-02-25 15:31 UTC, Josef Moravec
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2018-07-19 14:21:38 UTC
I would like to modify the add item template (additem.tt) to move JavaScript from the <head> to separate files: cataloging_additem.js and cataloging_additem.inc (for defining translatable strings used in the js).
Comment 1 Owen Leonard 2018-07-19 14:49:42 UTC Comment hidden (obsolete)
Comment 2 Claire Gravely 2018-08-16 07:55:16 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2018-08-17 16:02:43 UTC
Please rebase on top of bug 13618.

I do not think we should move the declaration of columns_settings in the .inc, it should be stay close to the datatables init.
Comment 4 Katrin Fischer 2018-08-26 16:40:45 UTC
Owen, can you please rebase and take a look at Jonathan's comment#3? Thx!
Comment 5 Owen Leonard 2018-11-28 18:24:47 UTC Comment hidden (obsolete)
Comment 6 Owen Leonard 2018-11-28 18:34:07 UTC
Created attachment 82708 [details] [review]
Bug 21091: Move add item template JavaScript to a separate file

This patch moves the JavaScript in the add item template to separate
files: 1 JS file and 1 include file containing translatable strings.

While moving the JS to cataloging_additem.js I have made some changes to
quiet ESLint warnings (spacing, variable definition).

To test, apply the patch and open the add item page for an existing
record. Test the various JS-driven functionalities:

- Table sorting
- Table column configuration
- Table searching
- Table inline edit/delete links (click anywhere in the table row)
- Add multiple item form show/hide
- Add multiple item warning when adding 100+ items
Comment 7 Owen Leonard 2018-11-28 18:35:08 UTC
(In reply to Jonathan Druart from comment #3)

> I do not think we should move the declaration of columns_settings in the
> .inc, it should be stay close to the datatables init.

I don't think it makes sense to create a whole new <script> block for columns_settings when it can be included in the include file.
Comment 8 José-Mario Monteiro-Santos 2019-02-15 21:59:27 UTC
Created attachment 85205 [details] [review]
Bug 21091: Move add item template JavaScript to a separate file

This patch moves the JavaScript in the add item template to separate
files: 1 JS file and 1 include file containing translatable strings.

While moving the JS to cataloging_additem.js I have made some changes to
quiet ESLint warnings (spacing, variable definition).

To test, apply the patch and open the add item page for an existing
record. Test the various JS-driven functionalities:

- Table sorting
- Table column configuration
- Table searching
- Table inline edit/delete links (click anywhere in the table row)
- Add multiple item form show/hide
- Add multiple item warning when adding 100+ items

Signed-off-by: Jose-Mario Monteiro-Santos <jose-mario.monteiro-santos@inLibro.com>
Comment 9 Katrin Fischer 2019-02-17 10:19:53 UTC
Hi Owen, 

there are some 'red flags' in the QA script, can you please take a look and fix/comment? In testing it did work well so far: 


FAIL	koha-tmpl/intranet-tmpl/prog/en/includes/str/cataloging_additem.inc
   OK	  filters
   OK	  forbidden patterns
   OK	  git manipulation
   FAIL	  js_in_body
		A <script> tag found inside head, must be moved to the body (see bug 17858)
   OK	  spelling
   OK	  tt_valid
   FAIL	  valid_template
		: filter not found
Comment 10 Owen Leonard 2019-02-19 13:35:14 UTC
(In reply to Katrin Fischer from comment #9)
> 
>    FAIL	  js_in_body
>    A <script> tag found inside head, must be moved to the body (see bug 17858)

This looks to me like it's a bug in the QA script?


>    OK	  spelling
>    OK	  tt_valid
>    FAIL	  valid_template
> 		: filter not found

I don't understand this error...
Comment 11 Katrin Fischer 2019-02-19 18:59:04 UTC
I am with you... I am not sure what to make of those 2 either.

@Jonathan - Can you help?
Comment 12 Jonathan Druart 2019-02-22 10:38:04 UTC
(In reply to Katrin Fischer from comment #9)
> FAIL	koha-tmpl/intranet-tmpl/prog/en/includes/str/cataloging_additem.inc
>    FAIL	  js_in_body
> 		A <script> tag found inside head, must be moved to the body (see bug 17858)

This is a bug indeed, I will try to fix it.

>    OK	  spelling
>    OK	  tt_valid
>    FAIL	  valid_template
> 		: filter not found

This is not a bug, [% USE raw %] is missing.
Comment 13 Jonathan Druart 2019-02-22 10:39:27 UTC
Created attachment 85499 [details] [review]
Bug 22015: Add missing USE raw statement
Comment 14 Jonathan Druart 2019-02-22 10:40:56 UTC
Created attachment 85500 [details] [review]
Bug 21091: Add missing USE raw statement
Comment 15 Jonathan Druart 2019-02-22 10:56:57 UTC
(In reply to Jonathan Druart from comment #12)
> (In reply to Katrin Fischer from comment #9)
> > FAIL	koha-tmpl/intranet-tmpl/prog/en/includes/str/cataloging_additem.inc
> >    FAIL	  js_in_body
> > 		A <script> tag found inside head, must be moved to the body (see bug 17858)
> 
> This is a bug indeed, I will try to fix it.

See https://gitlab.com/koha-community/qa-test-tools/issues/12
Comment 16 Katrin Fischer 2019-02-22 11:15:02 UTC
Thx Jonathan!
Comment 17 Josef Moravec 2019-02-25 15:31:05 UTC
Created attachment 85626 [details] [review]
Bug 21091: Move add item template JavaScript to a separate file

This patch moves the JavaScript in the add item template to separate
files: 1 JS file and 1 include file containing translatable strings.

While moving the JS to cataloging_additem.js I have made some changes to
quiet ESLint warnings (spacing, variable definition).

To test, apply the patch and open the add item page for an existing
record. Test the various JS-driven functionalities:

- Table sorting
- Table column configuration
- Table searching
- Table inline edit/delete links (click anywhere in the table row)
- Add multiple item form show/hide
- Add multiple item warning when adding 100+ items

Signed-off-by: Jose-Mario Monteiro-Santos <jose-mario.monteiro-santos@inLibro.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 18 Josef Moravec 2019-02-25 15:31:08 UTC
Created attachment 85627 [details] [review]
Bug 21091: Add missing USE raw statement

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 19 Nick Clemens 2019-03-11 13:11:49 UTC
Awesome work all!

Pushed to master for 19.05
Comment 20 Martin Renvoize 2019-03-12 09:25:42 UTC
Enhancement will not be backported to 18.11.x series.