From b14ece695f43b276696738b811bbc3ae3b48da2b Mon Sep 17 00:00:00 2001 From: Dara Keon Date: Fri, 20 Sep 2024 12:12:47 +0100 Subject: [PATCH] WIP site order --- core/Language/Language/Site/general.json | 2 + core/Language/Language/Site/logins.json | 2 - site/MVC/Controllers/OrdersController.cs | 1 - site/MVC/Models/OrdersCreateModel.cs | 52 +++++++++++++++++---- site/MVC/Views/Ops/Legend.cshtml | 1 + site/MVC/Views/Orders/Create.cshtml | 59 ++++++++++++++++++------ site/MVC/Views/Orders/Index.cshtml | 22 +++++---- site/MVC/Views/Orders/OrderRow.cshtml | 40 ++++++++-------- 8 files changed, 127 insertions(+), 52 deletions(-) diff --git a/core/Language/Language/Site/general.json b/core/Language/Language/Site/general.json index fd61e994f..15237636e 100644 --- a/core/Language/Language/Site/general.json +++ b/core/Language/Language/Site/general.json @@ -103,6 +103,7 @@ "Edition": "Edition", "Deletion": "Deletion", "Expiration": "Expiration", + "Exportation": "Exportation", "Scheduling": "Scheduled Creation", "Importing": "Imported Creation", "Amount": "Amount", @@ -295,6 +296,7 @@ "Edition": "Edição", "Deletion": "Exclusão", "Expiration": "Expiração", + "Exportation": "Exportação", "Scheduling": "Criação Agendada", "Importing": "Criação Importada", "Amount": "Qte", diff --git a/core/Language/Language/Site/logins.json b/core/Language/Language/Site/logins.json index adaddb385..0244f33f8 100644 --- a/core/Language/Language/Site/logins.json +++ b/core/Language/Language/Site/logins.json @@ -1,6 +1,5 @@ { "en-US": { - "Expiration": "Expiration", "Type": "Type", "Mobile": "Mobile", "Browser": "Browser", @@ -12,7 +11,6 @@ "": null }, "pt-BR": { - "Expiration": "Expiração", "Type": "Tipo", "Mobile": "Mobile", "Browser": "Web", diff --git a/site/MVC/Controllers/OrdersController.cs b/site/MVC/Controllers/OrdersController.cs index a673ac9ea..600f6d60d 100644 --- a/site/MVC/Controllers/OrdersController.cs +++ b/site/MVC/Controllers/OrdersController.cs @@ -1,5 +1,4 @@ using System; -using System.Threading.Tasks; using DFM.MVC.Helpers.Authorize; using DFM.MVC.Helpers.Controllers; using DFM.MVC.Models; diff --git a/site/MVC/Models/OrdersCreateModel.cs b/site/MVC/Models/OrdersCreateModel.cs index 846e323f1..76a94d3c2 100644 --- a/site/MVC/Models/OrdersCreateModel.cs +++ b/site/MVC/Models/OrdersCreateModel.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Globalization; using System.Linq; using DFM.BusinessLogic.Exceptions; using DFM.BusinessLogic.Response; @@ -17,28 +18,63 @@ public OrdersCreateModel() End = DateTime.Today, }; - var accountList = admin.GetAccountList(true) + AllAccountList = admin.GetAccountList(true) .Union(admin.GetAccountList(false)) - .ToList(); + .ToDictionary(a => a.Url, a => a); - AccountList = accountList.ToDictionary(a => a, _ => false); + AccountList = AllAccountList + .ToDictionary(a => a.Key, _ => false); - var categoryList = admin.GetCategoryList(true) + AllCategoryList = admin.GetCategoryList(true) .Union(admin.GetCategoryList(false)) - .ToList(); + .ToDictionary(c => c.Name, c => c); - CategoryList = categoryList.ToDictionary(a => a, _ => false); + CategoryList = AllCategoryList + .ToDictionary(c => c.Key, _ => false); } public OrderInfo Order { get; set; } - public IDictionary AccountList { get; set; } - public IDictionary CategoryList { get; set; } + public String Start + { + get => Order.Start?.ToString("yyyy-MM-dd"); + set { + DateTime.TryParse(value, out var start); + Order.Start = start; + } + } + + public String End + { + get => Order.End?.ToString("yyyy-MM-dd"); + set { + DateTime.TryParse(value, out var end); + Order.End = end; + } + } + + public IDictionary AllAccountList { get; set; } + public IDictionary AccountList { get; set; } + + public IDictionary AllCategoryList { get; set; } + public IDictionary CategoryList { get; set; } public List SaveOrder() { var errors = new List(); + AccountList + .Where(a => a.Value) + .Select(a => a.Key) + .ToList() + .ForEach(Order.AccountList.Add); + + CategoryList + .Where(a => a.Value) + .Select(a => a.Key) + .ToList() + .ForEach(Order.CategoryList.Add); + try { attendant.OrderExport(Order); diff --git a/site/MVC/Views/Ops/Legend.cshtml b/site/MVC/Views/Ops/Legend.cshtml index 32a362b62..3f817a8c3 100644 --- a/site/MVC/Views/Ops/Legend.cshtml +++ b/site/MVC/Views/Ops/Legend.cshtml @@ -40,6 +40,7 @@ { "ok", Context.Translate("Success") }, { "remove", Context.Translate("Error") }, { "repeat", Context.Translate("Retry") }, + { "download", Context.Translate("Download") }, { "ban-circle", Context.Translate("Cancel") + " / " + Context.Translate("Canceled") }, }; } diff --git a/site/MVC/Views/Orders/Create.cshtml b/site/MVC/Views/Orders/Create.cshtml index dc397c802..e9719b9e0 100644 --- a/site/MVC/Views/Orders/Create.cshtml +++ b/site/MVC/Views/Orders/Create.cshtml @@ -26,29 +26,62 @@
- @Html.LabelFor(m => m.Order.Start, Context.Translate("StartDate"), new { @class = "control-label" }) - @Html.ValidationMessageFor(m => m.Order.Start)
- @Html.TextBoxFor(m => m.Order.Start, new { type = "date", @class = "form-control " + hl["Start"] }) + @Html.LabelFor(m => m.Start, Context.Translate("StartDate"), new { @class = "control-label" }) + @Html.ValidationMessageFor(m => m.Start)
+ @Html.TextBoxFor(m => m.Start, new { type = "date", @class = "form-control " + hl["Start"] })
- @Html.LabelFor(m => m.Order.End, Context.Translate("EndDate"), new { @class = "control-label" }) - @Html.ValidationMessageFor(m => m.Order.End)
- @Html.TextBoxFor(m => m.Order.End, new { type = "date", @class = "form-control " + hl["End"] }) + @Html.LabelFor(m => m.End, Context.Translate("EndDate"), new { @class = "control-label" }) + @Html.ValidationMessageFor(m => m.End)
+ @Html.TextBoxFor(m => m.End, new { type = "date", @class = "form-control " + hl["End"] })
- @Html.ValidationMessageFor(m => m.Order.AccountList)
- @foreach (var key in Model.AccountList.Keys) - { - @Html.CheckBoxFor(m => m.AccountList[key]) - @Html.LabelFor(m => m.AccountList[key], key.Name, new { @class = "control-label" }) - } + @Html.LabelFor(m => m.Order.AccountList, Context.Translate("Accounts")) + @Html.ValidationMessageFor(m => m.Order.AccountList) + +
+ @foreach (var key in Model.AccountList.Keys) + { +
+
+
+ @Html.CheckBoxFor(m => m.AccountList[key]) +
+
+ @Html.LabelFor(m => m.AccountList[key], Model.AllAccountList[key].Name, new { @class = "control-label" }) +
+
+
+ } +
+
+ +
+ @Html.LabelFor(m => m.Order.CategoryList, Context.Translate("Categories")) + @Html.ValidationMessageFor(m => m.Order.CategoryList) + +
+ @foreach (var key in Model.CategoryList.Keys) + { +
+
+
+ @Html.CheckBoxFor(m => m.CategoryList[key]) +
+
+ @Html.LabelFor(m => m.CategoryList[key], Model.AllCategoryList[key].Name, new { @class = "control-label" }) +
+
+
+ } +
@section Footer { } diff --git a/site/MVC/Views/Orders/Index.cshtml b/site/MVC/Views/Orders/Index.cshtml index 697e79b24..a2dd1ffb8 100644 --- a/site/MVC/Views/Orders/Index.cshtml +++ b/site/MVC/Views/Orders/Index.cshtml @@ -17,11 +17,14 @@ .AddBox("TemplateButton", null, 4) .AddBox("CreateButton", null, 5) .AddBox("Row", 0, null) - .AddBox("Filename", 1, null) - .AddBox("Uploaded", 2, null) + .AddBox("DateRange", 2, null) + .AddBox("Accounts", 2, null) + .AddBox("Categories", 2, null) + .AddBox("Expiration", 2, null) .AddBox("Status", 3, null) .AddBox("Cancel", 4, null) - .AddBox("Lines", 5, null) + .AddBox("Retry", 4, null) + .AddBox("Download", 4, null) ; ViewBag.SettingsMenuClass = hl["SettingsMenu"]; @@ -42,13 +45,12 @@ @section TableHeader { - @Context.Translate("Creation") - @Context.Translate("Expiration") - @Context.Translate("DateRange") - @Context.Translate("Accounts") - @Context.Translate("Categories") - @Context.Translate("Status") - @Context.Translate("TODO") + @Context.Translate("DateRange") + @Context.Translate("Accounts") + @Context.Translate("Categories") + @Context.Translate("Expiration") + @Context.Translate("Status") + @Context.Translate("TODO") } diff --git a/site/MVC/Views/Orders/OrderRow.cshtml b/site/MVC/Views/Orders/OrderRow.cshtml index 2e8d36a83..6bacc239f 100644 --- a/site/MVC/Views/Orders/OrderRow.cshtml +++ b/site/MVC/Views/Orders/OrderRow.cshtml @@ -1,4 +1,5 @@ -@model OrderRowModel +@using DFM.Generic.Datetime +@model OrderRowModel @{ var hl = Model.WizardHL; @@ -6,29 +7,31 @@ } - - @order.Creation - - - - @order.Expiration + + @order.Start.ToShortDateString() + - + @order.End.ToShortDateString() - - @order.Start - - - @order.End + + @foreach (var account in order.AccountList) + { + @account
+ } - - @order.AccountList + + @foreach (var category in order.CategoryList) + { + @category
+ } - - @order.CategoryList + + @order.Expiration?.ToShortDateString() - + @await Html.PartialAsync("ExportStatus", order.Status) @@ -44,16 +47,17 @@ @await Html.PartialAsync( "Extensions/MicroForm", - MicroForm.WithGlyph(Context, "ban-circle", "Retry") + MicroForm.WithGlyph(Context, "repeat", "Retry") .AddIdUrl("Orders", "Retry", order.Guid) .AsAjax($"a{order.Guid}") ) + @if + title="@Context.Translate("Download")">