|
211 | 211 | } |
212 | 212 | private async Task ShowEditFormDialog(string title, AddEdit{itemname}Command command) |
213 | 213 | { |
214 | | - var parameters = new DialogParameters<{itemname}FormDialog> |
| 214 | + return DialogServiceHelper.ShowFormDialogAsync<{itemname}FormDialog, AddEdit{itemname}Command>( |
| 215 | + title, |
| 216 | + command, |
| 217 | + async () => |
215 | 218 | { |
216 | | - { x=>x._model,command }, |
217 | | - }; |
218 | | - var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Medium, FullWidth = true }; |
219 | | - var dialog = await DialogService.ShowAsync<{itemname}FormDialog>(title, parameters, options); |
220 | | - var state = await dialog.Result; |
221 | | - |
222 | | - if (state != null && !state.Canceled) |
223 | | - { |
224 | | - await _{nameofplurallowercase}Grid.ReloadServerData(); |
225 | | - _selected{nameofPlural}.Clear(); |
226 | | - } |
| 219 | + await _{nameofplurallowercase}Grid.ReloadServerData(); |
| 220 | + _selected{nameofPlural}.Clear(); |
| 221 | + }); |
227 | 222 | } |
228 | 223 | private void OnDataGridRowClick({itemname}Dto dto) |
229 | 224 | { |
230 | 225 | Navigation.NavigateTo($"/pages/{nameofplurallowercase}/view/{dto.Id}"); |
231 | 226 | } |
232 | | - private async Task OnCreate() |
| 227 | + private Task OnCreate() |
233 | 228 | { |
234 | 229 | var command = new AddEdit{itemname}Command(); |
235 | | - await ShowEditFormDialog(L["New {itemname}"], command); |
| 230 | + return ShowEditFormDialog(L["New {itemname}"], command); |
236 | 231 | } |
237 | | - private async Task OnClone{itemname}() |
| 232 | + private Task OnClone{itemname}() |
238 | 233 | { |
239 | 234 | var dto = _selected{nameofPlural}.First(); |
240 | 235 | var command = new AddEdit{itemname}Command() |
241 | 236 | { |
242 | 237 | {fieldAssignmentDefinition} |
243 | 238 | }; |
244 | | - await ShowEditFormDialog(L["Clone {itemname}"], command); |
| 239 | + return ShowEditFormDialog(L["Clone {itemname}"], command); |
245 | 240 | } |
246 | | - private async Task OnEdit{itemname}({itemname}Dto dto) |
| 241 | + private Task OnEdit{itemname}({itemname}Dto dto) |
247 | 242 | { |
248 | 243 | //var command = Mapper.Map<AddEdit{itemname}Command>(dto); |
249 | | - //await ShowEditFormDialog(L["Edit {itemname}"], command); |
| 244 | + //return ShowEditFormDialog(L["Edit {itemname}"], command); |
250 | 245 | Navigation.NavigateTo($"/pages/{nameofplurallowercase}/edit/{dto.Id}"); |
| 246 | + return Task.CompletedTask; |
251 | 247 | } |
252 | 248 |
|
253 | | - private async Task OnDelete{itemname}({itemname}Dto dto) |
| 249 | + private Task OnDelete{itemname}({itemname}Dto dto) |
254 | 250 | { |
255 | 251 | var contentText = string.Format(ConstantString.DeleteConfirmation, dto.Name); |
256 | 252 | var command = new Delete{itemname}Command(new int[] { dto.Id }); |
257 | | - await DialogServiceHelper.ShowDeleteConfirmationDialogAsync(command, ConstantString.DeleteConfirmationTitle, contentText,async () => |
258 | | - { |
259 | | - await InvokeAsync(async () => |
260 | | - { |
261 | | - await _{nameofplurallowercase}Grid.ReloadServerData(); |
262 | | - _selected{nameofPlural}.Clear(); |
263 | | - }); |
264 | | - }); |
| 253 | + return Delete{nameofPlural}Internal(command, contentText); |
265 | 254 | } |
266 | 255 |
|
267 | | - private async Task OnDeleteSelected{nameofPlural}() |
| 256 | + private Task OnDeleteSelected{nameofPlural}() |
268 | 257 | { |
269 | 258 | var contentText = string.Format(ConstantString.DeleteConfirmWithSelected, _selected{nameofPlural}.Count); |
270 | 259 | var command = new Delete{itemname}Command(_selected{nameofPlural}.Select(x => x.Id).ToArray()); |
271 | | - await DialogServiceHelper.ShowDeleteConfirmationDialogAsync(command, ConstantString.DeleteConfirmationTitle, contentText,async () => |
272 | | - { |
273 | | - await InvokeAsync(async () => |
| 260 | + return Delete{nameofPlural}Internal(command, contentText); |
| 261 | + } |
| 262 | + |
| 263 | + private Task Delete{nameofPlural}Internal(Delete{itemname}Command command, string contentText) |
| 264 | + { |
| 265 | + return DialogServiceHelper.ShowDeleteConfirmationDialogAsync( |
| 266 | + command, |
| 267 | + ConstantString.DeleteConfirmationTitle, |
| 268 | + contentText, |
| 269 | + async () => |
274 | 270 | { |
275 | 271 | await _{nameofplurallowercase}Grid.ReloadServerData(); |
276 | 272 | _selected{nameofPlural}.Clear(); |
277 | 273 | }); |
278 | | - }); |
279 | 274 | } |
280 | 275 |
|
| 276 | + |
281 | 277 | private async Task OnExport() |
282 | 278 | { |
283 | 279 | _exporting = true; |
|
0 commit comments