Repository navigation
Expand file tree
/
Copy pathdevday.code-snippets
More file actions
231 lines (231 loc) · 6.99 KB
/
Copy pathdevday.code-snippets
File metadata and controls
231 lines (231 loc) · 6.99 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
{
"AjaxCallForItems": {
"prefix": [
"getTasks"
],
"body": [
"@inject IBoardItemService boardService",
"\n<a href=\"/create\" class=\"btn btn-primary\">Create new item</a>",
"\n@code {",
"\n\tList<BoardItem> Tasks = new List<BoardItem>();",
"\n\tprotected override async Task OnInitializedAsync(){\n\t\tTasks = (await boardService.GetBoardItems()).ToList();\n\t}",
"}"
],
"description": "Index do ajax call to get services"
},
"ItemForDragAndDropHtml": {
"prefix": [
"dragAndDropItemHtml"
],
"body": [
"<li class=\"draggable\" draggable=\"true\" title=\"@BoardItem.Summary\" @ondragstart=\"@(() => HandleDragStart(BoardItem))\">",
"\t<p class=\"description\">@BoardItem.Description</p>",
"</li>"
],
"description": "Template for drag&drop item"
},
"ItemForDragAndDrop": {
"prefix": [
"dragAndDropItem"
],
"body": [
"@code {",
"\t[CascadingParameter] ItemsContainer Container { get; set; }",
"\t[Parameter] public BoardItem BoardItem { get; set; }",
"\n\tprivate void HandleDragStart(BoardItem selectedItem){\n\t\tContainer.Payload = selectedItem;\n\t}",
"}"
],
"description": "Code for drag&drop item"
},
"ItemListForDragAndDropHtml": {
"prefix": [
"dragAndDropItemListHtml"
],
"body": [
"<div class=\"task-status\">",
"\t<h3>@ListStatus (@Items.Count())</h3>",
"\t<ul class=\"dropzone @dropClass\" ondragover=\"event.preventDefault();\"",
"\t\t@ondrop=\"HandleDrop\"",
"\t\t@ondragenter=\"HandleDragEnter\"",
"\t\t@ondragleave=\"HandleDragLeave\">",
"\n\t@foreach (var item in Items)",
"\t{\n\t\t<Item BoardItem=\"item\"/>\n\t}",
"\t</ul>\n</div>"
],
"description": "Template for drag&drop item list"
},
"Code for drag&drop item list": {
"prefix": "dragAndDropItemList",
"body": [
"@code {",
"",
" [CascadingParameter] ItemsContainer Container { get; set; }",
" [Parameter] public Status ListStatus { get; set; }",
" [Parameter] public Status[] AllowedStatuses { get; set; }",
"",
" List<BoardItem> Items = new List<BoardItem>();",
" string dropClass = \"\";",
"",
" protected override void OnParametersSet()",
" {",
" Items.Clear();",
" Items.AddRange(Container.Tasks.Where(x => x.Status == ListStatus));",
" }",
"}"
],
"description": "Code for drag&drop item list"
},
"Code for drag&drop item list - DragEnter": {
"prefix": "dragAndDropItemListDragEnter",
"body": [
"private void HandleDragEnter()",
"{",
" if (ListStatus == Container.Payload.Status) return;",
"",
" if (AllowedStatuses != null && !AllowedStatuses.Contains(Container.Payload.Status))",
" {",
" dropClass = \"no-drop\";",
" }",
" else",
" {",
" dropClass = \"can-drop\";",
" }",
"}"
],
"description": "Code for drag&drop item list - DragEnter"
},
"Code for drag&drop item list - DragLeaveAndDrop": {
"prefix": "dragAndDropItemListDragLeaveAndDrop",
"body": [
"private void HandleDragLeave()",
"{",
" dropClass = \"\";",
"}",
"",
"private async Task HandleDrop()",
"{",
" dropClass = \"\";",
"",
" if (AllowedStatuses != null && !AllowedStatuses.Contains(Container.Payload.Status)) return;",
"",
" await Container.UpdateJobAsync(ListStatus);",
"}"
],
"description": "Code for drag&drop item list - DragLeaveAndDrop"
},
"Html for drag&drop container": {
"prefix": "dragAndDropContainerHtml",
"body": [
"<div class=\"items-container\">",
" <CascadingValue Value=\"this\">",
" @ChildContent",
" </CascadingValue>",
"</div>"
],
"description": "Html for drag&drop container"
},
"Code for drag&drop container": {
"prefix": "dragAndDropContainer",
"body": [
"@code{",
" [Parameter] public List<BoardItem> Tasks { get; set; }",
" [Parameter] public RenderFragment ChildContent { get; set; }",
" [Parameter] public EventCallback<BoardItem> OnStatusUpdated { get; set; }",
"",
" public BoardItem Payload { get; set; }",
"",
" public async Task UpdateJobAsync(Status newStatus)",
" {",
" var task = Tasks.SingleOrDefault(x => x.Id == Payload.Id);",
"",
" if (task != null)",
" {",
" task.Status = newStatus;",
" await OnStatusUpdated.InvokeAsync(Payload);",
" }",
" }",
"}"
],
"description": "Code for drag&drop container"
},
"Html for drag&drop component": {
"prefix": "dragAndDropComponent",
"body": [
"<ItemsContainer Tasks=\"Tasks\" OnStatusUpdated=\"HandleStatusUpdated\">",
" <ItemList ListStatus=\"Status.TODO\" AllowedStatuses=\"@(new Status[] { Status.INPROGRESS, Status.DONE })\" />",
" <ItemList ListStatus=\"Status.INPROGRESS\" AllowedStatuses=\"@(new Status[] { Status.TODO })\" />",
" <ItemList ListStatus=\"Status.DONE\" AllowedStatuses=\"@(new Status[] { Status.INPROGRESS })\" />",
"</ItemsContainer>"
],
"description": "Html for drag&drop component"
},
"Code for drag&drop component": {
"prefix": "dragAndDropComponentUpdateEvent",
"body": [
"async Task HandleStatusUpdated(BoardItem updatedTask)",
"{",
" await boardService.UpdateBoardItem(updatedTask);",
"}"
],
"description": "Code for drag&drop component"
},
"Form for create item": {
"prefix": "createItemFormHtml",
"body": [
"<a href=\"/\">Back to board</a>",
"",
"<EditForm Model=\"Item\" OnValidSubmit=\"@CreateItemAsync\">",
"",
" <DataAnnotationsValidator />",
" <ValidationSummary />",
"",
" <div class=\"form-group\">",
" <label>Summary</label>",
" <input type=\"text\" class=\"form-control\" placeholder=\"Summary\" @bind=\"Item.Summary\" />",
" </div>",
"",
" <div class=\"form-group\">",
" <label>Summary</label>",
" <input type=\"text\" class=\"form-control\" placeholder=\"Description\" @bind=\"Item.Description\" />",
" </div>",
" <div class=\"form-group\">",
" <label>Summary</label>",
" <input type=\"text\" class=\"form-control\" placeholder=\"Author\" @bind=\"Item.Author\" />",
" </div>",
" <input type=\"submit\" />",
"</EditForm>",
""
],
"description": "Form for create item"
},
"Code for create item": {
"prefix": "createItemForm",
"body": [
"@code {",
" public BoardItem Item { get; set; } = new BoardItem();",
" public bool ShowError { get; set; }",
"",
" public async Task CreateItemAsync()",
" {",
" if (await boardService.CreateBoardItem(Item))",
" {",
" navigationManager.NavigateTo(\"/\");",
" }",
" else",
" {",
" ShowError = true;",
" }",
" }",
"}"
],
"description": "Code for create item"
},
"Inject for create item": {
"prefix": "createItemFormInject",
"body": [
"@inject IBoardItemService boardService",
"@inject NavigationManager navigationManager"
],
"description": "Inject for create item"
}
}