Skip to content

Commit 51c1377

Browse files
author
Jani Giannoudis
committed
regulation item editor: added undo support and save confirmation
regulation page: added action support for collector and wage type payrun job page: added virtualization for list selections regulation obejct: added namespace refactored action editor updated to c# 14 updated version to 0.9.0-beta.13
1 parent 0d4fb74 commit 51c1377

116 files changed

Lines changed: 6136 additions & 4779 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Core/CaseFieldTimeTypeExtensions.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55
/// </summary>
66
public static class CaseValueTimeTypeExtensions
77
{
8-
/// <summary>
9-
/// Test if time type support a start moment
10-
/// </summary>
118
/// <param name="timeType">The value type</param>
12-
/// <returns>True for time types with a start</returns>
13-
public static bool HasStart(this CaseFieldTimeType timeType) =>
14-
timeType != CaseFieldTimeType.Timeless;
9+
extension(CaseFieldTimeType timeType)
10+
{
11+
/// <summary>
12+
/// Test if time type support a start moment
13+
/// </summary>
14+
/// <returns>True for time types with a start</returns>
15+
public bool HasStart() =>
16+
timeType != CaseFieldTimeType.Timeless;
1517

16-
/// <summary>
17-
/// Test if time type support an end moment
18-
/// </summary>
19-
/// <param name="timeType">The value type</param>
20-
/// <returns>True for time types with an end</returns>
21-
public static bool HasEnd(this CaseFieldTimeType timeType) =>
22-
timeType is CaseFieldTimeType.Period or CaseFieldTimeType.CalendarPeriod;
18+
/// <summary>
19+
/// Test if time type support an end moment
20+
/// </summary>
21+
/// <returns>True for time types with an end</returns>
22+
public bool HasEnd() =>
23+
timeType is CaseFieldTimeType.Period or CaseFieldTimeType.CalendarPeriod;
24+
}
2325
}

Core/DateTimeExtensions.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,22 @@ public static bool HasTime(this DateTime? moment)
2323
return moment.Value.TimeOfDay != TimeSpan.Zero;
2424
}
2525

26-
/// <summary>
27-
/// Convert a date into the UTC value with UTC time adaption
28-
/// </summary>
2926
/// <param name="dateTime">The source date time</param>
30-
/// <returns>The UTC date time</returns>
31-
public static DateTime SpecifyUtc(this DateTime dateTime) =>
32-
Date.SpecifyUtcTime(dateTime);
33-
34-
/// <summary>
35-
/// Convert a date into the OData date time format
36-
/// see https://stackoverflow.com/a/7400007/15659039
37-
/// </summary>
38-
/// <param name="dateTime">The date time</param>
39-
/// <returns>The UTC date time string</returns>
40-
public static string ToODataString(this DateTime dateTime) =>
41-
dateTime.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture);
27+
extension(DateTime dateTime)
28+
{
29+
/// <summary>
30+
/// Convert a date into the UTC value with UTC time adaption
31+
/// </summary>
32+
/// <returns>The UTC date time</returns>
33+
public DateTime SpecifyUtc() =>
34+
Date.SpecifyUtcTime(dateTime);
4235

36+
/// <summary>
37+
/// Convert a date into the OData date time format
38+
/// see https://stackoverflow.com/a/7400007/15659039
39+
/// </summary>
40+
/// <returns>The UTC date time string</returns>
41+
public string ToODataString() =>
42+
dateTime.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture);
43+
}
4344
}

Core/InputAttributesExtensions.cs

Lines changed: 208 additions & 188 deletions
Large diffs are not rendered by default.

Core/ItemCollection.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ public ItemCollection(List<T> items) :
6363

6464
#region Public Properties
6565

66-
private EqualityComparer<T> comparer;
6766
private EqualityComparer<T> Comparer =>
68-
comparer ??= EqualityComparer<T>.Default;
67+
field ??= EqualityComparer<T>.Default;
6968

7069
//private set => comparer = value;
7170
/// <summary>

Core/JsRuntimeExtensions.cs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,27 @@ namespace PayrollEngine.WebApp;
99
/// </summary>
1010
public static class JsRuntimeExtensions
1111
{
12-
/// <summary>
13-
/// Show javascript alert
14-
/// </summary>
1512
/// <param name="jsRuntime">Javascript runtime</param>
16-
/// <param name="message">Display message</param>
17-
public static ValueTask Alert(this IJSRuntime jsRuntime, string message) =>
18-
jsRuntime.InvokeVoidAsync("alert", message);
19-
20-
/// <summary>
21-
/// Show save-as dialog
22-
/// </summary>
23-
/// <param name="jsRuntime">Javascript runtime</param>
24-
/// <param name="filename">Download file name</param>
25-
/// <param name="data">Download data</param>
26-
public static ValueTask<object> SaveAs(this IJSRuntime jsRuntime, string filename, byte[] data)
13+
extension(IJSRuntime jsRuntime)
2714
{
28-
return jsRuntime.InvokeAsync<object>(
29-
"saveAsFile",
30-
filename,
31-
Convert.ToBase64String(data));
15+
/// <summary>
16+
/// Show javascript alert
17+
/// </summary>
18+
/// <param name="message">Display message</param>
19+
public ValueTask Alert(string message) =>
20+
jsRuntime.InvokeVoidAsync("alert", message);
21+
22+
/// <summary>
23+
/// Show save-as dialog
24+
/// </summary>
25+
/// <param name="filename">Download file name</param>
26+
/// <param name="data">Download data</param>
27+
public ValueTask<object> SaveAs(string filename, byte[] data)
28+
{
29+
return jsRuntime.InvokeAsync<object>(
30+
"saveAsFile",
31+
filename,
32+
Convert.ToBase64String(data));
33+
}
3234
}
3335
}

Core/LocalStorageServiceExtensions.cs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,42 @@ namespace PayrollEngine.WebApp;
1010
/// </summary>
1111
public static class LocalStorageServiceExtensions
1212
{
13-
/// <summary>
14-
/// Get local storage value as boolean
15-
/// </summary>
1613
/// <param name="storageService">Local storage service</param>
17-
/// <param name="key">Storage key</param>
18-
/// <param name="defaultValue">Default value</param>
19-
/// <param name="cancellationToken">Cancellation token</param>
20-
public static async Task<bool?> GetItemAsBooleanAsync(this ILocalStorageService storageService,
21-
string key, bool? defaultValue = null, CancellationToken cancellationToken = default)
14+
extension(ILocalStorageService storageService)
2215
{
23-
if (string.IsNullOrWhiteSpace(key))
16+
/// <summary>
17+
/// Get local storage value as boolean
18+
/// </summary>
19+
/// <param name="key">Storage key</param>
20+
/// <param name="defaultValue">Default value</param>
21+
/// <param name="cancellationToken">Cancellation token</param>
22+
public async Task<bool?> GetItemAsBooleanAsync(string key, bool? defaultValue = null, CancellationToken cancellationToken = default)
2423
{
25-
throw new ArgumentException(nameof(key));
26-
}
24+
if (string.IsNullOrWhiteSpace(key))
25+
{
26+
throw new ArgumentException(nameof(key));
27+
}
2728

28-
if (!await storageService.ContainKeyAsync(key, cancellationToken))
29-
{
29+
if (!await storageService.ContainKeyAsync(key, cancellationToken))
30+
{
31+
return defaultValue;
32+
}
33+
34+
var value = await storageService.GetItemAsStringAsync(key, cancellationToken);
35+
if (!string.IsNullOrWhiteSpace(value) && bool.TryParse(value, out var boolValue))
36+
{
37+
return boolValue;
38+
}
3039
return defaultValue;
3140
}
3241

33-
var value = await storageService.GetItemAsStringAsync(key, cancellationToken);
34-
if (!string.IsNullOrWhiteSpace(value) && bool.TryParse(value, out var boolValue))
35-
{
36-
return boolValue;
37-
}
38-
return defaultValue;
42+
/// <summary>
43+
/// Set local storage boolean value
44+
/// </summary>
45+
/// <param name="key">Storage key</param>
46+
/// <param name="data">Storage data</param>
47+
/// <param name="cancellationToken">Cancellation token</param>
48+
public async Task SetItemAsBooleanAsync(string key, bool data, CancellationToken cancellationToken = default) =>
49+
await storageService.SetItemAsStringAsync(key, data.ToString(), cancellationToken);
3950
}
40-
41-
/// <summary>
42-
/// Set local storage boolean value
43-
/// </summary>
44-
/// <param name="storageService">Local storage service</param>
45-
/// <param name="key">Storage key</param>
46-
/// <param name="data">Storage data</param>
47-
/// <param name="cancellationToken">Cancellation token</param>
48-
public static async Task SetItemAsBooleanAsync(this ILocalStorageService storageService,
49-
string key, bool data, CancellationToken cancellationToken = default) =>
50-
await storageService.SetItemAsStringAsync(key, data.ToString(), cancellationToken);
5151
}

Core/PayrollEngine.WebApp.Core.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="PayrollEngine.Client.Core" Version="0.9.0-beta.12" />
16-
<PackageReference Include="Microsoft.AspNetCore.Components" Version="9.0.10" />
15+
<PackageReference Include="PayrollEngine.Client.Core" Version="0.9.0-beta.13" />
16+
<PackageReference Include="Microsoft.AspNetCore.Components" Version="10.0.1" />
1717
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
18-
<PackageReference Include="Microsoft.JSInterop" Version="9.0.10" />
18+
<PackageReference Include="Microsoft.JSInterop" Version="10.0.1" />
1919
</ItemGroup>
2020

2121
<ItemGroup>

Core/RegulationItemTypeExtensions.cs

Lines changed: 64 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,78 +7,79 @@ namespace PayrollEngine.WebApp;
77
/// </summary>
88
public static class RegulationItemTypeExtensions
99
{
10-
/// <summary>
11-
/// Get localized regulation item type name
12-
/// </summary>
1310
/// <param name="itemType">Item type</param>
14-
/// <param name="localizer">Localizer</param>
15-
/// <param name="plural">Plural mode</param>
16-
public static string LocalizedName(this RegulationItemType itemType, Localizer localizer, bool plural = false)
11+
extension(RegulationItemType itemType)
1712
{
18-
switch (itemType)
13+
/// <summary>
14+
/// Get localized regulation item type name
15+
/// </summary>
16+
/// <param name="localizer">Localizer</param>
17+
/// <param name="plural">Plural mode</param>
18+
public string LocalizedName(Localizer localizer, bool plural = false)
1919
{
20-
case RegulationItemType.Case:
21-
return plural ? localizer.Case.Cases : localizer.Case.Case;
22-
case RegulationItemType.CaseField:
23-
return plural ? localizer.CaseField.CaseFields : localizer.CaseField.CaseField;
24-
case RegulationItemType.CaseRelation:
25-
return plural ? localizer.CaseRelation.CaseRelations : localizer.CaseRelation.CaseRelation;
26-
case RegulationItemType.Collector:
27-
return plural ? localizer.Collector.Collectors : localizer.Collector.Collector;
28-
case RegulationItemType.WageType:
29-
return plural ? localizer.WageType.WageTypes : localizer.WageType.WageType;
30-
case RegulationItemType.Report:
31-
return plural ? localizer.Report.Reports : localizer.Report.Report;
32-
case RegulationItemType.ReportParameter:
33-
return plural ? localizer.ReportParameter.ReportParameters : localizer.ReportParameter.ReportParameter;
34-
case RegulationItemType.ReportTemplate:
35-
return plural ? localizer.ReportTemplate.ReportTemplates : localizer.ReportTemplate.ReportTemplate;
36-
case RegulationItemType.Lookup:
37-
return plural ? localizer.Lookup.Lookups : localizer.Lookup.Lookup;
38-
case RegulationItemType.LookupValue:
39-
return plural ? localizer.LookupValue.LookupValues : localizer.LookupValue.LookupValue;
40-
case RegulationItemType.Script:
41-
return plural ? localizer.Script.Scripts : localizer.Script.Script;
42-
default:
43-
return itemType.ToString();
20+
switch (itemType)
21+
{
22+
case RegulationItemType.Case:
23+
return plural ? localizer.Case.Cases : localizer.Case.Case;
24+
case RegulationItemType.CaseField:
25+
return plural ? localizer.CaseField.CaseFields : localizer.CaseField.CaseField;
26+
case RegulationItemType.CaseRelation:
27+
return plural ? localizer.CaseRelation.CaseRelations : localizer.CaseRelation.CaseRelation;
28+
case RegulationItemType.Collector:
29+
return plural ? localizer.Collector.Collectors : localizer.Collector.Collector;
30+
case RegulationItemType.WageType:
31+
return plural ? localizer.WageType.WageTypes : localizer.WageType.WageType;
32+
case RegulationItemType.Report:
33+
return plural ? localizer.Report.Reports : localizer.Report.Report;
34+
case RegulationItemType.ReportParameter:
35+
return plural ? localizer.ReportParameter.ReportParameters : localizer.ReportParameter.ReportParameter;
36+
case RegulationItemType.ReportTemplate:
37+
return plural ? localizer.ReportTemplate.ReportTemplates : localizer.ReportTemplate.ReportTemplate;
38+
case RegulationItemType.Lookup:
39+
return plural ? localizer.Lookup.Lookups : localizer.Lookup.Lookup;
40+
case RegulationItemType.LookupValue:
41+
return plural ? localizer.LookupValue.LookupValues : localizer.LookupValue.LookupValue;
42+
case RegulationItemType.Script:
43+
return plural ? localizer.Script.Scripts : localizer.Script.Script;
44+
default:
45+
return itemType.ToString();
46+
}
4447
}
45-
}
4648

47-
/// <summary>
48-
/// Get the regulation parent item type
49-
/// </summary>
50-
/// <param name="itemType">Item type</param>
51-
public static RegulationItemType ParentType(this RegulationItemType itemType)
52-
{
53-
switch (itemType)
49+
/// <summary>
50+
/// Get the regulation parent item type
51+
/// </summary>
52+
public RegulationItemType ParentType()
5453
{
55-
case RegulationItemType.CaseField:
56-
return RegulationItemType.Case;
57-
case RegulationItemType.ReportParameter:
58-
case RegulationItemType.ReportTemplate:
59-
return RegulationItemType.Report;
60-
case RegulationItemType.LookupValue:
61-
return RegulationItemType.Lookup;
62-
default:
63-
throw new PayrollException($"Regulation item type {itemType} has no parent.");
54+
switch (itemType)
55+
{
56+
case RegulationItemType.CaseField:
57+
return RegulationItemType.Case;
58+
case RegulationItemType.ReportParameter:
59+
case RegulationItemType.ReportTemplate:
60+
return RegulationItemType.Report;
61+
case RegulationItemType.LookupValue:
62+
return RegulationItemType.Lookup;
63+
default:
64+
throw new PayrollException($"Regulation item type {itemType} has no parent.");
65+
}
6466
}
65-
}
6667

67-
/// <summary>
68-
/// Test for parent item type
69-
/// </summary>
70-
/// <param name="itemType">Item type</param>
71-
public static bool HasParentType(this RegulationItemType itemType)
72-
{
73-
switch (itemType)
68+
/// <summary>
69+
/// Test for parent item type
70+
/// </summary>
71+
public bool HasParentType()
7472
{
75-
case RegulationItemType.CaseField:
76-
case RegulationItemType.ReportParameter:
77-
case RegulationItemType.ReportTemplate:
78-
case RegulationItemType.LookupValue:
79-
return true;
80-
default:
81-
return false;
73+
switch (itemType)
74+
{
75+
case RegulationItemType.CaseField:
76+
case RegulationItemType.ReportParameter:
77+
case RegulationItemType.ReportTemplate:
78+
case RegulationItemType.LookupValue:
79+
return true;
80+
default:
81+
return false;
82+
}
8283
}
8384
}
8485
}

0 commit comments

Comments
 (0)