JsonSchema:SchemaBuilder/EnumTemplate
JsonSchema:SchemaBuilder/EnumTemplate
From Wikisphere
Jump to navigation
Jump to search
| $schema | "http://json-schema.org/draft-07/schema#" |
|---|
| $id | "https://wikisphere.org/wiki/JsonSchema:EnumTemplate" |
|---|
| title | "Enum template" |
|---|
| description | "Where dropdown options come from: one watched field, or a mix of watched fields and static entries." |
|---|
| type | "object" |
|---|
| definitions | | DynamicEntry | | title | "Dynamic entry" |
|---|
| description | "Options come from another field in this form (its value is watched and re-evaluated on change)." |
|---|
| type | "object" |
|---|
| properties | | source | | title | "Watched field" |
|---|
| description | "Name of the field whose value supplies the options." |
|---|
| type | "string" |
|---|
| examples | | "countries" |
| "users" |
| "categories" |
|
|---|
|
|---|
| title | | title | "Title template" |
|---|
| description | "Display label for each option. Use {{item.property}} to reference fields of the current item." |
|---|
| type | "string" |
|---|
| examples | | "{{item.name}}" |
| "{{item.name}} ({{item.email}})" |
|
|---|
|
|---|
| value | | title | "Value template" |
|---|
| description | "Underlying value for each option. Use {{item.property}} to reference fields of the current item." |
|---|
| type | "string" |
|---|
| examples | | "{{item.id}}" |
| "user:{{item.id}}" |
|
|---|
|
|---|
| filter | | title | "Filter expression" |
|---|
| description | "Only keep items where this template evaluates to a truthy value." |
|---|
| type | "string" |
|---|
| examples | | "{{item.active}}" |
| "{{item.status === 'published'}}" |
|
|---|
|
|---|
| slice | | title | "Slice" |
|---|
| description | "Take a sub-range of items, like Array.prototype.slice. One value = from index to end; two values = start and end." |
|---|
| type | "array" |
|---|
| items | |
|---|
| minItems | 1 |
|---|
| maxItems | 2 |
|---|
| examples | |
|---|
|
|---|
| sort | | title | "Sort" |
|---|
| description | "Sort options by value. Titles follow their values." |
|---|
| type | "string" |
|---|
| enum | |
|---|
| default | "asc" |
|---|
| options | |
|---|
|
|---|
|
|---|
| required | |
|---|
| additionalProperties | false |
|---|
|
|---|
| StaticEntry | | title | "Static entry" |
|---|
| description | "A fixed list of options. Use to mix in sentinel entries like "none" or "inherit" alongside dynamic ones." |
|---|
| type | "object" |
|---|
| properties | | items | | title | "Entries" |
|---|
| description | "Fixed list of options." |
|---|
| type | "array" |
|---|
| minItems | 1 |
|---|
| items | | title | "Option" |
|---|
| type | "object" |
|---|
| properties | | value | | title | "Value" |
|---|
| description | "The underlying value submitted for this option." |
|---|
| type | "string" |
|---|
| examples | |
|---|
|
|---|
| title | | title | "Title" |
|---|
| description | "Optional display label. Defaults to the value if omitted." |
|---|
| type | "string" |
|---|
| examples | | "— None —" |
| "Inherit from parent" |
|
|---|
|
|---|
|
|---|
| required | |
|---|
| additionalProperties | false |
|---|
|
|---|
| examples | | value | "none" |
|---|
| title | "— None —" |
|---|
|
| value | "inherit" |
|---|
| title | "— Inherit —" |
|---|
|
|
|
|
| value | "archived" |
|---|
| title | "Archived (read-only)" |
|---|
|
|
|
|---|
|
|---|
|
|---|
| required | |
|---|
| additionalProperties | false |
|---|
|
|---|
|
|---|
| oneOf | | title | "Single source" |
|---|
| description | "Options come from one watched field." |
|---|
| $ref | "#/definitions/DynamicEntry" |
|---|
| examples | |
| source | "users" |
|---|
| value | "{{item.id}}" |
|---|
| title | "{{item.name}}" |
|---|
| filter | "{{item.active}}" |
|---|
| sort | "asc" |
|---|
|
|
|---|
|
| title | "Multiple sources" |
|---|
| description | "Combine watched fields and static entries into one dropdown. Each entry contributes its own options, in order." |
|---|
| type | "array" |
|---|
| items | | oneOf | | $ref | "#/definitions/DynamicEntry" |
|---|
|
| $ref | "#/definitions/StaticEntry" |
|---|
|
|
|---|
|
|---|
| minItems | 1 |
|---|
| examples | | source | "items" |
|---|
| value | "{{item.id}}" |
|---|
| title | "{{item.name}}" |
|---|
|
| items | | value | "none" |
|---|
| title | "— None —" |
|---|
|
| value | "inherit" |
|---|
| title | "— Inherit —" |
|---|
|
|
|---|
|
|
| source | "groups" |
|---|
| value | "group:{{item.id}}" |
|---|
| title | "Group: {{item.name}}" |
|---|
|
| source | "users" |
|---|
| value | "user:{{item.id}}" |
|---|
| title | "User: {{item.name}}" |
|---|
|
|
|
|---|
|
|
|---|