Skip to content

Commit

Permalink
Merge pull request #1511 from alexed1/testQuickChoice
Browse files Browse the repository at this point in the history
Spring '24 fix
  • Loading branch information
alexed1 authored Jan 24, 2024
2 parents 8ab56b7 + 4a3ce57 commit 9e46f54
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const CB_ATTRIB_PREFIX = 'cb_'; // Used with fsc_flowCheckbox component

export default class QuickChoiceCpe extends LightningElement {
static delegatesFocus = true;
versionNumber = '2.43';
versionNumber = '2.44';
staticChoicesModalClass = 'staticChoicesModal';
_builderContext;
_values;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@

.paddingFix {
padding-right: 0rem !important;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
GetRecordTypeInfobyObjectTest
QuickChoiceMockHttpResponseGenerator
1/16/24 - Eric Smith - Version 2.44
Implemented workaround for Spring '24 bug with dependent picklists and other reactivity issues
12/12/23 - Eric Smith - Version 2.43
Added reactivity for the Record Type Id
Expand Down Expand Up @@ -213,4 +216,4 @@

</template>
</template>
</template>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ export default class QuickChoiceFSC extends LightningElement {
return this._choiceLabels;
}
set choiceLabels(value) {
this._choiceLabels = value;
if (this.isConnected) {
this._handleChoiceCollections();
if (value != null) {
this._choiceLabels = value;
if (this.isConnected) {
this._handleChoiceCollections();
}
}
}
_choiceLabels = [];
Expand All @@ -46,9 +48,11 @@ export default class QuickChoiceFSC extends LightningElement {
return this._choiceValues;
}
set choiceValues(value) {
this._choiceValues = value;
if (this.isConnected) {
this._handleChoiceCollections();
if (value != null) {
this._choiceValues = value;
if (this.isConnected) {
this._handleChoiceCollections();
}
}
}
_choiceValues = [];
Expand Down Expand Up @@ -92,6 +96,8 @@ export default class QuickChoiceFSC extends LightningElement {
get dependentPicklist() {
return (this.cb_dependentPicklist == CB_TRUE) ? true : false;
}
set dependentPicklist(value) {}

@api cb_dependentPicklist;

@api
Expand All @@ -100,11 +106,13 @@ export default class QuickChoiceFSC extends LightningElement {
}

set controllingCheckboxValue(value) {
this._controllingCheckboxValue = value;
this.controllingValue = value;
if (value != this.priorControllingValue) {
this.priorControllingValue = value;
this.setPicklistSelections(this.picklistFieldDetails);
if (value != null) {
this._controllingCheckboxValue = value;
this.controllingValue = value;
if (value != this.priorControllingValue) {
this.priorControllingValue = value;
this.setPicklistSelections(this.picklistFieldDetails);
}
}
}

Expand All @@ -114,11 +122,13 @@ export default class QuickChoiceFSC extends LightningElement {
}

set controllingPicklistValue(value) {
this._controllingPicklistValue = value;
this.controllingValue = value;
if (value != this.priorControllingValue) {
this.priorControllingValue = value;
this.setPicklistSelections(this.picklistFieldDetails);
if (value != null) {
this._controllingPicklistValue = value;
this.controllingValue = value;
if (value != this.priorControllingValue) {
this.priorControllingValue = value;
this.setPicklistSelections(this.picklistFieldDetails);
}
}
}

Expand All @@ -128,9 +138,11 @@ export default class QuickChoiceFSC extends LightningElement {
return this._choiceIcons;
}
set choiceIcons(value) {
this._choiceIcons = value;
if (this.isConnected) {
this._handleChoiceCollections();
if (value != null) {
this._choiceIcons = value;
if (this.isConnected) {
this._handleChoiceCollections();
}
}
}
_choiceIcons = [];
Expand All @@ -149,8 +161,10 @@ export default class QuickChoiceFSC extends LightningElement {
return this._staticChoicesString;
}
set staticChoicesString(jsonString) {
this._staticChoicesString = jsonString;
this.staticChoices = JSON.parse(jsonString);
if (jsonString != null) {
this._staticChoicesString = jsonString;
this.staticChoices = JSON.parse(jsonString);
}
}
_staticChoicesString;

Expand All @@ -160,12 +174,14 @@ export default class QuickChoiceFSC extends LightningElement {
}
set staticChoices(choices) {
console.log(this._masterLabel + ": ", 'setting staticChoices to '+ JSON.stringify(choices));
this._staticChoices = choices;
this._choiceValues = [];
this._choiceLabels = [];
for (let choice of choices) {
this._choiceValues.push(choice.value);
this._choiceLabels.push(choice.label);
if (choices != null) {
this._staticChoices = choices;
this._choiceValues = [];
this._choiceLabels = [];
for (let choice of choices) {
this._choiceValues.push(choice.value);
this._choiceLabels.push(choice.label);
}
}
}
@track _staticChoices = [];
Expand Down Expand Up @@ -318,50 +334,50 @@ export default class QuickChoiceFSC extends LightningElement {

// Process available selections for the picklist
setPicklistSelections(data) {

this._picklistOptions = [];
this._allValues = [];
this._allLabels = [];
if (this.allowNoneToBeChosen) {
this._picklistOptions.push({label: "--None--", value: "None"});
}

// Set isControlled only if a controlling value was provided and there are available controller values
this._isControlled = false;
let controllingIndex;
if (Object.keys(data.controllerValues).length > 0) {
this._isControlled = true;
this._showPicklist = true;
this.isControlledByCheckbox = ((Object.keys(data.controllerValues)[0] === 'false') && (Object.keys(data.controllerValues).length = 2)) ? true : false;
if ((this.controllingValue == undefined) && this.isControlledByCheckbox) {
this.controllingValue = 'false'; // Start checkbox controlled picklists with a controlling value of false
if (data != undefined) {
this._picklistOptions = [];
this._allValues = [];
this._allLabels = [];
if (this.allowNoneToBeChosen) {
this._picklistOptions.push({label: "--None--", value: "None"});
}
controllingIndex = data.controllerValues[this.controllingValue];
}

// Picklist values
data.values.forEach(key => {
if (!this._isControlled || key.validFor.includes(controllingIndex)) {
this._picklistOptions.push({
label: key.label,
value: key.value
});
this._allLabels.push(key.label);
this._allValues.push(key.value);
// Set isControlled only if a controlling value was provided and there are available controller values
this._isControlled = false;
let controllingIndex;
if (Object.keys(data.controllerValues).length > 0) {
this._isControlled = true;
this._showPicklist = true;
this.isControlledByCheckbox = ((Object.keys(data.controllerValues)[0] === 'false') && (Object.keys(data.controllerValues).length = 2)) ? true : false;
if ((this.controllingValue == undefined) && this.isControlledByCheckbox) {
this.controllingValue = 'false'; // Start checkbox controlled picklists with a controlling value of false
}
controllingIndex = data.controllerValues[this.controllingValue];
}
});

// Sort Picklist Values
this.picklistOptionsStorage = this.doSort(this._picklistOptions, this.sortList);
// Picklist values
data.values.forEach(key => {
if (!this._isControlled || key.validFor.includes(controllingIndex)) {
this._picklistOptions.push({
label: key.label,
value: key.value
});
this._allLabels.push(key.label);
this._allValues.push(key.value);
}
});

if (this._inputMode === "Picklist Field") {
this.setPicklistOptions();
}
if (this._allValues && this._allValues.length) {
this.dispatchFlowAttributeChangedEvent('allValues', this._allValues);
this.dispatchFlowAttributeChangedEvent('allLabels', this._allLabels);
}
// Sort Picklist Values
this.picklistOptionsStorage = this.doSort(this._picklistOptions, this.sortList);

if (this._inputMode === "Picklist Field") {
this.setPicklistOptions();
}
if (this._allValues && this._allValues.length) {
this.dispatchFlowAttributeChangedEvent('allValues', this._allValues);
this.dispatchFlowAttributeChangedEvent('allLabels', this._allLabels);
}
}
}

setPicklistOptions() {
Expand Down Expand Up @@ -585,4 +601,4 @@ export default class QuickChoiceFSC extends LightningElement {
return this.bottomPadding;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
<property name="richTextFlagString" label="Rich Text Descriptions?" type="String" description="Set to RICHTEXT to display Visual Card descriptions as Rich Text"/>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
</LightningComponentBundle>

0 comments on commit 9e46f54

Please sign in to comment.