From 7433f6a676542f73d21295919bbe9cedc9f2db87 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 5 May 2026 10:18:37 +0200 Subject: [PATCH] update customDialog --- EgwCoreLib.Razor/CustomDialog.razor | 75 +++++++++++++++++++ EgwCoreLib.Razor/CustomDialog_old.razor | 46 ++++++++++++ EgwCoreLib.Razor/CustomDialog_old.razor.css | 32 ++++++++ EgwCoreLib.Razor/CustomDialog_old.razor.less | 34 +++++++++ .../CustomDialog_old.razor.min.css | 1 + EgwCoreLib.Razor/EgwCoreLib.Razor.csproj | 4 + EgwCoreLib.Razor/ParetoProgress.razor | 8 +- EgwCoreLib.Razor/compilerconfig.json | 4 + 8 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 EgwCoreLib.Razor/CustomDialog.razor create mode 100644 EgwCoreLib.Razor/CustomDialog_old.razor create mode 100644 EgwCoreLib.Razor/CustomDialog_old.razor.css create mode 100644 EgwCoreLib.Razor/CustomDialog_old.razor.less create mode 100644 EgwCoreLib.Razor/CustomDialog_old.razor.min.css diff --git a/EgwCoreLib.Razor/CustomDialog.razor b/EgwCoreLib.Razor/CustomDialog.razor new file mode 100644 index 0000000..704919e --- /dev/null +++ b/EgwCoreLib.Razor/CustomDialog.razor @@ -0,0 +1,75 @@ +@using Microsoft.JSInterop +@inject IJSRuntime JS + + + +@code { + private TaskCompletionSource? tcs; + private string ModalId { get; } = $"modal_{Guid.NewGuid():N}"; + + [Parameter] + public string Title { get; set; } = ""; + + [Parameter] + public string Message { get; set; } = ""; + + [Parameter] + public string UserInput { get; set; } = ""; + + /// + /// Shows the Bootstrap modal and waits for user input. + /// + public async Task ShowAsync(string message, string defaultValue = "", string title = "Prompt") + { + Title = title; + Message = message; + UserInput = defaultValue; + tcs = new TaskCompletionSource(); + + await JS.InvokeVoidAsync("bootstrapModalHelper.show", $"#{ModalId}"); + return await tcs.Task; + } + /// + /// Shows the Bootstrap modal and waits for user input. + /// + public async Task ShowAsync() + { + // Title = title; + // Message = message; + // UserInput = defaultValue; + tcs = new TaskCompletionSource(); + + await JS.InvokeVoidAsync("bootstrapModalHelper.show", $"#{ModalId}"); + return await tcs.Task; + } + + private async Task Confirm() + { + await JS.InvokeVoidAsync("bootstrapModalHelper.hide", $"#{ModalId}"); + tcs?.TrySetResult(UserInput); + } + + private async Task Cancel() + { + await JS.InvokeVoidAsync("bootstrapModalHelper.hide", $"#{ModalId}"); + tcs?.TrySetResult(null); + } +} diff --git a/EgwCoreLib.Razor/CustomDialog_old.razor b/EgwCoreLib.Razor/CustomDialog_old.razor new file mode 100644 index 0000000..e82be47 --- /dev/null +++ b/EgwCoreLib.Razor/CustomDialog_old.razor @@ -0,0 +1,46 @@ + + +@code { + private bool _isVisible; + private TaskCompletionSource? _tcs; + + public string Message { get; set; } = ""; + public string UserInput { get; set; } = ""; + + /// + /// Shows the prompt and waits for user input. + /// + public Task ShowAsync(string message, string defaultValue = "") + { + Message = message; + UserInput = defaultValue; + _isVisible = true; + StateHasChanged(); + + _tcs = new TaskCompletionSource(); + return _tcs.Task; + } + + private void Confirm() + { + _isVisible = false; + _tcs?.TrySetResult(UserInput); + } + + private void Cancel() + { + _isVisible = false; + _tcs?.TrySetResult(null); + } +} + diff --git a/EgwCoreLib.Razor/CustomDialog_old.razor.css b/EgwCoreLib.Razor/CustomDialog_old.razor.css new file mode 100644 index 0000000..0b3d56a --- /dev/null +++ b/EgwCoreLib.Razor/CustomDialog_old.razor.css @@ -0,0 +1,32 @@ +.modal-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.5); + display: none; + /* Controlled by inline style in Razor */ + align-items: center; + justify-content: center; + z-index: 1000; +} +.modal-box { + background: white; + padding: 20px; + border-radius: 8px; + min-width: 300px; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); +} +.modal-buttons { + margin-top: 15px; + display: flex; + justify-content: flex-end; + gap: 10px; +} +.modal-box input { + width: 100%; + padding: 6px; + margin-top: 10px; + box-sizing: border-box; +} \ No newline at end of file diff --git a/EgwCoreLib.Razor/CustomDialog_old.razor.less b/EgwCoreLib.Razor/CustomDialog_old.razor.less new file mode 100644 index 0000000..8550183 --- /dev/null +++ b/EgwCoreLib.Razor/CustomDialog_old.razor.less @@ -0,0 +1,34 @@ +.modal-overlay { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.5); + display: none; /* Controlled by inline style in Razor */ + align-items: center; + justify-content: center; + z-index: 1000; +} + +.modal-box { + background: white; + padding: 20px; + border-radius: 8px; + min-width: 300px; + box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); +} + +.modal-buttons { + margin-top: 15px; + display: flex; + justify-content: flex-end; + gap: 10px; +} + +.modal-box input { + width: 100%; + padding: 6px; + margin-top: 10px; + box-sizing: border-box; +} diff --git a/EgwCoreLib.Razor/CustomDialog_old.razor.min.css b/EgwCoreLib.Razor/CustomDialog_old.razor.min.css new file mode 100644 index 0000000..61ad6bd --- /dev/null +++ b/EgwCoreLib.Razor/CustomDialog_old.razor.min.css @@ -0,0 +1 @@ +.modal-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.5);display:none;align-items:center;justify-content:center;z-index:1000;}.modal-box{background:#fff;padding:20px;border-radius:8px;min-width:300px;box-shadow:0 2px 10px rgba(0,0,0,.3);}.modal-buttons{margin-top:15px;display:flex;justify-content:flex-end;gap:10px;}.modal-box input{width:100%;padding:6px;margin-top:10px;box-sizing:border-box;} \ No newline at end of file diff --git a/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj b/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj index e64a332..4a94b3d 100644 --- a/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj +++ b/EgwCoreLib.Razor/EgwCoreLib.Razor.csproj @@ -26,6 +26,7 @@ + @@ -33,6 +34,9 @@ + + + diff --git a/EgwCoreLib.Razor/ParetoProgress.razor b/EgwCoreLib.Razor/ParetoProgress.razor index 07f0c04..44cb6bc 100644 --- a/EgwCoreLib.Razor/ParetoProgress.razor +++ b/EgwCoreLib.Razor/ParetoProgress.razor @@ -64,11 +64,15 @@ [Parameter] public bool ShowIcon { get; set; } = false; - + /// + /// Valore larghezza calcolata in % corretta + /// + /// + /// private string CalcPctCss(double currVal) { var dblVal = Total > 0 ? currVal / (double)Total * 100 : 0; - return $"{dblVal.ToString("F1", CultureInfo.InvariantCulture)}%"; + return $"{dblVal.ToString("F2", CultureInfo.InvariantCulture)}%"; } // Proprietà calcolate con fallback sicuro diff --git a/EgwCoreLib.Razor/compilerconfig.json b/EgwCoreLib.Razor/compilerconfig.json index 47adeac..35c2f67 100644 --- a/EgwCoreLib.Razor/compilerconfig.json +++ b/EgwCoreLib.Razor/compilerconfig.json @@ -26,5 +26,9 @@ { "outputFile": "LoadingData.razor.css", "inputFile": "LoadingData.razor.less" + }, + { + "outputFile": "CustomDialog.razor.css", + "inputFile": "CustomDialog.razor.less" } ] \ No newline at end of file