Exemplo n.º 1
0
        protected async void GameReset(object sender, PlayerEvent e)
        {
            players.ForEach(p => p.Vote = null);
            voteComplete = false;
            StateHasChanged();

            if (!observing)
            {
                var options = new ModalOptions()
                {
                    HideCloseButton         = true,
                    DisableBackgroundCancel = true
                };

                var voteModal   = Modal.Show <VotingModal>("Cast your vote!", options);
                var modalResult = await voteModal.Result;

                await ScrumPokerHub.VoteAsync((string)modalResult.Data);
            }
            else
            {
                await ScrumPokerHub.VoteAsync("🕵");
            }

            StateHasChanged();
        }
Exemplo n.º 2
0
        protected async Task HandleCreateListButton()
        {
            var options = new ModalOptions()
            {
                DisableBackgroundCancel = true,
                HideCloseButton         = true
            };

            var parameters = new ModalParameters();

            parameters.Add(nameof(User), User);

            var modal = Modal.Show <CreateMovieListForm>("New List", parameters, options);

            var result = await modal.Result;

            if (!result.Cancelled && User != null)
            {
                var user = await UserService.GetUserAsync(User.Id);

                User = user;

                StateHasChanged();
            }
        }
        protected async Task HandleEditListButton()
        {
            var options = new ModalOptions()
            {
                DisableBackgroundCancel = true,
                HideCloseButton         = true
            };

            var parameters = new ModalParameters();

            parameters.Add(nameof(User), User);
            parameters.Add(nameof(MovieList), MovieList);

            var modal  = Modal.Show <EditMovieListForm>("Edit List", parameters, options);
            var result = await modal.Result;

            if (!result.Cancelled && MovieList != null)
            {
                var movieList = await ListService.GetMovieListAsync(MovieList.Id);

                MovieList = movieList;

                StateHasChanged();
            }
        }
Exemplo n.º 4
0
        public static async Task <(bool, FuzzyModelDescriptionData)> FuzzyModelDescriptionEditor(IModalService modalService, FuzzyModelDescriptionData defaultValue)
        {
            if (modalService == null)
            {
                throw new NullReferenceException("modalService");
            }

            ModalParameters mp = new ModalParameters();

            mp.Add(nameof(FuzzyModelEditorForm.Data), defaultValue);

            ModalOptions mo = new ModalOptions();

            mo.DisableBackgroundCancel = true;
            mo.HideCloseButton         = true;

            IModalReference result = modalService.Show <FuzzyModelEditorForm>("Edycja opisu modelu", mp, mo);
            ModalResult     mr     = await result.Result;

            if (mr.Cancelled)
            {
                return(false, null);
            }
            return(true, mr.Data as FuzzyModelDescriptionData);
        }
Exemplo n.º 5
0
        protected void Forward()
        {
            StopTimer();
            var parameters      = new ModalParameters();
            ForwardViewModel fv = new ForwardViewModel();

            fv.NoteID      = currentHeader.Id;
            fv.FileID      = currentHeader.NoteFileId;
            fv.ArcID       = currentHeader.ArchiveId;
            fv.NoteOrdinal = currentHeader.NoteOrdinal;
            fv.NoteSubject = currentHeader.NoteSubject;

            if (currentHeader.ResponseCount > 0 || currentHeader.BaseNoteId > 0)
            {
                fv.hasstring = true;
            }

            parameters.Add("ForwardView", fv);

            Modal.OnClose += HideDialog;
            var options = new ModalOptions()
            {
                HideCloseButton = false
            };

            Modal.Show <Forward>("", parameters, options);
        }
 public void SetButtonSettings(ModalOptions options)
 {
     this.ShowCancelButton  = options.ButtonOptions.ShowCancelButton;
     this.ShowConfirmButton = options.ButtonOptions.ShowConfirmButton;
     this.CancelButtonText  = this.GetNameOfButtonType(options.ButtonOptions.CancelButtonType);
     this.ConfirmButtonText = this.GetNameOfButtonType(options.ButtonOptions.ConfirmButtonType);
 }
        private void SetModalOptions(ModalOptions options)
        {
            this.ComponentHideHeader = this.HideHeader;
            if (options.HideHeader.HasValue)
            {
                this.ComponentHideHeader = options.HideHeader.Value;
            }

            this.ComponentHideCloseButton = this.HideCloseButton;
            if (options.HideCloseButton.HasValue)
            {
                this.ComponentHideCloseButton = options.HideCloseButton.Value;
            }

            this.ComponentDisableBackgroundCancel = this.DisableBackgroundCancel;
            if (options.DisableBackgroundCancel.HasValue)
            {
                this.ComponentDisableBackgroundCancel = options.DisableBackgroundCancel.Value;
            }

            this.ComponentPosition = string.IsNullOrWhiteSpace(options.Position) ? this.Position : options.Position;
            if (string.IsNullOrWhiteSpace(this.ComponentPosition))
            {
                this.ComponentPosition = DefaultPosition;
            }

            this.ComponentStyle = string.IsNullOrWhiteSpace(options.Style) ? this.Style : options.Style;
            if (string.IsNullOrWhiteSpace(this.ComponentStyle))
            {
                this.ComponentStyle = DefaultStyle;
            }
        }
Exemplo n.º 8
0
 public Task <ModalResult> ShowAsync(string title, RenderComponent component, ModalOptions modalOptions = null)
 {
     modalModel = new ModalModel(component, title, modalOptions);
     modals.Push(modalModel);
     OnChanged?.Invoke();
     return(modalModel.Task);
 }
Exemplo n.º 9
0
        private async Task OnCreateClick()
        {
            var item       = this.PersistenceContext.CreateNew <TItem>();
            var parameters = new ModalParameters();

            parameters.Add(nameof(ModalCreateNew <TItem> .Item), item);
            parameters.Add(nameof(ModalCreateNew <TItem> .PersistenceContext), this.PersistenceContext);
            var options = new ModalOptions
            {
                DisableBackgroundCancel = true,
            };

            var modal  = this.Modal.Show <ModalCreateNew <TItem> >($"Create {typeof(TItem).Name}", parameters, options);
            var result = await modal.Result;

            if (result.Cancelled)
            {
                this.PersistenceContext.Delete(item);
            }
            else
            {
                this.Value.Add(item);
                this.PersistenceContext.SaveChanges();
                this.StateHasChanged();
            }
        }
Exemplo n.º 10
0
        private async Task OpenMetadataDetailsModalTemplate(Metadata metadata)
        {
            var templateOptions = new ViewModels.MetadataDetailsViewModel
            {
                Metadata = metadata
            };

            var modalConfig = new ModalOptions();

            modalConfig.Title    = "Metadata Preview";
            modalConfig.Width    = "90%";
            modalConfig.OnCancel = async(e) =>
            {
                await metadataDetailsModalRef.CloseAsync();
            };
            modalConfig.OnOk = async(e) =>
            {
                await metadataDetailsModalRef.CloseAsync();
            };

            modalConfig.AfterClose = () =>
            {
                InvokeAsync(StateHasChanged);

                return(Task.CompletedTask);
            };

            metadataDetailsModalRef = await ModalService
                                      .CreateModalAsync <MetadataDetailsModal, ViewModels.MetadataDetailsViewModel>(
                modalConfig, templateOptions);
        }
Exemplo n.º 11
0
        public void ShowInfoModal(string title, string message, ModalOptions options = null)
        {
            var parameters = new ModalParameters();

            parameters.Add("message", message);
            Show <InfoModal>(title, parameters, options, null);
        }
Exemplo n.º 12
0
        private async void ShowEditDialog()
        {
            var options = new ModalOptions();

            options.Set(ModalOptions.__Width, "80%");
            await this.Modal.ShowAsync <WeatherEditor>(options);
        }
Exemplo n.º 13
0
        private async void ShowViewDialog()
        {
            var options = new ModalOptions();

            options.Set(ModalOptions.__Width, "60%");
            await this.Modal.ShowAsync <WeatherViewer>(options);
        }
Exemplo n.º 14
0
 public void Show <T>(string title, ModalParameters parameters = null, ModalOptions options = null) where T : ComponentBase
 {
     Show(title,
          typeof(T),
          parameters ?? new ModalParameters(),
          options ?? new ModalOptions());
 }
Exemplo n.º 15
0
        /// <summary>
        /// Creates a new Account in a modal dialog.
        /// </summary>
        public async Task CreateNewInModalDialog()
        {
            var accountParameters = new AccountCreationParameters();
            var parameters        = new ModalParameters();

            parameters.Add(nameof(ModalCreateNew <AccountCreationParameters> .Item), accountParameters);
            var options = new ModalOptions
            {
                DisableBackgroundCancel = true,
            };

            var modal  = this.modalService.Show <ModalCreateNew <AccountCreationParameters> >($"Create {nameof(Account)}", parameters, options);
            var result = await modal.Result;

            if (!result.Cancelled)
            {
                var item = this.playerContext.CreateNew <Account>();
                item.LoginName        = accountParameters.LoginName;
                item.PasswordHash     = BCrypt.Net.BCrypt.HashPassword(accountParameters.Password);
                item.EMail            = accountParameters.EMail;
                item.State            = accountParameters.State;
                item.SecurityCode     = accountParameters.SecurityCode;
                item.RegistrationDate = DateTime.Now;
                this.playerContext.SaveChanges();
                this.RaiseDataChanged();
            }
        }
Exemplo n.º 16
0
 public void Show <T>(string title, ModalParameters parameters = null, ModalOptions options = null, Action <ModalResult> callback = null) where T : ComponentBase
 {
     Show(title,
          typeof(T),
          parameters ?? new ModalParameters(),
          options ?? new ModalOptions(),
          callback);
 }
Exemplo n.º 17
0
 public ModalServiceClient(IModalService modalService)
 {
     _modalService       = modalService;
     DefaultModalOptions = new ModalOptions
     {
         ContentScrollable = true
     };
 }
Exemplo n.º 18
0
        private async Task OpenVariableModalTemplate(Variable variable)
        {
            var templateOptions = new ViewModels.VariableModalViewModel
            {
                Variable = new Variable()
                {
                    Name            = variable.Name,
                    Description     = variable.Description,
                    Units           = variable.Units,
                    Height          = variable.Height,
                    Tags            = variable.Tags,
                    Methods         = variable.Methods,
                    QCApplied       = variable.QCApplied,
                    ProcessingLevel = variable.ProcessingLevel
                },
                ProcessingLevels  = State.AppConfig.ProcessingLevels,
                QCFlags           = State.AppConfig.QCTags,
                Tags              = State.AppConfig.Tags,
                SelectedTags      = variable.Tags ??= new List <string>(),
                SelectedQCApplied = variable.QCApplied ??= new List <string>()
            };

            var modalConfig = new ModalOptions();

            modalConfig.Title    = "Variable";
            modalConfig.Width    = "70%";
            modalConfig.OnCancel = async(e) =>
            {
                await variableModalRef.CloseAsync();
            };
            modalConfig.OnOk = async(e) =>
            {
                variable.Name            = templateOptions.Variable.Name;
                variable.Description     = templateOptions.Variable.Description;
                variable.Units           = templateOptions.Variable.Units;
                variable.Height          = templateOptions.Variable.Height;
                variable.Tags            = templateOptions.SelectedTags.ToList();
                variable.Methods         = templateOptions.Variable.Methods;
                variable.QCApplied       = templateOptions.SelectedQCApplied.ToList();
                variable.ProcessingLevel = templateOptions.Variable.ProcessingLevel;

                await variableModalRef.CloseAsync();
            };

            modalConfig.AfterClose = () =>
            {
                RemoveBlankVariables();

                InvokeAsync(StateHasChanged);

                return(Task.CompletedTask);
            };

            variableModalRef = await ModalService
                               .CreateModalAsync <VariableModal, ViewModels.VariableModalViewModel>(
                modalConfig, templateOptions);
        }
Exemplo n.º 19
0
        public static void ShowModal(string msg, IModalService Modal)
        {
            ModalOptions options = new ModalOptions()
            {
                HideCloseButton = true
            };

            Modal.Show <Confirm>(msg, options);
        }
Exemplo n.º 20
0
        private async void ShowEditDialog(Guid id)
        {
            var options = new ModalOptions();

            {
                options.Set(ModalOptions.__Width, "80%");
                options.Set(ModalOptions.__ID, id);
            }
            await this.Modal.ShowAsync <WeatherForecastEditor>(options);
        }
Exemplo n.º 21
0
        public async Task <ModalResult> Show(string title, string message, string confirmButtonText = "Yes")
        {
            var options = new ModalOptions {
                UseCustomLayout = true
            };
            var parameters = new ModalParameters();

            parameters.Add("Message", message);
            parameters.Add("ConfirmButtonText", confirmButtonText);
            return(await _modalService.Show <ConfirmDialog>(title, parameters, options).Result);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Shows the modal with the component type using the specified <paramref name="title"/>,
        /// passing the specified <paramref name="parameters"/> and setting a custom CSS style.
        /// </summary>
        /// <param name="title">Modal title.</param>
        /// <param name="parameters">Key/Value collection of parameters to pass to component being displayed.</param>
        /// <param name="options">Options to configure the modal.</param>
        public void Show <T>(string title, ModalParameters parameters, ModalOptions options) where T : ComponentBase
        {
            if (!typeof(ComponentBase).IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException($"{typeof(T).FullName} must be a Blazor Component");
            }

            var content = new RenderFragment(x => { x.OpenComponent(1, typeof(T)); x.CloseComponent(); });

            OnShow?.Invoke(title, content, parameters, options);
        }
Exemplo n.º 23
0
        protected void OpenUploadProfileImageDialog()
        {
            var parameters = new ModalParameters();

            parameters.Add("FormId", 3);

            var options = new ModalOptions(new ModalButtonOptions(true, false, CancelButton.Cancel, ConfirmButton.Save));

            this.Modal.OnClose += this.UploadProfileImageDialogClosed;
            this.Modal.Show <UploadProfileImageDialog>("Profile image upload", parameters, options);
        }
Exemplo n.º 24
0
        protected void OpenChangeUsernameDialog()
        {
            var parameters = new ModalParameters();

            parameters.Add("FormId", 4);

            var options = new ModalOptions(new ModalButtonOptions(true, true, CancelButton.Cancel, ConfirmButton.Save));

            this.Modal.OnClose += this.ChangeUsernameDialogClosed;
            this.Modal.Show <ChangeUsernameDialog>("Change user name", parameters, options);
        }
Exemplo n.º 25
0
        public void SetTags(SearchData.DisplayData data)
        {
            var parameters = new ModalParameters();

            parameters.Add("tags", data.Tags);
            var options = new ModalOptions()
            {
                Position = "blazored-modal-center"
            };

            Modal.Show <TagsComponent>("Tags", parameters);
        }
Exemplo n.º 26
0
        void ShowModal(string title, string desc)
        {
            var prms = new ModalParameters();

            prms.Add("Description", desc);

            var opts = new ModalOptions()
            {
                Animation = ModalAnimation.FadeIn(1)
            };
            var m = modal.Show <FAQ>(title, prms, opts);
        }
Exemplo n.º 27
0
        protected void RowExpand(ItemUser iu)
        {
            var parameters = new ModalParameters();

            parameters.Add("ItemUser", iu);
            var opts = new ModalOptions()
            {
                HideHeader = true
            };

            ModalService.Show <ItemHistoryComponent>("History", parameters, opts);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Method called when the user clicks on a row in the viewer.
        /// </summary>
        /// <param name="id"></param>
        protected async void OnModalAsync <TForm>(int id) where TForm : IComponent
        {
            var modalOptions = new ModalOptions()
            {
                HideHeader = true
            };

            modalOptions.Parameters.Add("ModalBodyCSS", "p-0");
            modalOptions.Parameters.Add("ModalCSS", "modal-xl");
            modalOptions.Parameters.Add("ID", id);
            await this.ViewManager.ShowModalAsync <TForm>(modalOptions);
        }
Exemplo n.º 29
0
        private string GenerateOpenModalJSCode(ModalOptions modalOptions, bool isRegisterPlugins)
        {
            Dictionary <ModalOptions, string> modalsDic = new Dictionary <ModalOptions, string>()
            {
                { ModalOptions.Full, ConstantHelper.FullModalId },
                { ModalOptions.MidiumSize, ConstantHelper.MidModalId },
                { ModalOptions.Message, ConstantHelper.MsgModalId }
            };

            return("openModal('" + modalsDic[modalOptions] + "'" +
                   "," + isRegisterPlugins.ToString().ToLower() + ")");
        }
Exemplo n.º 30
0
        protected void ShowHelp()
        {
            var parameters = new ModalParameters();

            Modal.OnClose += HideDialog;
            var options = new ModalOptions()
            {
                HideCloseButton = false
            };

            Modal.Show <HelpDialog2>("", parameters, options);
        }