Update gestioen ricetta
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MP.Data.Conf
|
||||
{
|
||||
@@ -11,30 +7,21 @@ namespace MP.Data.Conf
|
||||
/// </summary>
|
||||
public class RecipeBlockConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Dizionario delle chiavi, differenziate dai primi caratteri:
|
||||
/// C: --> Calcolato
|
||||
/// E: --> Enum: modificabile ma da dizionario valori seguente
|
||||
/// F: --> Fixed (NON modificabile)
|
||||
/// "" --> editabile
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ListKeys { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Dizionario degli enum permessi
|
||||
/// </summary>
|
||||
public Dictionary<string, Dictionary<string, string>> EnumVal { get; set; } = new Dictionary<string, Dictionary<string, string>>();
|
||||
/// <summary>
|
||||
/// Dizionario degli enum permessi
|
||||
/// </summary>
|
||||
public Dictionary<string, CalcDetail> CalcVal { get; set; } = new Dictionary<string, CalcDetail>();
|
||||
|
||||
public class CalcDetail
|
||||
{
|
||||
public string Description { get; set; } = "";
|
||||
public string Type { get; set; } = "";
|
||||
public string Format { get; set; } = "";
|
||||
}
|
||||
/// <summary>
|
||||
/// Dizionario delle chiavi, differenziate dai primi caratteri:
|
||||
/// C: --> Calcolato
|
||||
/// E: --> Enum: modificabile ma da dizionario valori seguente
|
||||
/// F: --> Fixed (NON modificabile) "" --> editabile
|
||||
/// </summary>
|
||||
public Dictionary<string, string> ListKeys { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,11 +92,15 @@ namespace MP.Data.Controllers
|
||||
/// <summary>
|
||||
/// Init ricetta dato PODL + conf
|
||||
/// </summary>
|
||||
/// <param name=""></param>
|
||||
/// <param name="confPath"></param>
|
||||
/// <param name="idxPODL"></param>
|
||||
/// <param name="CalcArgs"></param>
|
||||
/// <returns></returns>
|
||||
public RecipeModel InitRecipe(int idxPODL, string confPath)
|
||||
public RecipeModel InitRecipe(string confPath, int idxPODL, Dictionary<string, string> CalcArgs)
|
||||
{
|
||||
RecipeModel answ = new RecipeModel();
|
||||
// recupero dati da PODL...
|
||||
|
||||
// per prima cosa leggo file di conf x inizializzare ricetta...
|
||||
string fullPath = RecipePath(confPath);
|
||||
bool fileOk = File.Exists(fullPath);
|
||||
@@ -104,36 +108,8 @@ namespace MP.Data.Controllers
|
||||
{
|
||||
string rawData = File.ReadAllText(fullPath);
|
||||
var currRecipe = JsonConvert.DeserializeObject<RecipeConfig>(rawData);
|
||||
// copio la mia ricetta come conf...
|
||||
answ = new RecipeModel(idxPODL, currRecipe);
|
||||
|
||||
//answ = new RecipeModel()
|
||||
//{
|
||||
// IdxPODL = idxPODL,
|
||||
// TemplateFile = currRecipe.TemplateFile,
|
||||
// HeadConf = currRecipe.HeadConf,
|
||||
// RowsConf = currRecipe.RowsConf,
|
||||
// //HeadVal = currRecipe.HeadConf.ListKeys,
|
||||
// HeadVal = RecipeModel.ConvertToValues(currRecipe.HeadConf.ListKeys),
|
||||
// // aggiungo 1 riga...
|
||||
// RowsVal = new Dictionary<string, Dictionary<string, string>>()
|
||||
// {
|
||||
// { "1", currRecipe.RowsConf.ListKeys}
|
||||
// }
|
||||
|
||||
// //IdxPODL = idxPODL,
|
||||
// //TemplateFile = currRecipe.TemplateFile,
|
||||
// //HeadConf = currRecipe.HeadConf,
|
||||
// //RowsConf = currRecipe.RowsConf,
|
||||
// ////HeadVal = currRecipe.HeadConf.ListKeys,
|
||||
// //HeadVal = RecipeModel.ConvertToObj(currRecipe.HeadConf.ListKeys),
|
||||
// //// aggiungo 1 riga...
|
||||
// //RowsVal = new Dictionary<string, Dictionary<string, Element>>()
|
||||
// //{
|
||||
// // //{ "1", rigaBase }
|
||||
// // { "1", RecipeModel.ConvertToObj(currRecipe.RowsConf.ListKeys)}
|
||||
// //}
|
||||
//};
|
||||
// inizializzo dalla conf...
|
||||
answ = new RecipeModel(idxPODL, currRecipe, CalcArgs);
|
||||
}
|
||||
|
||||
return answ;
|
||||
|
||||
@@ -1034,6 +1034,7 @@ namespace MP.Data.Controllers
|
||||
.DbSetPODL
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxPromessa == idxPODL)
|
||||
.Include(a => a.ArticoloNav)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
catch (Exception exc)
|
||||
|
||||
@@ -21,19 +21,26 @@ namespace MP.Data.MgModels
|
||||
/// <summary>
|
||||
/// Init da configurazione di base
|
||||
/// </summary>
|
||||
/// <param name="origConfig"></param>
|
||||
public RecipeModel(int IdxPODL, RecipeConfig origConfig)
|
||||
/// <param name="IdxPODL">idx PODL</param>
|
||||
/// <param name="OrigConfig"></param>
|
||||
/// <param name="CalcArgs">Dizionario argomenti x decodifica (es cod articolo, descrizione...)</param>
|
||||
public RecipeModel(int IdxPODL, RecipeConfig OrigConfig, Dictionary<string, string> CalcArgs)
|
||||
{
|
||||
this.IdxPODL = IdxPODL;
|
||||
this.TemplateFile = origConfig.TemplateFile;
|
||||
this.HeadConf = origConfig.HeadConf;
|
||||
this.RowsConf = origConfig.RowsConf;
|
||||
this.TemplateFile = OrigConfig.TemplateFile;
|
||||
this.HeadConf = OrigConfig.HeadConf;
|
||||
this.RowsConf = OrigConfig.RowsConf;
|
||||
// init oggetti tipizzati da valori conf ricevuti
|
||||
this.HeadVal = ElementConverter(origConfig.HeadConf.ListKeys);
|
||||
this.HeadVal = ElementConverter(OrigConfig.HeadConf.ListKeys, CalcArgs);
|
||||
// aggiungo args x gestione contatori righe...
|
||||
CalcArgs.Add("RowNum", $"0");
|
||||
CalcArgs.Add("RowTot", $"{OrigConfig.NumRow}");
|
||||
// aggiungo righe elementi..
|
||||
for (int i = 1; i <= origConfig.NumRow; i++)
|
||||
for (int i = 1; i <= OrigConfig.NumRow; i++)
|
||||
{
|
||||
this.RowsVal.Add($"{i}", ElementConverter(origConfig.RowsConf.ListKeys));
|
||||
// valore calcolato numero riga gestito ad ogni iterazione
|
||||
CalcArgs["RowNum"] = $"{i}";
|
||||
this.RowsVal.Add($"{i}", ElementConverter(OrigConfig.RowsConf.ListKeys, CalcArgs));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,28 +99,14 @@ namespace MP.Data.MgModels
|
||||
/// <summary>
|
||||
/// Converte il dizionario in List Element
|
||||
/// </summary>
|
||||
public static List<Element> ElementConverter(Dictionary<string, string> ListKeys)
|
||||
public static List<Element> ElementConverter(Dictionary<string, string> ListKeys, Dictionary<string, string> CalcArgs)
|
||||
{
|
||||
List<Element> ListObj = ListKeys
|
||||
.Select(x => new Element(x.Key, x.Value))
|
||||
.Select(x => new Element(x.Key, x.Value, CalcArgs))
|
||||
.ToList();
|
||||
return ListObj;
|
||||
}
|
||||
|
||||
public static Element getToConfig(string rawKey, string rawVal)
|
||||
{
|
||||
return new Element(rawKey, rawVal);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clone dell'oggetto
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public RecipeModel Clone()
|
||||
{
|
||||
return (RecipeModel)this.MemberwiseClone();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Public Classes
|
||||
@@ -128,9 +121,9 @@ namespace MP.Data.MgModels
|
||||
/// <summary>
|
||||
/// Init classe da valore kvp
|
||||
/// </summary>
|
||||
/// <param name="rawKey"></param>
|
||||
/// <param name="rawVal"></param>
|
||||
public Element(string rawKey, string rawVal)
|
||||
/// <param name="rawKey">Chiave item</param>
|
||||
/// <param name="rawVal">Valore grezzo item</param>
|
||||
public Element(string rawKey, string rawVal, Dictionary<string, string> CalcArgs)
|
||||
{
|
||||
this.Key = rawKey;
|
||||
this.OrigVal = rawVal;
|
||||
@@ -143,7 +136,16 @@ namespace MP.Data.MgModels
|
||||
{
|
||||
case "C:":
|
||||
this.Type = KeyType.Calc;
|
||||
this.Value = rawVal.Substring(2);
|
||||
// recupero item x ricerca in dizionario...
|
||||
string cKey = rawVal.Substring(2);
|
||||
if (CalcArgs.ContainsKey(cKey))
|
||||
{
|
||||
this.Value = CalcArgs[cKey];
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Value = cKey;
|
||||
}
|
||||
break;
|
||||
|
||||
case "E:":
|
||||
|
||||
@@ -6,40 +6,32 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="card shadow p-1 mb-5 bg-body rounded">
|
||||
<div class="card shadow p-0 mb-5 bg-body rounded">
|
||||
<div class="card-header">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<h4>Testata Ricetta</h4>
|
||||
</div>
|
||||
<div>
|
||||
<div class="row g-1">
|
||||
@if (needSave)
|
||||
@if (!showHead)
|
||||
{
|
||||
<span class="px-2"><b>@CurrRecipe?.HeadVal.Count</b> par</span>
|
||||
}
|
||||
@if (needSave)
|
||||
{
|
||||
<button class="btn btn-sm btn-success" @onclick="() => SaveHeadData()"><i class="fa-regular fa-floppy-disk"></i> Save</button>
|
||||
<button class="btn btn-sm btn-warning" @onclick="() => CancelHeadData()"><i class="fa-solid fa-xmark"></i> Cancel</button>
|
||||
}
|
||||
<button class="btn btn-sm btn-outline-dark" @onclick="toggleHead">
|
||||
@if (showHead)
|
||||
{
|
||||
<div class="col">
|
||||
<div class="d-grid">
|
||||
<button class="btn btn-sm btn-success" @onclick="() => SaveHeadData()">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="d-grid">
|
||||
<button class="btn btn-sm btn-warning" @onclick="() => CancelHeadData()">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
<i class="fa-solid fa-chevron-up"></i>
|
||||
}
|
||||
<div class="col">
|
||||
<button class="btn btn-sm" @onclick="toggleHead">
|
||||
@if (showHead)
|
||||
{
|
||||
<i class="fa-solid fa-chevron-up"></i>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="fa-solid fa-chevron-down"></i>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
else
|
||||
{
|
||||
<i class="fa-solid fa-chevron-down"></i>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@if (showHead && CurrRecipe?.HeadVal != null)
|
||||
@@ -76,7 +68,24 @@ else
|
||||
}
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h5>Righe Ricetta</h5>
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<h5>Righe Ricetta</h5>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn btn-sm btn-success" @onclick="addRow"><i class="fa-solid fa-plus"></i> Add</button>
|
||||
<button class="btn btn-sm btn-outline-dark" @onclick="toggleRows">
|
||||
@if (showAllRows)
|
||||
{
|
||||
<i class="fa-solid fa-chevron-up"></i>
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="fa-solid fa-chevron-down"></i>
|
||||
}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@if (CurrRecipe?.RowsVal != null)
|
||||
{
|
||||
@foreach (var riga in CurrRecipe.RowsVal)
|
||||
|
||||
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components;
|
||||
using MP.Data;
|
||||
using MP.Data.MgModels;
|
||||
using MP.SPEC.Data;
|
||||
using MP.SPEC.Pages;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace MP.SPEC.Components
|
||||
@@ -80,6 +81,7 @@ namespace MP.SPEC.Components
|
||||
#region Private Fields
|
||||
|
||||
private bool showHead = true;
|
||||
private bool showAllRows = false;
|
||||
private Dictionary<string, bool> showRows = new Dictionary<string, bool>();
|
||||
|
||||
#endregion Private Fields
|
||||
@@ -95,12 +97,27 @@ namespace MP.SPEC.Components
|
||||
CurrRecipe = new RecipeModel();
|
||||
// effettua ricerca ricetta su MongoDb
|
||||
CurrRecipe = await MDService.RecipeGetByPODL(IdxPODL);
|
||||
OrigRecipe = await MDService.RecipeGetByPODL(IdxPODL);
|
||||
// se non trova crea nuova...
|
||||
if (CurrRecipe == null)
|
||||
{
|
||||
CurrRecipe = MDService.InitRecipe(IdxPODL, RecipePath);
|
||||
// preparo dizionario valori calcolati
|
||||
Dictionary<string, string> CalcArgs = new Dictionary<string, string>();
|
||||
// aggiungo dati PODL
|
||||
CalcArgs.Add("IdxPODL", $"{IdxPODL}");
|
||||
CalcArgs.Add("CodePODL", $"PODL{IdxPODL:00000000}");
|
||||
// recupero altri dati da PODL
|
||||
var rowPodl = await MDService.PODL_getByKey(IdxPODL);
|
||||
if (rowPodl != null)
|
||||
{
|
||||
CalcArgs.Add("CodArticolo", rowPodl.CodArticolo);
|
||||
CalcArgs.Add("DescArticolo", rowPodl.ArticoloNav.DescArticolo);
|
||||
}
|
||||
CurrRecipe = MDService.InitRecipe(RecipePath, IdxPODL, CalcArgs);
|
||||
// la salvo...
|
||||
await MDService.RecipeSetByPODL(CurrRecipe);
|
||||
}
|
||||
// rileggo la default
|
||||
OrigRecipe = await MDService.RecipeGetByPODL(IdxPODL);
|
||||
// sistemo lista bool x righe
|
||||
showRows = new Dictionary<string, bool>();
|
||||
for (int i = 1; i <= CurrRecipe.RowsVal.Count; i++)
|
||||
@@ -136,6 +153,10 @@ namespace MP.SPEC.Components
|
||||
}
|
||||
}
|
||||
|
||||
private async Task addRow()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
|
||||
private void toggleHead()
|
||||
@@ -143,6 +164,17 @@ namespace MP.SPEC.Components
|
||||
showHead = !showHead;
|
||||
}
|
||||
|
||||
private async Task toggleRows()
|
||||
{
|
||||
showAllRows = !showAllRows;
|
||||
foreach (var item in showRows)
|
||||
{
|
||||
showRows[item.Key] = showAllRows;
|
||||
}
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
|
||||
private async Task toggleRow(string rowNum)
|
||||
{
|
||||
showRows[rowNum] = !showRows[rowNum];
|
||||
|
||||
@@ -74,12 +74,13 @@ namespace MP.SPEC.Data
|
||||
/// <summary>
|
||||
/// Init ricetta
|
||||
/// </summary>
|
||||
/// <param name="idxPODL"></param>
|
||||
/// <param name="confPath"></param>
|
||||
/// <param name="idxPODL"></param>
|
||||
/// <param name="CalcArgs"></param>
|
||||
/// <returns></returns>
|
||||
public RecipeModel InitRecipe(int idxPODL, string confPath)
|
||||
public RecipeModel InitRecipe(string confPath, int idxPODL, Dictionary<string, string> CalcArgs)
|
||||
{
|
||||
return mongoController.InitRecipe(idxPODL, confPath);
|
||||
return mongoController.InitRecipe(confPath, idxPODL, CalcArgs);
|
||||
}
|
||||
/// <summary>
|
||||
/// Salva ricetta su MongoDB
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.SPEC</RootNamespace>
|
||||
<Version>6.16.2302.911</Version>
|
||||
<Version>6.16.2302.915</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Ricette
|
||||
- [Ricette](#ricette)
|
||||
- [Gestione formati e tag x ricette](#gestione-formati-e-tag-x-ricette)
|
||||
- [Campi Calcolati](#campi-calcolati)
|
||||
|
||||
|
||||
# Gestione formati e tag x ricette
|
||||
|
||||
Nelle ricette ci possono essere campi liberi, campi da enum (da configurare nel json) e campi calcolati
|
||||
|
||||
|
||||
## Campi Calcolati
|
||||
|
||||
I tag noti x decodifica riguardano i campi calcolati; hard coded, e riconosciuti, sono i seguenti:
|
||||
|
||||
| ID | Note | Format | Esempio |
|
||||
|--------------|-----------------------------------------|------------------|-----------------|
|
||||
| IdxPODL | IdxODL numerico | - | 123 |
|
||||
| CodePODL | Codice alfanumerico partendo da IdxPODL | PODL{0:00000000} | PODL00000123 |
|
||||
| CodArticolo | Campo CodArticolo | - | Art000123 |
|
||||
| DescArticolo | Campo DescArticolo | - | Articol 123 blu |
|
||||
| RowNum | Numero riga | - | 1 |
|
||||
| RowTot | Totale righe | - | 10 |
|
||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 6.16.2302.911</h4>
|
||||
<h4>Versione: 6.16.2302.915</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2302.911
|
||||
6.16.2302.915
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2302.911</version>
|
||||
<version>6.16.2302.915</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user