Add doc about autocompleters
This commit is contained in:
parent
922a7a5f11
commit
aa24c669a5
25
docs/data/autocomplete.rst
Normal file
25
docs/data/autocomplete.rst
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
Autocomplete
|
||||||
|
============
|
||||||
|
|
||||||
|
Even though autocomplete is generally most useful in a web app, e.g.
|
||||||
|
for customer lookup, here it is implemented in the data layer and has
|
||||||
|
no "web" parts to it per se. (Which means you could add autocomplete
|
||||||
|
to your console app?)
|
||||||
|
|
||||||
|
An "autocompleter" in Rattail is really just an object with one
|
||||||
|
important method,
|
||||||
|
:meth:`~rattail:rattail.autocomplete.base.Autocompleter.autocomplete()`.
|
||||||
|
|
||||||
|
Rattail comes with several autocompleters built-in. You can get a new
|
||||||
|
autocompleter easily enough from the app handler, and using it is just
|
||||||
|
as easy::
|
||||||
|
|
||||||
|
products_ac = app.get_autocompleter('products')
|
||||||
|
results = products_ac.autocomplete('root beer')
|
||||||
|
|
||||||
|
The results will be a list of dicts, each will have at least ``value``
|
||||||
|
(uuid) and ``label`` (name/description) items.
|
||||||
|
|
||||||
|
See also :class:`~rattail:rattail.autocomplete.base.Autocompleter` and
|
||||||
|
:meth:`~rattail:rattail.app.AppHandler.get_autocompleter()`.
|
|
@ -14,6 +14,7 @@ Data Layer
|
||||||
sync
|
sync
|
||||||
versioning
|
versioning
|
||||||
batch/index
|
batch/index
|
||||||
|
autocomplete
|
||||||
custorders/index
|
custorders/index
|
||||||
reports/index
|
reports/index
|
||||||
problems
|
problems
|
||||||
|
|
Loading…
Reference in a new issue