Skip to content

Commit

Permalink
WIP site order
Browse files Browse the repository at this point in the history
  • Loading branch information
darakeon committed Sep 20, 2024
1 parent b34e607 commit b14ece6
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 52 deletions.
2 changes: 2 additions & 0 deletions core/Language/Language/Site/general.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"Edition": "Edition",
"Deletion": "Deletion",
"Expiration": "Expiration",
"Exportation": "Exportation",
"Scheduling": "Scheduled Creation",
"Importing": "Imported Creation",
"Amount": "Amount",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions core/Language/Language/Site/logins.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"en-US": {
"Expiration": "Expiration",
"Type": "Type",
"Mobile": "Mobile",
"Browser": "Browser",
Expand All @@ -12,7 +11,6 @@
"": null
},
"pt-BR": {
"Expiration": "Expiração",
"Type": "Tipo",
"Mobile": "Mobile",
"Browser": "Web",
Expand Down
1 change: 0 additions & 1 deletion site/MVC/Controllers/OrdersController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
using DFM.MVC.Helpers.Authorize;
using DFM.MVC.Helpers.Controllers;
using DFM.MVC.Models;
Expand Down
52 changes: 44 additions & 8 deletions site/MVC/Models/OrdersCreateModel.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<AccountListItem, Boolean> AccountList { get; set; }
public IDictionary<CategoryListItem, Boolean> 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<String, AccountListItem> AllAccountList { get; set; }
public IDictionary<String, Boolean> AccountList { get; set; }

public IDictionary<String, CategoryListItem> AllCategoryList { get; set; }
public IDictionary<String, Boolean> CategoryList { get; set; }

public List<String> SaveOrder()
{
var errors = new List<String>();

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);
Expand Down
1 change: 1 addition & 0 deletions site/MVC/Views/Ops/Legend.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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") },
};
}
Expand Down
59 changes: 46 additions & 13 deletions site/MVC/Views/Orders/Create.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,62 @@

<div class="row">
<div class="form-group col-lg-6 col-sm-12">
@Html.LabelFor(m => m.Order.Start, Context.Translate("StartDate"), new { @class = "control-label" })
@Html.ValidationMessageFor(m => m.Order.Start)<br />
@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)<br />
@Html.TextBoxFor(m => m.Start, new { type = "date", @class = "form-control " + hl["Start"] })
</div>

<div class="form-group col-lg-6 col-sm-12">
@Html.LabelFor(m => m.Order.End, Context.Translate("EndDate"), new { @class = "control-label" })
@Html.ValidationMessageFor(m => m.Order.End)<br />
@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)<br />
@Html.TextBoxFor(m => m.End, new { type = "date", @class = "form-control " + hl["End"] })
</div>

<div class="form-group col-lg-12 col-sm-12">
@Html.ValidationMessageFor(m => m.Order.AccountList)<br />
@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)

<div class="row">
@foreach (var key in Model.AccountList.Keys)
{
<div class="col-sm-6 col-lg-4">
<div class="input-group">
<div class="input-group-addon">
@Html.CheckBoxFor(m => m.AccountList[key])
</div>
<div class="form-control">
@Html.LabelFor(m => m.AccountList[key], Model.AllAccountList[key].Name, new { @class = "control-label" })
</div>
</div>
</div>
}
</div>
</div>

<div class="form-group col-lg-12 col-sm-12">
@Html.LabelFor(m => m.Order.CategoryList, Context.Translate("Categories"))
@Html.ValidationMessageFor(m => m.Order.CategoryList)

<div class="row">
@foreach (var key in Model.CategoryList.Keys)
{
<div class="col-sm-6 col-lg-4">
<div class="input-group">
<div class="input-group-addon">
@Html.CheckBoxFor(m => m.CategoryList[key])
</div>
<div class="form-control">
@Html.LabelFor(m => m.CategoryList[key], Model.AllCategoryList[key].Name, new { @class = "control-label" })
</div>
</div>
</div>
}
</div>
</div>
</div>

@section Footer {
<button class="btn btn-success @hl["Button"]" type="submit">
@Context.Translate("Upload")
@Context.Translate("Create")
</button>
}
22 changes: 12 additions & 10 deletions site/MVC/Views/Orders/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand All @@ -42,13 +45,12 @@
@section TableHeader
{
<tr class="row">
<th class="col-sm-6">@Context.Translate("Creation")</th>
<th class="col-sm-2">@Context.Translate("Expiration")</th>
<th class="col-sm-2">@Context.Translate("DateRange")</th>
<th class="col-sm-2">@Context.Translate("Accounts")</th>
<th class="col-sm-2">@Context.Translate("Categories")</th>
<th class="col-sm-2 text-center">@Context.Translate("Status")</th>
<th class="col-sm-2 text-center" colspan="3">@Context.Translate("TODO")</th>
<th class="col-sm-2 text-center">@Context.Translate("DateRange")</th>
<th class="col-sm-2 text-center">@Context.Translate("Accounts")</th>
<th class="col-sm-2 text-center">@Context.Translate("Categories")</th>
<th class="col-sm-2 text-center">@Context.Translate("Expiration")</th>
<th class="col-sm-1 text-center">@Context.Translate("Status")</th>
<th class="col-sm-3 text-center" colspan="3">@Context.Translate("TODO")</th>
</tr>
}

Expand Down
40 changes: 22 additions & 18 deletions site/MVC/Views/Orders/OrderRow.cshtml
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
@model OrderRowModel
@using DFM.Generic.Datetime
@model OrderRowModel

@{
var hl = Model.WizardHL;
var order = Model.Order;
}

<tr class="row @hl?["Row"]" id="a@(order.Guid)">
<td class="col-sm-6 @hl?["Creation"]">
@order.Creation
</td>

<td class="col-sm-2 @hl?["Expiration"]">
@order.Expiration
<td class="col-sm-2 text-center @hl?["DateRange"]">
@order.Start.ToShortDateString()
-
@order.End.ToShortDateString()
</td>

<td class="col-sm-2 @hl?["DateRange"]">
@order.Start
-
@order.End
<td class="col-sm-2 text-center @hl?["Accounts"]">
@foreach (var account in order.AccountList)
{
@account <br />
}
</td>

<td class="col-sm-2 @hl?["Accounts"]">
@order.AccountList
<td class="col-sm-2 text-center @hl?["Categories"]">
@foreach (var category in order.CategoryList)
{
@category <br />
}
</td>

<td class="col-sm-2 @hl?["Categories"]">
@order.CategoryList
<td class="col-sm-1 text-center @hl?["Expiration"]">
@order.Expiration?.ToShortDateString()
</td>

<td class="col-sm-2 text-center @hl?["Status"]">
<td class="col-sm-1 text-center @hl?["Status"]">
@await Html.PartialAsync("ExportStatus", order.Status)
</td>

Expand All @@ -44,16 +47,17 @@
<td class="col-sm-1 text-center @hl?["Retry"]">
@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}")
)
</td>

<td class="col-sm-1 text-center @hl?["Download"]">
@if
<a href="@Url.Action("Download", new { id = order.Guid })">
<span class="glyphicon glyphicon-download"
title="@Context.Translate("Download")"></span>
title="@Context.Translate("Download")"></span>
</a>
</td>
</tr>

0 comments on commit b14ece6

Please sign in to comment.