Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $(function () {
const l = abp.localization.getResource('Payments');
const nullPlaceholder = '—';
const formatter = createNumberFormatter();
const guidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
let dt = $('#PaymentRequestListTable');
let dataTable;
let isApprove = false;
Expand Down Expand Up @@ -377,7 +378,29 @@ $(function () {
name: 'applicantName',
data: 'payeeName',
className: 'data-table-header',
index: columnIndex
index: columnIndex,
render: function (data, type, row) {
let applicantName = (typeof data !== 'string' || data.trim() === '') ? 'Applicant Name' : data;

if (type === 'sort' || type === 'filter') {
return applicantName;
}

const safeApplicantName = $.fn.dataTable.render.text().display(applicantName);

if (type === 'display' && abp.auth.isGranted('GrantApplicationManagement.Applicants.ViewList')) {
const applicantId = row?.correlationId;
const isGuid = applicantId && guidPattern.test(applicantId);

if (row?.correlationProvider === 'Application' && isGuid) {
return `<a href="/GrantApplicants/Details?ApplicationId=${encodeURIComponent(applicantId)}">${safeApplicantName}</a>`;
}

return safeApplicantName;
}

return applicantName;
Comment thread
plavoie-BC marked this conversation as resolved.
},
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ namespace Unity.GrantManager.Web.Pages.Applicants
public class DetailsModel : GrantManagerPageModel
{
private readonly IApplicantRepository _applicantRepository;
private readonly IApplicationRepository _applicationRepository;

[BindProperty(SupportsGet = true)]
public Guid ApplicantId { get; set; }

[BindProperty(SupportsGet = true)]
public Guid? ApplicationId { get; set; } = null;

public Applicant? Applicant { get; set; }
public string ApplicantDisplayName { get; set; } = string.Empty;
public string UnityApplicantId { get; set; } = string.Empty;
Expand All @@ -28,10 +32,12 @@ public class DetailsModel : GrantManagerPageModel

public DetailsModel(
IApplicantRepository applicantRepository,
IApplicationRepository applicationRepository,
ICurrentUser currentUser,
IConfiguration configuration)
{
_applicantRepository = applicantRepository;
_applicationRepository = applicationRepository;
CurrentUserId = currentUser.Id;
CurrentUserName = currentUser.SurName + ", " + currentUser.Name;
Extensions = configuration["S3:DisallowedFileTypes"] ?? "";
Expand All @@ -40,6 +46,20 @@ public DetailsModel(

public async Task<IActionResult> OnGetAsync()
{
// Resolve ApplicantId from ApplicationId if needed
if (ApplicantId == Guid.Empty && ApplicationId.HasValue)
{
try
{
var application = await _applicationRepository.WithBasicDetailsAsync(ApplicationId.Value);
ApplicantId = application.ApplicantId;
}
catch (Exception)
{
return NotFound();
}
}

if (ApplicantId == Guid.Empty)
{
return NotFound();
Expand All @@ -52,7 +72,7 @@ public async Task<IActionResult> OnGetAsync()
// Set properties for breadcrumb and display
ApplicantDisplayName = !string.IsNullOrEmpty(Applicant.ApplicantName)
? Applicant.ApplicantName
: "Unknown Applicant";
: "Applicant Name";

UnityApplicantId = Applicant.UnityApplicantId ?? "N/A";
Status = Applicant.Status ?? "Active";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$(function () {
let dt = $('#ApplicantsTable');
let dataTable;
const guidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;

// Default visible columns as per requirements
const defaultVisibleColumns = [
Expand Down Expand Up @@ -87,7 +88,29 @@ $(function () {
data: 'applicantName',
name: 'applicantName',
className: 'data-table-header',
index: columnIndex
index: columnIndex,
render: function (data, type, row) {
let applicantName = (typeof data !== 'string' || data.trim() === '') ? 'Applicant Name' : data;

if (type === 'sort' || type === 'filter') {
return applicantName;
}

const safeApplicantName = $.fn.dataTable.render.text().display(applicantName);

if (type === 'display') {
const applicantId = row?.id;
const isGuid = applicantId && guidPattern.test(applicantId);

if (isGuid) {
return `<a href="/GrantApplicants/Details?ApplicantId=${encodeURIComponent(applicantId)}">${safeApplicantName}</a>`;
}

return safeApplicantName;
}

return applicantName;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,14 +587,15 @@ $(function () {
className: 'data-table-header',
index: columnIndex,
render: function(data, type, row) {
let applicantName = (typeof data !== 'string' || data.trim() === '') ? '(Unknown Applicant)' : data;
let applicantName = (typeof data !== 'string' || data.trim() === '') ? 'Applicant Name' : data;

if (type === 'sort' || type === 'filter') {
return applicantName;
}

const safeApplicantName = $.fn.dataTable.render.text().display(applicantName);

if (type === 'display' && abp.auth.isGranted('GrantApplicationManagement.Applicants.ViewList')) {
const safeApplicantName = $.fn.dataTable.render.text().display(applicantName);
const applicantId = row?.applicant?.id;
const isGuid = applicantId && guidPattern.test(applicantId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task<IActionResult> GetApplicantBreadcrumbWidgetAsync(Guid applican
UnityApplicantId = applicant.UnityApplicantId ?? "N/A",
ApplicantName = !string.IsNullOrEmpty(applicant.ApplicantName)
? applicant.ApplicantName
: "Unknown Applicant",
: "Applicant Name",
Status = applicant.Status ?? "Active"
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task<IViewComponentResult> InvokeAsync(Guid applicantId)
UnityApplicantId = applicant.UnityApplicantId ?? "N/A",
ApplicantName = !string.IsNullOrEmpty(applicant.ApplicantName)
? applicant.ApplicantName
: "Unknown Applicant",
: "Applicant Name",
Status = applicant.Status ?? "Active"
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@model ApplicationBreadcrumbWidgetViewModel

@{
var renderedApplicantName = string.IsNullOrWhiteSpace(Model.ApplicantName) ? "Unknown Applicant" : Model.ApplicantName;
var renderedApplicantName = string.IsNullOrWhiteSpace(Model.ApplicantName) ? "Applicant Name" : Model.ApplicantName;
var hasViewPermission = await PermissionChecker.IsGrantedAsync(GrantApplicationPermissions.Applicants.ViewList);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ $(function () {

prepareDisplayData: function(link) {
const referenceNumber = escapeHtml(link.referenceNumber || 'Unknown Reference');
const applicantName = escapeHtml(link.applicantName || 'Unknown Applicant');
const applicantName = escapeHtml(link.applicantName || 'Applicant Name');
const category = escapeHtml(link.category || 'Unknown Category');
const applicationStatus = escapeHtml(link.applicationStatus || 'Status Unavailable');
const linkType = escapeHtml(link.linkType || 'Related');
Expand Down
Loading