Skip to content

Commit c306095

Browse files
authored
Merge pull request #303 from Resgrid/develop
RE1-T105 Fixing map issue
2 parents 1a0db64 + 1155e72 commit c306095

27 files changed

Lines changed: 1005 additions & 30 deletions

File tree

Core/Resgrid.Localization/Areas/User/Contacts/Contacts.en.resx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,4 +483,25 @@
483483
<data name="EditContact" xml:space="preserve">
484484
<value>Edit Contact</value>
485485
</data>
486+
<data name="Routes" xml:space="preserve">
487+
<value>Routes</value>
488+
</data>
489+
<data name="Route" xml:space="preserve">
490+
<value>Route</value>
491+
</data>
492+
<data name="StopName" xml:space="preserve">
493+
<value>Stop Name</value>
494+
</data>
495+
<data name="PriorityNormal" xml:space="preserve">
496+
<value>Normal</value>
497+
</data>
498+
<data name="PriorityHigh" xml:space="preserve">
499+
<value>High</value>
500+
</data>
501+
<data name="PriorityCritical" xml:space="preserve">
502+
<value>Critical</value>
503+
</data>
504+
<data name="PriorityOptional" xml:space="preserve">
505+
<value>Optional</value>
506+
</data>
486507
</root>

Core/Resgrid.Localization/Areas/User/Routes/Routes.en.resx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,4 +339,74 @@
339339
<data name="StopLabel" xml:space="preserve">
340340
<value>Stop</value>
341341
</data>
342+
<!-- Add Stop Modal -->
343+
<data name="AddStop" xml:space="preserve">
344+
<value>Add Stop</value>
345+
</data>
346+
<data name="StopTypeManual" xml:space="preserve">
347+
<value>Manual</value>
348+
</data>
349+
<data name="StopTypeScheduledCall" xml:space="preserve">
350+
<value>Scheduled Call</value>
351+
</data>
352+
<data name="StopTypeWaypoint" xml:space="preserve">
353+
<value>Waypoint</value>
354+
</data>
355+
<data name="LinkedCall" xml:space="preserve">
356+
<value>Linked Call</value>
357+
</data>
358+
<data name="LoadingCalls" xml:space="preserve">
359+
<value>Loading calls...</value>
360+
</data>
361+
<data name="PriorityNormal" xml:space="preserve">
362+
<value>Normal</value>
363+
</data>
364+
<data name="PriorityHigh" xml:space="preserve">
365+
<value>High</value>
366+
</data>
367+
<data name="PriorityCritical" xml:space="preserve">
368+
<value>Critical</value>
369+
</data>
370+
<data name="PriorityOptional" xml:space="preserve">
371+
<value>Optional</value>
372+
</data>
373+
<data name="Find" xml:space="preserve">
374+
<value>Find</value>
375+
</data>
376+
<data name="What3Words" xml:space="preserve">
377+
<value>What3Words</value>
378+
</data>
379+
<data name="Location" xml:space="preserve">
380+
<value>Location</value>
381+
</data>
382+
<data name="ClickMapToSetLocation" xml:space="preserve">
383+
<value>Click the map to set location, or use address / What3Words above.</value>
384+
</data>
385+
<data name="PlannedArrival" xml:space="preserve">
386+
<value>Planned Arrival</value>
387+
</data>
388+
<data name="PlannedDeparture" xml:space="preserve">
389+
<value>Planned Departure</value>
390+
</data>
391+
<data name="EstDwellMinutes" xml:space="preserve">
392+
<value>Est. Dwell (min)</value>
393+
</data>
394+
<data name="SelectContact" xml:space="preserve">
395+
<value>Select Contact</value>
396+
</data>
397+
<data name="SelectContactPlaceholder" xml:space="preserve">
398+
<value>-- Type manually or select existing --</value>
399+
</data>
400+
<data name="ContactAutofillHelp" xml:space="preserve">
401+
<value>Selecting a contact auto-fills name and number below.</value>
402+
</data>
403+
<data name="ContactName" xml:space="preserve">
404+
<value>Contact Name</value>
405+
</data>
406+
<data name="ContactNumber" xml:space="preserve">
407+
<value>Contact Number</value>
408+
</data>
409+
<data name="Notes" xml:space="preserve">
410+
<value>Notes</value>
411+
</data>
342412
</root>

Core/Resgrid.Model/Repositories/IRouteStopsRepository.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ public interface IRouteStopsRepository : IRepository<RouteStop>
77
{
88
Task<IEnumerable<RouteStop>> GetStopsByRoutePlanIdAsync(string routePlanId);
99
Task<IEnumerable<RouteStop>> GetStopsByCallIdAsync(int callId);
10+
Task<IEnumerable<RouteStop>> GetStopsByContactIdAsync(string contactId);
1011
}
1112
}

Core/Resgrid.Model/RouteStop.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public class RouteStop : IEntity
4141

4242
public string ContactNumber { get; set; }
4343

44+
public string ContactId { get; set; }
45+
4446
public string Notes { get; set; }
4547

4648
public bool IsDeleted { get; set; }

Core/Resgrid.Model/Services/IRouteService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public interface IRouteService
1717
// Route Stop CRUD
1818
Task<RouteStop> SaveRouteStopAsync(RouteStop routeStop, CancellationToken cancellationToken = default);
1919
Task<List<RouteStop>> GetRouteStopsForPlanAsync(string routePlanId);
20+
Task<List<RouteStop>> GetRouteStopsForContactAsync(string contactId, int departmentId);
2021
Task<bool> ReorderRouteStopsAsync(string routePlanId, List<string> orderedStopIds, CancellationToken cancellationToken = default);
2122
Task<bool> DeleteRouteStopAsync(string routeStopId, CancellationToken cancellationToken = default);
2223

Core/Resgrid.Services/RouteService.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ public async Task<List<RouteStop>> GetRouteStopsForPlanAsync(string routePlanId)
8484
return stops?.Where(x => !x.IsDeleted).OrderBy(x => x.StopOrder).ToList() ?? new List<RouteStop>();
8585
}
8686

87+
public async Task<List<RouteStop>> GetRouteStopsForContactAsync(string contactId, int departmentId)
88+
{
89+
var stops = await _routeStopsRepository.GetStopsByContactIdAsync(contactId);
90+
if (stops == null)
91+
return new List<RouteStop>();
92+
93+
var plans = await _routePlansRepository.GetRoutePlansByDepartmentIdAsync(departmentId);
94+
var planIds = plans?.Where(p => !p.IsDeleted).Select(p => p.RoutePlanId).ToHashSet() ?? new HashSet<string>();
95+
96+
return stops.Where(s => !s.IsDeleted && planIds.Contains(s.RoutePlanId)).ToList();
97+
}
98+
8799
public async Task<bool> ReorderRouteStopsAsync(string routePlanId, List<string> orderedStopIds, CancellationToken cancellationToken = default)
88100
{
89101
var stops = await _routeStopsRepository.GetStopsByRoutePlanIdAsync(routePlanId);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using FluentMigrator;
2+
3+
namespace Resgrid.Providers.Migrations.Migrations
4+
{
5+
[Migration(54)]
6+
public class M0054_AddContactIdToRouteStops : Migration
7+
{
8+
public override void Up()
9+
{
10+
Alter.Table("RouteStops")
11+
.AddColumn("ContactId").AsString(128).Nullable();
12+
}
13+
14+
public override void Down()
15+
{
16+
Delete.Column("ContactId").FromTable("RouteStops");
17+
}
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using FluentMigrator;
2+
3+
namespace Resgrid.Providers.MigrationsPg.Migrations
4+
{
5+
[Migration(54)]
6+
public class M0054_AddContactIdToRouteStopsPg : Migration
7+
{
8+
public override void Up()
9+
{
10+
Alter.Table("routestops")
11+
.AddColumn("contactid").AsCustom("citext").Nullable();
12+
}
13+
14+
public override void Down()
15+
{
16+
Delete.Column("contactid").FromTable("routestops");
17+
}
18+
}
19+
}

Repositories/Resgrid.Repositories.DataRepository/Configs/SqlConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ protected SqlConfiguration() { }
497497
public string SelectActiveRoutePlansByDepartmentIdQuery { get; set; }
498498
public string SelectRouteStopsByRoutePlanIdQuery { get; set; }
499499
public string SelectRouteStopsByCallIdQuery { get; set; }
500+
public string SelectRouteStopsByContactIdQuery { get; set; }
500501
public string SelectRouteSchedulesByRoutePlanIdQuery { get; set; }
501502
public string SelectActiveSchedulesDueQuery { get; set; }
502503
public string SelectRouteInstancesByDepartmentIdQuery { get; set; }
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Resgrid.Model;
2+
using Resgrid.Model.Repositories.Queries.Contracts;
3+
using Resgrid.Repositories.DataRepository.Configs;
4+
using Resgrid.Repositories.DataRepository.Extensions;
5+
6+
namespace Resgrid.Repositories.DataRepository.Queries.Routes
7+
{
8+
public class SelectRouteStopsByContactIdQuery : ISelectQuery
9+
{
10+
private readonly SqlConfiguration _sqlConfiguration;
11+
public SelectRouteStopsByContactIdQuery(SqlConfiguration sqlConfiguration)
12+
{
13+
_sqlConfiguration = sqlConfiguration;
14+
}
15+
16+
public string GetQuery()
17+
{
18+
var query = _sqlConfiguration.SelectRouteStopsByContactIdQuery
19+
.ReplaceQueryParameters(_sqlConfiguration, _sqlConfiguration.SchemaName,
20+
_sqlConfiguration.RouteStopsTableName,
21+
_sqlConfiguration.ParameterNotation,
22+
new string[] { "%CONTACTID%" },
23+
new string[] { "ContactId" });
24+
25+
return query;
26+
}
27+
28+
public string GetQuery<TEntity>() where TEntity : class, IEntity
29+
{
30+
throw new System.NotImplementedException();
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)