Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed Jan 15, 2024
1 parent 4d6aa3b commit f2cce3c
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
"choices"
]
}
},
{
"$ref": "condition.json"
}
],
"properties": {
"id": {
"type": "string",
"description": "Unique identifier of the property."
},
"value": {
"$id": "#/properties/property/value",
"type": [
Expand Down Expand Up @@ -143,9 +142,6 @@
"$id": "#/properties/property/group",
"type": "string",
"description": "The custom group of a control field."
},
"condition": {
"$ref": "condition.json"
}
}
}
Expand Down
155 changes: 81 additions & 74 deletions packages/element-templates-json-schema-shared/src/defs/condition.json
Original file line number Diff line number Diff line change
@@ -1,94 +1,101 @@
{
"$id": "#/condition",
"type": "object",
"description": "Condition(s) to activate the binding.",
"allOf": [
{
"$ref": "examples.json#/condition"
}
],
"definitions": {
"properties": {
"id": {
"type": "string",
"description": "Unique identifier of the property."
},
"condition": {
"type": "object",
"required": [
"property"
],
"properties": {
"type": {
"$id": "#/condition/type",
"const": "simple",
"description": "The type of the condition.",
"default": "simple"
},
"property": {
"$id": "#/condition/property",
"type": "string",
"description": "The id of the property to check."
}
},
"oneOf": [
"description": "Condition(s) to activate the binding.",
"allOf": [
{
"$ref": "examples.json#/condition"
}
],
"definitions": {
"condition": {
"type": "object",
"required": [
"property"
],
"properties": {
"equals": {
"type": [
"string",
"number",
"boolean"
]
"type": {
"$id": "#/condition/type",
"const": "simple",
"description": "The type of the condition.",
"default": "simple"
},
"property": {
"$id": "#/condition/property",
"type": "string",
"description": "The id of the property to check."
}
},
"required": [
"equals"
"oneOf": [
{
"properties": {
"equals": {
"type": [
"string",
"number",
"boolean"
]
}
},
"required": [
"equals"
]
},
{
"properties": {
"oneOf": {
"type": "array",
"items": {
"type": [
"string",
"number"
]
}
}
},
"required": [
"oneOf"
]
},
{
"properties": {
"isActive": {
"type": "boolean",
"description": "For `true`, activates the property when given property is active"
}
},
"required": [
"isActive"
]
}
]
}
},
"oneOf": [
{
"$ref": "#/properties/condition/definitions/condition"
},
{
"properties": {
"oneOf": {
"allMatch": {
"$id": "#/allMatch",
"type": "array",
"items": {
"type": [
"string",
"number"
]
}
}
},
"required": [
"oneOf"
]
},
{
"properties": {
"isActive": {
"type": "boolean",
"description": "For `true`, activates the property when given property is active"
"$ref": "#/properties/condition/definitions/condition"
},
"minItems": 1
}
},
"required": [
"isActive"
"allMatch"
]
}
]
}
},
"oneOf": [
{
"$ref": "#/definitions/condition"
},
{
"properties": {
"allMatch": {
"$id": "#/allMatch",
"type": "array",
"items": {
"$ref": "#/definitions/condition"
},
"minItems": 1
}
},
"required": [
"allMatch"
]
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ function createValidator(schema, errors) {

const ajv = new Ajv({
allErrors: true,
strict: false
strict: false,
$data: true
});

AjvErrors(ajv);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const template = {
'name': 'Condition',
'id': 'example.com.condition',
'appliesTo': [
'bpmn:ServiceTask'
],
'properties': [
{
'id': 'myId',
'label': 'input 1',
'type': 'String',
'binding': {
'type': 'property',
'name': 'input1'
},
'condition': {
property: 'myId',
equals: 'text'
}
}
]
};

export const errors = [];
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const template = {
}
},
{
'id': 'someId',
'label': 'default condition type',
'type': 'String',
'condition': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ describe('validation', function() {
errors
} = validateTemplate(template);

printNested(errors);

// then
expect(errors).to.eql(expectedErrors);
});
Expand Down Expand Up @@ -258,7 +260,7 @@ describe('validation', function() {

describe('condition', function() {

testTemplate('condition');
testOnly('condition');


testTemplate('condition-missing-property');
Expand Down Expand Up @@ -289,6 +291,9 @@ describe('validation', function() {


testTemplate('condition-dropdown-choices-invalid');


testOnly('condition-on-itself');
});


Expand Down

0 comments on commit f2cce3c

Please sign in to comment.