Documentation
¶
Index ¶
- func DefineCheckboxForm(id taskid.TaskImplementationID[bool], priority int, label string, ...) coretask.Task[bool]
- func DefineFileForm(id taskid.TaskImplementationID[upload.UploadResult], priority int, ...) coretask.Task[upload.UploadResult]
- func DefineSetForm[T any](id taskid.TaskImplementationID[T], priority int, label string, ...) coretask.Task[T]
- func DefineTextForm[T any](id taskid.TaskImplementationID[T], priority int, label string, ...) coretask.Task[T]
- func GenerateUploadIDWithTaskContext(ctx context.Context, formId string) string
- type CheckboxFormDefaultValueGenerator
- type CheckboxFormHintGenerator
- type CheckboxFormReadonlyProvider
- type CheckboxFormSpec
- type CheckboxFormValidator
- type SetFormBoolProvider
- type SetFormDefaultValueGenerator
- type SetFormHintGenerator
- type SetFormOptionsProvider
- type SetFormSpec
- type SetFormValidator
- type SetFormValueConverter
- type TextFormDefaultValueGenerator
- type TextFormHintGenerator
- type TextFormReadonlyProvider
- type TextFormSpec
- type TextFormSuggestionsProvider
- type TextFormValidator
- type TextFormValueConverter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefineCheckboxForm ¶ added in v0.60.1
func DefineCheckboxForm(id taskid.TaskImplementationID[bool], priority int, label string, description string, bind func(b *coretask.Binder) CheckboxFormSpec, labelOpts ...coretask.LabelOpt) coretask.Task[bool]
DefineCheckboxForm defines a checkbox form task with a Binder. id, priority, label and description are required for every form. bind runs once, declares the inputs on the Binder, and returns the optional settings whose callbacks read those inputs. A form that reads no input returns its settings without declaring any.
func DefineFileForm ¶ added in v0.60.1
func DefineFileForm(id taskid.TaskImplementationID[upload.UploadResult], priority int, label string, description string, verifier upload.UploadFileVerifier, labelOpts ...coretask.LabelOpt) coretask.Task[upload.UploadResult]
DefineFileForm defines a form task that receives a file uploaded by the user and returns the upload result. verifier checks the uploaded file. The form reads no input, so it declares nothing on the Binder.
func DefineSetForm ¶ added in v0.60.1
func DefineSetForm[T any](id taskid.TaskImplementationID[T], priority int, label string, description string, bind func(b *coretask.Binder) SetFormSpec[T], labelOpts ...coretask.LabelOpt) coretask.Task[T]
DefineSetForm defines a set form task with a Binder. id, priority, label and description are required for every form. bind runs once, declares the inputs on the Binder, and returns the optional settings whose callbacks read those inputs. A form that reads no input returns its settings without declaring any.
func DefineTextForm ¶ added in v0.60.1
func DefineTextForm[T any](id taskid.TaskImplementationID[T], priority int, label string, description string, bind func(b *coretask.Binder) TextFormSpec[T], labelOpts ...coretask.LabelOpt) coretask.Task[T]
DefineTextForm defines a text form task with a Binder. id, priority, label and description are required for every form. bind runs once, declares the inputs on the Binder, and returns the optional settings whose callbacks read those inputs. A form that reads no input returns its settings without declaring any.
Types ¶
type CheckboxFormDefaultValueGenerator ¶ added in v0.59.0
CheckboxFormDefaultValueGenerator generates the default checked state for the checkbox.
type CheckboxFormHintGenerator ¶ added in v0.59.0
type CheckboxFormHintGenerator = func(ctx context.Context, value bool) (string, inspectionmetadata.ParameterHintType, error)
CheckboxFormHintGenerator generates a hint message and its severity type for the checkbox field.
type CheckboxFormReadonlyProvider ¶ added in v0.59.0
CheckboxFormReadonlyProvider determines whether the checkbox should be disabled/readonly.
type CheckboxFormSpec ¶ added in v0.60.1
type CheckboxFormSpec struct {
// Readonly reports whether the field is read only. Defaults to false.
Readonly CheckboxFormReadonlyProvider
// DefaultValue generates the default checked state. Defaults to false.
DefaultValue CheckboxFormDefaultValueGenerator
// Validator validates the checked state. Defaults to a validator that accepts any value.
Validator CheckboxFormValidator
// Hint generates a hint message for the form field. Defaults to no hint.
Hint CheckboxFormHintGenerator
}
CheckboxFormSpec holds the optional settings of a checkbox form defined with DefineCheckboxForm. Callbacks may read inputs declared on the Binder passed to the bind function. A nil callback uses the default.
type CheckboxFormValidator ¶ added in v0.59.0
CheckboxFormValidator validates whether the given boolean value is valid. Returns an empty string when valid, or an error message to display on the frontend. The second return value is used for unrecoverable errors during validation.
type SetFormBoolProvider ¶ added in v0.51.0
SetFormBoolProvider is a function type to provide boolean flags dynamically.
func ConstantBool ¶ added in v0.60.1
func ConstantBool(value bool) SetFormBoolProvider
ConstantBool returns a SetFormBoolProvider that always returns value.
type SetFormDefaultValueGenerator ¶ added in v0.51.0
type SetFormDefaultValueGenerator = func(ctx context.Context, previousValues []string) ([]string, error)
SetFormDefaultValueGenerator is a function type to generate the default value.
func PreviousOrConstantDefaultValue ¶ added in v0.60.1
func PreviousOrConstantDefaultValue(values []string) SetFormDefaultValueGenerator
PreviousOrConstantDefaultValue returns a SetFormDefaultValueGenerator that returns the previous values when they exist, otherwise values.
type SetFormHintGenerator ¶ added in v0.51.0
type SetFormHintGenerator = func(ctx context.Context, value []string, convertedValue any) (string, inspectionmetadata.ParameterHintType, error)
SetFormHintGenerator is a function type to generate a hint string
type SetFormOptionsProvider ¶ added in v0.51.0
type SetFormOptionsProvider = func(ctx context.Context, previousValues []string) ([]inspectionmetadata.SetParameterFormFieldOptionItem, error)
SetFormOptionsProvider is a function to return the list of options.
func ConstantOptions ¶ added in v0.60.1
func ConstantOptions(options ...inspectionmetadata.SetParameterFormFieldOptionItem) SetFormOptionsProvider
ConstantOptions returns a SetFormOptionsProvider that always returns options.
type SetFormSpec ¶ added in v0.60.1
type SetFormSpec[T any] struct { // AllowCustomValue reports whether users can input custom values. Defaults to false. AllowCustomValue SetFormBoolProvider // DisableAddAll reports whether the "Add All" option is disabled. Defaults to false. DisableAddAll SetFormBoolProvider // DisableRemoveAll reports whether the "Remove All" option is disabled. Defaults to false. DisableRemoveAll SetFormBoolProvider // DefaultValue generates the default value of the set form. Defaults to nil. DefaultValue SetFormDefaultValueGenerator // Options provides the available options for the set form. Defaults to an empty slice. Options SetFormOptionsProvider // Validator validates the input string slice. Defaults to a validator that accepts any input. Validator SetFormValidator // Converter converts the input string slice to T. Defaults to a conversion that only works when T is []string. Converter SetFormValueConverter[T] // Hint generates a hint message for the form field. Defaults to no hint. Hint SetFormHintGenerator }
SetFormSpec holds the optional settings of a set form defined with DefineSetForm. Callbacks may read inputs declared on the Binder passed to the bind function. A nil callback or a zero value uses the default.
type SetFormValidator ¶ added in v0.51.0
SetFormValidator is a function to check if the given value is valid or not.
type SetFormValueConverter ¶ added in v0.51.0
SetFormValueConverter is a function type to convert the given string slice value to another type stored in the variable set.
type TextFormDefaultValueGenerator ¶
type TextFormDefaultValueGenerator = func(ctx context.Context, previousValues []string) (string, error)
TextFormDefaultValueGenerator is a function type to generate the default value.
func PreviousOrDefaultValue ¶ added in v0.60.1
func PreviousOrDefaultValue(defaultValue func(ctx context.Context) (string, error)) TextFormDefaultValueGenerator
PreviousOrDefaultValue returns a TextFormDefaultValueGenerator that returns the most recent previous value when one exists, or calls defaultValue to compute the initial default value.
type TextFormHintGenerator ¶
type TextFormHintGenerator = func(ctx context.Context, value string, convertedValue any) (string, inspectionmetadata.ParameterHintType, error)
TextFormHintGenerator is a function type to generate a hint string
type TextFormReadonlyProvider ¶
TextFormReadonlyProvider is a function type to compute if the field is allowed edit or not.
type TextFormSpec ¶ added in v0.60.1
type TextFormSpec[T any] struct { // Readonly reports whether the field is read only. Defaults to false. Readonly TextFormReadonlyProvider // DefaultValue generates the default value of the text form. Defaults to empty string. DefaultValue TextFormDefaultValueGenerator // Suggestions provides suggestions for the text form. Defaults to nil. Suggestions TextFormSuggestionsProvider // Validator validates the input string. Defaults to a validator that accepts any string. Validator TextFormValidator // Converter converts the input string to T. Defaults to a conversion that only works when T is string. Converter TextFormValueConverter[T] // Hint generates a hint message for the form field. Defaults to no hint. Hint TextFormHintGenerator // ValidationTiming specifies when form validation should occur. Defaults to inspectionmetadata.Change. ValidationTiming inspectionmetadata.TextFormValidationTimingType }
TextFormSpec holds the optional settings of a text form defined with DefineTextForm. Callbacks may read inputs declared on the Binder passed to the bind function. A nil callback or a zero value uses the default.
type TextFormSuggestionsProvider ¶
type TextFormSuggestionsProvider = func(ctx context.Context, value string, previousValues []string) ([]string, error)
TextFormSuggestionsProvider is a function to return the list of strings shown in the autocomplete. Return nil instead of empty string array means the autocomplete is disabled for the field.
func ConstantSuggestions ¶ added in v0.60.1
func ConstantSuggestions(suggestions ...string) TextFormSuggestionsProvider
ConstantSuggestions returns a suggestions provider that always returns the given suggestions.
type TextFormValidator ¶
TextFormValidator is a function to check if the given value is valid or not. Returns "" as the result when it has no error, otherwise the returned value is used as an error message on frontend. Returning an error as the 2nd returning value is only when the validator detects an unrecoverble error.