Skip to content

Commit

Permalink
feat: support placeholder on String and Text properties
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed May 28, 2024
1 parent 3ff89d5 commit 9473b18
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/zeebe-element-templates-json-schema/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to [@camunda/zeebe-element-templates-json-schema](https://gi

___Note:__ Yet to be released changes appear here._

## 0.20.0

* `FEAT`: support `placeholder` property

## 0.19.2

* `FIX`: allow number values for `Number` properties ([#138](https://github.com/camunda/element-templates-json-schema/issues/138))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,46 @@
}
}
}
},
{
"if": {
"oneOf": [
{
"properties": {
"type": {
"enum": [
"String",
"Text"
]
}
},
"required": [
"type"
]
},
{
"not": {
"required": [
"type"
]
}
}
]
},
"then": {
"properties": {
"placeholder": {
"type": "string"
}
}
},
"else": {
"not": {
"required": [
"placeholder"
]
}
}
}
],
"properties": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
export const template = {
name: 'Tooltip',
id: 'example.com.tooltip',
appliesTo: [
'bpmn:ServiceTask'
],
properties: [
{
label: 'Input with placeholder',
type: 'Boolean',
binding: {
type: 'property',
name: 'prop'
},
placeholder: 'Invalid input type'
},
{
label: 'Input with placeholder',
type: 'Number',
binding: {
type: 'property',
name: 'prop'
},
placeholder: 'Invalid input type'
}
]
};

export const errors = [
{
'dataPath': '/properties/0',
'keyword': 'not',
'message': 'should NOT be valid',
'params': {},
'schemaPath': '#/allOf/1/items/allOf/10/else/not',
},
{
'dataPath': '/properties/0',
'keyword': 'if',
'message': 'should match "else" schema',
params: { failingKeyword: 'else' },
schemaPath: '#/allOf/1/items/allOf/10/if'
},
{
'dataPath': '/properties/1',
'keyword': 'not',
'message': 'should NOT be valid',
'params': {},
'schemaPath': '#/allOf/1/items/allOf/10/else/not',
},
{
'dataPath': '/properties/1',
'keyword': 'if',
'message': 'should match "else" schema',
params: { failingKeyword: 'else' },
schemaPath: '#/allOf/1/items/allOf/10/if'
},
{
keyword: 'type',
dataPath: '',
schemaPath: '#/oneOf/1/type',
params: { type: 'array' },
message: 'should be array'
},
{
keyword: 'oneOf',
dataPath: '',
schemaPath: '#/oneOf',
params: { passingSchemas: null },
message: 'should match exactly one schema in oneOf'
}
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export const template = {
name: 'Tooltip',
id: 'example.com.tooltip',
appliesTo: [
'bpmn:ServiceTask'
],
properties: [
{
label: 'Input with placeholder',
type: 'String',
binding: {
type: 'property',
name: 'prop'
},
placeholder: [ 'invalid placeholder type' ]
}
]
};

export const errors = [
{
keyword: 'type',
dataPath: '/properties/0/placeholder',
schemaPath: '#/allOf/1/items/allOf/10/then/properties/placeholder/type',
params: { type: 'string' },
message: 'should be string'
},
{
dataPath: '/properties/0',
keyword: 'if',
message: 'should match "then" schema',
params: { failingKeyword: 'then' },
schemaPath: '#/allOf/1/items/allOf/10/if'
},
{
keyword: 'type',
dataPath: '',
schemaPath: '#/oneOf/1/type',
params: { type: 'array' },
message: 'should be array'
},
{
keyword: 'oneOf',
dataPath: '',
schemaPath: '#/oneOf',
params: { passingSchemas: null },
message: 'should match exactly one schema in oneOf'
}
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export const template = {
name: 'Tooltip',
id: 'example.com.tooltip',
appliesTo: [
'bpmn:ServiceTask'
],
properties: [
{
label: 'Input with placeholder',
type: 'String',
binding: {
type: 'property',
name: 'prop'
},
placeholder: 'This field has a placeholder'
},
{
label: 'Input with placeholder',
type: 'Text',
binding: {
type: 'property',
name: 'prop'
},
placeholder: 'This field has a placeholder'
},
{
label: 'Input with placeholder',
binding: {
type: 'property',
name: 'prop'
},
placeholder: 'This field has a placeholder'
}
]
};

export const errors = null;
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,16 @@ describe('validation', function() {

testTemplate('called-element-missing-property');
});


describe('placeholder', function() {

testTemplate('placeholder');

testTemplate('placeholder-invalid-property');

testTemplate('placeholder-invalid-type');
});
});

});
Expand Down

0 comments on commit 9473b18

Please sign in to comment.