marklogic-community / grove

Grove, a toolkit full of tooling, templates, and other resources that help with building UI applications on top of MarkLogic.
https://marklogic-community.github.io/grove/
Other
5 stars 2 forks source link

Honor the search:options page-length (configured in all.xml for example) #19

Open bobstarbird opened 5 years ago

bobstarbird commented 5 years ago

search:options page-length 10 behaves as if it is hard-coded in js. Changing search options file all.xml has no effect. I could not find where to change the value in the js source. Documenting how to change it would be helpful.

danielholgate commented 5 years ago

For Vue apps you need to modify the pageLength property (in typedSearchState function) in ui/src/store.js to modify page length. Not sure for React

patrickmcelwee commented 5 years ago

This is a helpful ticket, because this is likely to be fairly common, and the current implementation breaks expectations.

The named search options stored in MarkLogic are unable to set page length because of several points at which eager code will default it to 10:

  1. the front-end usually sets it. a. In the React stack, grove-search-redux defaults the pageLength property of the stagedSearch to 10. In fact, the grove-search-redux library currently lacks an action to change the page length. ... ... I have overridden this in at least one project by circumventing the pageLength property of the stagedSearch, and directly changing the pageLength. See, eg, https://project.marklogic.com/repo/projects/INT/repos/rpaas/browse/rpaas-ui/ui/src/containers/EntitySearchContainer.js#68 ... but that is fairly invasive. b. In the Vue stack, as @danielholgate mentioned, it can be reset in ui/src/store.js: https://github.com/marklogic-community/grove-vue-ui/blob/9af54252f8544afc89ff9b18e2043f85f9c63a86/src/store.js#L137

  2. if the front-end does not set it, the middle-tier will set it to 10.

I think we should:

  1. Stop providing a default page-length in grove-search-redux. Create the missing action to update the pageLength if desired. Document how to use it.
  2. Comment out the pageLength in /ui/src/store.js in grove-vue-ui, but document how to add it back if desired by the developer.
  3. Stop defaulting page-length in the middle-tier (MarkLogic already defaults to 10).
grtjn commented 5 years ago

I think you had to override it in the frontend in slush-ml-node as well, rather than in the search options. That said, it should be possible to rely more on backend to provide a default page length, as long as it would still be possible to override it from front-end, in case a user specifies page length from the ui (for instance using a page length drop down or such)..