Skip to content

Commit

Permalink
Merge pull request #588 from SalesforceFoundation/feature/238__blitz-…
Browse files Browse the repository at this point in the history
…fixes

Update Service Session Bucket Names and Default Service Session Complete Status on the Attendance Component
  • Loading branch information
AndersonTarren committed Mar 25, 2022
2 parents a305bb2 + 801a004 commit 3e71996
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 26 deletions.
4 changes: 3 additions & 1 deletion force-app/main/default/classes/AttendanceController_TEST.cls
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

@IsTest
public with sharing class AttendanceController_TEST {
private static final String COMPLETE_BUCKET = 'ServiceSessionStatusComplete';
private static final String PENDING_BUCKET = 'ServiceSessionStatusPending';
private static BasicStub serviceStub = new BasicStub(ServiceDeliveryService.class);

@IsTest
Expand Down Expand Up @@ -169,7 +171,7 @@ public with sharing class AttendanceController_TEST {

@IsTest
private static void testGetServiceSessionStatusBuckets() {
List<String> bucketNames = new List<String>{ 'Complete', 'Pending' };
List<String> bucketNames = new List<String>{ COMPLETE_BUCKET, PENDING_BUCKET };
String methodName = 'getServiceSessionStatusBuckets';

Map<String, List<String>> expectedValues = new Map<String, List<String>>();
Expand Down
4 changes: 3 additions & 1 deletion force-app/main/default/classes/ServiceSessionSelector.cls
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

public with sharing class ServiceSessionSelector {
private static final String RECENT_SESSIONS_VIEW = 'RecentSessionsView';
private static final String COMPLETE_BUCKET = 'ServiceSessionStatusComplete';
private static final String PENDING_BUCKET = 'ServiceSessionStatusPending';

@TestVisible
private FieldBucketSelector bucketSelector = new FieldBucketSelector();
Expand Down Expand Up @@ -55,7 +57,7 @@ public with sharing class ServiceSessionSelector {
}

public Set<String> getAllowedServiceSessionStatusValues() {
List<String> bucketNames = new List<String>{ 'Pending', 'Complete' };
List<String> bucketNames = new List<String>{ PENDING_BUCKET, COMPLETE_BUCKET };
Set<String> statuses = new Set<String>();

Schema.SObjectType serviceSessionSObjType = ServiceSession__c.SObjectType;
Expand Down
6 changes: 3 additions & 3 deletions force-app/main/default/classes/ServiceSessionService.cls
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public with sharing class ServiceSessionService {
@TestVisible
private FieldBucketSelector bucketSelector = new FieldBucketSelector();

public static final String COMPLETE = 'Complete';
private static final String PENDING = 'Pending';
private static final String COMPLETE_BUCKET = 'ServiceSessionStatusComplete';
private static final String PENDING_BUCKET = 'ServiceSessionStatusPending';

public Map<String, List<ServiceSession__c>> getServiceSessionsByStartDate(
String dateLiteral
Expand Down Expand Up @@ -46,7 +46,7 @@ public with sharing class ServiceSessionService {
}

public Map<String, List<String>> getServiceSessionStatusBuckets() {
List<String> bucketNames = new List<String>{ COMPLETE, PENDING };
List<String> bucketNames = new List<String>{ COMPLETE_BUCKET, PENDING_BUCKET };
Map<String, List<String>> buckets = new Map<String, List<String>>();

Schema.SObjectType serviceSessionSObjType = ServiceSession__c.SObjectType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

@IsTest
public with sharing class ServiceSessionService_TEST {
private static final String COMPLETE_BUCKET = 'ServiceSessionStatusComplete';
private static final String PENDING_BUCKET = 'ServiceSessionStatusPending';

private static TestStub bucketSelectorStub;

private static BasicStub serviceSelectorStub = new BasicStub(
Expand Down Expand Up @@ -90,7 +93,7 @@ public with sharing class ServiceSessionService_TEST {
@IsTest
private static void testGetServiceSessionStatusBuckets() {
String methodName = 'getBuckets';
List<String> bucketNames = new List<String>{ 'Complete', 'Pending' };
List<String> bucketNames = new List<String>{ COMPLETE_BUCKET, PENDING_BUCKET };

Schema.SObjectType serviceSessionSObjType = ServiceSession__c.SObjectType;
Schema.SObjectField statusField = ServiceSession__c.Status__c;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
*/

public class ServiceSessionStatusPicklist extends VisualEditor.DynamicPickList {
private static final String COMPLETE = 'Complete';

@TestVisible
private List<Schema.PicklistEntry> statusPicklistEntries = null;

public override VisualEditor.DataRow getDefaultValue() {
List<Schema.PicklistEntry> ples = getStatusPicklistEntries();
for (Schema.PicklistEntry ple : ples) {
if (ple.getValue() == ServiceSessionService.COMPLETE) {
if (ple.getValue() == COMPLETE) {
return new VisualEditor.DataRow(ple.getLabel(), ple.getValue());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

@IsTest
public with sharing class ServiceSessionStatusPicklist_TEST {
private static final String COMPLETE = 'Complete';

private static List<Schema.PicklistEntry> statusPicklistEntries = ServiceSession__c.Status__c.getDescribe()
.getPicklistValues();

Expand All @@ -18,17 +20,14 @@ public with sharing class ServiceSessionStatusPicklist_TEST {

VisualEditor.DataRow defaultDataRow = servSeshPicklist.getDefaultValue();
System.AssertEquals(
ServiceSessionService.COMPLETE,
COMPLETE,
defaultDataRow.getValue(),
'Default value should be Complete option'
);

// remove the "Complete" option to test the edge case where customer has removed the complete option
for (Integer i = 0; i < servSeshPicklist.statusPicklistEntries.size(); i++) {
if (
servSeshPicklist.statusPicklistEntries[i].getValue() ==
ServiceSessionService.COMPLETE
) {
if (servSeshPicklist.statusPicklistEntries[i].getValue() == COMPLETE) {
servSeshPicklist.statusPicklistEntries.remove(i);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Pending</label>
<label>Service Session Status: Complete</label>
<protected>false</protected>
<values>
<field>BucketedField__c</field>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Complete</label>
<label>Service Session Status: Pending</label>
<protected>false</protected>
<values>
<field>BucketedField__c</field>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Complete</label>
<label>Service Session Status: Complete</label>
<protected>false</protected>
<values>
<field>Bucket__c</field>
<value xsi:type="xsd:string">Complete</value>
<value xsi:type="xsd:string">ServiceSessionStatusComplete</value>
</values>
<values>
<field>Value__c</field>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomMetadata xmlns="http://soap.sforce.com/2006/04/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<label>Pending</label>
<label>Service Session Status: Pending</label>
<protected>false</protected>
<values>
<field>Bucket__c</field>
<value xsi:type="xsd:string">Pending</value>
<value xsi:type="xsd:string">ServiceSessionStatusPending</value>
</values>
<values>
<field>Value__c</field>
Expand Down
11 changes: 6 additions & 5 deletions force-app/main/default/lwc/attendance/attendance.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ import BAD_TAB_HEADER from "@salesforce/label/c.Incorrect_Tab";
import ATTENDANCE_TAB_MESSAGE from "@salesforce/label/c.Attendance_Tab_Message";
import pmmFolder from "@salesforce/resourceUrl/pmm";

const COMPLETE = "Complete";
const PENDING = "Pending";
const COMPLETE_STATUS = "Complete";
const COMPLETE_BUCKET = "ServiceSessionStatusComplete";
const PENDING_BUCKET = "ServiceSessionStatusPending";
const ID = "Id";
const ITEM_PAGE_NAVIGATION_TYPE = "standard__navItemPage";
const ATTENDANCE_TAB = "Attendance";
Expand Down Expand Up @@ -216,11 +217,11 @@ export default class Attendance extends NavigationMixin(LightningElement) {

if (result.data) {
for (const [key, value] of Object.entries(result.data)) {
if (key.toLowerCase() === COMPLETE.toLowerCase()) {
if (key.toLowerCase() === COMPLETE_BUCKET.toLowerCase()) {
this.completeBucketedStatuses = value.map(status =>
status.toLowerCase()
);
} else if (key.toLowerCase() === PENDING.toLowerCase()) {
} else if (key.toLowerCase() === PENDING_BUCKET.toLowerCase()) {
this.pendingBucketedStatuses = value.map(status =>
status.toLowerCase()
);
Expand Down Expand Up @@ -346,7 +347,7 @@ export default class Attendance extends NavigationMixin(LightningElement) {
})
.then(() => {
if (this.isPending) {
let newStatus = COMPLETE;
let newStatus = COMPLETE_STATUS;
if (
this.serviceSessionStatusForAfterSubmit &&
this.serviceSessionStatusForAfterSubmit !== ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
label="Status for Service Session after attendance is submitted"
datasource="apex://ServiceSessionStatusPicklist"
description="Status for Service Session after attendance is submitted."
default=""
default="Complete"
type="String" />
<property name="omitServiceParticipantStatuses"
label="Excluded Service Participant Statuses"
Expand Down
4 changes: 2 additions & 2 deletions force-app/main/default/lwc/recentSessions/recentSessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const MEDIUM_REGION_WIDTH = 768;
const SMALL = "SMALL";
const MEDIUM = "MEDIUM";
const LARGE = "LARGE";
const COMPLETE = "Complete";
const COMPLETE_BUCKET = "ServiceSessionStatusComplete";
export default class RecentSessions extends LightningElement {
@track sessionsData = [];
@track sessionIds;
Expand Down Expand Up @@ -155,7 +155,7 @@ export default class RecentSessions extends LightningElement {

if (result.data) {
for (const [key, value] of Object.entries(result.data)) {
if (key.toLowerCase() === COMPLETE.toLowerCase()) {
if (key.toLowerCase() === COMPLETE_BUCKET.toLowerCase()) {
this.completeBucketedStatuses = value.map(status =>
status.toLowerCase()
);
Expand Down

0 comments on commit 3e71996

Please sign in to comment.