diff --git a/IlluminatedCloud/Salesforce_Indicators__dev/OfflineSymbolTable.zip b/IlluminatedCloud/Salesforce_Indicators__dev/OfflineSymbolTable.zip new file mode 100644 index 0000000..ca3c7ab Binary files /dev/null and b/IlluminatedCloud/Salesforce_Indicators__dev/OfflineSymbolTable.zip differ diff --git a/force-app/main/default/classes/ObjectFieldSelectorController.cls b/force-app/main/default/classes/ObjectFieldSelectorController.cls new file mode 100644 index 0000000..8c32eb4 --- /dev/null +++ b/force-app/main/default/classes/ObjectFieldSelectorController.cls @@ -0,0 +1,116 @@ +public with sharing class ObjectFieldSelectorController { + + public static final String STANDARD = 'standard'; + public static final String SPECIFIC = 'specific'; + public static final String CUSTOM = 'custom'; + public static final String BOTH = 'both'; + public static final String ANCILLARY = 'ancillary'; + public static final String ALL = 'all'; + + @AuraEnabled + public static GetObjectsResult getObjects(String selectionType, List availableObjects) { + if (String.isBlank(selectionType)) + selectionType = BOTH; + selectionType = selectionType.toLowerCase(); + GetObjectsResult result = new GetObjectsResult(); + result.objects = new List(); + List describeResults = new List(); + if (selectionType == ALL) { + Map objMap = Schema.getGlobalDescribe(); + for (Schema.SObjectType objType : objMap.values()) { + describeResults.add(objType.getDescribe()); + } + } else if (selectionType == SPECIFIC) { + describeResults = Schema.describeSObjects(availableObjects); + } else { + List objectNames = new List(); + List entityDefs = new List(); + if (selectionType == STANDARD || selectionType == BOTH) { + entityDefs.addAll([SELECT KeyPrefix, QualifiedApiName, DeveloperName FROM EntityDefinition WHERE (NOT QualifiedApiName LIKE '%__c') AND (NOT QualifiedApiName LIKE '%Feed') AND (NOT QualifiedApiName LIKE '%Tag') AND (NOT QualifiedApiName LIKE '%Share') AND (NOT QualifiedApiName LIKE '%ChangeEvent') AND (NOT QualifiedApiName LIKE '%History')]); + } + if (selectionType == CUSTOM || selectionType == BOTH) { + entityDefs.addAll([SELECT QualifiedApiName FROM EntityDefinition WHERE QualifiedApiName LIKE '%__c']); + } + if (selectionType == ANCILLARY) { + entityDefs.addAll([SELECT QualifiedApiName, DeveloperName FROM EntityDefinition WHERE QualifiedApiName LIKE '%Feed' OR QualifiedApiName LIKE '%Tag' OR QualifiedApiName LIKE '%Share' OR QualifiedApiName LIKE '%ChangeEvent' OR QualifiedApiName LIKE '%History']); + } + for (EntityDefinition def : entityDefs) { + // The standard list of EntityDefinitions may still return some odd types like metadata, so we filter out any object with double underscores + if (selectionType != STANDARD || !def.QualifiedApiName.contains('__')) { + objectNames.add(def.QualifiedApiName); + } + } + describeResults = Schema.describeSObjects(objectNames); + } + for (Schema.DescribeSObjectResult res : describeResults) { + result.objects.add(new ObjectResult(res.getLabel(), res.getName())); + } + return result; + } + + @AuraEnabled(cacheable=true) + public static GetObjectFieldsResult getObjectFields(String objectName) { + GetObjectFieldsResult result = new GetObjectFieldsResult(); + result.fields = new List(); + try { + Map tokenMap = ((SObject)Type.forName('Schema', objectName).newInstance()).getSObjectType().getDescribe().fields.getMap(); + for (Schema.SObjectField objField : tokenMap.values()) { + FieldResult newField = new FieldResult(objField.getDescribe()); + System.debug(newField); + result.fields.add(newField); + } + } catch (Exception e) { + result.errorMessage = e.getMessage(); + return result; + } + System.debug('about to return result, with '+ result.fields.size() +' fields'); + return result; + } + + public class GetObjectsResult { + @AuraEnabled public List objects; + } + + public class ObjectResult { + @AuraEnabled public String label; + @AuraEnabled public String value; + + public ObjectResult(String label, String value) { + this.label = label; + this.value = value; + } + } + + public class GetObjectFieldsResult { + @AuraEnabled public String errorMessage; + @AuraEnabled public List fields; + } + + public class FieldResult { + @AuraEnabled public String apiName; + @AuraEnabled public String label; + @AuraEnabled public String dataType; + @AuraEnabled public boolean nameField; + @AuraEnabled public List referenceToInfos; + + public FieldResult(Schema.DescribeFieldResult fieldResult) { + this.apiName = fieldResult.getName(); + this.label = fieldResult.getLabel(); + this.dataType = fieldResult.getType().name(); + this.nameField = fieldResult.isNameField(); + List refToInfos = new List(); + for (Schema.sObjectType objType : fieldResult.getReferenceTo()) { + refToInfos.add(new ReferenceToInfo(objType.getDescribe().getName())); + } + this.referenceToInfos = refToInfos; + } + } + + public class ReferenceToInfo { + @AuraEnabled public String apiName; + + public ReferenceToInfo(String apiName) { + this.apiName = apiName; + } + } +} diff --git a/force-app/main/default/classes/ObjectFieldSelectorController.cls-meta.xml b/force-app/main/default/classes/ObjectFieldSelectorController.cls-meta.xml new file mode 100644 index 0000000..40d6793 --- /dev/null +++ b/force-app/main/default/classes/ObjectFieldSelectorController.cls-meta.xml @@ -0,0 +1,5 @@ + + + 54.0 + Active + diff --git a/force-app/main/default/classes/ObjectFieldSelectorControllerTest.cls b/force-app/main/default/classes/ObjectFieldSelectorControllerTest.cls new file mode 100644 index 0000000..8c0cb53 --- /dev/null +++ b/force-app/main/default/classes/ObjectFieldSelectorControllerTest.cls @@ -0,0 +1,18 @@ +@isTest +public class ObjectFieldSelectorControllerTest { + + @isTest + public static void testOFSController() { + ObjectFieldSelectorController.GetObjectsResult result1 = ObjectFieldSelectorController.getObjects('all', new List()); + ObjectFieldSelectorController.GetObjectsResult result2 = ObjectFieldSelectorController.getObjects('both', new List()); + ObjectFieldSelectorController.GetObjectsResult result3 = ObjectFieldSelectorController.getObjects('specific', new List{'Account', 'Opportunity'}); + System.assertEquals(result3.objects.size(), 2); + System.assert(result3.objects.size() < result2.objects.size()); + System.assert(result2.objects.size() < result1.objects.size()); + + ObjectFieldSelectorController.GetObjectFieldsResult result4 = ObjectFieldSelectorController.getObjectFields('Account'); + ObjectFieldSelectorController.GetObjectFieldsResult result5 = ObjectFieldSelectorController.getObjectFields('NotARealObject'); + System.assert(String.isBlank(result4.errorMessage)); + System.assert(!String.isBlank(result5.errorMessage)); + } +} diff --git a/force-app/main/default/classes/ObjectFieldSelectorControllerTest.cls-meta.xml b/force-app/main/default/classes/ObjectFieldSelectorControllerTest.cls-meta.xml new file mode 100644 index 0000000..40d6793 --- /dev/null +++ b/force-app/main/default/classes/ObjectFieldSelectorControllerTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 54.0 + Active + diff --git a/force-app/main/default/classes/SldsIconController.cls b/force-app/main/default/classes/SldsIconController.cls new file mode 100644 index 0000000..a724921 --- /dev/null +++ b/force-app/main/default/classes/SldsIconController.cls @@ -0,0 +1,56 @@ +public with sharing class SldsIconController { + + static final String COMMA = ','; + static final String NEWLINE = '\r\n'; + static final String SPACE = ' '; + + public class Option { + @AuraEnabled + public String label {get; set;} + @AuraEnabled + public String value {get; set;} + @AuraEnabled + public String icon {get; set;} + } + + @AuraEnabled (cacheable=true) + public static List