Use fieldState
This commit is contained in:
parent
56d5a0b8f6
commit
33e37261b2
|
@ -6,6 +6,7 @@
|
||||||
export let field
|
export let field
|
||||||
export let label
|
export let label
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
export let readonly = false
|
||||||
export let compact = false
|
export let compact = false
|
||||||
export let validation
|
export let validation
|
||||||
export let extensions
|
export let extensions
|
||||||
|
@ -71,6 +72,7 @@
|
||||||
{label}
|
{label}
|
||||||
{field}
|
{field}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
{readonly}
|
||||||
{validation}
|
{validation}
|
||||||
type="attachment"
|
type="attachment"
|
||||||
bind:fieldState
|
bind:fieldState
|
||||||
|
@ -81,7 +83,7 @@
|
||||||
{#if fieldState}
|
{#if fieldState}
|
||||||
<CoreDropzone
|
<CoreDropzone
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled || fieldState.readonly}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
on:change={handleChange}
|
on:change={handleChange}
|
||||||
{processFiles}
|
{processFiles}
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
{label}
|
{label}
|
||||||
{field}
|
{field}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
{readonly}
|
||||||
{validation}
|
{validation}
|
||||||
defaultValue={isTruthy(defaultValue)}
|
defaultValue={isTruthy(defaultValue)}
|
||||||
type="boolean"
|
type="boolean"
|
||||||
|
@ -50,7 +51,7 @@
|
||||||
<CoreCheckbox
|
<CoreCheckbox
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
{readonly}
|
readonly={fieldState.readonly}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
{size}
|
{size}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
export let label
|
export let label
|
||||||
export let type = "barcodeqr"
|
export let type = "barcodeqr"
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
export let readonly = false
|
||||||
export let validation
|
export let validation
|
||||||
export let defaultValue = ""
|
export let defaultValue = ""
|
||||||
export let onChange
|
export let onChange
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
{label}
|
{label}
|
||||||
{field}
|
{field}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
{readonly}
|
||||||
{validation}
|
{validation}
|
||||||
{defaultValue}
|
{defaultValue}
|
||||||
{type}
|
{type}
|
||||||
|
@ -42,7 +44,7 @@
|
||||||
<CodeScanner
|
<CodeScanner
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
on:change={handleUpdate}
|
on:change={handleUpdate}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled || fieldState.readonly}
|
||||||
{allowManualEntry}
|
{allowManualEntry}
|
||||||
scanButtonText={scanText}
|
scanButtonText={scanText}
|
||||||
{beepOnScan}
|
{beepOnScan}
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
{label}
|
{label}
|
||||||
{field}
|
{field}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
{readonly}
|
||||||
{validation}
|
{validation}
|
||||||
{defaultValue}
|
{defaultValue}
|
||||||
type="datetime"
|
type="datetime"
|
||||||
|
@ -41,7 +42,7 @@
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
on:change={handleChange}
|
on:change={handleChange}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
{readonly}
|
readonly={fieldState.readonly}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
appendTo={document.getElementById("flatpickr-root")}
|
appendTo={document.getElementById("flatpickr-root")}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
export let defaultValue
|
export let defaultValue
|
||||||
export let type
|
export let type
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
export let readonly = false
|
||||||
export let validation
|
export let validation
|
||||||
|
|
||||||
// Get contexts
|
// Get contexts
|
||||||
|
@ -29,6 +30,7 @@
|
||||||
type,
|
type,
|
||||||
defaultValue,
|
defaultValue,
|
||||||
disabled,
|
disabled,
|
||||||
|
readonly,
|
||||||
validation,
|
validation,
|
||||||
formStep
|
formStep
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
export let theme
|
export let theme
|
||||||
export let size
|
export let size
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
export let readonly = false
|
||||||
export let actionType = "Create"
|
export let actionType = "Create"
|
||||||
export let initialFormStep = 1
|
export let initialFormStep = 1
|
||||||
|
|
||||||
|
@ -39,7 +40,7 @@
|
||||||
$: schemaKey = generateSchemaKey(schema)
|
$: schemaKey = generateSchemaKey(schema)
|
||||||
$: initialValues = getInitialValues(actionType, dataSource, $context)
|
$: initialValues = getInitialValues(actionType, dataSource, $context)
|
||||||
$: resetKey = Helpers.hashString(
|
$: resetKey = Helpers.hashString(
|
||||||
schemaKey + JSON.stringify(initialValues) + disabled
|
schemaKey + JSON.stringify(initialValues) + disabled + readonly
|
||||||
)
|
)
|
||||||
|
|
||||||
// Returns the closes data context which isn't a built in context
|
// Returns the closes data context which isn't a built in context
|
||||||
|
@ -97,6 +98,7 @@
|
||||||
{theme}
|
{theme}
|
||||||
{size}
|
{size}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
{readonly}
|
||||||
{actionType}
|
{actionType}
|
||||||
{schema}
|
{schema}
|
||||||
{table}
|
{table}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
export let dataSource
|
export let dataSource
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
export let readonly = false
|
||||||
export let initialValues
|
export let initialValues
|
||||||
export let size
|
export let size
|
||||||
export let schema
|
export let schema
|
||||||
|
@ -148,6 +149,7 @@
|
||||||
type,
|
type,
|
||||||
defaultValue = null,
|
defaultValue = null,
|
||||||
fieldDisabled = false,
|
fieldDisabled = false,
|
||||||
|
fieldReadOnly = false,
|
||||||
validationRules,
|
validationRules,
|
||||||
step = 1
|
step = 1
|
||||||
) => {
|
) => {
|
||||||
|
@ -205,6 +207,7 @@
|
||||||
error: initialError,
|
error: initialError,
|
||||||
disabled:
|
disabled:
|
||||||
disabled || fieldDisabled || (isAutoColumn && !editAutoColumns),
|
disabled || fieldDisabled || (isAutoColumn && !editAutoColumns),
|
||||||
|
readonly: readonly || fieldReadOnly,
|
||||||
defaultValue,
|
defaultValue,
|
||||||
validator,
|
validator,
|
||||||
lastUpdate: Date.now(),
|
lastUpdate: Date.now(),
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
{label}
|
{label}
|
||||||
{field}
|
{field}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
{readonly}
|
||||||
{validation}
|
{validation}
|
||||||
{defaultValue}
|
{defaultValue}
|
||||||
type="json"
|
type="json"
|
||||||
|
@ -61,7 +62,7 @@
|
||||||
value={serialiseValue(fieldState.value)}
|
value={serialiseValue(fieldState.value)}
|
||||||
on:change={handleChange}
|
on:change={handleChange}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
{readonly}
|
readonly={fieldState.readonly}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
{label}
|
{label}
|
||||||
{field}
|
{field}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
{readonly}
|
||||||
{validation}
|
{validation}
|
||||||
{defaultValue}
|
{defaultValue}
|
||||||
type="longform"
|
type="longform"
|
||||||
|
@ -72,7 +73,7 @@
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
on:change={handleChange}
|
on:change={handleChange}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
{readonly}
|
readonly={fieldState.readonly}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
|
@ -90,7 +91,7 @@
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
on:change={handleChange}
|
on:change={handleChange}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
{readonly}
|
readonly={fieldState.readonly}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
{field}
|
{field}
|
||||||
{label}
|
{label}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
{readonly}
|
||||||
{validation}
|
{validation}
|
||||||
defaultValue={expandedDefaultValue}
|
defaultValue={expandedDefaultValue}
|
||||||
type="array"
|
type="array"
|
||||||
|
@ -72,7 +73,7 @@
|
||||||
getOptionValue={flatOptions ? x => x : x => x.value}
|
getOptionValue={flatOptions ? x => x : x => x.value}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
{readonly}
|
readonly={fieldState.readonly}
|
||||||
on:change={handleChange}
|
on:change={handleChange}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
{options}
|
{options}
|
||||||
|
@ -83,7 +84,7 @@
|
||||||
value={fieldState.value || []}
|
value={fieldState.value || []}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
{readonly}
|
readonly={fieldState.readonly}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
{options}
|
{options}
|
||||||
{direction}
|
{direction}
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
{field}
|
{field}
|
||||||
{label}
|
{label}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
{readonly}
|
||||||
{validation}
|
{validation}
|
||||||
{defaultValue}
|
{defaultValue}
|
||||||
type="options"
|
type="options"
|
||||||
|
@ -59,7 +60,7 @@
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
{readonly}
|
readonly={fieldState.readonly}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
{options}
|
{options}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
|
@ -74,7 +75,7 @@
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
{readonly}
|
readonly={fieldState.readonly}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
{options}
|
{options}
|
||||||
{direction}
|
{direction}
|
||||||
|
|
|
@ -184,6 +184,7 @@
|
||||||
{label}
|
{label}
|
||||||
{field}
|
{field}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
{readonly}
|
||||||
{validation}
|
{validation}
|
||||||
defaultValue={expandedDefaultValue}
|
defaultValue={expandedDefaultValue}
|
||||||
{type}
|
{type}
|
||||||
|
@ -201,7 +202,7 @@
|
||||||
on:loadMore={loadMore}
|
on:loadMore={loadMore}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
{readonly}
|
readonly={fieldState.readonly}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
getOptionLabel={getDisplayName}
|
getOptionLabel={getDisplayName}
|
||||||
getOptionValue={option => option._id}
|
getOptionValue={option => option._id}
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
export let placeholder
|
export let placeholder
|
||||||
export let type = "text"
|
export let type = "text"
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
|
export let readonly = false
|
||||||
export let validation
|
export let validation
|
||||||
export let defaultValue = ""
|
export let defaultValue = ""
|
||||||
export let align
|
export let align
|
||||||
export let onChange
|
export let onChange
|
||||||
export let readonly = false
|
|
||||||
|
|
||||||
let fieldState
|
let fieldState
|
||||||
let fieldApi
|
let fieldApi
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
{label}
|
{label}
|
||||||
{field}
|
{field}
|
||||||
{disabled}
|
{disabled}
|
||||||
|
{readonly}
|
||||||
{validation}
|
{validation}
|
||||||
{defaultValue}
|
{defaultValue}
|
||||||
type={type === "number" ? "number" : "string"}
|
type={type === "number" ? "number" : "string"}
|
||||||
|
@ -40,12 +41,12 @@
|
||||||
value={fieldState.value}
|
value={fieldState.value}
|
||||||
on:change={handleChange}
|
on:change={handleChange}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
|
readonly={fieldState.readonly}
|
||||||
error={fieldState.error}
|
error={fieldState.error}
|
||||||
id={fieldState.fieldId}
|
id={fieldState.fieldId}
|
||||||
{placeholder}
|
{placeholder}
|
||||||
{type}
|
{type}
|
||||||
{align}
|
{align}
|
||||||
{readonly}
|
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</Field>
|
</Field>
|
||||||
|
|
Loading…
Reference in New Issue