Remove LocationParsingConfiguration and LocationPatternMatcher classes, along with related tests and UI components. Update EventOccurrenceParserService to include location validation logic, enhancing warning reporting for long locations and potential date/time patterns. Adjust appsettings and UI to reflect the removal of location parsing settings.

This commit is contained in:
2026-01-09 09:10:22 -05:00
parent 2eae3f205c
commit ea1a4a04ad
9 changed files with 95 additions and 547 deletions
@@ -21,17 +21,7 @@
<MudGrid>
<MudItem xs="12" md="6">
<MudPaper Elevation="2" Class="pa-3 pa-md-6">
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Class="mb-4">
<MudText Typo="Typo.h5">Paste Event Occurrence Data</MudText>
<MudButton
Variant="Variant.Text"
Color="Color.Secondary"
Size="Size.Small"
StartIcon="@Icons.Material.Filled.Settings"
OnClick="OpenLocationSettings">
Location Settings
</MudButton>
</MudStack>
<MudText Typo="Typo.h5" Class="mb-4">Paste Event Occurrence Data</MudText>
<MudStack Spacing="3">
<MudStack Row="true" Spacing="2">
@@ -138,6 +128,53 @@
</MudAlert>
}
@* Locations Summary *@
@if (_parseResult.IsSuccess && _parseResult.Occurrences.Any())
{
var allLocations = _parseResult.Occurrences.Values
.SelectMany(list => list)
.Select(eo => eo.Location)
.Where(loc => !string.IsNullOrWhiteSpace(loc))
.Distinct()
.OrderBy(loc => loc)
.ToList();
// Check which locations have warnings (long or contain date/time)
var dateTimePattern = new System.Text.RegularExpressions.Regex(
@"\b(January|February|March|April|May|June|July|August|September|October|November|December)\s+\d{1,2}\b|\b\d{1,2}:\d{2}\s*(a|p)\.?m\.?\b|\bNOON\b",
System.Text.RegularExpressions.RegexOptions.IgnoreCase);
var longLocations = allLocations.Where(loc => loc.Length > 50).ToList();
var locationsWithDateTime = allLocations.Where(loc => dateTimePattern.IsMatch(loc)).ToList();
@if (allLocations.Any())
{
var warningCount = longLocations.Count + locationsWithDateTime.Count;
<MudText Typo="Typo.h6" Class="mt-4 mb-2">Parsed Locations (@allLocations.Count unique@(warningCount > 0 ? $", {warningCount} with warnings" : ""))</MudText>
<MudExpansionPanels Elevation="0">
<MudExpansionPanel Text="All Locations">
<MudList T="string">
@foreach (var location in allLocations)
{
var isLong = longLocations.Contains(location);
var hasDateTime = locationsWithDateTime.Contains(location);
var hasWarning = isLong || hasDateTime;
<MudListItem T="string">
<MudStack Row="true" Spacing="2" AlignItems="AlignItems.Center">
@if (hasWarning)
{
<MudChip T="string" Color="Color.Warning" Size="Size.Small">Warning</MudChip>
}
<MudText Style="@(hasWarning ? "color: var(--mud-palette-warning);" : "")">@location</MudText>
</MudStack>
</MudListItem>
}
</MudList>
</MudExpansionPanel>
</MudExpansionPanels>
}
}
@* Parsed Occurrences List *@
@if (_parseResult.IsSuccess && _parseResult.Occurrences.Any())
{
@@ -307,9 +344,5 @@
};
}
private void OpenLocationSettings()
{
NavigationManager.NavigateTo("/calendar/event-occurrences/import/settings");
}
}