Beispiel #1
0
        protected override void OnParametersSet()
        {
            if (createItemFormViewModel is null)
            {
                createItemFormViewModel            = new CreateItemFormViewModel <TModel>(CreateItemContext.CreateItemOptions);
                createItemFormViewModel.SaveAction = async model =>
                {
                    if (string.IsNullOrEmpty(CreateItemContext.CreateItemOptions.CreateUri))
                    {
                        CreateItemContext.NotifyItemCreated(model);
                    }
                    else
                    {
                        var dto = await CreateItemHandle.CreateItem(model, CreateItemContext.CreateItemOptions, CancellationToken.None);

                        CreateItemContext.NotifyItemCreated(dto);
                    }
                    createItemFormViewModel.ClearModel();

                    if (CreateItemContext.CreateItemOptions.CloseAfterSuccessfullySaved)
                    {
                        await FlexGridInterop.HideModal(CreateItemOptions.CreateItemModalName);
                    }

                    StateHasChanged();
                };
            }
        }
 protected override void BuildRendererTreeInternal(GridRendererContext rendererContext, PermissionContext permissionContext)
 {
     rendererContext
     .RendererTreeBuilder
     .OpenElement(HtmlTagNames.Div, "modal")
     .AddAttribute(HtmlAttributes.Id, DeleteItemOptions.DialogName)
     .AddAttribute("role", "dialog")
     .OpenElement(HtmlTagNames.Div, $"modal-dialog modal-dialog-centered")
     .AddAttribute(HtmlAttributes.Id, CreateItemOptions.CreateItemModalSizeDiv)
     .OpenElement(HtmlTagNames.Div, "modal-content")
     .OpenElement(HtmlTagNames.Div, "modal-header")
     .OpenElement(HtmlTagNames.H4, "modal-title")
     .AddContent("Confirm delete")
     .CloseElement()
     .CloseElement()
     .OpenElement(HtmlTagNames.Div, "modal-body")
     .AddContent("Are you sure you want to delete item?")
     .CloseElement()
     .OpenElement(HtmlTagNames.Div, "modal-footer")
     .OpenElement(HtmlTagNames.Button, rendererContext.CssClasses.DeleteDialogCssClasses.CancelButton)
     .AddAttribute(HtmlAttributes.Type, "button")
     .AddAttribute("data-dismiss", "modal")
     .AddAttribute(HtmlJSEvents.OnClick, EventCallback.Factory.Create(this, (MouseEventArgs e) => flexGridInterop.HideModal(DeleteItemOptions.DialogName)))
     .AddContent("Cancel")
     .CloseElement()
     .OpenElement(HtmlTagNames.Button, rendererContext.CssClasses.DeleteDialogCssClasses.DeleteButton)
     .AddAttribute(HtmlAttributes.Type, "button")
     .AddAttribute("data-dismiss", "modal")
     .AddAttribute(HtmlJSEvents.OnClick,
                   EventCallback.Factory.Create(this, (MouseEventArgs e) =>
     {
         rendererContext.TableDataSet.DeleteItem(rendererContext.FlexGridContext.SelectedItem);
         rendererContext.FlexGridContext.RemoveSelection();
         flexGridInterop.HideModal(DeleteItemOptions.DialogName);
         rendererContext.RequestRerenderNotification?.Invoke();
     }))
     .AddContent("Delete")
     .CloseElement()
     .CloseElement()
     .CloseElement()
     .CloseElement()
     .CloseElement();
 }
Beispiel #3
0
        protected override void BuildRendererTreeInternal(GridRendererContext rendererContext, PermissionContext permissionContext)
        {
            if (!permissionContext.HasCreateItemPermission)
            {
                return;
            }

            rendererContext.OpenElement(HtmlTagNames.Div, "modal");
            rendererContext.AddAttribute(HtmlAttributes.Id, CreateItemOptions.CreateItemModalName);
            rendererContext.AddAttribute("role", "dialog");

            rendererContext.OpenElement(HtmlTagNames.Div, "modal-dialog modal-lg modal-dialog-centered");
            rendererContext.OpenElement(HtmlTagNames.Div, "modal-content");

            rendererContext.OpenElement(HtmlTagNames.Div, "modal-header");
            rendererContext.OpenElement(HtmlTagNames.H4, "modal-title");
            rendererContext.AddContent("Create Item");
            rendererContext.CloseElement();
            rendererContext.OpenElement(HtmlTagNames.Button, "close");
            rendererContext.AddOnClickEvent(() =>
                                            BindMethods.GetEventHandlerValue((UIMouseEventArgs e) =>
                                                                             FlexGridInterop.HideModal(CreateItemOptions.CreateItemModalName)));
            rendererContext.AddAttribute(HtmlAttributes.Type, "button");
            rendererContext.AddAttribute("data-dismiss", "modal");
            rendererContext.AddAttribute("aria-label", "Close");
            rendererContext.OpenElement(HtmlTagNames.Span);
            rendererContext.AddAttribute(HtmlAttributes.AriaHidden, "true");
            rendererContext.AddContent("&times;");
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();

            rendererContext.OpenElement(HtmlTagNames.Div, "modal-body");
            rendererContext.AddCreateItemComponent();

            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
            rendererContext.CloseElement();
        }