Esempio n. 1
0
        public static async Task <TReturn> Show <TReturn, TComponent>(string name, params object[] param)
            where TComponent : Modal
        {
            lastResult = null;
            parameters = param;
            ModalService.Show <TComponent>(name);

            ModalResult result = null;

            ModalService.OnClose += (ModalResult res) =>
            {
                result = res;
            };

            while (result == null)
            {
                await Task.Delay(500);
            }

            if (lastResult is TReturn returnData)
            {
                return(returnData);
            }
            else
            {
                return(default(TReturn));
            }
        }
Esempio n. 2
0
        public async Task Error(string text)
        {
            var parameters = new ModalParameters();

            parameters.Add("Text", "Provided file contains invalid data");
            var modal = instance.Show <Alert>("Error", parameters);
            await modal.Result;
        }
Esempio n. 3
0
        /// <see cref="ITableauViewModel.DeleteTableau"/>
        public async Task DeleteTableau()
        {
            var messageForm = ModalService.Show <ConfirmDeleteComponent>("Confirmation");
            var result      = await messageForm.Result;

            if (!result.Cancelled)
            {
                await DataAccess.DeleteTableau(TableauSelected.IdTableau);

                // Revenir à la page des tableaux
                NavigationManager.NavigateTo("/mestableaux", true);
            }
        }
Esempio n. 4
0
        public void AddCategory()
        {
            _modalService.OnClose += _modalService_OnClose;
            var parameters = new ModalParameters();
            var options    = new ModalOptions()
            {
                DisableBackgroundCancel = true
            };

            _modalService.Show <CategoryForm>("Dodawanie nowej kategorii", parameters, options);
            parameters.Add("category", new CategoryModel());

            currentAction = ActionState.Adding;
        }
        public async Task ShowMessageAsync(string Title, string Message, int Duration = 0)
        {
            ModalParameters modalParameters = new ModalParameters();

            modalParameters.Add("Message", Message);

            var modalRef = modalService.Show <ShowMessagePopupComponent>(Title);

            if (Duration > 0)
            {
                await Task.Delay(Duration);

                modalRef.Close();
            }
        }
        public static async Task <bool> Confirm(this IModalService modalService, string text)
        {
            var modal  = modalService.Show <ConfirmModal>(text);
            var result = await modal.Result;

            return(!result.Cancelled);
        }
Esempio n. 7
0
        public static async Task <bool> OkCancel(IModalService modalService, string title, string message)
        {
            if (modalService == null)
            {
                throw new NullReferenceException("modalService");
            }

            ModalParameters mp = new ModalParameters();

            mp.Add(nameof(OkCancelContent.Message), message);

            ModalOptions mo = new ModalOptions();

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

            IModalReference result = modalService.Show <OkCancelContent>(title, mp, mo);
            ModalResult     mr     = await result.Result;

            if (mr.Cancelled)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        public static async Task <(bool, string)> TextInput(IModalService modalService, string title, string message, string defaultValue = null)
        {
            if (modalService == null)
            {
                throw new NullReferenceException("modalService");
            }

            ModalParameters mp = new ModalParameters();

            mp.Add(nameof(TextInputContent.Message), message);
            mp.Add(nameof(TextInputContent.Value), defaultValue);

            ModalOptions mo = new ModalOptions();

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

            IModalReference result = modalService.Show <TextInputContent>(title, mp, mo);
            ModalResult     mr     = await result.Result;

            if (mr.Cancelled)
            {
                return(false, null);
            }
            return(true, mr.Data as string);
        }
        public async ValueTask Display(string title, string message)
        {
            var parameters = new ModalParameters();

            parameters.Add("Message", message);
            var modal = modalService.Show <DisplayMessage>(title, parameters);
            await modal.Result;
        }
Esempio n. 11
0
        public void AddProduct()
        {
            _modalService.OnClose += _modalService_OnClose;
            var parameters = new ModalParameters();
            var options    = new ModalOptions()
            {
                DisableBackgroundCancel = true
            };

            parameters.Add("product", new ProductModel {
                Tax = 23, CategoryId = CategoryList[0].Id
            });
            parameters.Add("categories", CategoryList);
            _modalService.Show <ProductForm>("Dodawanie nowego produktu", parameters, options);

            currentAction = ActionState.Adding;
        }
Esempio n. 12
0
        public static void ShowModal(string msg, IModalService Modal)
        {
            ModalOptions options = new ModalOptions()
            {
                HideCloseButton = true
            };

            Modal.Show <Confirm>(msg, options);
        }
Esempio n. 13
0
        /// <summary>
        /// Shows a message in a modal dialog.
        /// </summary>
        /// <param name="modalService">The modal service.</param>
        /// <param name="title">The title.</param>
        /// <param name="message">The message.</param>
        public static Task ShowMessageAsync(this IModalService modalService, string title, string message)
        {
            var messageParams = new ModalParameters();

            messageParams.Add(nameof(ModalMessage.Text), message);
            var modal = modalService.Show <ModalMessage>(title, messageParams);

            return(modal.Result);
        }
Esempio n. 14
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);
        }
        void ShowModal(string appName, string displayName)
        {
            var opt = new ModalOptions()
            {
                ContentScrollable = true,
                FocusFirstElement = true
            };

            ChangeModalState(appName);

            Modal.Show <WorkDetails>(displayName, opt);
        }
        public void DeleteOrder(UserOrderHeaderModel userOrderHeaderModel)
        {
            _modalService.OnClose += _modalService_OnClose;
            var parameters = new ModalParameters();

            parameters.Add("order", userOrderHeaderModel);
            var options = new ModalOptions()
            {
                DisableBackgroundCancel = true
            };

            _modalService.Show <DeleteIndyvidualOrderForm>("Czy na pewno chcesz usunąć zamówienie?", parameters, options);
        }
Esempio n. 17
0
        public async Task <string> ShowAsync()
        {
            var options = new ModalOptions()
            {
                DisableBackgroundCancel = true,
                HideCloseButton         = true
            };

            var userNamePrompt = _modal.Show <UserNamePrompt>("Edit Profile", options);
            var result         = await userNamePrompt.Result;

            return((string)result.Data);
        }
        public async Task <BarcodeResult> ScanBarcode(IModalService modalService)
        {
            myIsScanning = true;
            var moviesModal = modalService.Show <BarcodeScannerComponent>("Scanner");
            var result      = await moviesModal.Result;

            if (result.Data is BarcodeResult barcodeResult)
            {
                myIsScanning = false;
                return(barcodeResult);
            }
            myIsScanning = false;
            return(null);
        }
        public async Task <bool> Confirm(string title, string message)
        {
            var parameters = new ModalParameters();

            parameters.Add("Message", message);
            var options = new ModalOptions
            {
                HideCloseButton = true
            };
            var modal  = modalService.Show <YesNoModal>(title, parameters, options);
            var result = await modal.Result;

            return(result.DataType == typeof(int) && (int)result.Data == (int)ConfirmDisplayerResult.Yes);
        }
        internal static async Task <StudyGroupToSelectDto?> SelectStudyGroup(this IModalService modalService, TextService textService)
        {
            // Show modal window
            var modal  = modalService.Show <SelectStudyGroupModal>(textService.SelectFacultyModal_Title);
            var result = await modal.Result;

            // Check if the modal is canceled
            if (result.Cancelled)
            {
                return(null);
            }

            // Get selected study group
            var studyGroup = result.Data as StudyGroupToSelectDto;

            return(studyGroup);
        }
Esempio n. 21
0
        public static async Task AddEditLaunchAsync(IModalService modalService, SmartishTable.Root <LaunchDto> table, int index, RocketDto?rocketDto = null)
        {
            if (table == null || table.SafeList == null)
            {
                return;
            }

            var       isNew = index == -1;
            LaunchDto?dto   = null;

            if (!isNew)
            {
                dto = table.GetAt(index);
            }
            var parameters = new Blazored.Modal.ModalParameters();

            parameters.Add(nameof(LaunchAddEdit.DtoOriginal), dto);
            if (rocketDto != null)
            {
                parameters.Add(nameof(LaunchAddEdit.SelectedRocketId), rocketDto.RocketId);
            }
            parameters.Add(nameof(LaunchAddEdit.InitialLaunchNumber), (rocketDto?.NumberOfLaunches ?? 0) + 1);
            var modalReference = modalService.Show <LaunchAddEdit>("Launch Add/Edit", parameters, new ModalOptions()
            {
            });
            var modalResult = await modalReference.Result;

            dto = modalResult.Data as LaunchDto;
            if (dto != null)
            {
                if (isNew)
                {
                    await table.Add(dto);
                }
                else
                {
                    await table.UpdateAt(index, dto);
                }

                if (rocketDto != null && dto.LaunchNumber > rocketDto.NumberOfLaunches)
                {
                    rocketDto.NumberOfLaunches = dto.LaunchNumber;
                }
            }
        }
Esempio n. 22
0
        public static async Task Download(string filename, AppState AppState, IModalService Modal, MonacoEditor editor, IJSRuntime js, bool twoEditorForm)
        {
            AppState.Message = filename;
            ModalOptions options = new ModalOptions()
            {
                HideCloseButton = true
            };
            var FileNameForm = Modal.Show <FileNameForm>(title: "", options);
            var result       = await FileNameForm.Result;

            if (result.Cancelled)
            {
                return;
            }

            if (await js.InvokeAsync <int>("isChrome") > -1)
            {
                if (twoEditorForm)
                {
                    var w21 = await js.InvokeAsync <string>("getWidth", "editor-source");

                    var h21 = await js.InvokeAsync <string>("getHeight", "editor-source");

                    await js.InvokeVoidAsync("setSize", "editor-source", w21, h21);

                    var w22 = await js.InvokeAsync <string>("getWidth", "editor-target");

                    var h22 = await js.InvokeAsync <string>("getHeight", "editor-target");

                    await js.InvokeVoidAsync("setSize", "editor-target", w22, h22);
                }
                else
                {
                    var w11 = await js.InvokeAsync <string>("getWidth", "editor-lookup");

                    var h11 = await js.InvokeAsync <string>("getHeight", "editor-lookup");

                    await js.InvokeVoidAsync("setSize", "editor-lookup", w11, h11);
                }
            }

            byte[] file = System.Text.Encoding.UTF8.GetBytes(await editor.GetValue());
            await js.InvokeVoidAsync("BlazorDownloadFile", result.Data?.ToString() ?? string.Empty, "text/xml", file);
        }
Esempio n. 23
0
        public void RejectOrder(SellerOrderHeaderModel sellerOrderHeaderModel)
        {
            _modalService.OnClose += _modalService_OnClose;
            var parameters = new ModalParameters();
            UserOrderHeaderModel userOrderHeaderModel = new UserOrderHeaderModel
            {
                Id = sellerOrderHeaderModel.Id,
                CreationDateFormatted = sellerOrderHeaderModel.CreationDateFormatted,
                SummaryValue          = sellerOrderHeaderModel.SummaryValue,
                BuyerId = sellerOrderHeaderModel.BuyerId
            };

            parameters.Add("order", userOrderHeaderModel);
            var options = new ModalOptions()
            {
                DisableBackgroundCancel = true
            };

            _modalService.Show <DeleteIndyvidualOrderForm>("Czy na pewno musisz odrzucić zamówienie?", parameters, options);
        }
Esempio n. 24
0
        /// <summary>
        /// Shows a loading indicator in a modal dialog.
        /// </summary>
        /// <param name="modalService">The modal service.</param>
        /// <returns>The disposable which closes the modal indicator.</returns>
        public static IDisposable ShowLoadingIndicator(this IModalService modalService)
        {
            var cts          = new CancellationTokenSource();
            var modalOptions = new ModalOptions
            {
                DisableBackgroundCancel = true,
                HideCloseButton         = true,
                HideHeader = true,
            };
            var modalParameters = new ModalParameters();

            modalParameters.Add(nameof(ModalLoadingIndicator.CancellationToken), cts.Token);
            modalService.Show <ModalLoadingIndicator>(string.Empty, modalParameters, modalOptions);

            return(new DisposeWrapper(() =>
            {
                cts.Cancel();
                cts.Dispose();
            }));
        }
Esempio n. 25
0
        /// <see cref="INewTableViewModel.EditColonne(int, Guid)"/>
        public async Task EditColonne(int idColonne, Guid idTableau)
        {
            try
            {
                var colonneSelected = TableauModel.Colonnes.FirstOrDefault(x => x.IdColonne == idColonne && x.TableId == idTableau);

                var parameters = new ModalParameters();
                parameters.Add(nameof(EditColonneComponent.Colonne), colonneSelected);

                var messageForm = ModalService.Show <EditColonneComponent>("Edition", parameters);
                var result      = await messageForm.Result;

                if (!result.Cancelled)
                {
                    colonneSelected = (ColonneModel)result.Data;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Erreur sur l'édition d'une colonne.");
            }
        }
Esempio n. 26
0
        public static async Task AddEditRocketAsync(IModalService modalService, SmartishTable.Root <RocketDto> table, int index)
        {
            if (table == null || table.SafeList == null)
            {
                return;
            }

            var       isNew = index == -1;
            RocketDto?dto   = null;

            if (!isNew)
            {
                dto = table.GetAt(index);
            }

            var parameters = new Blazored.Modal.ModalParameters();

            parameters.Add(nameof(RocketAddEdit.DtoOriginal), dto);
            var modalReference = modalService.Show <RocketAddEdit>("Rocket Add/Edit", parameters, new ModalOptions()
            {
            });
            var modalResult = await modalReference.Result;

            dto = modalResult.Data as RocketDto;
            if (dto != null)
            {
                if (isNew)
                {
                    await table.Add(dto);
                }
                else
                {
                    await table.UpdateAt(index, dto);
                }
            }
        }
Esempio n. 27
0
        public async Task <ModalResult> ShowSpecimenModal(int id)
        {
            var modalParams = new ModalParameters();

            modalParams.Add("Id", id);
            modalParams.Add("IsModal", true);

            var specimenModal = _modalService.Show <SpecimenViewer>("Specimen", modalParams, DefaultModalOptions);

            return(await specimenModal.Result);
        }
 public Task HandleShowIncrementCountModalAction(ShowIncrementCountModalAction action, IDispatcher dispatcher)
 {
     modalService.Show <IncrementCountModal>("Enter increment");
     return(Task.CompletedTask);
 }