Skip to content
This repository was archived by the owner on Sep 18, 2020. It is now read-only.

Commit 9ee1be7

Browse files
committed
3.108.0
1 parent 225efcb commit 9ee1be7

10 files changed

Lines changed: 117 additions & 87 deletions

File tree

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,33 +43,34 @@ resources:
4343
| Name | Type | Requirement | Description
4444
| ---- | ---- | ------- | -----------
4545
| type | string | **Required** | `custom:calendar-card`
46-
| title | string | **Optional** | `Calendar` Header shown at top of card
47-
| hideHeader | boolean | **Optional** | `false` Hide the header regardless of value
48-
| numberOfDays | number | **Optional** | `7` Number of days to display from calendars
4946
| entities | object | **Required** | List of calendars to display
50-
| timeFormat | string | **Optional** | `HH:mm` Format to show event time (see [here](https://momentjs.com/docs/#/displaying/format/) for options)
5147
| dateTopFormat | string | **Optional** | `DD` Format for top line of event date
5248
| dateBottomFormat | string | **Optional** | `ddd` Format to bottom line of event date
53-
| ignoreEventsExpression | string | **Optional** | Simple case insensitive regex to ignore events that match title
49+
| disableLinks | boolean | **Optional** | `false` Disables all links (to open calendar and location)
50+
| endText | string | **Optional** | `End` Set custom text for event end time
51+
| eventsLimit | integer | **Optional** | `99` Maximum number of events to show (shows rest of day after cut off)
52+
| fullDayEventText | string | **Optional** | `All day` Set custom text for a full day event
53+
| hardLimit | boolean | **Optional** | `false` Overrides `eventsLimit` default of showing rest of day's events even after cutoff
54+
| hideDeclined | boolean | **Optional** | `false` Hides events that you declined
55+
| hideHeader | boolean | **Optional** | `false` Hide the header regardless of value
56+
| hidePastEvents | boolean | **Optional** | `false` Hide events that have passed
57+
| hideTime | boolean | **Optional** | `false` Hides event time section entirely
58+
| highlightToday | boolean | **Optional** | `false` Hightlight's today's events
5459
| ignoreEventsByLocationExpression | string | **Optional** | Simple case insensitive regex to ignore events that match location
60+
| ignoreEventsExpression | string | **Optional** | Simple case insensitive regex to ignore events that match title
61+
| maxHeight | boolean | **Optional** | `false` Sets max height for card to 500px and overflows the rest
62+
| notifyEntity | Entity | **Optional** | Send a notification on new events
63+
| notifyDateTimeFormat | string | **Optional** | `MM/DD/YYYY HH:mma` Format for event date/time in notify message (see [here](https://momentjs.com/docs/#/displaying/format/) for options)
64+
| numberOfDays | number | **Optional** | `7` Number of days to display from calendars
5565
| removeFromEventTitle | string | **Optional** | Removes substring from all event titles (case insensitive)
5666
| progressBar | boolean | **Optional** | `false` Adds progress bar to ongoing events
57-
| hideTime | boolean | **Optional** | `false` Hides event time section entirely
67+
| showEventOrigin | boolean | **Optional** | `false` Shows what calendar each event is from
5868
| showLocation | boolean | **Optional** | `false` Shows location address
5969
| showLocationIcon | boolean | **Optional** | `true` Shows map icon when event has a location
6070
| showMultiDay | boolean | **Optional** | `false` Split multiday events into per day
61-
| showEventOrigin | boolean | **Optional** | `false` Shows what calendar each event is from
62-
| highlightToday | boolean | **Optional** | `false` Hightlight's today's events
63-
| hidePastEvents | boolean | **Optional** | `false` Hide events that have passed
64-
| eventsLimit | integer | **Optional** | `99` Maximum number of events to show (shows rest of day after cut off)
65-
| hardLimit | boolean | **Optional** | `false` Overrides `eventsLimit` default of showing rest of day's events even after cutoff
66-
| hideDeclined | boolean | **Optional** | `false` Hides events that you declined
67-
| maxHeight | boolean | **Optional** | `false` Sets max height for card to 500px and overflows the rest
68-
| fullDayEventText | string | **Optional** | `All day` Set custom text for a full day event
6971
| startText | string | **Optional** | `Start` Set custom text for event start time
70-
| endText | string | **Optional** | `End` Set custom text for event end time
71-
| notifyEntity | Entity | **Optional** | Send a notification on new events
72-
| notifyDateTimeFormat | string | **Optional** | `MM/DD/YYYY HH:mma` Format for event date/time in notify message (see [here](https://momentjs.com/docs/#/displaying/format/) for options)
72+
| title | string | **Optional** | `Calendar` Header shown at top of card
73+
| timeFormat | string | **Optional** | `HH:mm` Format to show event time (see [here](https://momentjs.com/docs/#/displaying/format/) for options)
7374

7475
## Configurations
7576
---

dist/calendar-card.js

Lines changed: 51 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/calendar-card.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "calendar-card",
3-
"version": "3.107.0",
3+
"version": "3.108.0",
44
"description": "A calendar card for Home Assistant Lovelace UI",
55
"keywords": [
66
"home-assistant",

src/defaults.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default {
2323
hardLimit: false,
2424
hideDeclined: false,
2525
notifyEntity: null,
26+
disableLinks: false,
2627
notifyDateTimeFormat: 'MM/DD/YYYY HH:mma',
2728
fullDayEventText: 'All day',
2829
startText: 'Start',

src/event.tools.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,12 @@ export function groupEventsByDay(events, config) {
5252
}
5353

5454
/**
55-
* opens a calendar event in a new tab if has link
55+
* opens a link in a new tab if config allows it
5656
* @param {CalendarEvent} event
5757
*/
58-
export function getLinkHtml(event) {
59-
if (event.htmlLink) {
60-
window.open(event.htmlLink);
61-
}
58+
export function openLink(e, link, config) {
59+
if (!link || config.disableLinks) return;
60+
window.open(link);
6261
}
6362

6463
export async function sendNotificationForNewEvents(config, hass, events, oldEvents) {

src/html.tools.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { html } from 'lit-element';
22
import moment from './locales';
33

4-
import { getEventDateTime } from './event.tools';
4+
import { getEventDateTime, openLink } from './event.tools';
55

66
/**
77
* create card header
@@ -74,27 +74,37 @@ export function getTimeHtml(event, config) {
7474
return html`<div class="time">${date}</div>`;
7575
}
7676

77+
/**
78+
* generate link for an Anchor element
79+
* @param {Config} config
80+
* @param String} link
81+
*/
82+
export const getLink = (config, link) => {
83+
if (config.disableLinks) return '#';
84+
else link;
85+
}
86+
7787
/**
7888
* generate the html for showing an event location
7989
* @param {CalendarEvent} event
8090
*/
8191
export function getLocationHtml(event, config) {
82-
if (!event.location || !event.locationAddress)
83-
return html``;
92+
if (!event.location || !event.locationAddress) return html``;
93+
94+
const link = `https://www.google.com/maps?daddr=${event.location} ${event.locationAddress}`;
8495

85-
return html`
86-
<a href="https://www.google.com/maps?daddr=${event.location} ${event.locationAddress}" target="_blank" rel="nofollow noreferrer noopener"
87-
title='open location'>
88-
${config.showLocationIcon ?
89-
html`
90-
<div>
91-
<ha-icon icon="mdi:map-marker"></ha-icon>&nbsp;
92-
</div>
93-
` : null
94-
}
95-
<div>
96-
${config.showLocation ? event.location : ''}
97-
</div>
98-
</a>
99-
`;
96+
return html`
97+
<a @click=${e => openLink(e, link, config)} title='open location' class=${config.disableLinks ? 'no-pointer' : ''}>
98+
${config.showLocationIcon ?
99+
html`
100+
<div>
101+
<ha-icon icon="mdi:map-marker"></ha-icon>&nbsp;
102+
</div>
103+
` : null
104+
}
105+
<div>
106+
${config.showLocation ? event.location : ''}
107+
</div>
108+
</a>
109+
`;
100110
}

src/index-editor.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ export default class CalendarCardEditor extends LitElement {
146146
.checked=${this._config.hideDeclined}
147147
.configValue="${"hideDeclined"}"
148148
>Hide Declined Events</paper-checkbox>
149+
<paper-checkbox
150+
@checked-changed="${this.checkboxChanged}"
151+
.checked=${this._config.disableLinks}
152+
.configValue="${"disableLinks"}"
153+
>Disable Links</paper-checkbox>
149154
</div>
150155
151156
<div class='entities'>

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { LitElement, html } from 'lit-element';
44
import { repeat } from 'lit-html/directives/repeat';
55
import packageJson from '../package.json';
66

7-
import { groupEventsByDay, getLinkHtml, getAllEvents, sendNotificationForNewEvents } from './event.tools';
7+
import { groupEventsByDay, openLink, getAllEvents, sendNotificationForNewEvents } from './event.tools';
88

99
import {
1010
getLocationHtml, createHeader, getDateHtml,
@@ -145,12 +145,14 @@ class CalendarCard extends LitElement {
145145
const eventDateTime = moment(eventDay.day);
146146
const todayKls = this.config.highlightToday && eventDateTime.isSame(today, "day") ? 'highlight-events' : '';
147147

148+
const disableLink = this.config.disableLinks || !event.htmlLink;
149+
148150
return html`
149151
<tr class='day-wrapper ${lastKls} ${todayKls}'>
150152
<td class="${isLastEventInGroup ? '' : 'date'}">
151153
${getDateHtml(index, eventDateTime, this.config)}
152154
</td>
153-
<td class="overview" @click=${()=> getLinkHtml(event)}>
155+
<td class="overview ${disableLink ? 'no-pointer' : ''}" @click=${e => openLink(e, event.htmlLink, this.config)}>
154156
<div class="title">${event.title}</div>
155157
${getEventOrigin(event, this.config)}
156158
${getTimeHtml(event, this.config)}

src/style.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const style = css`
3434
padding: 24px 0px 0px;
3535
}
3636
37+
.no-pointer {
38+
cursor: default !important;
39+
}
40+
3741
table {
3842
border-spacing: 0;
3943
margin-bottom: 10px;

0 commit comments

Comments
 (0)