-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(pat-autosuggest): load more #1195
base: master
Are you sure you want to change the base?
Conversation
8aa1a62
to
67c0530
Compare
67c0530
to
6960bf9
Compare
@reinhardt adding your suggestion from the chat in here:
|
Co-authored-by: Manuel Reinhardt <[email protected]>
I noted on 11.June that @cornae wanted to contact @thet on the specifics of this PR to determine how to name the pattern attributes. Could you do this this week? The timeouts we get are causing repeated helpdesk requests from osha and are getting quite disruptive, so fixing this will have an immediately positive impact on our peace. |
Usecases that we want to support with suggested properties design: No batching, but AJAX (default)
Or with an initial batch size that is not 10:
Batching with arbitrary sizeExample for batching enabled with a batch size of 30 and an initial list size of 10:
Example for batching enabled with a batch size of 20 and an initial list size of 30:
Not for now
|
We can tell select2 to batch or not to batch.
If we batch, we can tell select2 how many items it should load per batch.
Please say how you would like to state these options in terms of pat-autosuggest attributes.
The text below is background information by Hannes.
pat-autosuggest currently does not have ajax batching support aka infinite scrolling.
It can only load a fixed number of items and not load more when the user scrolls down the list.
There is some batching support already prepared, but in it's current form this does not work.
This draft PR adds real batching support for ajax requests.
For the batching support to work, the backend also needs to support it, but more on that later.
We added two options to pat-autosuggest:
ajax-batch-size
(default:10
) - This defines the number of items which should be loaded from the backend within one request. The default is10
- this is the same number we currently have hard-coded in this Pattern.ajax-batch-mode
(default:fixed
, possible other value:batched
) - This defines if the batching/inifinite scrolling should be enabled or not. The default isfixed
, which reflects the current behavior. When set tobatched
it will request more items if the user reaches the end of the selection list.The logic to determine if more results should be loaded from the server is simple: If the number of items in the result is lower than the batch size no more results will be loaded. If the number is equal to the batch size, the next batch from the server will be requested. If there are no more items an empty list would be returned.
The server needs to support these request parameters for batching support (these are already submitted to the server):
page
(Integer): The page number of the batch.1
for the first result set,2
for the second and for forth.page_limit
(Integer): The batch size. This is the same as theajax-batch-size
parameter.The server needs to respond with an JSON array of objects with
id
andtext
as keys (This is already the case).If there are no more results, the server needs to return an empty list.
@cornae, please give us feedback on adding this feature in general and the new options and possible naming suggestions in particular.
Ref: syslabcom/scrum#1638
For more information on this see:
https://select2.github.io/select2/#infinite