diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs index 616e7865..4b825be5 100644 --- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs +++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs @@ -1669,6 +1669,64 @@ namespace EgwCoreLib.Lux.Data.Controllers } return answ; } + /// + /// Upsert dell'elenco dei tags associati + /// + /// ID Job richiesto + /// Elenco Tags richiesto + /// + internal async Task JobTask2TagsUpsertAsync(int JobID, List reqTagList) + { + bool answ = false; + //using (DataLayerContext dbCtx = new DataLayerContext(_config)) + using (DataLayerContext dbCtx = new DataLayerContext()) + { + try + { + var currRec = dbCtx + .DbSetJobTask + .Where(x => x.JobID == JobID) + .Include(t => t.TagNav) + .FirstOrDefault(); + // se trovato --> aggiorno + if (currRec != null) + { + var currentTags = currRec.TagNav.Select(t => t.CodTag).ToList(); + + // calcolo modifiche + var toAdd = reqTagList.Except(currentTags).ToList(); + var toRemove = currentTags.Except(reqTagList).ToList(); + + // aggiunte + foreach (var tag in toAdd) + { + currRec.TagNav.Add(new JobTaskTagModel + { + JobID = JobID, + CodTag = tag + }); + } + // rimozioni + foreach (var tag in toRemove) + { + var entity = currRec.TagNav.FirstOrDefault(t => t.CodTag == tag); + if (entity != null) + dbCtx.Remove(entity); + } + + dbCtx.Entry(currRec).State = EntityState.Modified; + } + // salvo... + int numAct = await dbCtx.SaveChangesAsync(); + answ = numAct > 0; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante JobTask2TagsUpsertAsync{Environment.NewLine}{exc}"); + } + } + return answ; + } /// /// Elenco completo offerte da DB diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs index d0b065de..2fee2283 100644 --- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs +++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs @@ -902,6 +902,20 @@ namespace EgwCoreLib.Lux.Data.Services return result; } + /// + /// Esegue Upsert info Tag associati + /// + /// + /// + /// + public async Task JobTask2TagsUpsertAsync(int JobID, List reqTagList) + { + bool result = await dbController.JobTask2TagsUpsertAsync(JobID, reqTagList); + await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:JobTaskList:*"); + await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:JobStep:*"); + return result; + } + /// /// Elenco completo offerte da DB /// diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index 232f3cf9..199a7ebe 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 0.9.2511.1219 + 0.9.2511.1312 diff --git a/Lux.UI/Components/Compo/JobTask/JobTaskListMan.razor b/Lux.UI/Components/Compo/JobTask/JobTaskListMan.razor index 752f83ae..2ea0a972 100644 --- a/Lux.UI/Components/Compo/JobTask/JobTaskListMan.razor +++ b/Lux.UI/Components/Compo/JobTask/JobTaskListMan.razor @@ -97,7 +97,7 @@ @item.Description @item.NumChild - + diff --git a/Lux.UI/Components/Compo/JobTask/JobTaskListMan.razor.cs b/Lux.UI/Components/Compo/JobTask/JobTaskListMan.razor.cs index 82c8d7b9..ed9b6a30 100644 --- a/Lux.UI/Components/Compo/JobTask/JobTaskListMan.razor.cs +++ b/Lux.UI/Components/Compo/JobTask/JobTaskListMan.razor.cs @@ -237,6 +237,20 @@ namespace Lux.UI.Components.Compo.JobTask return answ; } + /// + /// Update record x elenco tags + /// + /// + /// + private async Task DoSaveTags(TagDisplay.SavePayload args) + { + // chiamo update + await DLService.JobTask2TagsUpsertAsync(args.Id, args.Tags); + await EC_Updated.InvokeAsync(true); + //// refresh! + //ResetEdit(); + } + /// /// Esegue spostamento /// diff --git a/Lux.UI/Components/Compo/JobTask/TagDisplay.razor b/Lux.UI/Components/Compo/JobTask/TagDisplay.razor index 661dec8a..8344b045 100644 --- a/Lux.UI/Components/Compo/JobTask/TagDisplay.razor +++ b/Lux.UI/Components/Compo/JobTask/TagDisplay.razor @@ -1,7 +1,7 @@ 
- @if (currTagsList != null && currTagsList.Count > 0) + @if (WorkingTags != null && WorkingTags.Count > 0) { - foreach (var tag in currTagsList) + foreach (var tag in WorkingTags) { @tag } @@ -16,7 +16,7 @@
diff --git a/Lux.UI/Components/Compo/JobTask/TagDisplay.razor.cs b/Lux.UI/Components/Compo/JobTask/TagDisplay.razor.cs index 4ed0ac7b..e09b08e5 100644 --- a/Lux.UI/Components/Compo/JobTask/TagDisplay.razor.cs +++ b/Lux.UI/Components/Compo/JobTask/TagDisplay.razor.cs @@ -23,21 +23,13 @@ namespace Lux.UI.Components.Compo.JobTask /// Elenco Tags attivi ///
[Parameter] - public List ActiveTagsList - { - get => currTagsList; - set - { - currTagsList = value; - origTagsList = value; - } - } + public List ActiveTagsList { get; set; } = new List(); /// /// Elenco completo Tags ammissibili /// [Parameter] - public List AllTagsList { get; set; } = new(); + public List AllTagsList { get; set; } = null!; /// /// base css display: "bg-info bg-gradient bg-opacity-50 text-dark" @@ -52,18 +44,45 @@ namespace Lux.UI.Components.Compo.JobTask /// Richiesta update elenco tags associati all'obj /// [Parameter] - public EventCallback> EC_ReqSave { get; set; } + public EventCallback EC_ReqSave { get; set; } [Parameter] public bool EnableEdit { get; set; } = false; + /// + /// Id Parent + /// + [Parameter] + public int ParentId { get; set; } = 0; + + /// + /// UID Parent + /// + [Parameter] + public string ParentUid { get; set; } = string.Empty; + #endregion Public Properties + #region Public Classes + + public class SavePayload + { + #region Public Properties + + public int Id { get; set; } = 0; + public List Tags { get; set; } = new(); + public string Uid { get; set; } = string.Empty; + + #endregion Public Properties + } + + #endregion Public Classes + #region Protected Properties protected List AvailTagsList { - get => AllTagsList.Except(currTagsList).ToList(); + get => AllTagsList.Except(WorkingTags).ToList(); } protected string spanCss @@ -77,18 +96,40 @@ namespace Lux.UI.Components.Compo.JobTask protected void AddTag(string codTag) { - currTagsList.Add(codTag); + WorkingTags.Add(codTag); + } + protected void RemTag(string codTag) + { + WorkingTags.Remove(codTag); } protected string cssEnab(string tag2check) { - return currTagsList.Contains(tag2check) ? "disabled bg-opacity-10" : ""; + return WorkingTags.Contains(tag2check) ? "disabled bg-opacity-10" : ""; + } + + protected void DoCancel() + { + isEdit = false; + WorkingTags = new List(ActiveTagsList); } protected async Task DoSave() { + isEdit = false; // sollevo evento - await EC_ReqSave.InvokeAsync(currTagsList); + var payload = new SavePayload() + { + Id = ParentId, + Uid = ParentUid, + Tags = WorkingTags + }; + await EC_ReqSave.InvokeAsync(payload); + } + + protected override void OnParametersSet() + { + WorkingTags = new List(ActiveTagsList); } #endregion Protected Methods @@ -96,16 +137,10 @@ namespace Lux.UI.Components.Compo.JobTask #region Private Fields private bool isEdit = false; + private List WorkingTags = new(); #endregion Private Fields - #region Private Properties - - private List currTagsList { get; set; } = new(); - private List origTagsList { get; set; } = new(); - - #endregion Private Properties - #region Private Methods private void ToggleEdit() @@ -116,7 +151,7 @@ namespace Lux.UI.Components.Compo.JobTask } if (!isEdit) { - _ = EC_ReqSave.InvokeAsync(origTagsList); + WorkingTags = new List(ActiveTagsList); } } diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index 431d1b71..e17ff5a7 100644 --- a/Lux.UI/Lux.UI.csproj +++ b/Lux.UI/Lux.UI.csproj @@ -5,7 +5,7 @@ enable enable aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50 - 0.9.2511.1219 + 0.9.2511.1312 diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 01667546..304139ed 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 0.9.2511.1219

+

Versione: 0.9.2511.1312


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index c3d9e29d..0ed33c1f 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -0.9.2511.1219 +0.9.2511.1312 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 0cb13c0c..1f930d21 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 0.9.2511.1219 + 0.9.2511.1312 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false