Bug 32301 - Show correct defaultSortField in staff interface advanced search
Summary: Show correct defaultSortField in staff interface advanced search
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal (vote)
Assignee: Nick Clemens
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on: 22605
Blocks:
  Show dependency treegraph
 
Reported: 2022-11-21 02:37 UTC by wainuiwitikapark
Modified: 2023-12-28 20:44 UTC (History)
9 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.05,22.05.13,21.11.21


Attachments
Sort by option in Staff Client Advanced Search (5.39 KB, image/png)
2022-11-21 02:37 UTC, wainuiwitikapark
Details
Bug 32301: defaultSortField changes the default Sort By in Staff Client Advanced Search (1.73 KB, patch)
2022-11-29 01:28 UTC, wainuiwitikapark
Details | Diff | Splinter Review
Bug 32301: defaultSortField changes the default Sort By in Staff Client Advanced Search (1.78 KB, patch)
2022-11-29 16:31 UTC, David Nind
Details | Diff | Splinter Review
Bug 32301: defaultSortField changes the default Sort By in Staff Client Advanced Search (1.84 KB, patch)
2023-03-08 20:03 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 32301: [alternate] Fix default search sorting in advanced search when not editing a search (1.92 KB, patch)
2023-03-17 11:23 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 32301: [alternate] Fix default search sorting in advanced search when not editing a search (1.97 KB, patch)
2023-03-30 11:54 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 32301: [alternate] Fix default search sorting in advanced search when not editing a search (2.03 KB, patch)
2023-04-10 17:14 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description wainuiwitikapark 2022-11-21 02:37:42 UTC
Created attachment 144096 [details]
Sort by option in Staff Client Advanced Search

The defaultSortField system preference doesn't seem to affect the Staff Client Advanced Search, it still shows 'relevance' as the sort field whichever option you use in the syspref. 

However, when you submit the search it does in fact search by the value of the syspref.

Need to:

- In the advanced search in the staff client, display the correct default "sort by" option that is chosen in the defaultSortField system preference
Comment 1 wainuiwitikapark 2022-11-21 03:25:07 UTC
Sort by option in Staff Client Advanced Search

The defaultSortField system preference doesn't seem to affect the Staff Client Advanced Search, it still shows 'relevance' as the sort field whichever option you use in the syspref. 

However, when you submit the search it does in fact search by the value of the syspref.

Need to:

- In the advanced search in the staff client, display the correct default "sort by" option that is chosen in the defaultSortField system preference
Comment 2 Katrin Fischer 2022-11-21 20:21:21 UTC
Confirmed on master. It works nicely in simple search, but not in advanced search:

* Set defaultSortField: title
* Set defaultSortOrder: A-Z
* Do a catalog search for... anything (I used perl)
* Sorting is alphabetic and in the sort pull down, the title has a little checkmark in front of the entry (could stand out a little more)


* Set defaultSortField: author
* Set defaultSortOrder: ascending
* Searched for 'perl' again
* No author is on top, rest seems to sort ok, C D G...
* Checkmark on search shows

But on advanced search, the search pull down seems stuck to Relevance no matter what.
Comment 3 wainuiwitikapark 2022-11-29 01:28:34 UTC
Created attachment 144310 [details] [review]
Bug 32301: defaultSortField changes the default Sort By in Staff Client Advanced Search

Use the system preference "defaultSortField" to choose the default Sort
By in the Staff Client Advances Search

To test:
1) Go to staff client
2) Go to Advanced Search
3) Notice the default Sort By value is "Relevance"
4) Go to system preferences
5) Go to "defaultSortField"
6) Change the value of the system preference
7) Go back to Advanced Search and refresh the page
8) Notice that there are no changes, the default Sort By is still
"Relevance"
9) Apply patch
10) Notice that changing the system preference now changes the default
Sort By in Advanced Search

Sponsored-by: National Institute of Atmospheric and Water Research
Comment 4 David Nind 2022-11-29 16:31:44 UTC
Created attachment 144327 [details] [review]
Bug 32301: defaultSortField changes the default Sort By in Staff Client Advanced Search

Use the system preference "defaultSortField" to choose the default Sort
By in the Staff Client Advances Search

To test:
1) Go to staff client
2) Go to Advanced Search
3) Notice the default Sort By value is "Relevance"
4) Go to system preferences
5) Go to "defaultSortField"
6) Change the value of the system preference
7) Go back to Advanced Search and refresh the page
8) Notice that there are no changes, the default Sort By is still
"Relevance"
9) Apply patch
10) Notice that changing the system preference now changes the default
Sort By in Advanced Search

Sponsored-by: National Institute of Atmospheric and Water Research

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 Katrin Fischer 2022-12-07 21:49:30 UTC
Hi Wainui, I believe this fix is not completely right yet:

1) Do an advanced search, change the sort order from default to something else
2) In the result list click on "edit this search" on top of the results list
3) notice that the sort is kept 
4) Apply patch, restart all the things
5) Repeat steps above - sort will be changed back to the default
Comment 6 Aleisha Amohia 2023-03-06 02:26:04 UTC
Hi Katrin

I've just re-tested this and believe it does work as described, can you please test again?

Thanks
Aleisha
Comment 7 Laura Escamilla 2023-03-06 19:14:31 UTC
(In reply to wainuiwitikapark from comment #3)
> Created attachment 144310 [details] [review] [review]
> Bug 32301: defaultSortField changes the default Sort By in Staff Client
> Advanced Search
> 
> Use the system preference "defaultSortField" to choose the default Sort
> By in the Staff Client Advances Search
> 
> To test:
> 1) Go to staff client
> 2) Go to Advanced Search
> 3) Notice the default Sort By value is "Relevance"
> 4) Go to system preferences
> 5) Go to "defaultSortField"
> 6) Change the value of the system preference
> 7) Go back to Advanced Search and refresh the page
> 8) Notice that there are no changes, the default Sort By is still
> "Relevance"
> 9) Apply patch
> 10) Notice that changing the system preference now changes the default
> Sort By in Advanced Search
> 
> Sponsored-by: National Institute of Atmospheric and Water Research

Works as described. 

Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Comment 8 ByWater Sandboxes 2023-03-08 20:03:11 UTC
Created attachment 147984 [details] [review]
Bug 32301: defaultSortField changes the default Sort By in Staff Client Advanced Search

Use the system preference "defaultSortField" to choose the default Sort
By in the Staff Client Advances Search

To test:
1) Go to staff client
2) Go to Advanced Search
3) Notice the default Sort By value is "Relevance"
4) Go to system preferences
5) Go to "defaultSortField"
6) Change the value of the system preference
7) Go back to Advanced Search and refresh the page
8) Notice that there are no changes, the default Sort By is still
"Relevance"
9) Apply patch
10) Notice that changing the system preference now changes the default
Sort By in Advanced Search

Sponsored-by: National Institute of Atmospheric and Water Research

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com>
Comment 9 Nick Clemens 2023-03-17 11:23:30 UTC
Created attachment 148326 [details] [review]
Bug 32301: [alternate] Fix default search sorting in advanced search when not editing a search

Bug 22605 changed the sorting to expect the passed parameter from the
previous search, this broke default when the search page was loaded
fresh.

We should simply fallback from the edited search to the default if it is
not set

To test:
1) Go to staff client
2) Go to Advanced Search
3) Notice the default Sort By value is "Relevance"
4) Go to system preferences
5) Go to "defaultSortField"
6) Change the value of the system preference
7) Go back to Advanced Search and refresh the page
8) Notice that there are no changes, the default Sort By is still
"Relevance"
9) Apply patch
10) Notice that changing the system preference now changes the default
Sort By in Advanced Search
11) Perform a search, change the sorting, then edit the search
12) Confirm the correct sorting from the search is preserved
Comment 10 Nick Clemens 2023-03-17 11:24:12 UTC
I think Katrin is correct, I provided an alternate patch
Comment 11 ByWater Sandboxes 2023-03-30 11:54:40 UTC
Created attachment 148973 [details] [review]
Bug 32301: [alternate] Fix default search sorting in advanced search when not editing a search

Bug 22605 changed the sorting to expect the passed parameter from the
previous search, this broke default when the search page was loaded
fresh.

We should simply fallback from the edited search to the default if it is
not set

To test:
1) Go to staff client
2) Go to Advanced Search
3) Notice the default Sort By value is "Relevance"
4) Go to system preferences
5) Go to "defaultSortField"
6) Change the value of the system preference
7) Go back to Advanced Search and refresh the page
8) Notice that there are no changes, the default Sort By is still
"Relevance"
9) Apply patch
10) Notice that changing the system preference now changes the default
Sort By in Advanced Search
11) Perform a search, change the sorting, then edit the search
12) Confirm the correct sorting from the search is preserved

Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Comment 12 Katrin Fischer 2023-04-10 17:14:48 UTC
Created attachment 149405 [details] [review]
Bug 32301: [alternate] Fix default search sorting in advanced search when not editing a search

Bug 22605 changed the sorting to expect the passed parameter from the
previous search, this broke default when the search page was loaded
fresh.

We should simply fallback from the edited search to the default if it is
not set

To test:
1) Go to staff client
2) Go to Advanced Search
3) Notice the default Sort By value is "Relevance"
4) Go to system preferences
5) Go to "defaultSortField"
6) Change the value of the system preference
7) Go back to Advanced Search and refresh the page
8) Notice that there are no changes, the default Sort By is still
"Relevance"
9) Apply patch
10) Notice that changing the system preference now changes the default
Sort By in Advanced Search
11) Perform a search, change the sorting, then edit the search
12) Confirm the correct sorting from the search is preserved

Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 13 Katrin Fischer 2023-04-10 17:15:27 UTC
Thx Nick, this now also works with the "Edit search" as expected.
Comment 14 Tomás Cohen Arazi 2023-04-12 12:27:40 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 15 Matt Blenkinsop 2023-04-17 09:03:28 UTC
Nice work everyone!

Pushed to stable for 22.11.x
Comment 16 Lucas Gass 2023-05-05 21:55:16 UTC
Backported to 22.05.x for upcoming 22.05.13.
Comment 17 Aleisha Amohia 2023-05-16 04:45:57 UTC
This bug is present in 21.11.x, can it please be backported?
Comment 18 Arthur Suzuki 2023-05-23 09:30:37 UTC
applied to 21.11 for 21.11.21