diff --git a/webapp/Pages/Categories/Index.cshtml b/webapp/Pages/Categories/Index.cshtml index c4375bc..5894e91 100644 --- a/webapp/Pages/Categories/Index.cshtml +++ b/webapp/Pages/Categories/Index.cshtml @@ -193,7 +193,7 @@ - + @@ -213,18 +213,22 @@ function actionComplete(args) { console.log(args); if (args.requestType === "beginEdit" || args.requestType === "add") { - var dialog = args.dialog; + let dialog = args.dialog; dialog.element.style.maxHeight = "1000px"; dialog.header = args.requestType === "beginEdit" ? "@Localizer["Edit category"].Value" + args.rowData["Name"] : "@Localizer["Add category"].Value"; } if (args.requestType === "delete") { - // todo: Show dialog when delete operation is canceled. - var canceled = args.cancel; + if (args.data != null && args.data.length > 0) { + let selectedCategory = args.data[0]; + fetch("/Categories/NumberOfTransactionsAssociated?id=" + selectedCategory.Id).then(function (result) { return result.json() }).then(function (data) { + if (data > 0) alert("@Localizer["Cancel message"].Value"); + }); + } } } function toolbarClick(args) { - var gridObj = document.getElementById("grid").ej2_instances[0]; + let gridObj = document.getElementById("grid").ej2_instances[0]; if (args.item.id === "grid_excelexport") { gridObj.showSpinner(); gridObj.excelExport(); diff --git a/webapp/Pages/Categories/Index.cshtml.cs b/webapp/Pages/Categories/Index.cshtml.cs index 6fd4db4..9eb37e5 100644 --- a/webapp/Pages/Categories/Index.cshtml.cs +++ b/webapp/Pages/Categories/Index.cshtml.cs @@ -34,6 +34,21 @@ public async Task OnGetAsync() { return Page(); } + public async Task OnGetNumberOfTransactionsAssociatedAsync(long id) { + if (!(User.Identity?.IsAuthenticated ?? false)) return Redirect("/"); + + var user = await GetUserAsync(); + if (user == null) return Redirect("/"); + + var transactionsWithCategory = await _databaseContext.Transactions + .AsNoTracking() + .Where(x => x.UserId == user.Id) + .Where(x => x.CategoryId == id) + .ToListAsync(); + + return new JsonResult(transactionsWithCategory.Count); + } + public async Task OnPostDataSourceAsync([FromBody] DataManagerRequest dm) { if (!(User.Identity?.IsAuthenticated ?? false)) return Redirect("/"); diff --git a/webapp/Pages/Dashboard.cshtml b/webapp/Pages/Dashboard.cshtml index 21f4c4d..d5f93fe 100644 --- a/webapp/Pages/Dashboard.cshtml +++ b/webapp/Pages/Dashboard.cshtml @@ -264,13 +264,13 @@ } document.addEventListener("DOMContentLoaded", function() { - var lineObj = document.getElementById("lineChart").ej2_instances[0]; + let lineObj = document.getElementById("lineChart").ej2_instances[0]; lineObj.refresh(); - var pieObj = document.getElementById("pieChart").ej2_instances[0]; + let pieObj = document.getElementById("pieChart").ej2_instances[0]; pieObj.refresh(); - var splineObj = document.getElementById("splineChart").ej2_instances[0]; + let splineObj = document.getElementById("splineChart").ej2_instances[0]; splineObj.refresh(); }); diff --git a/webapp/Pages/FixedCosts/Index.cshtml b/webapp/Pages/FixedCosts/Index.cshtml index b30c9e5..cc9f34d 100644 --- a/webapp/Pages/FixedCosts/Index.cshtml +++ b/webapp/Pages/FixedCosts/Index.cshtml @@ -143,7 +143,7 @@ function actionComplete(args) { if ((args.requestType === "beginEdit" || args.requestType === "add")) { - var dialog = args.dialog; + let dialog = args.dialog; dialog.element.style.maxHeight = "1000px"; dialog.header = args.requestType === "beginEdit" ? "@Localizer["Edit transaction"].Value" + args.rowData["Note"] : "@Localizer["Add transaction"].Value"; } @@ -197,7 +197,7 @@ } function toolbarClick(args) { - var gridObj = document.getElementById("grid").ej2_instances[0]; + let gridObj = document.getElementById("grid").ej2_instances[0]; if (args.item.id === "grid_excelexport") { gridObj.showSpinner(); gridObj.excelExport(); diff --git a/webapp/Pages/Transactions/Index.cshtml b/webapp/Pages/Transactions/Index.cshtml index ecb8884..2ba71d0 100644 --- a/webapp/Pages/Transactions/Index.cshtml +++ b/webapp/Pages/Transactions/Index.cshtml @@ -52,11 +52,8 @@ var searchSettings = new string[] { "Note", "CategoryId" }; var validationRules = new { required = true }; - // todo: date params problem on filtering: time is displayed var dateEdit = new DatePicker() { Format = Localizer["Date format"].Value, - Min = DateOnly.MinValue, - Max = DateOnly.MaxValue, }; var statusParams = new List() { new { Value = false, Text = Localizer["Pending"].Value }, @@ -66,7 +63,7 @@ DataSource = statusParams, Query = "new ej.data.Query()", Fields = new DropDownListFieldSettings() { Value = "Value", Text = "Text" }, - }; + }; var categoryParams = Model.Categories.Select(x => new { Value = x.Id, Text = x.Description }); var categoryEdit = new DropDownList() { DataSource = categoryParams, diff --git a/webapp/Resources/Pages/Categories/Index.en.resx b/webapp/Resources/Pages/Categories/Index.en.resx index 64b7d12..abddab1 100644 --- a/webapp/Resources/Pages/Categories/Index.en.resx +++ b/webapp/Resources/Pages/Categories/Index.en.resx @@ -120,6 +120,9 @@ Add category + + Cannot be deleted : the category is linked to other transactions. + Categories diff --git a/webapp/Resources/Pages/Categories/Index.fr.resx b/webapp/Resources/Pages/Categories/Index.fr.resx index 3fc191e..346b96d 100644 --- a/webapp/Resources/Pages/Categories/Index.fr.resx +++ b/webapp/Resources/Pages/Categories/Index.fr.resx @@ -120,6 +120,9 @@ Créer une catégorie + + Suppression impossible : la cat\u00e9gorie est li\u00e9e \u00e0 d\u0027autres transactions. + Catégories