Skip to content

Commit b65772b

Browse files
Merge pull request #172 from Sarveshgithub/dev
Master Sync : Auto Generated PR
2 parents 3d5ca53 + 6c05118 commit b65772b

File tree

1 file changed

+43
-20
lines changed

1 file changed

+43
-20
lines changed

force-app/main/default/classes/RelatedList.cls

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,32 @@ public with sharing class RelatedList {
1414
public Boolean editable;
1515
@AuraEnabled
1616
public Boolean sortable;
17-
@AuraEnabled
17+
@AuraEnabled
1818
public Boolean wrapText = false;
19-
@AuraEnabled
19+
@AuraEnabled
2020
public TypeAttributeColumnJsonWithPicklist typeAttributes = null;
2121

22-
public void setTypeAttributes(List<PicklistColumnUtils.PicklistValue> options) {
22+
public void setTypeAttributes(
23+
List<PicklistColumnUtils.PicklistValue> options
24+
) {
2325
this.typeAttributes = new TypeAttributeColumnJsonWithPicklist();
2426
this.typeAttributes.options = options;
2527
this.typeAttributes.fieldName = this.fieldName;
2628
}
2729
}
28-
30+
2931
public class TypeAttributeColumnJsonWithPicklist {
30-
@AuraEnabled public List<PicklistColumnUtils.PicklistValue> options = new List<PicklistColumnUtils.PicklistValue>();
31-
@AuraEnabled public ContextTypeAttributeColumnJsonWithPicklist context = new ContextTypeAttributeColumnJsonWithPicklist();
32-
@AuraEnabled public String fieldName;
32+
@AuraEnabled
33+
public List<PicklistColumnUtils.PicklistValue> options = new List<PicklistColumnUtils.PicklistValue>();
34+
@AuraEnabled
35+
public ContextTypeAttributeColumnJsonWithPicklist context = new ContextTypeAttributeColumnJsonWithPicklist();
36+
@AuraEnabled
37+
public String fieldName;
3338
}
3439

3540
public class ContextTypeAttributeColumnJsonWithPicklist {
36-
@AuraEnabled public string fieldName = 'Id';
41+
@AuraEnabled
42+
public string fieldName = 'Id';
3743
}
3844

3945
public class ListResults {
@@ -87,11 +93,14 @@ public with sharing class RelatedList {
8793
mapPreCols = checkOverride(mapPreCols, fieldName, mfields);
8894

8995
//set picklistValues for picklist type
90-
if(mapPreCols.get(fieldName).type == 'picklist') {
91-
RelatedList.initPicklistColumn(mapPreCols, objectName, fieldName);
96+
if (mapPreCols.get(fieldName).type == 'picklist') {
97+
RelatedList.initPicklistColumn(
98+
mapPreCols,
99+
objectName,
100+
fieldName
101+
);
92102
}
93103
}
94-
95104
}
96105
return new ListResults(
97106
getRecords(soql),
@@ -103,9 +112,16 @@ public with sharing class RelatedList {
103112
throw new AuraHandledException(e.getMessage());
104113
}
105114
}
106-
107-
public static void initPicklistColumn(Map<String, ColumnJson> mapPreCols, String objectName, String fieldName) {
108-
List<PicklistColumnUtils.PicklistValue> picklistValues = PicklistColumnUtils.getPicklistValues(objectName, fieldName);
115+
116+
public static void initPicklistColumn(
117+
Map<String, ColumnJson> mapPreCols,
118+
String objectName,
119+
String fieldName
120+
) {
121+
List<PicklistColumnUtils.PicklistValue> picklistValues = PicklistColumnUtils.getPicklistValues(
122+
objectName,
123+
fieldName
124+
);
109125
mapPreCols.get(fieldName).wrapText = true;
110126
mapPreCols.get(fieldName).setTypeAttributes(picklistValues);
111127
}
@@ -143,10 +159,17 @@ public with sharing class RelatedList {
143159

144160
@AuraEnabled(cacheable=true)
145161
public static Integer countRecords(String objectName, String whereClause) {
146-
String formattedWhere = (String.isBlank(whereClause)) ? '' : ' ' + whereClause;
147-
148-
if(String.isNotEmpty(objectName)) {
149-
return database.countQuery('SELECT count() FROM ' +objectName + formattedWhere +' WITH SECURITY_ENFORCED');
162+
String formattedWhere = (String.isBlank(whereClause))
163+
? ''
164+
: ' ' + whereClause;
165+
166+
if (String.isNotEmpty(objectName)) {
167+
return database.countQuery(
168+
'SELECT count() FROM ' +
169+
objectName +
170+
formattedWhere +
171+
' WITH SECURITY_ENFORCED'
172+
);
150173
}
151174
return 0;
152175
}
@@ -175,5 +198,5 @@ public with sharing class RelatedList {
175198
mapPreCols.get(fieldName).editable = editable;
176199
mapPreCols.get(fieldName).sortable = sortable;
177200
return mapPreCols;
178-
}
179-
}
201+
}
202+
}

0 commit comments

Comments
 (0)