Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-177: Suppress last name on patrol sheets #186

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Model/Members/MembersPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ public class MembersPageViewModel
[Display(Name = "Include Leaders")]
public bool IncludeLeaders { get; set; } = false;
public string GroupName { get; set; } = string.Empty;
public bool SuppressLastName { get; set; }
}
}
2 changes: 1 addition & 1 deletion Services/ReportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public IWorkbook GeneratePatrolSheetsWorkbook(List<MemberListModel> sortedPatrol
//Adding cell style.
IStyle headingStyle = workbook.Styles.Add("headingStyle");
headingStyle.Font.Bold = true;
headingStyle.Font.Size = 40;
headingStyle.Font.Size = 30;
headingStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter;
headingStyle.VerticalAlignment = ExcelVAlign.VAlignCenter;
headingStyle.WrapText = true;
Expand Down
21 changes: 18 additions & 3 deletions Topo/Controller/MembersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class MembersController : ComponentBase
[Inject]
public StorageService _storageService { get; set; }

[Inject]
[Inject]
IJSRuntime JS { get; set; }

[Inject]
Expand All @@ -35,6 +35,7 @@ protected override async Task OnInitializedAsync()

model.Units = _storageService.Units;
model.GroupName = _storageService.GroupNameDisplay;
model.SuppressLastName = _storageService.SuppressLastName;
if (!string.IsNullOrEmpty(_storageService.UnitId))
{
await UnitChange(_storageService.UnitId);
Expand All @@ -55,7 +56,7 @@ internal async Task UnitChange(string unitId)
_storageService.UnitId = model.UnitId;
model.UnitName = _storageService.UnitName;
model.Members = new List<MemberListModel>();
return;
return;
}
model.UnitId = unitId;
_storageService.UnitId = model.UnitId;
Expand Down Expand Up @@ -151,7 +152,21 @@ private async Task<byte[]> PatrolSheet(OutputType outputType = OutputType.PDF)
var groupName = _storageService.GroupName ?? "Group Name";
var unitName = _storageService.UnitName ?? "Unit Name";
var section = _storageService.Section;
var sortedMemberList = model.Members.Where(m => m.isAdultLeader == 0).OrderBy(m => m.patrol_name).ToList();
_storageService.SuppressLastName = model.SuppressLastName;
List<MemberListModel> sortedMemberList = new List<MemberListModel>();
foreach (var member in model.Members.Where(m => m.isAdultLeader == 0).OrderBy(m => m.patrol_name))
{
string lastName = _storageService.SuppressLastName ? member.last_name.Substring(0, 1).ToUpper() : member.last_name;
MemberListModel memberCopy = new MemberListModel
{
patrol_name = member.patrol_name,
first_name = member.first_name,
last_name = lastName,
isAdultLeader = member.isAdultLeader,
patrol_duty = member.patrol_duty
};
sortedMemberList.Add(memberCopy);
}
var serialisedSortedMemberList = JsonConvert.SerializeObject(sortedMemberList);

var report = await _reportService.GetPatrolSheetsReport(groupName, section, unitName, outputType, serialisedSortedMemberList);
Expand Down
7 changes: 7 additions & 0 deletions Topo/Pages/Members.razor
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@
<div class="col-sm">
<button type="submit" name="button" @onclick="PatrolSheetPdfClick" class="btn btn-primary">Generate Patrol sheets (pdf)</button>
<button type="submit" name="button" @onclick="PatrolSheetXlsxClick" class="btn btn-success">Generate Patrol sheets (xlsx)</button>
<div class="form-check-inline">
<InputCheckbox id="suppressLastName" class="form-check-input"
@bind-Value="model.SuppressLastName" />
<label class="form-check-label" for="suppressLastName">
Suppress Last Name
</label>
</div>
</div>
</div>
}
Expand Down