Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combo box actions #1617

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,11 @@
<shortDescription>Value Label</shortDescription>
<value>Value</value>
</labels>
<labels>
<fullName>fsc_Manual_Reference_Allowed</fullName>
<language>en_US</language>
<protected>true</protected>
<shortDescription>ComboBox Placeholder Txxt</shortDescription>
<value>Manual reference allowed</value>
</labels>
</CustomLabels>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="slds-combobox_container">
<div class={dropdownClass} data-id="resultBox" aria-expanded="false" aria-haspopup="listbox"
role="combobox">
<div class="slds-form-element__control slds-input-has-icon slds-input-has-icon slds-input-has-icon--right"
<div class="slds-form-element__control slds-input-has-icon slds-input-has-icon slds-input-has-icon_right"
role="none" style="height: 55px;">
<template if:false={displayPill}>
<div onkeyup={handleSearchKeyUp}>
Expand All @@ -27,7 +27,7 @@
onkeydown={handleKeyDown}
onclick={handleOpenOptions}
autocomplete={autocomplete}

placeholder={placeholderText}
></lightning-input>
</div>
</template>
Expand All @@ -52,13 +52,13 @@
role="listbox">
<ul class="slds-listbox slds-listbox_vertical" role="presentation">
<template if:false={_options.length}>
<div class="slds-p-around--small">
<div class="slds-p-around_small">
{labels.noDataAvailable}
</div>
</template>
<template for:each={_options} for:item="curOption">
<li role="presentation" class="slds-listbox__item" key={curOption.type}>
<div class="slds-p-around--xx-small custom-text-transform_uppercase">
<div class="slds-p-around_xx-small custom-text-transform_uppercase">
<lightning-icon
icon-name="utility:chevronleft"
class="slds-icon slds-icon_small slds-icon-text-default"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
12/26/24 Eric Smith FlowScreenComponentsBasePack v3.3.5 or later
Updated to recognize the output from Action Buttons and Screen Actions
Added override option for CPEs to allow hard-coded references (Filter & Transform element outputs)
Placeholder text is added to the input where the override is allowed
Partial updates from PR#1581 (adamerstelle)
*/

import {LightningElement, wire, api, track} from 'lwc';
import {getObjectInfo} from 'lightning/uiObjectInfoApi';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';
Expand All @@ -8,7 +16,16 @@ import {
removeFormatting,
flowComboboxDefaults
} from 'c/fsc_flowComboboxUtils';
import getObjectFields from '@salesforce/apex/usf3.FieldSelectorController.getObjectFields';
import Placeholder_Text from '@salesforce/label/c.fsc_Manual_Reference_Allowed';
import getObjectFields from '@salesforce/apex/usf3.FieldSelectorController.getObjectFields'; // Requires FlowActionsBasePack v3.17 or later

// TODO: Handle outputs from Filter and Transform
/* Filter Notes (Eric Smith)
Process a typeDescriptor of collectionProcessors where collectionProcessorType = FilterCollectionProcessor
isCollectionField will always be true
to find the value for objectTypeField you will need to recursively check the objectTypeField value for
a typeDescriptor whose apiName matches the value for collectionReference
*/

const OUTPUTS_FROM_LABEL = 'Outputs from ';
export default class FlowCombobox extends LightningElement {
Expand All @@ -21,6 +38,18 @@ export default class FlowCombobox extends LightningElement {
@api autocomplete = 'off';
@api fieldLevelHelp;
@api disabled;

@api
get allowHardCodeReference() {
return this._allowHardCodeReference;
}
set allowHardCodeReference(value) {
this._allowHardCodeReference = value;
this.placeholderText = value ? Placeholder_Text : '';
}
_allowHardCodeReference = false; // Set to true in the CPE to allow the user to hard code a reference like {!Filter_Element} or {!Transform_Output}
placeholderText;

@track _dataType;
@track _value;
@track allOptions;
Expand Down Expand Up @@ -111,6 +140,7 @@ export default class FlowCombobox extends LightningElement {
// {apiName: 'actionCalls.outputParameters', label: 'Variables', dataType: flowComboboxDefaults.stringDataType},
// {apiName: 'apexPluginCalls', label: 'Variables', dataType: flowComboboxDefaults.stringDataType},
{apiName: 'globalVariables', label: 'Global Variables', dataType: flowComboboxDefaults.stringDataType}, // Not within Flow Metadata API but compiled to allow Global Variables to be used
{apiName: 'screens.actions', label: 'Screen Actions', dataType: flowComboboxDefaults.screenActionType} // ***
];

_staticOptions
Expand Down Expand Up @@ -162,6 +192,16 @@ export default class FlowCombobox extends LightningElement {

set builderContext(value) {
this._builderContext = value;
if (this._automaticOutputVariables) {
this.initFromBuilderContextAndAutomaticOutputVariables();
}
}

@api get automaticOutputVariables () {
return this._automaticOutputVariables;
}

initFromBuilderContextAndAutomaticOutputVariables () {
this._mergeFields = this.generateMergeFieldsFromBuilderContext(this._builderContext);
this._mergeFields = this.adjustOptions(this._mergeFields);
if (!this._selectedObjectType) {
Expand All @@ -170,13 +210,12 @@ export default class FlowCombobox extends LightningElement {
}
}

@api get automaticOutputVariables () {
return this._automaticOutputVariables;
}

set automaticOutputVariables(value) {
// console.log('setting automaticOutputVariables to ' + JSON.stringify(value));
this._automaticOutputVariables = value;
if (this._builderContext) {
this.initFromBuilderContextAndAutomaticOutputVariables();
}
}

get displayPill() {
Expand Down Expand Up @@ -513,23 +552,28 @@ export default class FlowCombobox extends LightningElement {
let typeOptions = [];
objectArray.forEach(curObject => {
let isActionCall = (typeDescriptor.apiName === flowComboboxDefaults.actionType);
let isScreenAction = typeDescriptor.dataType === flowComboboxDefaults.screenActionType;
let isScreenComponent = (typeDescriptor.dataType === flowComboboxDefaults.screenComponentType) && curObject.storeOutputAutomatically;
let curDataType = (isActionCall) ? flowComboboxDefaults.actionType : isScreenComponent ? flowComboboxDefaults.screenComponentType : this.getTypeByDescriptor(curObject[typeField], typeDescriptor);
let label = isActionCall ? OUTPUTS_FROM_LABEL + curObject['name'] : curObject[labelField] ? curObject[labelField] : curObject[valueField];
let curDataType = isScreenAction ? flowComboboxDefaults.screenActionType : (isActionCall) ? flowComboboxDefaults.actionType : isScreenComponent ? flowComboboxDefaults.screenComponentType : this.getTypeByDescriptor(curObject[typeField], typeDescriptor);
let label = isActionCall||isScreenAction ? OUTPUTS_FROM_LABEL + curObject['name'] : curObject[labelField] ? curObject[labelField] : curObject[valueField];
let curIsCollection = this.isCollection(curObject, isCollectionField);
typeOptions.push(this.generateOptionLine(
curDataType,
label,//curObject[labelField] ? curObject[labelField] : curObject[valueField],
typeDescriptor.dataType === flowComboboxDefaults.screenComponentType ? curObject[valueField].split('.')[1] : curObject[valueField], // For the split "Child_Case_Creation_Form.Text_Area" would be "Text_Area" only for screen components
typeDescriptor.apiName === flowComboboxDefaults.recordLookupsType ? !curIsCollection : !!curIsCollection,
curObject[objectTypeField],
this.getIconNameByType(curDataType),
(curDataType === flowComboboxDefaults.dataTypeSObject || typeDescriptor.apiName === flowComboboxDefaults.recordLookupsType),
curDataType === flowComboboxDefaults.dataTypeSObject ? curObject[objectTypeField] : curDataType,
flowComboboxDefaults.defaultKeyPrefix + this.key++,
null,
curObject.storeOutputAutomatically && typeDescriptor.dataType !== 'SObject'
));
const storeOutputAutomatically = (curObject.storeOutputAutomatically && typeDescriptor.dataType !== 'SObject') || typeDescriptor.dataType === flowComboboxDefaults.screenActionType;
if (!isScreenAction || this.automaticOutputVariables[curObject.name]) {
typeOptions.push(this.generateOptionLine(
curDataType,
label,//curObject[labelField] ? curObject[labelField] : curObject[valueField],
typeDescriptor.dataType === flowComboboxDefaults.screenComponentType ? curObject[valueField].split('.')[1] : curObject[valueField], // For the split "Child_Case_Creation_Form.Text_Area" would be "Text_Area" only for screen components
typeDescriptor.apiName === flowComboboxDefaults.recordLookupsType ? !curIsCollection : !!curIsCollection,
curObject[objectTypeField],
this.getIconNameByType(curDataType),
(curDataType === flowComboboxDefaults.dataTypeSObject || typeDescriptor.apiName === flowComboboxDefaults.recordLookupsType),
curDataType === flowComboboxDefaults.dataTypeSObject ? curObject[objectTypeField] : curDataType,
flowComboboxDefaults.defaultKeyPrefix + this.key++,
null,
//curObject.storeOutputAutomatically && typeDescriptor.dataType !== 'SObject'
storeOutputAutomatically
));
}
});
return typeOptions;
}
Expand Down Expand Up @@ -580,7 +624,8 @@ export default class FlowCombobox extends LightningElement {
}

handleSetSelectedRecord(event) {
event.stopPropagation(); // stops the window generic click handlers from firing 2x more times, not sure it makes a difference but it reduced my debugging here into a 3rd
event.stopPropagation(); // stops the window generic click handlers from firing 2x more times

if (event.currentTarget.dataset) {
if (this.value && this.value.endsWith(event.currentTarget.dataset.value) && event.currentTarget.dataset.objectType) {
this.doOpenObject(event, event.currentTarget.dataset.value, event.currentTarget.dataset.objectType);
Expand Down Expand Up @@ -882,6 +927,9 @@ export default class FlowCombobox extends LightningElement {
return null;
}

this._selectedFieldPath = (this._selectedFieldPath ? this._selectedFieldPath + '.' : '') + value;
this.value = this._selectedFieldPath + '.';

// Set the Options
this.setOptions([{type: value + ' Outputs', options: tempOptions}]);

Expand All @@ -898,12 +946,15 @@ export default class FlowCombobox extends LightningElement {
event.stopPropagation();
this._selectedFieldPath = (this._selectedFieldPath ? this._selectedFieldPath + '.' : '') + value;
this.value = this._selectedFieldPath + '.';
this.getActionOutputs(value);
// this.getActionOutputs(value);
this.getActionOutputs(this._selectedFieldPath);
}

getActionOutputs(actionName) {
// getActionOutputs(actionName) {
getActionOutputs(path) {
let tempOptions = [];
this.automaticOutputVariables[actionName].forEach(
// this.automaticOutputVariables[actionName].forEach(
this.automaticOutputVariables[path].forEach(
output => {

let curObjectType = output.sobjectType ? output.sobjectType : output.subtype;
Expand All @@ -917,11 +968,14 @@ export default class FlowCombobox extends LightningElement {
this.getIconNameByType(curDataType),
curDataType === 'SObject',
curDataType === 'SObject' ? curObjectType : curDataType,
flowComboboxDefaults.defaultKeyPrefix + this.key++
flowComboboxDefaults.defaultKeyPrefix + this.key++,
undefined,
!!this.automaticOutputVariables[path+'.'+output.apiName]
));
}
);
this.setOptions([{type: actionName + ' Outputs', options: tempOptions}]);
// this.setOptions([{type: actionName + ' Outputs', options: tempOptions}]);
this.setOptions([{type: path + ' Outputs', options: tempOptions}]);
}


Expand Down Expand Up @@ -1015,7 +1069,8 @@ export default class FlowCombobox extends LightningElement {
let localOptions = curOption.options;

if (this.builderContextFilterType) {
localOptions = localOptions.filter(opToFilter => opToFilter.displayType?.toLowerCase() === this.builderContextFilterType.toLowerCase() || opToFilter.storeOutputAutomatically === true || ( opToFilter.type === 'SObject' && !this.builderContextFilterCollectionBoolean));
// localOptions = localOptions.filter(opToFilter => opToFilter.displayType?.toLowerCase() === this.builderContextFilterType.toLowerCase() || opToFilter.storeOutputAutomatically === true || ( opToFilter.type === 'SObject' && !this.builderContextFilterCollectionBoolean));
localOptions = localOptions.filter(opToFilter => opToFilter.displayType?.toLowerCase() === this.builderContextFilterType.toLowerCase() || opToFilter.storeOutputAutomatically === true || ( opToFilter.type.toLowerCase() === 'SObject'.toLowerCase() && !this.builderContextFilterCollectionBoolean));
}

if (typeof this.builderContextFilterCollectionBoolean !== "undefined") {
Expand Down Expand Up @@ -1137,7 +1192,7 @@ export default class FlowCombobox extends LightningElement {
this._value = removeFormatting(valueInput.value);
if (isRef) {
let typeOption = this.getTypeOption(this._value);
if (!typeOption) {
if (!typeOption && !this._allowHardCodeReference) {
this.hasError = true;
}
this._dataType = flowComboboxDefaults.referenceDataType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const flowComboboxDefaults = {
dataTypeSObject: 'SObject',
isCollectionField: 'isCollection',
actionType: 'actionCalls',
screenComponentType: 'screenComponent'
screenComponentType: 'screenComponent',
screenActionType: 'screenAction',

}

Expand Down