1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-24 20:55:49 +00:00

Expose location for calendar events (#27983)

* Expose location for calendar events

* from review
This commit is contained in:
karwosts
2025-11-19 05:40:19 -08:00
committed by GitHub
parent f8923ed648
commit ba9c7f3012
4 changed files with 34 additions and 4 deletions

View File

@@ -31,6 +31,7 @@ export interface CalendarEventData {
dtend: string;
rrule?: string;
description?: string;
location?: string;
}
export interface CalendarEventMutableParams {
@@ -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
@@ -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,

View File

@@ -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>
@@ -241,7 +243,7 @@ class DialogCalendarEventDetail extends LitElement {
haStyleDialog,
css`
state-info {
line-height: 40px;
margin-top: 24px;
}
ha-svg-icon {
width: 40px;

View File

@@ -63,6 +63,8 @@ class DialogCalendarEventEditor extends LitElement {
@state() private _description? = "";
@state() private _location? = "";
@state() private _rrule?: string;
@state() private _allDay = false;
@@ -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;
@@ -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");
@@ -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 });
}
@@ -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"
@@ -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;
}
@@ -399,6 +422,7 @@ class DialogCalendarEventEditor extends LitElement {
const data: CalendarEventMutableParams = {
summary: this._summary,
description: this._description,
location: this._location || (this._hasLocation ? "" : undefined),
rrule: this._rrule || undefined,
dtstart: "",
dtend: "",

View File

@@ -1237,7 +1237,8 @@
"times": "times"
},
"summary": "Summary",
"description": "Description"
"description": "Description",
"location": "Location"
},
"views": {
"dayGridMonth": "[%key:ui::panel::lovelace::editor::card::calendar::views::dayGridMonth%]",