-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommerce-plugin.ts
More file actions
97 lines (93 loc) · 2.39 KB
/
commerce-plugin.ts
File metadata and controls
97 lines (93 loc) · 2.39 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
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 CommercePlugin implements Plugin {
public static readonly SHOP_ENTITY_NAME='Online Shop';
getConfiguration(): PluginConfig {
return {
plugin: {
id: 'CommercePlugin',
'display-name': 'Commerce Plugin for anything related to products, prices, shops.',
version: '1.0.0'
},
'schema-updates': [{
id: 'price-field',
description: 'A price of a product in a shop',
changes: [{
location: {
parent: '#/$defs/field',
id: 'type'
},
update: {
enum: [{
Commerce: {
enum: [
'Price',
'Shop',
'Shop type'
]}
}
]
},
replace: false
}]
}],
'preview-handlers': [
{
location: {
parent: DontCodeModel.APP_FIELDS,
id: 'type',
values: [{
Commerce: {
enum: [
'Price'
]}
}]
},
class: {
name: 'PriceComponent',
source: 'commerce'
}
},
{
location: {
parent: DontCodeModel.APP_FIELDS,
id: 'type',
values: [{
Commerce: {
enum: [
'Shop'
]}
}]
},
class: {
name: 'ShopHandlerComponent',
source: 'commerce'
}
},
{
location: {
parent: DontCodeModel.APP_FIELDS,
id: 'type',
values: [{
Commerce: {
enum: [
'Shop type'
]}
}]
},
class: {
name: 'ShopTypeHandlerComponent',
source: 'commerce'
}
}
]
}
}
pluginInit(dontCode: Core): void {
// Nothing to do here
}
}