Feat v0.6.3 dead code sweep (#38)
All checks were successful
All checks were successful
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #38.
This commit is contained in:
@@ -120,22 +120,21 @@ var ValidAudiences = map[string]bool{
|
||||
|
||||
// ── Typed Form Template ─────────────────────
|
||||
|
||||
// TypedFormTemplate is the structured form_template schema (v0.29.3).
|
||||
// v0.35.0: added Fieldsets for progressive multi-step forms.
|
||||
// TypedFormTemplate is the structured form_template schema.
|
||||
type TypedFormTemplate struct {
|
||||
Fields []FormField `json:"fields"`
|
||||
Fieldsets []FormFieldset `json:"fieldsets,omitempty"` // v0.35.0: multi-step form groups
|
||||
Fieldsets []FormFieldset `json:"fieldsets,omitempty"`
|
||||
Hooks *FormHooks `json:"hooks,omitempty"`
|
||||
}
|
||||
|
||||
// FormFieldset groups fields into a labelled step for progressive forms (v0.35.0).
|
||||
// FormFieldset groups fields into a labelled step for progressive forms.
|
||||
// When fieldsets is present, top-level fields is ignored.
|
||||
type FormFieldset struct {
|
||||
Label string `json:"label"`
|
||||
Fields []FormField `json:"fields"`
|
||||
}
|
||||
|
||||
// FieldCondition controls conditional visibility of a form field (v0.35.0).
|
||||
// FieldCondition controls conditional visibility of a form field.
|
||||
// When set, the field is shown/validated only if the condition is met.
|
||||
type FieldCondition struct {
|
||||
When string `json:"when"` // key of the field to check
|
||||
@@ -153,7 +152,7 @@ type FormField struct {
|
||||
Default interface{} `json:"default,omitempty"`
|
||||
Options []FormOption `json:"options,omitempty"`
|
||||
Validation *FormValidation `json:"validation,omitempty"`
|
||||
Condition *FieldCondition `json:"condition,omitempty"` // v0.35.0: conditional visibility
|
||||
Condition *FieldCondition `json:"condition,omitempty"`
|
||||
}
|
||||
|
||||
// FormOption is a choice for select fields.
|
||||
@@ -200,7 +199,6 @@ func ParseTypedFormTemplate(raw json.RawMessage) *TypedFormTemplate {
|
||||
return nil
|
||||
}
|
||||
|
||||
// v0.35.0: If fieldsets present, flatten into fields for backward compat
|
||||
if len(tpl.Fieldsets) > 0 {
|
||||
var allFields []FormField
|
||||
for _, fs := range tpl.Fieldsets {
|
||||
@@ -237,7 +235,6 @@ type FieldError struct {
|
||||
func ValidateFormData(tpl *TypedFormTemplate, data map[string]interface{}) []FieldError {
|
||||
var errs []FieldError
|
||||
for _, f := range tpl.Fields {
|
||||
// v0.35.0: Skip fields whose condition is not met
|
||||
if f.Condition != nil && !evaluateFieldCondition(f.Condition, data) {
|
||||
continue
|
||||
}
|
||||
@@ -392,7 +389,7 @@ func validateSelect(f FormField, val interface{}) []FieldError {
|
||||
return []FieldError{{Key: f.Key, Message: f.Label + " is not a valid option"}}
|
||||
}
|
||||
|
||||
// ── Field Condition Evaluator (v0.35.0) ─────
|
||||
// ── Field Condition Evaluator ─────
|
||||
|
||||
// evaluateFieldCondition checks if a conditional field should be visible/validated.
|
||||
func evaluateFieldCondition(cond *FieldCondition, data map[string]interface{}) bool {
|
||||
@@ -505,7 +502,7 @@ type WorkflowAssignment struct {
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
// ── Workflow Signoff (v0.3.4) ───────────────
|
||||
// ── Workflow Signoff ───────────────
|
||||
|
||||
// WorkflowSignoff records a user's approval or rejection at a stage boundary.
|
||||
type WorkflowSignoff struct {
|
||||
|
||||
Reference in New Issue
Block a user