Completata gestione editing Tags x Job
This commit is contained in:
@@ -1669,6 +1669,64 @@ namespace EgwCoreLib.Lux.Data.Controllers
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Upsert dell'elenco dei tags associati
|
||||
/// </summary>
|
||||
/// <param name="JobID">ID Job richiesto</param>
|
||||
/// <param name="reqTagList">Elenco Tags richiesto</param>
|
||||
/// <returns></returns>
|
||||
internal async Task<bool> JobTask2TagsUpsertAsync(int JobID, List<string> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco completo offerte da DB
|
||||
|
||||
@@ -902,6 +902,20 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue Upsert info Tag associati
|
||||
/// </summary>
|
||||
/// <param name="JobID"></param>
|
||||
/// <param name="reqTagList"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> JobTask2TagsUpsertAsync(int JobID, List<string> reqTagList)
|
||||
{
|
||||
bool result = await dbController.JobTask2TagsUpsertAsync(JobID, reqTagList);
|
||||
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:JobTaskList:*");
|
||||
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:JobStep:*");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco completo offerte da DB
|
||||
/// </summary>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>0.9.2511.1219</Version>
|
||||
<Version>0.9.2511.1312</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
<td>@item.Description</td>
|
||||
<td class="text-center">@item.NumChild</td>
|
||||
<td class="text-center">
|
||||
<TagDisplay AllTagsList="ListAllTags" EnableEdit="true" ActiveTagsList="@item.TagsList" DisplayAs="TagDisplay.TagMode.badge"></TagDisplay>
|
||||
<TagDisplay ParentId="@item.JobID" AllTagsList="ListAllTags" EnableEdit="true" ActiveTagsList="@item.TagsList" DisplayAs="TagDisplay.TagMode.badge" EC_ReqSave="DoSaveTags"></TagDisplay>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<TagDisplay AllTagsList="ListCostDrivers" EnableEdit="false" ActiveTagsList="@ListDriversName(item)" BaseCss="bg-primary bg-gradient bg-opacity-50 text-dark" DisplayAs="TagDisplay.TagMode.pill"></TagDisplay>
|
||||
|
||||
@@ -237,6 +237,20 @@ namespace Lux.UI.Components.Compo.JobTask
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update record x elenco tags
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
/// <returns></returns>
|
||||
private async Task DoSaveTags(TagDisplay.SavePayload args)
|
||||
{
|
||||
// chiamo update
|
||||
await DLService.JobTask2TagsUpsertAsync(args.Id, args.Tags);
|
||||
await EC_Updated.InvokeAsync(true);
|
||||
//// refresh!
|
||||
//ResetEdit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue spostamento
|
||||
/// </summary>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div @onclick="ToggleEdit">
|
||||
@if (currTagsList != null && currTagsList.Count > 0)
|
||||
@if (WorkingTags != null && WorkingTags.Count > 0)
|
||||
{
|
||||
foreach (var tag in currTagsList)
|
||||
foreach (var tag in WorkingTags)
|
||||
{
|
||||
<span class="@spanCss @BaseCss small me-1 mb-1">@tag</span>
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
<div class="modal" tabindex="-1" style="display:block; background-color: rgba(10,10,10,.6);" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<div class="modal-header text-bg-info bg-gradient bg-opacity-50">
|
||||
<div class="modal-title fs-3">Gestione Tags</div>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" @onclick="ToggleEdit">
|
||||
</button>
|
||||
@@ -27,18 +27,31 @@
|
||||
<div class="fs-4 mb-2">Disponibili</div>
|
||||
@foreach (var tag in AvailTagsList)
|
||||
{
|
||||
<button class="btn btn-sm btn-primary me-1 mb-1" @onclick="() => AddTag(tag)">@tag</button>
|
||||
<button class="btn btn-sm2 btn-primary me-1 mb-1" @onclick="() => AddTag(tag)">@tag <small><i class="fa-solid fa-plus"></i></small></button>
|
||||
}
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="fs-4 mb-2">Attivi</div>
|
||||
@foreach (var tag in currTagsList)
|
||||
@if (WorkingTags != null && WorkingTags.Count > 0)
|
||||
{
|
||||
<button class="btn btn-sm btn-info me-1 mb-1">@tag</button>
|
||||
foreach (var tag in WorkingTags)
|
||||
{
|
||||
<button class="btn btn-sm2 btn-info me-1 mb-1" @onclick="() => RemTag(tag)">@tag <small><i class="fa-solid fa-xmark"></i></small></button>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer text-bg-info bg-gradient bg-opacity-50">
|
||||
<div class="row w-100">
|
||||
<div class="col-6">
|
||||
<button class="btn btn-lg btn-success w-100" @onclick="DoSave">Save</button>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button class="btn btn-lg btn-warning w-100" @onclick="DoCancel">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -23,21 +23,13 @@ namespace Lux.UI.Components.Compo.JobTask
|
||||
/// Elenco Tags attivi
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public List<string> ActiveTagsList
|
||||
{
|
||||
get => currTagsList;
|
||||
set
|
||||
{
|
||||
currTagsList = value;
|
||||
origTagsList = value;
|
||||
}
|
||||
}
|
||||
public List<string> ActiveTagsList { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Elenco completo Tags ammissibili
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public List<string> AllTagsList { get; set; } = new();
|
||||
public List<string> AllTagsList { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback<List<string>> EC_ReqSave { get; set; }
|
||||
public EventCallback<SavePayload> EC_ReqSave { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool EnableEdit { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Id Parent
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public int ParentId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// UID Parent
|
||||
/// </summary>
|
||||
[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<string> Tags { get; set; } = new();
|
||||
public string Uid { get; set; } = string.Empty;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
#endregion Public Classes
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected List<string> 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<string>(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<string>(ActiveTagsList);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
@@ -96,16 +137,10 @@ namespace Lux.UI.Components.Compo.JobTask
|
||||
#region Private Fields
|
||||
|
||||
private bool isEdit = false;
|
||||
private List<string> WorkingTags = new();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private List<string> currTagsList { get; set; } = new();
|
||||
private List<string> 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<string>(ActiveTagsList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
|
||||
<Version>0.9.2511.1219</Version>
|
||||
<Version>0.9.2511.1312</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>LUX - Web Windows MES</i>
|
||||
<h4>Versione: 0.9.2511.1219</h4>
|
||||
<h4>Versione: 0.9.2511.1312</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
0.9.2511.1219
|
||||
0.9.2511.1312
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>0.9.2511.1219</version>
|
||||
<version>0.9.2511.1312</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user