Skip to content

Commit

Permalink
day one
Browse files Browse the repository at this point in the history
  • Loading branch information
bhanudas committed Feb 6, 2024
1 parent d3ab2fc commit 15dc874
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 14 deletions.
18 changes: 17 additions & 1 deletion .forceignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
**/jsconfig.json
# .forceignore v2
# List files or directories below to ignore them when running force:source:push, force:source:pull, and force:source:status
# More information: https://developer.salesforce.com/docs/atlas.en-us.sfdx_dev.meta/sfdx_dev/sfdx_dev_exclude_source.htm
#

# Standard metadata
package.xml
**/appMenus/**
**/appSwitcher/**
**/objectTranslations/**
**/profiles/**
**/settings/**

# LWC configuration files
**/jsconfig.json
**/.eslintrc.json

# LWC Jest
**/__tests__/**
23 changes: 23 additions & 0 deletions force-app/main/default/classes/FieldLabelController.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
public with sharing class FieldLabelController {
@AuraEnabled(cacheable=true)
public static String getFieldLabels(String objectName, String fieldAPIName) {
System.debug('objectName: ' + objectName);
System.debug('fieldApiNames: ' + fieldAPIName);
List<String> fieldLabels = new List<String>();
Map<String, Schema.SObjectField> fieldMap = Schema.getGlobalDescribe().get(objectName).getDescribe().fields.getMap();
return fieldMap.get(fieldAPIName).getDescribe().getLabel();
}
@AuraEnabled(cacheable=true)
public static String getSObjectType(sObject record){
System.debug('records: ' + record);
String sObjectType = null;
try {
Id recordId = record.Id;
sObjectType = recordId.getSObjectType().getDescribe().getName();
System.debug('sObjectType: ' + sObjectType);
} catch (Exception e) {
throw new AuraHandledException(e.getMessage());
}
return sObjectType;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<status>Active</status>
</ApexClass>
12 changes: 12 additions & 0 deletions force-app/main/default/classes/FieldLabelControllerTest.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@isTest
public class FieldLabelControllerTest {
@isTest
static void basicTest () {
// tests FieldLabelController
List<String> fieldApiNames = new List<String> ();
fieldApiNames.add('CreatedDate');
fieldApiNames.add('LastModifiedDate');
List<String> fieldLabels = FieldLabelController.getFieldLabels('Account',fieldApiNames);
System.assertEquals('Created Date', fieldLabels[0]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public class StickySelectronFieldDefinition {
@AuraEnabled
public String fieldApiName;
@AuraEnabled
public String label;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>59.0</apiVersion>
<status>Active</status>
</ApexClass>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>54.0</apiVersion>
<apiVersion>59.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-disable no-console */
/* eslint-disable @lwc/lwc/no-api-reassignments */
import { LightningElement, api, track } from "lwc";
import getFieldLabels from "@salesforce/apex/FieldLabelController.getFieldLabels";
import getSObjectType from "@salesforce/apex/FieldLabelController.getSObjectType";

// Note that sometimes we are dealing with a Proxy object and want to print it to console
// while debugging
Expand Down Expand Up @@ -69,22 +71,41 @@ export default class StickySelectronMain extends LightningElement {
isAsc = true;
sortedField = "Name";

connectedCallback() {
async connectedCallback() {
/*
console.log("inputTableFieldNames: ", this.inputTableFieldNames);
console.log("tableHeader: ", this.tableHeader);
console.log("sObjectApiName: ", this.sObjectApiName);
console.log("workingInputObjList: ", this.workingInputObjList);
*/
// get sobject type
const sObjectType = await getSObjectType({
record: this.workingInputObjList[0],
});
console.log("sObjectType: ", sObjectType);
if (this.inputTableFieldNames && this.inputTableFieldNames.length) {
for (let inputTableFieldName of this.inputTableFieldNames) {
const fieldLabel = await getFieldLabels({
objectName: sObjectType,
fieldAPIName: inputTableFieldName,
});
this.fieldsOnLeft.push({
label: inputTableFieldName,
label: fieldLabel,
fieldname: inputTableFieldName,
isDynamic: true
isDynamic: true,
});
}
}
if (this.selectedTableFieldNames && this.selectedTableFieldNames.length) {
for (let selectedTableFieldName of this.selectedTableFieldNames) {
const fieldLabel = await getFieldLabels({
objectName: sObjectType,
fieldAPIName: selectedTableFieldName,
});
this.fieldsOnRight.push({
label: selectedTableFieldName,
label: fieldLabel,
fieldname: selectedTableFieldName,
isDynamic: true
isDynamic: true,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>54.0</apiVersion>
<apiVersion>59.0</apiVersion>
<isExposed>true</isExposed>

<masterLabel>Sticky Selectron</masterLabel>
<targets>
<target>lightning__FlowScreen</target>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>

<targetConfigs>
<targetConfig targets="lightning__FlowScreen">
<propertyType
name="T"
extends="SObject"
extends="sObject"
label="Input sObject Type"
description="Select the object the component will use"
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>54.0</apiVersion>
<apiVersion>59.0</apiVersion>
<isExposed>false</isExposed>
</LightningComponentBundle>

0 comments on commit 15dc874

Please sign in to comment.