Skip to content

Commit

Permalink
Merge branch 'task/system-text-json-migration' into issue/OCC-245
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Jun 14, 2024
2 parents ec95382 + 35fcc10 commit c6a6ae5
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 68 deletions.
42 changes: 22 additions & 20 deletions Lombiq.ChartJs.Samples/Controllers/SampleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ public SampleController(
public async Task<IActionResult> Balance() =>
View(new BalanceViewModel
{
Labels = new[] { Labels.Balance },
DataSets = new[]
{
Labels = [Labels.Balance],
DataSets =
[
// You can find more detailed description about dataset here:
// https://www.chartjs.org/docs/2.9.4/charts/bar.html#dataset-properties
new ChartJsDataSet
{
Label = Labels.Incomes,
BackgroundColor = new[] { ChartColors.IncomesBarChartBackgroundColor },
Data = new double?[]
{
BackgroundColor = [ChartColors.IncomesBarChartBackgroundColor],
Data =
[
(await _session.QueryIndex<NumericFieldIndex>(
index =>
index.Published &&
Expand All @@ -68,14 +68,14 @@ public async Task<IActionResult> Balance() =>
.ListAsync())
.Select(index => decimal.ToDouble(index.Numeric ?? 0m))
.Sum(),
},
],
},
new ChartJsDataSet
{
Label = Labels.Expenses,
BackgroundColor = new[] { ChartColors.ExpensesBarChartBackgroundColor },
Data = new double?[]
{
BackgroundColor = [ChartColors.ExpensesBarChartBackgroundColor],
Data =
[
(await _session.QueryIndex<NumericFieldIndex>(
index =>
index.Published &&
Expand All @@ -87,9 +87,9 @@ public async Task<IActionResult> Balance() =>
.ListAsync())
.Select(index => decimal.ToDouble(index.Numeric ?? 0m))
.Sum(),
},
],
},
},
],
Options = new
{
// These options below are to simplify UI testing.
Expand All @@ -114,6 +114,8 @@ public async Task<IActionResult> Balance() =>
// /Lombiq.ChartJs.Samples/Sample/History
public async Task<IActionResult> History(string incomeTag = null, string expenseTag = null)
{
if (!ModelState.IsValid) return BadRequest(ModelState);

var transactions = await GetMonthlyTransactionsAsync(incomeTag, expenseTag);

return View(new HistoryViewModel
Expand All @@ -123,27 +125,27 @@ public async Task<IActionResult> History(string incomeTag = null, string expense
.Select(item => item.ToString("MMMM yyyy", CultureInfo.InvariantCulture)),
// You can find more detailed description about dataset here:
// https://www.chartjs.org/docs/2.9.4/charts/line.html#dataset-properties
DataSets = new[]
{
DataSets =
[
new ChartJsDataSet
{
Label = Labels.Incomes,
BackgroundColor = new[] { ChartColors.Transparent },
BorderColor = new[] { ChartColors.IncomesLineChartBorderColor },
BackgroundColor = [ChartColors.Transparent],
BorderColor = [ChartColors.IncomesLineChartBorderColor],
Data = transactions
.OrderBy(item => item.Key)
.Select(item => item.Value.Income),
},
new ChartJsDataSet
{
Label = Labels.Expenses,
BackgroundColor = new[] { ChartColors.Transparent },
BorderColor = new[] { ChartColors.ExpensesLineChartBorderColor },
BackgroundColor = [ChartColors.Transparent],
BorderColor = [ChartColors.ExpensesLineChartBorderColor],
Data = transactions
.OrderBy(item => item.Key)
.Select(item => item.Value.Expense),
},
},
],
Options = new
{
// These options below are to simplify UI testing.
Expand Down Expand Up @@ -203,7 +205,7 @@ await FindDateFieldIndexesByTagsFilterAsync(incomeTag, incomeTagsFilter, expense

private async Task<IEnumerable<string>> GetItemIdsByTermIdAsync(string taxonomyId, string termId) =>
string.IsNullOrEmpty(termId)
? Array.Empty<string>()
? []
: (await _orchardHelper.QueryCategorizedContentItemsAsync(query => query
.Where(taxIndex => taxIndex.TaxonomyContentItemId == taxonomyId)
.Where(taxIndex => taxIndex.TermContentItemId == termId)))
Expand Down
13 changes: 0 additions & 13 deletions Lombiq.ChartJs.Samples/License.md

This file was deleted.

3 changes: 1 addition & 2 deletions Lombiq.ChartJs.Samples/Lombiq.ChartJs.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
<PackageTags>OrchardCore;Lombiq;AspNetCore;Chart.js</PackageTags>
<RepositoryUrl>https://github.com/Lombiq/Orchard-Chart.js</RepositoryUrl>
<PackageProjectUrl>https://github.com/Lombiq/Orchard-Chart.js/blob/dev/Lombiq.ChartJs.Samples/Readme.md</PackageProjectUrl>
<PackageLicenseFile>License.md</PackageLicenseFile>
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<None Include="License.md" Pack="true" PackagePath="" />
<None Include="Readme.md" />
<None Include="NuGetIcon.png" Pack="true" PackagePath="" />
</ItemGroup>
Expand Down
13 changes: 0 additions & 13 deletions Lombiq.ChartJs.Tests.UI/License.md

This file was deleted.

3 changes: 1 addition & 2 deletions Lombiq.ChartJs.Tests.UI/Lombiq.ChartJs.Tests.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageTags>OrchardCore;Lombiq;AspNetCore;Chart.js</PackageTags>
<RepositoryUrl>https://github.com/Lombiq/Orchard-Chart.js</RepositoryUrl>
<PackageProjectUrl>https://github.com/Lombiq/Orchard-Chart.js/blob/dev/Lombiq.ChartJs.Tests.UI/Readme.md</PackageProjectUrl>
<PackageLicenseFile>License.md</PackageLicenseFile>
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
Expand All @@ -40,7 +40,6 @@
</ItemGroup>

<ItemGroup>
<None Include="License.md" Pack="true" PackagePath="" />
<None Include="NuGetIcon.png" Pack="true" PackagePath="" />
<None Include="Readme.md" />
</ItemGroup>
Expand Down
13 changes: 0 additions & 13 deletions Lombiq.ChartJs/License.md

This file was deleted.

3 changes: 1 addition & 2 deletions Lombiq.ChartJs/Lombiq.ChartJs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
<PackageTags>OrchardCore;Lombiq;AspNetCore;Chart.js;chart</PackageTags>
<RepositoryUrl>https://github.com/Lombiq/Orchard-Chart.js</RepositoryUrl>
<PackageProjectUrl>https://github.com/Lombiq/Orchard-Chart.js</PackageProjectUrl>
<PackageLicenseFile>License.md</PackageLicenseFile>
<PackageLicenseExpression>BSD-3-Clause</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<None Include="License.md" Pack="true" PackagePath="" />
<None Include="NuGetIcon.png" Pack="true" PackagePath="" />
<None Include="..\Readme.md" />
<None Remove="node_modules\**" />
Expand Down
5 changes: 2 additions & 3 deletions Lombiq.ChartJs/TagHelpers/ChartTagHelper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Lombiq.ChartJs.Models;
using Microsoft.AspNetCore.Razor.TagHelpers;
using OrchardCore.DisplayManagement;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

Expand All @@ -17,10 +16,10 @@ public class ChartTagHelper : TagHelper
public string ChartType { get; set; } = "bar";

[HtmlAttributeName("labels")]
public IEnumerable<string> Labels { get; set; } = Array.Empty<string>();
public IEnumerable<string> Labels { get; set; } = [];

[HtmlAttributeName("datasets")]
public IEnumerable<ChartJsDataSet> DataSets { get; set; } = Array.Empty<ChartJsDataSet>();
public IEnumerable<ChartJsDataSet> DataSets { get; set; } = [];

[HtmlAttributeName("options")]
public object Options { get; set; } = new();
Expand Down

0 comments on commit c6a6ae5

Please sign in to comment.