diff --git a/demo-api/collections/fields/testfield.yml b/demo-api/collections/fields/testfield.yml index c47ee99..a6a7c38 100644 --- a/demo-api/collections/fields/testfield.yml +++ b/demo-api/collections/fields/testfield.yml @@ -1,6 +1,5 @@ name: testfield type: string meta: - label: - de: test - \ No newline at end of file + label: + de: test diff --git a/schemas/api-config/collection.json b/schemas/api-config/collection.json index 9bb4acb..35a94cf 100644 --- a/schemas/api-config/collection.json +++ b/schemas/api-config/collection.json @@ -26,130 +26,31 @@ "type": "object", "description": "meta object used for admin ui configuration", "additionalProperties": true, + "allOf": [{ "$ref": "collectionNavigation.json" }], "properties": { - "label": { - "$ref": "field.json#/definitions/i18nString" - }, - "muiIcon": { - "type": "string", - "description": "material ui icon name" - }, "rowIdentTpl": { "description": "template which evaluates to short string to identify entry in pe. select boxes", "$ref": "field.json#/definitions/evalExpressions" }, - "defaultSort": { - "type": "object", - "description": "default sort in admin ui lists", - "additionalProperties": false, - "properties": { - "field": { - "$ref": "field.json#/definitions/fieldSource" - }, - "order": { - "description": "sort order", - "enum": ["ASC", "DESC"] + "subNavigation": { + "oneOf": [ + { "$comment": "for include tag", "type": "string" }, + { + "type": "array", + "description": "sub navigation of collection", + "items": { + "oneOf": [ + { + "$comment": "for include tag", + "type": "string" + }, + { + "$ref": "collectionNavigation.json" + } + ] + } } - } - }, - "views": { - "type": "array", - "description": "list views", - "items": { - "type": "object", - "properties": { - "mediaQuery": { - "type": "string", - "description": "css media query to select this view in ui" - } - }, - "oneOf": [ - { - "properties": { - "type": { - "const": "simpleList" - }, - "primaryText": { - "oneOf": [ - { - "$ref": "field.json#/definitions/fieldSource" - }, - { - "$ref": "field.json#/definitions/evalExpressions" - } - ] - }, - "secondaryText": { - "oneOf": [ - { - "$ref": "field.json#/definitions/fieldSource" - }, - { - "$ref": "field.json#/definitions/evalExpressions" - } - ] - }, - "tertiaryText": { - "oneOf": [ - { - "$ref": "field.json#/definitions/fieldSource" - }, - { - "$ref": "field.json#/definitions/evalExpressions" - } - ] - } - }, - "required": ["type", "primaryText"] - }, - { - "properties": { - "type": { - "const": "table" - }, - "columns": { - "type": "array", - "items": { - "oneOf": [ - { - "anyOf": [ - { - "$ref": "field.json#/definitions/fieldSource" - }, - { - "type": "object", - "properties": { - "label": { - "$ref": "field.json#/definitions/i18nString" - } - } - } - ] - }, - { - "allOf": [ - { - "$ref": "field.json#/definitions/evalExpressions" - }, - { - "properties": { - "label": { - "$ref": "field.json#/definitions/i18nString" - } - } - } - ] - } - ] - }, - "minItems": 1 - } - }, - "required": ["type", "columns"] - } - ], - "required": ["type"] - } + ] } } }, diff --git a/schemas/api-config/collectionNavigation.json b/schemas/api-config/collectionNavigation.json new file mode 100644 index 0000000..c78aaa6 --- /dev/null +++ b/schemas/api-config/collectionNavigation.json @@ -0,0 +1,143 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "JSON Schema tibi-server collection meta navigation configuration", + "description": "tibi-server collection navigation linter", + "type": "object", + "additionalProperties": true, + "patternProperties": { + "^x\\-": { + "description": "template property" + } + }, + "required": ["label"], + "properties": { + "name": { + "type": "string", + "description": "name of navigation" + }, + "label": { + "$ref": "field.json#/definitions/i18nString" + }, + "muiIcon": { + "type": "string", + "description": "material ui icon name" + }, + "defaultSort": { + "type": "object", + "description": "default sort in admin ui lists", + "additionalProperties": false, + "properties": { + "field": { + "$ref": "field.json#/definitions/fieldSource" + }, + "order": { + "description": "sort order", + "enum": ["ASC", "DESC"] + } + } + }, + "filter": { + "type": "object", + "description": "filter for prefiltering collection view" + }, + "views": { + "type": "array", + "description": "list views", + "items": { + "type": "object", + "properties": { + "mediaQuery": { + "type": "string", + "description": "css media query to select this view in ui" + } + }, + "oneOf": [ + { + "properties": { + "type": { + "const": "simpleList" + }, + "primaryText": { + "oneOf": [ + { + "$ref": "field.json#/definitions/fieldSource" + }, + { + "$ref": "field.json#/definitions/evalExpressions" + } + ] + }, + "secondaryText": { + "oneOf": [ + { + "$ref": "field.json#/definitions/fieldSource" + }, + { + "$ref": "field.json#/definitions/evalExpressions" + } + ] + }, + "tertiaryText": { + "oneOf": [ + { + "$ref": "field.json#/definitions/fieldSource" + }, + { + "$ref": "field.json#/definitions/evalExpressions" + } + ] + } + }, + "required": ["type", "primaryText"] + }, + { + "properties": { + "type": { + "const": "table" + }, + "columns": { + "type": "array", + "items": { + "oneOf": [ + { + "anyOf": [ + { + "$ref": "field.json#/definitions/fieldSource" + }, + { + "type": "object", + "properties": { + "label": { + "$ref": "field.json#/definitions/i18nString" + } + } + } + ] + }, + { + "allOf": [ + { + "$ref": "field.json#/definitions/evalExpressions" + }, + { + "properties": { + "label": { + "$ref": "field.json#/definitions/i18nString" + } + } + } + ] + } + ] + }, + "minItems": 1 + } + }, + "required": ["type", "columns"] + } + ], + "required": ["type"] + } + } + } +} diff --git a/schemas/api-config/field.json b/schemas/api-config/field.json index b10fd60..25e7968 100644 --- a/schemas/api-config/field.json +++ b/schemas/api-config/field.json @@ -172,6 +172,36 @@ ] } } + }, + "dependsOn": { + "description": "depends on rule", + "oneOf": [ + { "type": "string" }, + { + "type": "object", + "properties": { + "eval": { + "type": "string", + "description": "js code with $, $this, $parent and $stack variables" + } + } + } + ] + }, + "defaultValue": { + "description": "default value or code to get the value", + "oneOf": [ + { "type": "string" }, + { + "type": "object", + "properties": { + "eval": { + "type": "string", + "description": "js code with $navigation variable" + } + } + } + ] } } }