public interface LookupField<F extends LookupField<F>> extends Filterable<F>, Dependent<F>, Field<F>, Trackable<F>
FieldTypes.LOOKUP
field. A lookup field is useful when the
user needs to be able to choose between a number of externally sourced options.Modifier and Type | Interface and Description |
---|---|
static class |
LookupField.Attributes |
static class |
LookupField.EndpointTypes |
static class |
LookupField.SelectionTypes
This enum represents the way in which the lookup selections are persisted within the form
state.
|
static class |
LookupField.ViewTypes |
Dependent.DependentFieldsList
Modifier and Type | Method and Description |
---|---|
default Optional<Endpoint<?>> |
findHydrateEndpoint() |
default Optional<LookupFieldModal<?>> |
findModal()
Finds the metadata for the
LookupField.ViewTypes.LOOKUP_MODAL configured for this lookup. |
default Optional<PageableEndpoint<?>> |
findReadEndpoint() |
default Endpoint<?> |
getHydrateEndpoint() |
default PageableEndpoint<?> |
getReadEndpoint() |
default F |
hydrateEndpoint(Endpoint<?> endpoint)
Configures the hydration endpoint for the lookup.
|
default F |
hydrateEndpoint(UnaryOperator<Endpoint<?>> fn)
Configures the hydration endpoint for the lookup.
|
default F |
hydrateScope(String scope)
Configures
hydrateEndpoint(UnaryOperator) url. |
default F |
hydrateUrl(String url)
Configures
hydrateEndpoint(UnaryOperator) url. |
default F |
hydrateUrl(String url,
String scope)
Configures
hydrateEndpoint(UnaryOperator) url and scope. |
default boolean |
isSearchable() |
default F |
labelKey(String labelKey)
Sets the name of the label key.
|
default F |
loadingMessage(String loadingMessageKey)
Configure the message to be displayed while the lookup is loading it's options.
|
default F |
modalComponent(String modalComponent)
Sets the name of the React component that will be used for rendering the modal search.
|
default F |
modalSearch(UnaryOperator<LookupFieldModal<?>> fn)
Configure this lookup with a modal for more advanced searching.
|
default F |
modalToggleLabel(String modalLabelKey)
Configures the label for the modal search toggle.
|
default F |
multi()
Configures this lookup to support multi-selection.
|
default F |
multi(boolean isMulti)
Configures whether or not the lookup supports multi-selection.
|
default F |
noOptionsMessage(String noOptionsMessageKey)
Configure the message to be displayed when the lookup finds no options.
|
default F |
notModalSearch()
Disables modal support and remove the Advanced button from the lookup field.
|
default F |
notMulti()
Configures this lookup to not support multi-selection.
|
default F |
notSearchable()
Configures the lookup to not be searchable.
|
default F |
optionSelection()
Configures the lookup with the
LookupField.SelectionTypes.OPTION selection type. |
default F |
readEndpoint(PageableEndpoint<?> endpoint)
Configure the read endpoint for the lookup.
|
default F |
readEndpoint(UnaryOperator<PageableEndpoint<?>> fn)
Configure the read endpoint for the lookup.
|
default F |
readScope(String scope)
Configures
readEndpoint(UnaryOperator) scope. |
default F |
readUrl(String url)
Configures
readEndpoint(UnaryOperator) url. |
default F |
readUrl(String url,
String scope)
Configures
readEndpoint(UnaryOperator) url with scope |
default F |
removeSelectionTransforms()
Remove any existing transformations added by
transformSelection(com.broadleafcommerce.metadata.dsl.core.Mapping<?>...) . |
default F |
searchable()
Configures the lookup to be searchable.
|
default F |
searchable(boolean isSearchable)
Configures the lookup to be searchable or not
|
default F |
searchableDefaults()
Configures the lookup to be searchable and configures the endpoint to map over the default
`q` and `cq` parameters.
|
default F |
selectComponent(String selectComponentName)
Sets the name of the React component that will be used for rendering the select input.
|
default F |
selectionType(String selectionType)
Sets the
LookupField.Attributes.SELECTION_TYPE for this lookup. |
default F |
transformSelection(List<Mapping<?>> mappings)
Configure a set of
Mapping to transform the option the user selects before the form
state is updated. |
default F |
transformSelection(Mapping<?>... mappings)
Configure a set of
Mapping to transform the option the user selects before the form
state is updated. |
default F |
transformSelection(UnaryOperator<List<Mapping<?>>> fn)
Configure a set of
Mapping to transform the option the user selects before the form
state is updated. |
default F |
valueKey(String valueKey)
Sets the name of the value key.
|
default F |
valueSelection()
Configures the lookup with the
LookupField.SelectionTypes.VALUE selection type. |
implicitFilter, implicitFilters, implicitFilters
clearDependentFields, dependentField, dependentFields, parentIdField
decorated, defaultValue, getDefaultValue, getName, getPlaceholder, getRequiredMessage, getValidationSchema, isReadOnly, isRequired, isShowInQueryBuilder, name, notReadOnly, notRequired, placeholder, placeholder, readOnly, readOnly, required, required, required, required, requiredMessage, requiredMessage, setDefaultValue, setName, setPlaceholder, setReadOnly, setRequired, setRequiredMessage, setShowInQueryBuilder, setValidationSchema, validationMethod, validationSchema, validationSchema
getHelpText, getHint, getTooltip, helpText, helpText, hidden, hidden, hint, hint, isHidden, notHidden, setHelpText, setHidden, setHint, setTooltip, tooltip, tooltip
addAction, addAction, addComponent, addEndpoint, addEndpoint, apply, attribute, augmentationKey, classifier, clearConditionals, clearEndpoints, conditional, conditionals, description, description, findAction, findAction, findActions, findAttribute, findComponent, findComponent, findComponents, findEndpoint, findEndpoint, findEndpoints, get, get, getAction, getAction, getActions, getActionsList, getAttribute, getAttribute, getAttributes, getAugmentationKey, getClassifier, getComponent, getComponent, getComponents, getComponentsList, getConditionals, getDescription, getEndpoint, getEndpoint, getEndpoints, getEndpointsList, getId, getLabel, getOrder, getScope, getType, hasAction, hasAttribute, hasComponent, hasEndpoint, id, isAugmentable, isTranslatable, label, label, notTranslatable, order, removeAction, removeAttribute, removeComponent, removeEndpoint, scope, self, setActions, setAttributes, setAugmentationKey, setClassifier, setComponents, setConditionals, setDescription, setEndpoints, setId, setLabel, setOrder, setScope, setTranslatable, setType, translatable, translatable, type
compareTo
catalogTrackable, notCatalogTrackable, notSandboxTrackable, sandboxTrackable
default F readEndpoint(PageableEndpoint<?> endpoint)
PageableEndpoint
and
supports different paging strategies.endpoint
- the endpointdefault F readEndpoint(UnaryOperator<PageableEndpoint<?>> fn)
PageableEndpoint
and
supports different paging strategies.fn
- function to configure the endpointdefault F readUrl(String url)
readEndpoint(UnaryOperator)
url.default F readScope(String scope)
readEndpoint(UnaryOperator)
scope.default F readUrl(String url, String scope)
readEndpoint(UnaryOperator)
url with scopedefault PageableEndpoint<?> getReadEndpoint()
default Optional<PageableEndpoint<?>> findReadEndpoint()
default F hydrateEndpoint(Endpoint<?> endpoint)
This is only necessary when only the option value is being stored in the property as when
configured with a valueSelection()
. This may be necessary in certain
optionSelection()
situations when the option being stored is heavily transformed by
transformSelection(Mapping[])
.
endpoint
- the hydrate endpointdefault F hydrateEndpoint(UnaryOperator<Endpoint<?>> fn)
This is only necessary when only the option value is being stored in the property as when
configured with a valueSelection()
. This may be necessary in certain
optionSelection()
situations when the option being stored is heavily transformed by
transformSelection(Mapping[])
.
fn
- a function to configure the hydrate endpointdefault F hydrateUrl(String url)
hydrateEndpoint(UnaryOperator)
url.default F hydrateScope(String scope)
hydrateEndpoint(UnaryOperator)
url.default F hydrateUrl(String url, String scope)
hydrateEndpoint(UnaryOperator)
url and scope.default Endpoint<?> getHydrateEndpoint()
default Optional<Endpoint<?>> findHydrateEndpoint()
default F searchable(boolean isSearchable)
isSearchable
- whether or not searchabledefault F searchable()
searchableDefaults()
.default boolean isSearchable()
default F searchableDefaults()
searchable(boolean)
should be used and the readEndpoint(UnaryOperator)
configured
with the parameters.default F notSearchable()
searchable()
is
not used.default F multi(boolean isMulti)
default F multi()
For configurations where valueSelection()
is chosen, the selected options will have
their values persisted in an array.
For configurations where optionSelection()
is chosen, the selected options will
themselves be stored in an array.
default F notMulti()
default F selectionType(String selectionType)
LookupField.Attributes.SELECTION_TYPE
for this lookup. This attribute drives the way in
which the option chosen by the user is persisted within the form state.selectionType
- the modal component namefor more details on the different selection types
,
for behavior to select only the option's value
,
for behavior to select the entire option
default F valueSelection()
LookupField.SelectionTypes.VALUE
selection type. This engages
behavior that will cause only the selected option's value to be stored within the form state
for this field.
Note, the value of the selected option is driven by the valueKey(String)
, which
defaults to "id".
default F optionSelection()
LookupField.SelectionTypes.OPTION
selection type. This engages
behavior that will cause the entire selected option to be stored within the form state for
this field.
Note, the option that is stored may be different from the data selected if this lookup is
configured with transformSelection(Mapping[])
, as that transforms the selected value
before persistence.
default F transformSelection(Mapping<?>... mappings)
Mapping
to transform the option the user selects before the form
state is updated. For LookupField.SelectionTypes.OPTION
, this can be used to transform the chosen
option into a new structure. For LookupField.SelectionTypes.VALUE
, this can be used to map over
additional properties from the chosen option outside of the option's value.default F transformSelection(List<Mapping<?>> mappings)
Mapping
to transform the option the user selects before the form
state is updated. For LookupField.SelectionTypes.OPTION
, this can be used to transform the chosen
option into a new structure. For LookupField.SelectionTypes.VALUE
, this can be used to map over
additional properties from the chosen option outside of the option's value.default F transformSelection(UnaryOperator<List<Mapping<?>>> fn)
Mapping
to transform the option the user selects before the form
state is updated. For LookupField.SelectionTypes.OPTION
, this can be used to transform the chosen
option into a new structure. For LookupField.SelectionTypes.VALUE
, this can be used to map over
additional properties from the chosen option outside of the option's value.default F removeSelectionTransforms()
transformSelection(com.broadleafcommerce.metadata.dsl.core.Mapping<?>...)
.default F labelKey(String labelKey)
labelKey
- the label keydefault F valueKey(String valueKey)
valueKey
- the label keydefault F loadingMessage(String loadingMessageKey)
loadingMessageKey
- the label keydefault F noOptionsMessage(String noOptionsMessageKey)
noOptionsMessageKey
- the label keydefault F selectComponent(String selectComponentName)
selectComponentName
- the modal component namedefault F modalComponent(String modalComponent)
Note, you must configure the modal component metadata using modalSearch(java.util.function.UnaryOperator<com.broadleafcommerce.metadata.dsl.core.extension.fields.LookupFieldModal<?>>)
modalComponent
- the modal component namedefault F modalToggleLabel(String modalLabelKey)
Note, you must configure the modal component metadata using modalSearch(java.util.function.UnaryOperator<com.broadleafcommerce.metadata.dsl.core.extension.fields.LookupFieldModal<?>>)
modalLabelKey
- the message keydefault Optional<LookupFieldModal<?>> findModal()
LookupField.ViewTypes.LOOKUP_MODAL
configured for this lookup.
Note, the metadata this retrieves can be configured using modalSearch(java.util.function.UnaryOperator<com.broadleafcommerce.metadata.dsl.core.extension.fields.LookupFieldModal<?>>)
.
default F modalSearch(UnaryOperator<LookupFieldModal<?>> fn)
Note, you can use modalComponent(java.lang.String)
to configure a custom React component for the
modal, or modalToggleLabel(java.lang.String)
to configure the label for the modal toggle button.
Lastly, modal search can be disabled again using notModalSearch()
.
fn
- a function that further configures the search modaldefault F notModalSearch()
Copyright © 2021. All rights reserved.