-
Notifications
You must be signed in to change notification settings - Fork 1
Embedded Components
Table of Content
A React Component for rendering Formatted Instance's field in Search Form or Create/Edit/Show Form.
Props:
Name | Type | Necessity | Default | Description |
---|---|---|---|---|
readOnly | boolean | optional | false | Whether field value can be changed |
value | serializable | mandatory | - | Persistent field value formated to appropriate UI Type |
onChange | function | mandatory | - | Handler called when component's value changes.
|
onBlur | function | optional | - | Handler called when component loses focus.
|
In CRUD Editor here are two embedded FieldInputComponents:
FieldInputComponent | id |
---|---|
BUILTIN_INPUT | "input" |
BUILTIN_RANGE_INPUT | "rangeInput" |
For being treated as embedded, string id must be used. Additionally, the embedded FieldInputComponents can be imported from CRUD Editor package:
import { BUILTIN_INPUT, BUILTIN_RANGE_INPUT } from '@opuscapita/react-crudeditor';
Embedded FieldInputComponents also accept all props defined for FieldInputComponent.
Singular input field.
props.type | Description | UI Type | Auto-convertable field types |
---|---|---|---|
string |
Regular input field which works with strings | UI_TYPE_STRING | FIELD_TYPE_STRING, FIELD_TYPE_BOOLEAN, FIELD_TYPE_DECIMAL, FIELD_TYPE_INTEGER, FIELD_TYPE_STRING_DATE, FIELD_TYPE_STRING_DECIMAL, FIELD_TYPE_STRING_INTEGER |
checkbox |
Checkbox | UI_TYPE_BOOLEAN | FIELD_TYPE_BOOLEAN |
date |
DateInput | UI_TYPE_DATE | FIELD_TYPE_STRING_DATE |
integer |
Input which accepts only numbers and - sign and formats using i18n.formatNumber |
UI_TYPE_INTEGER | FIELD_TYPE_STRING_INTEGER, FIELD_TYPE_INTEGER, FIELD_TYPE_BOOLEAN, FIELD_TYPE_STRING |
decimal |
Input which accepts only numbers and - sign and formats using i18n.formatDecimalNumber |
UI_TYPE_DECIMAL | FIELD_TYPE_STRING_DECIMAL, FIELD_TYPE_DECIMAL, FIELD_TYPE_BOOLEAN, FIELD_TYPE_STRING |
Range input field.
props.type | Description | UI Type | Auto-convertable field types |
---|---|---|---|
string |
Range input which works with strings | UI_TYPE_STRING_RANGE_OBJECT | FIELD_TYPE_DECIMAL_RANGE, FIELD_TYPE_INTEGER_RANGE, FIELD_TYPE_STRING_DATE_RANGE, FIELD_TYPE_STRING_DECIMAL_RANGE, FIELD_TYPE_STRING_INTEGER_RANGE |
date |
DateRangeInput | UI_TYPE_DATE_RANGE_OBJECT | FIELD_TYPE_STRING_DATE_RANGE |
integer |
Range input which accepts only numbers and - sign and formats using i18n.formatNumber |
UI_TYPE_INTEGER_RANGE_OBJECT | FIELD_TYPE_STRING_INTEGER_RANGE, FIELD_TYPE_INTEGER_RANGE |
decimal |
Range input which accepts only numbers and - sign and formats using i18n.formatDecimalNumber |
UI_TYPE_DECIMAL_RANGE_OBJECT | FIELD_TYPE_STRING_DECIMAL_RANGE, FIELD_TYPE_DECIMAL_RANGE |
If you define just a Field Type in Model Definition's model.fields.<field name>.type (and omit any custom render in searchableFields and formLayout), the following components will be default for the fields:
Field Type | Component | props.type |
---|---|---|
FIELD_TYPE_BOOLEAN | BUILTIN_INPUT | 'checkbox' |
FIELD_TYPE_STRING | BUILTIN_INPUT | 'string' |
FIELD_TYPE_DECIMAL_RANGE | BUILTIN_RANGE_INPUT | 'decimal' |
FIELD_TYPE_INTEGER_RANGE | BUILTIN_RANGE_INPUT | 'integer' |
FIELD_TYPE_STRING_DATE_RANGE | BUILTIN_RANGE_INPUT | 'date' |
FIELD_TYPE_STRING_DECIMAL_RANGE | BUILTIN_RANGE_INPUT | 'string' |
FIELD_TYPE_STRING_INTEGER_RANGE | BUILTIN_RANGE_INPUT | 'string' |
Field Type | Component | props.type |
---|---|---|
FIELD_TYPE_DECIMAL | BUILTIN_INPUT | 'decimal' |
FIELD_TYPE_INTEGER | BUILTIN_INPUT | 'integer' |
FIELD_TYPE_STRING_DATE | BUILTIN_INPUT | 'date' |
FIELD_TYPE_STRING_DECIMAL | BUILTIN_INPUT | 'string' |
FIELD_TYPE_STRING_INTEGER | BUILTIN_INPUT | 'string' |
Field Type | Component | props.type |
---|---|---|
FIELD_TYPE_DECIMAL | BUILTIN_RANGE_INPUT | 'decimal' |
FIELD_TYPE_INTEGER | BUILTIN_RANGE_INPUT | 'integer' |
FIELD_TYPE_STRING_DATE | BUILTIN_RANGE_INPUT | 'date' |
FIELD_TYPE_STRING_DECIMAL | BUILTIN_RANGE_INPUT | 'string' |
FIELD_TYPE_STRING_INTEGER | BUILTIN_RANGE_INPUT | 'string' |
Custom React component for rendering Formated Instance's persistent/composite field value in Search Result listing.
Props:
Name | Type | Necessity | Default | Description |
---|---|---|---|---|
name | string | mandatory | - | Field name from Model Definition's ui.search().resultFields |
instance | object | mandatory | - | Entity instance |
React component for a custom rendering of Tab form in create/edit/show Views.
Props:
Name | Type | Necessity | Default | Description |
---|---|---|---|---|
viewName | string | mandatory | - | View Name |
instance | object | mandatory | - | persistent instance |
doTransition | function | optional | - | Editor State change handler |
React component for a custom View.
Props:
Name | Type | Necessity | Default | Description |
---|---|---|---|---|
viewState | object | mandatory | - | Custom View State |
doTransition | function | optional | - | Editor State change handler |
This handler is called when
- active View changes its State, name argument is optional in such case;
- another View must be displayed, state argument is optional in such case.
function ({
?name: <string, View Name>,
?state: <object, View State>
}) {
...
return; // return value is ignored.
}
Arguments:
Name | Default | Description |
---|---|---|
name | active View Name | To-be-displayed View Name |
state | {} |
Full/sliced to-be-displayed View State |
If View State is sliced, not given or {}
, all not-mentioned properties retain their current values (or default values in case of initial View rendering).