Bug 26248

Summary: Simplify keep_text Javascript function
Product: Koha Reporter: David Cook <dcook>
Component: Staff interfaceAssignee: Bugs List <koha-bugs>
Status: RESOLVED INVALID QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: cornejo.alvaro, gmcharlt
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 14189, 26249    
Bug Blocks:    
Attachments: Bug 26248: Simplify keep_text function used in header search
Example pendings on last-borrower
Bug 26248: Simplify keep_text function used in header search

Description David Cook 2020-08-19 05:13:41 UTC
The keep_text function in koha-tmpl/intranet-tmpl/prog/js/staff-global.js is functional but not very readable.

We can simplify it.
Comment 1 David Cook 2020-08-19 05:16:43 UTC
Created attachment 108567 [details] [review]
Bug 26248: Simplify keep_text function used in header search

The current code is functional but not very readable. This patch
simplifies the code to be more readable and to be more efficient.

To test:
1) Apply patch
2) Refresh browser cache
3) Type "A" in "Check out" tab
4) Click "Check in" (and other tabs)
5) Observe that text is persisted from original tab
6) Type "B" in "Search the catalog" tab
7) Click "Renew" tab
8) Observe that text is persisted from latest changed tab
Comment 2 David Cook 2020-08-19 05:25:27 UTC
Hmm working fine on mainpage.pl but having an issue clicking on "Search the catalog" on search.pl...
Comment 3 David Cook 2020-08-19 05:35:53 UTC
For some reason that tab is passing an index value of 4 rather than 3...
Comment 4 David Cook 2020-08-19 05:41:25 UTC
Ahh the keep_text isn't set correctly in "koha-tmpl/intranet-tmpl/prog/en/includes/cat-search.inc"
Comment 5 David Cook 2020-08-19 05:47:55 UTC
Adding dependency on Bug 26249
Comment 6 Alvaro Cornejo 2020-08-23 16:44:44 UTC Comment hidden (obsolete)
Comment 7 Alvaro Cornejo 2020-08-23 16:47:26 UTC Comment hidden (obsolete)
Comment 8 Mazen Khallaf 2021-01-18 23:28:45 UTC
Created attachment 115262 [details] [review]
Bug 26248: Simplify keep_text function used in header search

The current code is functional but not very readable. This patch
simplifies the code to be more readable and to be more efficient.

To test:
1) Apply patch
2) Refresh browser cache
3) Type "A" in "Check out" tab
4) Click "Check in" (and other tabs)
5) Observe that text is persisted from original tab
6) Type "B" in "Search the catalog" tab
7) Click "Renew" tab
8) Observe that text is persisted from latest changed tab

Signed-off-by: Mazen Khallaf <mazen.i.khallaf@gamil.com>
Comment 9 Katrin Fischer 2021-01-18 23:42:20 UTC
I believe there is still a small glitch here:
When I 
- enter something in one tab
- move to the next
- empty the input field
- switch tab again
- the deleted string reappears
Comment 10 David Cook 2021-01-18 23:44:51 UTC
(In reply to Katrin Fischer from comment #9)
> I believe there is still a small glitch here:
> When I 
> - enter something in one tab
> - move to the next
> - empty the input field
> - switch tab again
> - the deleted string reappears

Hmm weird. I thought that I'd thoroughly tested this. 

I probably don't have time to work on this again for a long time, but that's a useful note!
Comment 11 David Cook 2023-06-02 02:01:29 UTC
I don't recall why I cared about this in the first place...