Skip to content

Commit

Permalink
Merge pull request #237 from FamousWolf/224-visual-editor-bug
Browse files Browse the repository at this point in the history
[BUGFIX] Fix adding and removing calendars with visual editor
  • Loading branch information
FamousWolf authored Jan 4, 2025
2 parents dff69ea + 7740c0c commit 3c12590
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ export class WeekPlannerCardEditor extends LitElement {
${this.addTextField('calendars.' + index + '.filterText', 'Filter event text (regex)')}
${this.addBooleanField('calendars.' + index + '.hideInLegend', 'Hide in legend')}
${this.addButton('Remove calendar', 'mdi:trash-can', () => {
const config = Object.assign({}, this._config);
const config = JSON.parse(JSON.stringify(this._config));
if (config.calendars.length === 1) {
config.calendars = [];
} else {
delete config.calendars[index];
config.calendars = config.calendars.filter(Boolean);
}
this._config = config;
this.dispatchConfigChangedEvent();
Expand Down Expand Up @@ -323,7 +324,7 @@ export class WeekPlannerCardEditor extends LitElement {
}

setConfigValue(key, value) {
const config = Object.assign({}, this._config);
const config = JSON.parse(JSON.stringify(this._config));
const keyParts = key.split('.');
const lastKeyPart = keyParts.pop();
const lastObject = keyParts.reduce((objectPart, keyPart) => {
Expand Down

0 comments on commit 3c12590

Please sign in to comment.