Skip to content

Commit 9242dbb

Browse files
Default tab with variable
1 parent 0798297 commit 9242dbb

File tree

6 files changed

+71
-24
lines changed

6 files changed

+71
-24
lines changed

force-app/main/default/lwc/odFlowTabs/odFlowTabs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export default class OD_FlowTabs extends LightningElement {
66
@api title;
77
@api variant;
88
@api tabs;
9+
@api selectedTab;
910

1011
// output variables
1112
@api activeTab;
@@ -17,7 +18,7 @@ export default class OD_FlowTabs extends LightningElement {
1718
// =================================================================
1819
connectedCallback() {
1920
// put the default as active at the beginning
20-
this.theActiveTab = this.theTabs.find((tb) => tb.isDefault)?.value || this.theTabs[0].value;
21+
this.theActiveTab = this.selectedTab || this.theTabs[0].value;
2122
}
2223

2324
// =================================================================

force-app/main/default/lwc/odFlowTabs/odFlowTabs.js-meta.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
<property name="title" label="Title" type="String"
2121
role="inputOnly"
2222
description="Displays tooltip text when the mouse moves over the tabset." />
23+
<property name="selectedTab" label="Selected Tab" type="String"
24+
role="inputOnly"
25+
description="Sets a specific tab to open by default using a string that matches a tab's value string. If not used, the first tab opens by default." />
2326

2427
<!-- Output variables -->
2528
<property name="activeTab" label="Active Tab"

force-app/main/default/lwc/odFlowTabsConfigurationEditor/odFlowTabsConfigurationEditor.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@
3434
You must create at least one tab. Click the button to do it.
3535
</div>
3636
</template>
37+
<div class="slds-m-top--small">
38+
<lightning-combobox
39+
name="selectedTab"
40+
label={inputValues.selectedTab.label}
41+
value={inputValues.selectedTab.value}
42+
placeholder="Select Default Tab"
43+
options={selectedTabOptions}
44+
onchange={handleInputChange}
45+
class="slds-m-top--x-small"
46+
field-level-help={inputValues.selectedTab.helpText}
47+
>
48+
</lightning-combobox>
49+
</div>
3750
</div>
3851
</fieldset>
3952
</template>

force-app/main/default/lwc/odFlowTabsConfigurationEditor/odFlowTabsConfigurationEditor.js

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export default class OD_FlowTabsConfigurationEditor extends LightningElement {
1515
label: 'Title',
1616
helpText: 'Displays tooltip text when the mouse moves over the tabset.',
1717
},
18-
activeTab: {
19-
label: 'Active Tab',
18+
selectedTab: {
19+
label: 'Selected Tab',
2020
helpText:
2121
"Sets a specific tab to open by default using a string that matches a tab's value string. If not used, the first tab opens by default.",
2222
},
@@ -75,6 +75,57 @@ export default class OD_FlowTabsConfigurationEditor extends LightningElement {
7575
];
7676
}
7777

78+
get selectedTabOptions() {
79+
const result = [];
80+
81+
// variables
82+
const variables = this.builderContext.variables;
83+
if (variables.length > 0) {
84+
const variablesPerType = variables.filter((vr) => vr.dataType.toLowerCase() === 'string');
85+
86+
if (variablesPerType.length > 0) {
87+
variablesPerType.forEach((vpo) => {
88+
result.push({
89+
label: vpo.name,
90+
value: `{!${vpo.name}}`,
91+
});
92+
});
93+
}
94+
}
95+
96+
// formulas
97+
const formulas = this.builderContext.formulas;
98+
if (formulas.length > 0) {
99+
const formulasPerType = formulas.filter((fml) => fml.dataType.toLowerCase() === 'string');
100+
101+
if (formulasPerType.length > 0) {
102+
formulasPerType.forEach((fml) => {
103+
result.push({
104+
label: fml.name,
105+
value: `{!${fml.name}}`,
106+
});
107+
});
108+
}
109+
}
110+
111+
// constants
112+
const constants = this.builderContext.constants;
113+
if (constants.length > 0) {
114+
const constantsPerType = constants.filter((cnt) => cnt.dataType.toLowerCase() === 'string');
115+
116+
if (constantsPerType.length > 0) {
117+
constantsPerType.forEach((cnt) => {
118+
result.push({
119+
label: cnt.name,
120+
value: `{!${cnt.name}}`,
121+
});
122+
});
123+
}
124+
}
125+
126+
return result;
127+
}
128+
78129
// =================================================================
79130
// setter for inputs
80131
// =================================================================

force-app/main/default/lwc/odFlowTabsConfigurationTabs/odFlowTabsConfigurationTabs.html

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
>
3030
</lightning-helptext>
3131
</th>
32-
<th class="slds-p-around--x-small slds-text-align--center" style="width: 150px">Default Active?</th>
3332
<th class="slds-p-around--x-small" style="width: 80px">Order</th>
3433
</tr>
3534
</thead>
@@ -111,16 +110,6 @@
111110
</div>
112111
</template>
113112
</td>
114-
<td class="slds-text-align--center">
115-
<input
116-
type="radio"
117-
name="isDefault"
118-
value={tab.isDefault}
119-
onchange={handleSelectRadioDefault}
120-
data-value={tab.value}
121-
checked={tab.isDefault}
122-
/>
123-
</td>
124113
<td>
125114
<lightning-input
126115
type="number"

force-app/main/default/lwc/odFlowTabsConfigurationTabs/odFlowTabsConfigurationTabs.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,6 @@ export default class OD_FlowTabsConfigurationTabs extends LightningModal {
139139
};
140140
}
141141

142-
handleSelectRadioDefault(event) {
143-
const checked = event.target.checked;
144-
145-
// all in false
146-
this.theTabs.forEach((tb) => (tb.isDefault = false));
147-
148-
event.detail = { value: checked };
149-
this.handleUpdateField(event);
150-
}
151-
152142
handleClose() {
153143
this.close();
154144
}

0 commit comments

Comments
 (0)