-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed-plugin.ts
More file actions
99 lines (97 loc) · 2.44 KB
/
Copy pathseed-plugin.ts
File metadata and controls
99 lines (97 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import {Plugin, DontCodeModel, PluginConfig, Core} from '@dontcode/core';
/**
* This plugin demonstrate 2 things:
* - how to declare a new field type that can be selected in the Builder and how to manage the display and edition of this new type in the Previewer.
* - As well it adds a new attribute 'seed' to any Entity and provides a viewer for the Previewer when its value is Yes or Maybe.
*/
export class SeedPlugin implements Plugin {
getConfiguration(): PluginConfig {
return {
plugin: {
id: 'SeedPlugin',
'display-name': 'An starter project for development of Dont-code plugins.',
version: '1.0.0'
},
'schema-updates': [{
id: 'seed-field',
description: 'Add a new type of field to Dont-code: the SeedField',
changes: [{
location: {
parent: '#/$defs/field',
id: 'type'
},
update: {
enum: [
'Seed Field'
]
},
replace: false
}]
}, {
id: "seeded-entity",
description: "Adds 'seed' attribute to any entity and display the entity if seed is Maybe or Yes",
changes: [{
location: {
parent: '#/$defs/entity',
id: 'seed',
after: 'name'
},
update: {
enum: [
'Yes',
'Maybe'
]
},
replace: true
}, {
location: {
parent: '/$defs/entity',
id: 'seed',
after: 'name'
},
update: {
enum: [
'No'
]
},
replace: false
}]
}],
'preview-handlers': [
{
location: {
parent: DontCodeModel.APP_FIELDS,
id: 'type',
values: [{
Seed: {
enum: [
'Seed Field'
]
}
}]
},
class: {
name: 'SeedFieldComponent',
source: 'seed'
}
},
{
location: {
parent: DontCodeModel.APP_ENTITIES,
id: "seed",
values: [
"Yes", "Maybe"
]
},
class: {
name: "SeededEntityComponent",
source: "seed"
}
}
]
}
}
pluginInit(dontCode: Core): void {
// Nothing to do here
}
}