Skip to content

Commit

Permalink
Adds dynamic custom component support
Browse files Browse the repository at this point in the history
  • Loading branch information
mamikals committed Nov 26, 2024
1 parent ac23ce6 commit db73b92
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 26 deletions.
4 changes: 2 additions & 2 deletions force-app/main/default/classes/Timeline_Model.cls
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ global with sharing class Timeline_Model implements Comparable {
public String subtitleOverride;

@AuraEnabled
public Boolean useCustomView;
public String customComponent;
}

public class Filter {
Expand Down Expand Up @@ -115,7 +115,7 @@ global with sharing class Timeline_Model implements Comparable {
record.overdue = getIsOverdue(config, sObj, record);
record.dateValueDb = getDateValue(config, sObj, record);
record.subtitleOverride = (String) get(sObj, config.Timeline_Child__r.SObjectSubtitle__c); // To add subtitle for samtale
record.useCustomView = config.Timeline_Child__r.CustomView__c;
record.customComponent = config.Timeline_Child__r.CustomComponent__c;

theme.sldsTimelineItemColor = config.Timeline_Child__r.SLDS_Timeline_Color__c;
theme.icon = getIconValue(config, sObj);
Expand Down
2 changes: 1 addition & 1 deletion force-app/main/default/classes/Timeline_QueriesHelper.cls
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public with sharing class Timeline_QueriesHelper {
'Timeline_Child__r.SubtitleRelatedUserPrepositionEng__c, Timeline_Child__r.SubtitleRelatedUserPrepositionNor__c, ' +
'Timeline_Child__r.AutomaticRefresh__c, Timeline_Child__r.AutomaticRefresh_PushTopicName__c, ' +
'Timeline_Child__r.AllowAutoOpen__c, ' +
'Timeline_Child__r.CustomView__c,' +
'Timeline_Child__r.CustomComponent__c,' +
'Timeline_Child__r.FilterablePicklist1__c, Timeline_Child__r.FilterablePicklist2__c, Timeline_Child__r.FilterableCheckbox__c ' +
'FROM TimelineParent__mdt ' +
'WHERE SObjectParent__c = : parentSObjectType';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<behavior>Edit</behavior>
<field>CustomView__c</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>CustomComponent__c</field>
</layoutItems>
</layoutColumns>
<layoutColumns>
<layoutItems>
Expand Down Expand Up @@ -255,7 +259,7 @@
<field>ExpandedFieldsToDisplay__c</field>
</layoutItems>
</layoutColumns>
<layoutColumns />
<layoutColumns/>
<style>TwoColumnsLeftToRight</style>
</layoutSections>
<layoutSections>
Expand Down Expand Up @@ -290,9 +294,9 @@
<detailHeading>true</detailHeading>
<editHeading>false</editHeading>
<label>Custom Links</label>
<layoutColumns />
<layoutColumns />
<layoutColumns />
<layoutColumns/>
<layoutColumns/>
<layoutColumns/>
<style>CustomLinks</style>
</layoutSections>
<showEmailCheckbox>false</showEmailCheckbox>
Expand All @@ -301,9 +305,9 @@
<showRunAssignmentRulesCheckbox>false</showRunAssignmentRulesCheckbox>
<showSubmitAndAttachButton>false</showSubmitAndAttachButton>
<summaryLayout>
<masterLabel>00h1x000003OyV8</masterLabel>
<masterLabel>00hKM0000018E96</masterLabel>
<sizeX>4</sizeX>
<sizeY>0</sizeY>
<summaryLayoutStyle>Default</summaryLayoutStyle>
</summaryLayout>
</Layout>
</Layout>
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<template>
<template if:true={isThread}>
<c-timeline-thread-viewer record-id={recordId}></c-timeline-thread-viewer>
</template>
<template if:true={isConversationNote}>
<c-timeline-conv-note-viewer record-id={recordId}></c-timeline-conv-note-viewer>
</template>
<lwc:component lwc:is={customComponent} record-id={recordId}></lwc:component>
</template>
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { LightningElement, api} from 'lwc';
export default class TimelineCustomView extends LightningElement {
@api recordId;
@api recordType;
@api customComponentName;

customComponent;

get isThread(){
return this.recordType ==='Thread__c';
connectedCallback() {
import('c/' + this.customComponentName).then(({ default: ctor }) => (this.customComponent = ctor))
}

get isConversationNote(){
return this.recordType ==='Conversation_Note__c';
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>55.0</apiVersion>
<apiVersion>62.0</apiVersion>
<isExposed>false</isExposed>
<capabilities>
<capability>lightning__dynamicComponent</capability>
</capabilities>
</LightningComponentBundle>
4 changes: 2 additions & 2 deletions force-app/main/default/lwc/timelineItem/timelineItem.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ <h3 class="slds-truncate" title={row.record.title}>
alternative-text="Loading details"
></lightning-spinner>
<!-- ! Displays expand information useing lightning record view form. Does not support event and task object -->
<template if:true={isCustom}>
<c-timeline-custom-view record-id={row.record.recordId} record-type={row.record.sObjectKind}></c-timeline-custom-view>
<template lwc:if={isCustom}>
<c-timeline-custom-view record-id={row.record.recordId} custom-component-name={row.record.customComponent}></c-timeline-custom-view>
</template>
<lightning-record-view-form
record-id={row.record.recordId}
Expand Down
2 changes: 1 addition & 1 deletion force-app/main/default/lwc/timelineItem/timelineItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,6 @@ export default class TimelineItem extends NavigationMixin(LightningElement) {
return this.row.record.subtitleOverride != null ? (this.expanded === true ? false : true) : false;
}
get isCustom() {
return this.row.record.useCustomView;
return this.row.record.customComponent != null && this.row.record.customComponent != '';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomField xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>CustomComponent__c</fullName>
<externalId>false</externalId>
<fieldManageability>DeveloperControlled</fieldManageability>
<label>Custom Component</label>
<length>30</length>
<required>false</required>
<type>Text</type>
<unique>false</unique>
</CustomField>

0 comments on commit db73b92

Please sign in to comment.