Skip to content

Commit 0747597

Browse files
committed
feat: support placeholder on String and Text properties
Related to bpmn-io/bpmn-js-element-templates#92
1 parent 3ff89d5 commit 0747597

File tree

12 files changed

+387
-0
lines changed

12 files changed

+387
-0
lines changed

packages/element-templates-json-schema-shared/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ All notable changes to [@camunda/element-templates-json-schema-shared](https://g
66

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

9+
## 0.11.0
10+
11+
* `FEAT`: support `placeholder` property
12+
913
## 0.10.2
1014

1115
* `FIX`: allow number values for `Number` properties ([#138](https://github.com/camunda/element-templates-json-schema/issues/138))

packages/element-templates-json-schema-shared/src/defs/base-properties.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,46 @@
5151
}
5252
}
5353
}
54+
},
55+
{
56+
"if": {
57+
"oneOf": [
58+
{
59+
"properties": {
60+
"type": {
61+
"enum": [
62+
"String",
63+
"Text"
64+
]
65+
}
66+
},
67+
"required": [
68+
"type"
69+
]
70+
},
71+
{
72+
"not": {
73+
"required": [
74+
"type"
75+
]
76+
}
77+
}
78+
]
79+
},
80+
"then": {
81+
"properties": {
82+
"placeholder": {
83+
"type": "string"
84+
}
85+
}
86+
},
87+
"else": {
88+
"not": {
89+
"required": [
90+
"placeholder"
91+
]
92+
}
93+
}
5494
}
5595
],
5696
"properties": {

packages/element-templates-json-schema/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ All notable changes to [@camunda/element-templates-json-schema](https://github.c
66

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

9+
## 0.18.0
10+
11+
* `FEAT`: support `placeholder` property
12+
913
## 0.17.2
1014

1115
* `FIX`: allow number values for `Number` properties ([#138](https://github.com/camunda/element-templates-json-schema/issues/138))
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
export const template = {
2+
name: 'Tooltip',
3+
id: 'example.com.tooltip',
4+
appliesTo: [
5+
'bpmn:ServiceTask'
6+
],
7+
properties: [
8+
{
9+
label: 'Input with placeholder',
10+
type: 'Boolean',
11+
binding: {
12+
type: 'property',
13+
name: 'prop'
14+
},
15+
placeholder: 'Invalid input type'
16+
},
17+
{
18+
label: 'Input with placeholder',
19+
type: 'Hidden',
20+
binding: {
21+
type: 'property',
22+
name: 'prop'
23+
},
24+
placeholder: 'Invalid input type'
25+
}
26+
]
27+
};
28+
29+
export const errors = [
30+
{
31+
'dataPath': '/properties/0',
32+
'keyword': 'not',
33+
'message': 'should NOT be valid',
34+
'params': {},
35+
'schemaPath': '#/allOf/0/items/allOf/3/else/not',
36+
},
37+
{
38+
'dataPath': '/properties/0',
39+
'keyword': 'if',
40+
'message': 'should match "else" schema',
41+
params: { failingKeyword: 'else' },
42+
schemaPath: '#/allOf/0/items/allOf/3/if'
43+
},
44+
{
45+
'dataPath': '/properties/1',
46+
'keyword': 'not',
47+
'message': 'should NOT be valid',
48+
'params': {},
49+
'schemaPath': '#/allOf/0/items/allOf/3/else/not',
50+
},
51+
{
52+
'dataPath': '/properties/1',
53+
'keyword': 'if',
54+
'message': 'should match "else" schema',
55+
params: { failingKeyword: 'else' },
56+
schemaPath: '#/allOf/0/items/allOf/3/if'
57+
},
58+
{
59+
keyword: 'type',
60+
dataPath: '',
61+
schemaPath: '#/oneOf/1/type',
62+
params: { type: 'array' },
63+
message: 'should be array'
64+
},
65+
{
66+
keyword: 'oneOf',
67+
dataPath: '',
68+
schemaPath: '#/oneOf',
69+
params: { passingSchemas: null },
70+
message: 'should match exactly one schema in oneOf'
71+
}
72+
];
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
export const template = {
2+
name: 'Tooltip',
3+
id: 'example.com.tooltip',
4+
appliesTo: [
5+
'bpmn:ServiceTask'
6+
],
7+
properties: [
8+
{
9+
label: 'Input with placeholder',
10+
type: 'String',
11+
binding: {
12+
type: 'property',
13+
name: 'prop'
14+
},
15+
placeholder: [ 'invalid placeholder type' ]
16+
}
17+
]
18+
};
19+
20+
export const errors = [
21+
{
22+
keyword: 'type',
23+
dataPath: '/properties/0/placeholder',
24+
schemaPath: '#/allOf/0/items/allOf/3/then/properties/placeholder/type',
25+
params: { type: 'string' },
26+
message: 'should be string'
27+
},
28+
{
29+
dataPath: '/properties/0',
30+
keyword: 'if',
31+
message: 'should match "then" schema',
32+
params: { failingKeyword: 'then' },
33+
schemaPath: '#/allOf/0/items/allOf/3/if'
34+
},
35+
{
36+
keyword: 'type',
37+
dataPath: '',
38+
schemaPath: '#/oneOf/1/type',
39+
params: { type: 'array' },
40+
message: 'should be array'
41+
},
42+
{
43+
keyword: 'oneOf',
44+
dataPath: '',
45+
schemaPath: '#/oneOf',
46+
params: { passingSchemas: null },
47+
message: 'should match exactly one schema in oneOf'
48+
}
49+
];
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
export const template = {
2+
name: 'Tooltip',
3+
id: 'example.com.tooltip',
4+
appliesTo: [
5+
'bpmn:ServiceTask'
6+
],
7+
properties: [
8+
{
9+
label: 'Input with placeholder',
10+
type: 'String',
11+
binding: {
12+
type: 'property',
13+
name: 'prop'
14+
},
15+
placeholder: 'This field has a placeholder'
16+
},
17+
{
18+
label: 'Input with placeholder',
19+
type: 'Text',
20+
binding: {
21+
type: 'property',
22+
name: 'prop'
23+
},
24+
placeholder: 'This field has a placeholder'
25+
},
26+
{
27+
label: 'Input with placeholder',
28+
binding: {
29+
type: 'property',
30+
name: 'prop'
31+
},
32+
placeholder: 'This field has a placeholder'
33+
}
34+
]
35+
};
36+
37+
export const errors = null;

packages/element-templates-json-schema/test/spec/validationSpec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,15 @@ describe('validation', function() {
328328

329329
});
330330

331+
332+
describe('placeholder', function() {
333+
334+
testTemplate('placeholder');
335+
336+
testTemplate('placeholder-invalid-property');
337+
338+
testTemplate('placeholder-invalid-type');
339+
});
331340
});
332341

333342

packages/zeebe-element-templates-json-schema/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ All notable changes to [@camunda/zeebe-element-templates-json-schema](https://gi
66

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

9+
## 0.20.0
10+
11+
* `FEAT`: support `placeholder` property
12+
913
## 0.19.2
1014

1115
* `FIX`: allow number values for `Number` properties ([#138](https://github.com/camunda/element-templates-json-schema/issues/138))
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
export const template = {
2+
name: 'Tooltip',
3+
id: 'example.com.tooltip',
4+
appliesTo: [
5+
'bpmn:ServiceTask'
6+
],
7+
properties: [
8+
{
9+
label: 'Input with placeholder',
10+
type: 'Boolean',
11+
binding: {
12+
type: 'property',
13+
name: 'prop'
14+
},
15+
placeholder: 'Invalid input type'
16+
},
17+
{
18+
label: 'Input with placeholder',
19+
type: 'Number',
20+
binding: {
21+
type: 'property',
22+
name: 'prop'
23+
},
24+
placeholder: 'Invalid input type'
25+
}
26+
]
27+
};
28+
29+
export const errors = [
30+
{
31+
'dataPath': '/properties/0',
32+
'keyword': 'not',
33+
'message': 'should NOT be valid',
34+
'params': {},
35+
'schemaPath': '#/allOf/0/items/allOf/3/else/not',
36+
},
37+
{
38+
'dataPath': '/properties/0',
39+
'keyword': 'if',
40+
'message': 'should match "else" schema',
41+
params: { failingKeyword: 'else' },
42+
schemaPath: '#/allOf/0/items/allOf/3/if'
43+
},
44+
{
45+
'dataPath': '/properties/1',
46+
'keyword': 'not',
47+
'message': 'should NOT be valid',
48+
'params': {},
49+
'schemaPath': '#/allOf/0/items/allOf/3/else/not',
50+
},
51+
{
52+
'dataPath': '/properties/1',
53+
'keyword': 'if',
54+
'message': 'should match "else" schema',
55+
params: { failingKeyword: 'else' },
56+
schemaPath: '#/allOf/0/items/allOf/3/if'
57+
},
58+
{
59+
keyword: 'type',
60+
dataPath: '',
61+
schemaPath: '#/oneOf/1/type',
62+
params: { type: 'array' },
63+
message: 'should be array'
64+
},
65+
{
66+
keyword: 'oneOf',
67+
dataPath: '',
68+
schemaPath: '#/oneOf',
69+
params: { passingSchemas: null },
70+
message: 'should match exactly one schema in oneOf'
71+
}
72+
];
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
export const template = {
2+
name: 'Tooltip',
3+
id: 'example.com.tooltip',
4+
appliesTo: [
5+
'bpmn:ServiceTask'
6+
],
7+
properties: [
8+
{
9+
label: 'Input with placeholder',
10+
type: 'String',
11+
binding: {
12+
type: 'property',
13+
name: 'prop'
14+
},
15+
placeholder: [ 'invalid placeholder type' ]
16+
}
17+
]
18+
};
19+
20+
export const errors = [
21+
{
22+
keyword: 'type',
23+
dataPath: '/properties/0/placeholder',
24+
schemaPath: '#/allOf/0/items/allOf/3/then/properties/placeholder/type',
25+
params: { type: 'string' },
26+
message: 'should be string'
27+
},
28+
{
29+
dataPath: '/properties/0',
30+
keyword: 'if',
31+
message: 'should match "then" schema',
32+
params: { failingKeyword: 'then' },
33+
schemaPath: '#/allOf/0/items/allOf/3/if'
34+
},
35+
{
36+
keyword: 'type',
37+
dataPath: '',
38+
schemaPath: '#/oneOf/1/type',
39+
params: { type: 'array' },
40+
message: 'should be array'
41+
},
42+
{
43+
keyword: 'oneOf',
44+
dataPath: '',
45+
schemaPath: '#/oneOf',
46+
params: { passingSchemas: null },
47+
message: 'should match exactly one schema in oneOf'
48+
}
49+
];

0 commit comments

Comments
 (0)