From aa24c669a5abe63370c39698385cbd847e31a11f Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 16 Oct 2021 22:13:58 -0400 Subject: [PATCH] Add doc about autocompleters --- docs/data/autocomplete.rst | 25 +++++++++++++++++++++++++ docs/data/index.rst | 1 + 2 files changed, 26 insertions(+) create mode 100644 docs/data/autocomplete.rst diff --git a/docs/data/autocomplete.rst b/docs/data/autocomplete.rst new file mode 100644 index 0000000..e7de06c --- /dev/null +++ b/docs/data/autocomplete.rst @@ -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()`. diff --git a/docs/data/index.rst b/docs/data/index.rst index d4b79e8..c5ab856 100644 --- a/docs/data/index.rst +++ b/docs/data/index.rst @@ -14,6 +14,7 @@ Data Layer sync versioning batch/index + autocomplete custorders/index reports/index problems