Liking cljdoc? Tell your friends :D

com.fulcrologic.rad.picker-options

Utilities to help support entity/enumeration pickers in the UI, along with loading/normalizing/caching the options.

Pickers are commonly used for things like autocomplete fields and (cascading) dropdowns where the list of options must be loaded dynamically due to some event in the UI.

Picker options are placed in a well-known top-level table which contains the original query result, the transformed (usable) options, and a timestamp for expiration. UI plugins will query for that table as [::picker-options/options-cache '_] which will cause the entire picker options cache to be visible in props.

Picker options can be used in form fields, report controls, etc. They are usable anywhere you can link their query in and trigger a load to ensure the options are properly loaded. Picker options can also be statically defined.

Utilities to help support entity/enumeration pickers in the UI, along with loading/normalizing/caching the options.

Pickers are commonly used for things like autocomplete fields and (cascading) dropdowns where the list of options must be loaded dynamically
due to some event in the UI.

Picker options are placed in a well-known top-level table which contains the original query result, the transformed (usable)
options, and a timestamp for expiration. UI plugins will query for that table as `[::picker-options/options-cache '_]`
which will cause the entire picker options cache to be visible in props.

Picker options can be used in form fields, report controls, etc.  They are usable anywhere you can link their query
in and trigger a load to ensure the options are properly loaded. Picker options can also be statically
defined.
raw docstring

cache-keyclj/s

A keyword or (fn [cls props] keyword?) under which the normalized picker options will be saved.

A keyword or `(fn [cls props] keyword?)` under which the normalized picker options will be saved.
sourceraw docstring

cache-time-msclj/s

How long the options can be cached. This allows multiple uses of the same options load to be used over time. Caching is done under ::cache-key.

How long the options can be cached. This allows multiple uses of the same options load to be used over time. Caching
is done under ::cache-key.
sourceraw docstring

current-form-optionsclj/s

(current-form-options form-instance attr)

Gets the current picker options for the given form-instance and attribute.

Gets the current picker options for the given form-instance and attribute.
sourceraw docstring

current-optionsclj/s

DEPRECATED NAME: Use current-form-options

DEPRECATED NAME: Use current-form-options
sourceraw docstring

current-picker-optionsclj/s

(current-picker-options component-instance)
(current-picker-options component-instance picker-options)

Gets the current picker options (when not using a form). See current-form-options for a form-specific variant.

component-instance - A mounted component whose props will contain the picker options table (e.g. the link query [::picker-options/options-cache '_]). This instance can also have picker options in its component-options. picker-options - Optional. A map that contains picker option (overrides). Will be merged (as overrides) for any that are found in component options on the component instance. Note that since this function does no loading, this is only useful if your original picker options are not on the same component as the query.

Gets the current picker options (when not using a form). See `current-form-options` for a form-specific variant.

`component-instance` - A mounted component whose props will contain the picker options table (e.g. the link query
`[::picker-options/options-cache '_]`). This instance can also have picker options in its `component-options`.
`picker-options` - Optional. A map that contains picker option (overrides). Will be merged (as overrides) for any that are found in
component options on the component instance. Note that since this function does no loading, this is only useful if your
original picker options are not on the same component as the query.
sourceraw docstring

current-to-one-labelclj/s

(current-to-one-label form-instance attr)

Extracts the current to-one label from the given attribute's value via the picker options

Extracts the current to-one label from the given attribute's value via the picker options
sourceraw docstring

current-to-one-valueclj/s

(current-to-one-value form-instance attr)

Returns the current to-one ref value for the given reference attribute as an ident.

Returns the current to-one ref value for the given reference attribute as an ident.
sourceraw docstring

load-options!clj/s

(load-options! app-ish form-class props attribute)
(load-options! app-ish
               form-class
               props
               {:com.fulcrologic.rad.attributes/keys [qualified-key]
                :as attribute}
               load-options)

Load picker options into the options cache for a form field. This should be used by the UI implementation of a form field to ensure picker options are loaded. Typically you'll call this in a component lifecycle method (or one-shot effect hook).

  • app-ish - Anything you can transact! against
  • form-class - The form that holds the field for which you are loading options (passed to picker option lambdas)
  • props - The ui props of the form (passed to the picker option lambdas)
  • attribute - A RAD attribute that could contain picker options, and also designates data that the field will be picking.
  • load-options - Additional options to pass to load if the options are loaded. Some options may be overridden internally. See load-picker-options!.

The picker options will be a combination of the field options for the field and any found on the attribute.

Load picker options into the options cache for a form field. This should be used by the UI implementation of
a form field to ensure picker options are loaded. Typically you'll call this in a component lifecycle method (or one-shot
effect hook).

* `app-ish` - Anything you can `transact!` against
* `form-class` - The form that holds the field for which you are loading options (passed to picker option lambdas)
* `props` - The ui props of the form (passed to the picker option lambdas)
* `attribute` - A RAD attribute that could contain picker options, and also designates data that the field will
be picking.
* `load-options` - Additional options to pass to load if the options are loaded. Some options may be overridden
internally. See `load-picker-options!`.

The picker options will be a combination of the field options for the field and any found on the attribute.
sourceraw docstring

load-picker-options!clj/s

(load-picker-options! app-ish component-class props picker-options)
(load-picker-options! app-ish component-class props picker-options load-options)

Load picker options based on raw picker options. This function does all of the picker-centric inner workings of caching and such, so calling this function may do little more than link your component to an existing cached value of options.

  • app-ish - An application or live component, used for pulling state and submitting loads.
  • component-class - The component class that will be passed through to the various picker option lambdas. Usually a form or report class, but could also be a UI control.
  • props - The UI props of that will be passed through to the various picker option lambdas. Usually the props of the instance that contains the options.
  • picker-options - A map that contains ::picker-options options. Often the component options, but could also be declared in a control's definition map.
  • load-options - Additional options you wish to pass to the load (optional). Only used if the cache was missing or stale for the options. Currently you cannot use :target, :params, or :post-action. ::picker-options/remote can be used to select the load remote.

This function can has general purpose application, and is not report or form specific. It should be called as part of a component's lifecycle to link/populate the options. For example in componentDidMount or in a useEffect that does has an empty dependency vector (one-shot on mount).

Load picker options based on raw picker options. This function does all of the picker-centric inner workings
of caching and such, so calling this function may do little more than link your component to an existing cached
value of options.

* `app-ish` - An application or live component, used for pulling state and submitting loads.
* `component-class` - The component class that will be passed through to the various picker option lambdas.
Usually a form or report class, but could also be a UI control.
* `props` - The UI props of that will be passed through to the various picker option lambdas. Usually the props
of the instance that contains the options.
* `picker-options` - A map that contains ::picker-options options. Often the component options, but could also be
declared in a control's definition map.
* `load-options` - Additional options you wish to pass to the load (optional). Only used if the cache was missing or
stale for the options. Currently you cannot use `:target`, `:params`, or `:post-action`. `::picker-options/remote` can
be used to select the load remote.

This function can has general purpose application, and is not report or form specific. It should be called as part of
a component's lifecycle to link/populate the options. For example in `componentDidMount` or in a `useEffect` that does
has an empty dependency vector (one-shot on mount).
sourceraw docstring

options-xformclj/s

A (fn [normalized-result raw-result] [{:text t :value v} ...]). This generates the options to show the user. If not provided then it is assumed that the query result itself is a vector of these text/value pair maps.

A `(fn [normalized-result raw-result] [{:text t :value v} ...])`. This generates the options to show the user. If
not provided then it is assumed that the query result itself is a vector of these text/value pair maps.
sourceraw docstring

query-componentclj/s

A Fulcro defsc with the subquery to use for pulling options.

A Fulcro defsc with the subquery to use for pulling options.
sourceraw docstring

query-keyclj/s

The top-level query keyword to use when pulling the options.

The top-level query keyword to use when pulling the options.
sourceraw docstring

query-parametersclj/s

A map of query parameters to include in the option load, or a (fn [app cls props] map?) that can generate those props on demand.

A map of query parameters to include in the option load, or a `(fn [app cls props] map?)` that can generate those
props on demand.
sourceraw docstring

remoteclj/s

The keyword name of the remote that the picker options are loaded from. Defaults to :remote.

The keyword name of the remote that the picker options are loaded from. Defaults to :remote.
sourceraw docstring

transform-optionsclj/s

INTERNAL MUTATION. Do not use.

INTERNAL MUTATION. Do not use.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close