Skip to content

Commit 73252ba

Browse files
committed
add rule toggle
1 parent e7ba3d5 commit 73252ba

File tree

3 files changed

+64
-4
lines changed

3 files changed

+64
-4
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.config-page {
2+
padding: 1rem;
3+
background-color: #f4f6f9;
4+
}
5+
6+
.slds-table th {
7+
background-color: #003087; /* Dark blue background */
8+
color: #ffffff; /* White text */
9+
font-weight: bold;
10+
padding: 0.5rem;
11+
}
12+
13+
.slds-table td {
14+
padding: 0.5rem;
15+
}
16+
17+
.toggle-all-row {
18+
background-color: #ffffff; /* Match table row background */
19+
border-bottom: 1px solid #ddd; /* Match table borders */
20+
}
21+
22+
.toggle-all-checkbox {
23+
--slds-c-checkbox-label-font-size: 0.875rem;
24+
--slds-c-checkbox-label-font-weight: bold;
25+
--slds-c-checkbox-color-border: #003087; /* Dark blue border */
26+
padding-left: 0.5rem;
27+
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@
1111
</tr>
1212
</thead>
1313
<tbody>
14+
<tr class="toggle-all-row">
15+
<td colspan="4">
16+
<lightning-input
17+
type="checkbox"
18+
label={toggleAllLabel}
19+
checked={allRulesEnabled}
20+
onchange={handleToggleAllRules}
21+
class="toggle-all-checkbox"
22+
></lightning-input>
23+
</td>
24+
</tr>
1425
<template for:each={rules} for:item="rule">
1526
<tr key={rule.id}>
1627
<td>

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { LightningElement, api, track } from 'lwc';
33
export default class scanConfigurator extends LightningElement {
44
@api rules;
55
@track localRules;
6-
// Severity options for dropdown
76
severityOptions = [
87
{ label: 'Error', value: 'error' },
98
{ label: 'Warning', value: 'warning' },
@@ -12,10 +11,35 @@ export default class scanConfigurator extends LightningElement {
1211
];
1312

1413
connectedCallback() {
15-
// Initialize localRules to ensure reactivity
1614
this.localRules = this.rules ? JSON.parse(JSON.stringify(this.rules)) : [];
1715
}
1816

17+
get allRulesDisabled() {
18+
return this.localRules.every(rule => !rule.isActive);
19+
}
20+
21+
get allRulesEnabled() {
22+
return this.localRules.every(rule => rule.isActive);
23+
}
24+
25+
get toggleAllLabel() {
26+
return this.allRulesDisabled ? 'Enable All Rules' : 'Disable All Rules';
27+
}
28+
29+
handleToggleAllRules(event) {
30+
const isChecked = event.target.checked;
31+
this.localRules = this.localRules.map(rule => ({
32+
...rule,
33+
isActive: isChecked
34+
}));
35+
36+
this.dispatchEvent(
37+
new CustomEvent('rulechange', {
38+
detail: { rules: this.localRules }
39+
})
40+
);
41+
}
42+
1943
handleRuleToggle(event) {
2044
const ruleId = event.target.dataset.ruleId;
2145
this.localRules = this.localRules.map(rule => {
@@ -25,7 +49,6 @@ export default class scanConfigurator extends LightningElement {
2549
return rule;
2650
});
2751

28-
// Dispatch custom event with updated rules
2952
this.dispatchEvent(
3053
new CustomEvent('rulechange', {
3154
detail: { rules: this.localRules }
@@ -43,7 +66,6 @@ export default class scanConfigurator extends LightningElement {
4366
return rule;
4467
});
4568

46-
// Dispatch custom event with updated rules
4769
this.dispatchEvent(
4870
new CustomEvent('rulechange', {
4971
detail: { rules: this.localRules }

0 commit comments

Comments
 (0)