Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 0 deletions src/data/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface CalendarEventData {
dtend: string;
rrule?: string;
description?: string;
location?: string;
}

export interface CalendarEventMutableParams {
Expand All @@ -39,6 +40,7 @@ export interface CalendarEventMutableParams {
dtend: string;
rrule?: string;
description?: string;
location?: string;
}

// The scope of a delete/update for a recurring event
Expand Down Expand Up @@ -96,6 +98,7 @@ export const fetchCalendarEvents = async (
uid: ev.uid,
summary: ev.summary,
description: ev.description,
location: ev.location,
dtstart: eventStart,
dtend: eventEnd,
recurrence_id: ev.recurrence_id,
Expand Down
8 changes: 5 additions & 3 deletions src/panels/calendar/dialog-calendar-event-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ class DialogCalendarEventDetail extends LitElement {
${this._data!.rrule
? this._renderRRuleAsText(this._data.rrule)
: ""}
${this._data.location
? html`${this._data.location} <br />`
: nothing}
${this._data.description
? html`<br />
<div class="description">${this._data.description}</div>
<br />`
<div class="description">${this._data.description}</div>`
: nothing}
</div>
</div>
Expand Down Expand Up @@ -241,7 +243,7 @@ class DialogCalendarEventDetail extends LitElement {
haStyleDialog,
css`
state-info {
line-height: 40px;
margin-top: 24px;
}
ha-svg-icon {
width: 40px;
Expand Down
24 changes: 24 additions & 0 deletions src/panels/calendar/dialog-calendar-event-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class DialogCalendarEventEditor extends LitElement {

@state() private _description? = "";

@state() private _location? = "";

@state() private _rrule?: string;

@state() private _allDay = false;
Expand All @@ -79,6 +81,8 @@ class DialogCalendarEventEditor extends LitElement {
// timezone, but floating without a timezone.
private _timeZone?: string;

private _hasLocation = false;

public showDialog(params: CalendarEventEditDialogParams): void {
this._error = undefined;
this._info = undefined;
Expand All @@ -99,6 +103,10 @@ class DialogCalendarEventEditor extends LitElement {
this._allDay = isDate(entry.dtstart);
this._summary = entry.summary;
this._description = entry.description;
if (entry.location) {
this._hasLocation = true;
this._location = entry.location;
}
this._rrule = entry.rrule;
if (this._allDay) {
this._dtstart = new Date(entry.dtstart + "T00:00:00");
Expand Down Expand Up @@ -130,6 +138,8 @@ class DialogCalendarEventEditor extends LitElement {
this._dtend = undefined;
this._summary = "";
this._description = "";
this._location = "";
this._hasLocation = false;
this._rrule = undefined;
fireEvent(this, "dialog-closed", { dialog: this.localName });
}
Expand Down Expand Up @@ -181,6 +191,15 @@ class DialogCalendarEventEditor extends LitElement {
.validationMessage=${this.hass.localize("ui.common.error_required")}
dialogInitialFocus
></ha-textfield>
<ha-textfield
class="location"
name="location"
.label=${this.hass.localize(
"ui.components.calendar.event.location"
)}
.value=${this._location}
@change=${this._handleLocationChanged}
></ha-textfield>
<ha-textarea
class="description"
name="description"
Expand Down Expand Up @@ -326,6 +345,10 @@ class DialogCalendarEventEditor extends LitElement {
this._description = ev.target.value;
}

private _handleLocationChanged(ev: Event) {
this._location = (ev.target as HTMLInputElement).value;
}

private _handleRRuleChanged(ev) {
this._rrule = ev.detail.value;
}
Expand Down Expand Up @@ -399,6 +422,7 @@ class DialogCalendarEventEditor extends LitElement {
const data: CalendarEventMutableParams = {
summary: this._summary,
description: this._description,
location: this._location || (this._hasLocation ? "" : undefined),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was trying to avoid here populating location key with an empty string where it wasn't previously present (I think every calendar integration supports location, but I'm not 100% sure).

But once location has a value, neither undefined or null will clear it, so we have to use empty string in that case.

rrule: this._rrule || undefined,
dtstart: "",
dtend: "",
Expand Down
3 changes: 2 additions & 1 deletion src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,8 @@
"times": "times"
},
"summary": "Summary",
"description": "Description"
"description": "Description",
"location": "Location"
},
"views": {
"dayGridMonth": "[%key:ui::panel::lovelace::editor::card::calendar::views::dayGridMonth%]",
Expand Down
Loading