Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0c7e698
[TASK] Add action to only allow PRs for main branch from dev branch
FamousWolf Jun 27, 2024
2192392
Merge pull request #87 from FamousWolf/dev
FamousWolf Jun 27, 2024
449b1f7
Merge pull request #90 from FamousWolf/dev
FamousWolf Jun 28, 2024
d9654ec
Merge pull request #104 from FamousWolf/dev
FamousWolf Jul 10, 2024
b7db639
[FEATURE] Add data attributes for date parts
FamousWolf Sep 1, 2024
99ba825
[FEATURE] Add event filter
Sep 1, 2024
1d780e8
[FEATURE] Add option to add or subtract days from the starting date
FamousWolf Sep 2, 2024
2c279b2
[FEATURE] Add option to show legend
Sep 2, 2024
38babe7
[FEATURE] Make sure events with the same starting date are sorted by …
Sep 2, 2024
07ee0a0
[TASK] Increase version to 1.7.0
Sep 2, 2024
2517b1a
Merge pull request #125 from FamousWolf/dev
FamousWolf Sep 2, 2024
e930a59
[BUGFIX] Fix legend styling bug
Sep 4, 2024
457a51b
Merge pull request #133 from FamousWolf/dev
FamousWolf Sep 4, 2024
395343f
Merge pull request #171 from FamousWolf/dev
FamousWolf Oct 28, 2024
40e4a2e
Merge pull request #181 from FamousWolf/dev
FamousWolf Nov 14, 2024
4481805
Merge pull request #185 from FamousWolf/dev
FamousWolf Nov 15, 2024
6b60b12
Merge pull request #195 from FamousWolf/dev
FamousWolf Nov 20, 2024
aef1328
Merge pull request #199 from FamousWolf/dev
FamousWolf Nov 21, 2024
168b528
Merge pull request #212 from FamousWolf/dev
FamousWolf Dec 3, 2024
ef3ed10
Merge pull request #227 from FamousWolf/dev
FamousWolf Dec 24, 2024
0128158
Merge pull request #239 from FamousWolf/dev
FamousWolf Jan 4, 2025
88e247a
Merge pull request #244 from FamousWolf/dev
FamousWolf Jan 6, 2025
4609bf2
Merge pull request #266 from FamousWolf/dev
FamousWolf Mar 6, 2025
56d4a56
Update visual editor: conditionally show 'Calendars toggled off by de…
halwehrenberg Mar 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,12 @@ export class WeekPlannerCard extends LitElement {
this._combineSimilarEvents = config.combineSimilarEvents ?? false;
this._showLegend = config.showLegend ?? false;
this._legendToggle = config.legendToggle ?? false;
this._toggledOffByDefault = config.toggledOffByDefault ?? [];
this._actions = config.actions ?? false;
this._columns = config.columns ?? {};
this._maxEvents = config.maxEvents ?? false;
this._maxDayEvents = config.maxDayEvents ?? false;
this._hideCalendars = [];
this._hideCalendars = [...(this._toggledOffByDefault || [])];
if (config.locale) {
LuxonSettings.defaultLocale = config.locale;
}
Expand Down
49 changes: 49 additions & 0 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ export class WeekPlannerCardEditor extends LitElement {
html`
${this.addBooleanField('showLegend', 'Show legend')}
${this.addBooleanField('legendToggle', 'Toggle calendars by clicking on the legend')}
${this.getConfigValue('legendToggle') ?
this.addMultiSelectCalendarsField('toggledOffByDefault', 'Calendars toggled off by default') :
''}
`
)}
${this.addExpansionPanel(
Expand Down Expand Up @@ -204,6 +207,52 @@ export class WeekPlannerCardEditor extends LitElement {
`;
}

addMultiSelectCalendarsField(name, label) {
if (!this._config || !this._config.calendars) {
return html``;
}

// Get calendar options from the config
const options = this._config.calendars.map(calendar => ({
value: calendar.entity,
label: calendar.name || calendar.entity
}));

// Get current value as array
const currentValue = Array.isArray(this._config[name]) ? this._config[name] : [];

return html`
<div>
<label>${label}</label>
<div style="display: flex; flex-direction: column; margin-top: 8px; margin-bottom: 16px;">
${options.map(option => html`
<ha-formfield label="${option.label}">
<ha-checkbox
.checked=${currentValue.includes(option.value)}
@change=${(e) => this._multiSelectChanged(e, name, option.value)}
></ha-checkbox>
</ha-formfield>
`)}
</div>
</div>
`;
}

_multiSelectChanged(event, name, value) {
const checked = event.target.checked;
// Make sure we're working with an array
let currentValue = Array.isArray(this._config[name]) ? [...this._config[name]] : [];

if (checked && !currentValue.includes(value)) {
currentValue.push(value);
} else if (!checked && currentValue.includes(value)) {
currentValue = currentValue.filter(v => v !== value);
}

// Set the updated value in the config
this.setConfigValue(name, currentValue);
}

addTextField(name, label, type, defaultValue) {
return html`
<ha-textfield
Expand Down