diff --git a/EgwCoreLib.Lux.Data/Repository/Admin/VocabolarioRepository.cs b/EgwCoreLib.Lux.Data/Repository/Admin/VocabolarioRepository.cs index 5da8958b..63d85bef 100644 --- a/EgwCoreLib.Lux.Data/Repository/Admin/VocabolarioRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Admin/VocabolarioRepository.cs @@ -42,6 +42,16 @@ return false; } + // creo nuova lingua se non esistesse... + var recLang = await dbCtx.DbSetLingua.FirstOrDefaultAsync(x => x.Lingua == linguaDest); + if (recLang == null) + { + recLang = new LinguaModel() { Lingua = linguaDest, Note = $"Cloned from {linguaOrig}" }; + + await dbCtx.DbSetLingua.AddAsync(recLang); + await dbCtx.SaveChangesAsync(); + } + // 2. Proietto nei nuovi record... var listNew = listOrig.Select(x => new VocabolarioModel() { diff --git a/Lux.UI/Components/Compo/Admin/VocabMan.razor b/Lux.UI/Components/Compo/Admin/VocabMan.razor index 8a09b2f5..60fa78df 100644 --- a/Lux.UI/Components/Compo/Admin/VocabMan.razor +++ b/Lux.UI/Components/Compo/Admin/VocabMan.razor @@ -4,6 +4,7 @@ Lingua
+
+ + @if (!string.IsNullOrEmpty(selLingua)) + { + + } +
diff --git a/Lux.UI/Components/Compo/Admin/VocabMan.razor.cs b/Lux.UI/Components/Compo/Admin/VocabMan.razor.cs index c2cf1c36..a7a0a402 100644 --- a/Lux.UI/Components/Compo/Admin/VocabMan.razor.cs +++ b/Lux.UI/Components/Compo/Admin/VocabMan.razor.cs @@ -12,6 +12,9 @@ namespace Lux.UI.Components.Compo.Admin [Parameter] public EventCallback EC_Updated { get; set; } + [Parameter] + public EventCallback EC_ReqClone { get; set; } + [Parameter] public List ListLingue { get; set; } = null!; @@ -31,6 +34,12 @@ namespace Lux.UI.Components.Compo.Admin } } + private async Task DoClone() + { + if (!string.IsNullOrEmpty(selLingua)) + await EC_ReqClone.InvokeAsync(selLingua); + } + #endregion Protected Methods #region Private Fields diff --git a/Lux.UI/Components/Pages/Vocabulary.razor b/Lux.UI/Components/Pages/Vocabulary.razor index 0a5ef741..2d68a8dc 100644 --- a/Lux.UI/Components/Pages/Vocabulary.razor +++ b/Lux.UI/Components/Pages/Vocabulary.razor @@ -39,10 +39,10 @@ {
- +
- +
} @@ -50,4 +50,5 @@
+ diff --git a/Lux.UI/Components/Pages/Vocabulary.razor.cs b/Lux.UI/Components/Pages/Vocabulary.razor.cs index 1b94b88f..b1749e3f 100644 --- a/Lux.UI/Components/Pages/Vocabulary.razor.cs +++ b/Lux.UI/Components/Pages/Vocabulary.razor.cs @@ -1,4 +1,5 @@ using EgwCoreLib.Lux.Data.DbModel.Admin; +using EgwCoreLib.Razor; namespace Lux.UI.Components.Pages { @@ -86,6 +87,30 @@ namespace Lux.UI.Components.Pages await ReloadDataAsync(); } + private async Task DoCloneLang(string origLang) + { + mTitle = "Attenzione"; + mMessage = "Sicuro di voler duplicare il vocabolario della lingua selezionata?\n" + + $"Sorgente: {origLang}"; + mMode = BootstrapModal.ModalMode.Confirm; + modalOpt = new(); + modalOpt.Add(true, "Si"); + modalOpt.Add(false, "No"); + if (!await Modal!.ShowAsync()) + return; + + // dovrebbe chiedere nuova lingua... + string destLang = "FR"; + // ora duplica... + await VService.CloneAsync(origLang, destLang); + await ReloadDataAsync(); + } + private BootstrapModal Modal = new(); + private string mTitle = ""; + private string mMessage = ""; + private BootstrapModal.ModalMode mMode = BootstrapModal.ModalMode.ND; + private Dictionary modalOpt = new Dictionary(); + #endregion Private Methods } } \ No newline at end of file