Пример #1
0
        private async Task HandleCancel(MouseEventArgs e)
        {
            var args = new ModalClosingEventArgs(e, false);

            if (ConfirmRef.ModalTemplate != null)
            {
                await ConfirmRef.ModalTemplate.CancelAsync(args);
            }
            if (!args.Cancel && Config.OnCancel != null)
            {
                Config.CancelButtonProps.Loading = true;
                await InvokeAsync(StateHasChanged);

                await Config.OnCancel.Invoke(args);
            }

            if (args.Cancel)
            {
                Config.CancelButtonProps.Loading = false;
                await InvokeAsync(StateHasChanged);
            }
            else
            {
                await Close();

                ConfirmRef.TaskCompletionSource?.SetResult(ConfirmResult.Cancel);
            }
        }
        private async Task HandleOk(MouseEventArgs e)
        {
            var args = new ModalClosingEventArgs(e, false);

            var modalTemplate = (ConfirmRef as IFeedbackRef)?.ModalTemplate;

            if (modalTemplate != null)
            {
                await modalTemplate.OnFeedbackOkAsync(args);
            }

            if (!args.Cancel && Config.OnOk != null)
            {
                Config.OkButtonProps.Loading = true;
                await InvokeAsync(StateHasChanged);

                await Config.OnOk.Invoke(args);
            }

            if (args.Cancel)
            {
                Config.OkButtonProps.Loading = false;
                await InvokeAsync(StateHasChanged);
            }
            else
            {
                await Close();

                ConfirmRef.TaskCompletionSource?.TrySetResult(ConfirmResult.OK);
            }
        }
Пример #3
0
        private async Task HandleCancel(MouseEventArgs e)
        {
            var args = new ModalClosingEventArgs(e, false);

            if (ModalRef.ModalTemplate != null)
            {
                await ModalRef.ModalTemplate.CancelAsync(args);
            }
            if (args.Cancel == false)
            {
                if (Config.OnCancel != null)
                {
                    Config.CancelButtonProps.Loading = true;
                    await InvokeAsync(StateHasChanged);

                    await Config.OnCancel.Invoke(args);
                }
            }

            if (args.Cancel == true)
            {
                Config.CancelButtonProps.Loading = false;
                await InvokeAsync(StateHasChanged);
            }
            else
            {
                await Close();
            }
        }
Пример #4
0
        /// <summary>
        /// Cancel button click
        /// </summary>
        /// <returns></returns>
        public async Task CancelAsync(ModalClosingEventArgs e)
        {
            await CloseAsync();

            if (OnCancel != null)
            {
                await OnCancel();
            }
        }
Пример #5
0
        /// <summary>
        /// Ok button click
        /// </summary>
        /// <returns></returns>
        public async Task OkAsync(ModalClosingEventArgs e)
        {
            await CloseAsync();

            if (OnOk != null)
            {
                await OnOk();
            }
        }
Пример #6
0
        /// <summary>
        /// close Confirm dialog
        /// </summary>
        /// <returns></returns>
        public override async Task CloseAsync()
        {
            var e = new ModalClosingEventArgs();

            await(OnClosing?.Invoke(e) ?? Task.CompletedTask);
            if (!e.Cancel)
            {
                await _service.CloseAsync(this);

                if (OnClose != null)//before close
                {
                    await OnClose.Invoke();
                }
            }
        }
Пример #7
0
#pragma warning restore 649

        private DialogOptions BuildDialogOptions()
        {
            DialogOptions options = new DialogOptions()
            {
                OnClosed       = AfterClose,
                BodyStyle      = BodyStyle,
                CancelText     = CancelText ?? Locale.CancelText,
                Centered       = Centered,
                Closable       = Closable,
                Draggable      = Draggable,
                DragInViewport = DragInViewport,
                CloseIcon      = CloseIcon,
                ConfirmLoading = ConfirmLoading,
                Footer         = Footer,

                GetContainer = GetContainer,
                Keyboard     = Keyboard,
                Mask         = Mask,
                MaskClosable = MaskClosable,
                MaskStyle    = MaskStyle,

                OkText        = OkText ?? Locale.OkText,
                OkType        = OkType,
                Title         = Title,
                TitleTemplate = TitleTemplate,
                Width         = Width,
                WrapClassName = WrapClassName,
                ZIndex        = ZIndex,
                OnCancel      = async(e) =>
                {
                    var args = new ModalClosingEventArgs(e, false);

                    var modalTemplate = (ModalRef as IFeedbackRef)?.ModalTemplate;
                    if (modalTemplate != null)
                    {
                        await modalTemplate.OnFeedbackCancelAsync(args);
                    }
                    if (!args.Cancel)
                    {
                        await(ModalRef?.OnCancel?.Invoke() ?? Task.CompletedTask);

                        if (OnCancel.HasDelegate)
                        {
                            await OnCancel.InvokeAsync(e);
                        }
                    }
                },
                OnOk = async(e) =>
                {
                    var args = new ModalClosingEventArgs(e, false);

                    var modalTemplate = (ModalRef as IFeedbackRef)?.ModalTemplate;
                    if (modalTemplate != null)
                    {
                        await modalTemplate.OnFeedbackOkAsync(args);
                    }
                    if (!args.Cancel)
                    {
                        await(ModalRef?.OnOk?.Invoke() ?? Task.CompletedTask);

                        if (OnOk.HasDelegate)
                        {
                            await OnOk.InvokeAsync(e);
                        }
                    }
                    else
                    {
                        ConfirmLoading = false;
                        await InvokeStateHasChangedAsync();
                    }
                },
                OkButtonProps = OkButtonProps,

                CancelButtonProps = CancelButtonProps,
                Rtl           = Rtl,
                MaxBodyHeight = MaxBodyHeight
            };

            return(options);
        }
Пример #8
0
 public virtual Task OkAsync(ModalClosingEventArgs args)
 {
     return(Task.CompletedTask);
 }