Skip to content
Open
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
9 changes: 5 additions & 4 deletions force-app/main/default/classes/ProgramEngagementSelector.cls
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public with sharing class ProgramEngagementSelector {
public List<ProgramEngagement__c> getProgramEngagementsByProgramId(
Id programId,
Set<String> fields,
Set<String> stages
Set<String> stages,
Integer engagementLimit
) {
if (
!(Schema.SObjectType.ProgramEngagement__c.isAccessible() &&
Expand All @@ -84,8 +85,8 @@ public with sharing class ProgramEngagementSelector {
return new List<ProgramEngagement__c>();
}

Integer limitTo =
System.Limits.getLimitQueryRows() - System.Limits.getQueryRows();
// Integer limitTo =
// System.Limits.getLimitQueryRows() - System.Limits.getQueryRows();

queryBuilder
.reset()
Expand All @@ -95,7 +96,7 @@ public with sharing class ProgramEngagementSelector {
String.valueOf(ProgramEngagement__c.Program__c) + ' = :programId'
)
.addCondition(String.valueOf(ProgramEngagement__c.Stage__c) + ' IN :stages')
.withLimit(limitTo);
.withLimit(engagementLimit);

List<ProgramEngagement__c> programEngagements = Database.query(
queryBuilder.buildSoqlQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public with sharing class ServiceScheduleCreatorController {
}

@AuraEnabled(cacheable=true)
public static SelectParticipantModel getSelectParticipantModel(Id serviceId) {
public static SelectParticipantModel getSelectParticipantModel(Id serviceId, Integer engagementLimit) {
try {
return service.getSelectParticipantModel(serviceId);
return service.getSelectParticipantModel(serviceId, engagementLimit);
} catch (Exception ex) {
throw Util.getAuraHandledException(ex);
}
Expand Down
10 changes: 6 additions & 4 deletions force-app/main/default/classes/ServiceScheduleService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public with sharing class ServiceScheduleService {
domain.insertParticipants(engagements, schedule);
}

public SelectParticipantModel getSelectParticipantModel(Id serviceId) {
public SelectParticipantModel getSelectParticipantModel(Id serviceId, Integer engagementLimit) {
SelectParticipantModel model = new SelectParticipantModel();
loadAndPopulateParticipantRecords(serviceId, model);
loadAndPopulateParticipantRecords(serviceId, model, engagementLimit);
return model;
}

Expand Down Expand Up @@ -248,7 +248,8 @@ public with sharing class ServiceScheduleService {

private void loadAndPopulateParticipantRecords(
Id serviceId,
SelectParticipantModel model
SelectParticipantModel model,
Integer engagementLimit
) {
model.program = programEngagementSelector.getProgramByServiceId(serviceId);
if (model.program == null) {
Expand All @@ -262,7 +263,8 @@ public with sharing class ServiceScheduleService {
model.programEngagements = programEngagementSelector.getProgramEngagementsByProgramId(
model.program.Id,
getSelectFieldsWithToLabel(model),
progEngagementService.getActiveStages()
progEngagementService.getActiveStages(),
engagementLimit
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@
onclick={handleSelectAll}
></lightning-button>
</lightning-layout-item>
<lightning-layout-item
size="12"
class="slds-var-p-bottom_small"
if:true={showLimitInfo}
>
<c-scoped-notification
theme="info"
title={none}
></c-scoped-notification>
</lightning-layout-item>
<lightning-layout-item
size="12"
if:false={noRecordsFound}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import removeLabel from "@salesforce/label/c.Remove";

const TIME = "TIME";
const SEARCH_DELAY = 1000;
const ENGAGEMENT_LIMIT = 1000;

export default class ParticipantSelector extends LightningElement {
@api serviceId;
Expand Down Expand Up @@ -69,6 +70,7 @@ export default class ParticipantSelector extends LightningElement {
offsetRows = 50;
offset = this.offsetRows;
showSpinner = false;
showLimitInfo = false;

_searchTimeout;

Expand Down Expand Up @@ -161,14 +163,15 @@ export default class ParticipantSelector extends LightningElement {
return `${name} (${this.participantCount}/${this.capacity})`;
}

@wire(getSelectParticipantModel, { serviceId: "$serviceId" })
@wire(getSelectParticipantModel, { serviceId: "$serviceId", engagementLimit: (ENGAGEMENT_LIMIT + 1)})
dataSetup(result) {
this.wiredData = result;
if (!(result.data || result.error)) {
return;
}

if (result.data) {
this.showLimitInfo = (result.data.programEngagements.length > ENGAGEMENT_LIMIT);
this.loadTable(result.data);
this.loadTableRows(result.data);
this.loadPreviousSelections();
Expand Down Expand Up @@ -207,7 +210,7 @@ export default class ParticipantSelector extends LightningElement {

loadTableRows(data) {
let selectedIds = this.selectedEngagements.map(engagement => engagement.Id);
this.allEngagements = data.programEngagements.slice(0);
this.allEngagements = data.programEngagements.slice(0, ENGAGEMENT_LIMIT);

this.availableEngagementRows = this.allEngagements
.filter(engagement => !selectedIds.includes(engagement.Id))
Expand Down