-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathMigrations.cs
More file actions
85 lines (80 loc) · 2.95 KB
/
Copy pathMigrations.cs
File metadata and controls
85 lines (80 loc) · 2.95 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
using OrchardCore.ContentFields.Settings;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentManagement.Metadata.Settings;
using OrchardCore.Data.Migration;
namespace StatCan.OrchardCore.Canvas
{
public class Migrations : DataMigration
{
private readonly IContentDefinitionManager _contentDefinitionManager;
public Migrations(IContentDefinitionManager contentDefinitionManager)
{
_contentDefinitionManager = contentDefinitionManager;
}
public int Create()
{
CreateCanvas();
return 1;
}
private void CreateCanvas() {
_contentDefinitionManager.AlterTypeDefinition("Canvas", type => type
.DisplayedAs("Canvas")
.Stereotype("Widget")
.WithPart("Canvas", part => part
.WithPosition("0")
)
);
_contentDefinitionManager.AlterPartDefinition("Canvas", part => part
.WithField("CanvasType", field => field
.OfType("TextField")
.WithDisplayName("CanvasType")
.WithEditor("PredefinedList")
.WithPosition("0")
.WithSettings(new TextFieldSettings
{
Hint = "Choose from the following options",
Required = true,
})
.WithSettings(new TextFieldPredefinedListEditorSettings
{
Options = new ListValueOption[] {
new ListValueOption() {
Name="Business",
Value="business"
},
new ListValueOption() {
Name="Client",
Value="client"
},
new ListValueOption() {
Name="Community",
Value="community"
}
},
})
)
.WithField("Data", field => field
.OfType("TextField")
.WithDisplayName("Data")
.WithEditor("CodeMirror")
.WithPosition("2")
.WithSettings(new TextFieldSettings
{
Hint = "Enter the json for the data.",
Required = true,
})
)
.WithField("Colour", field => field
.OfType("TextField")
.WithDisplayName("Colour")
.WithEditor("Color")
.WithPosition("1")
.WithSettings(new TextFieldSettings
{
Hint = "Select a colour to match the website's theme",
})
)
);
}
}
}