Skip to content

Commit b7102b4

Browse files
authored
Merge pull request #185 from marksie1988/checkDeclined
Check declined
2 parents 60c4a3c + 38846ab commit b7102b4

File tree

8 files changed

+213
-175
lines changed

8 files changed

+213
-175
lines changed

dist/atomic-calendar-revive-editor.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const e=(e,t,i,o)=>{o=o||{},i=null==i?{}:i;const a=new Event(t,{bubbles:void 0===o.bubbles||o.bubbles,cancelable:Boolean(o.cancelable),composed:void 0===o.composed||o.composed});return a.detail=i,e.dispatchEvent(a),a};!customElements.get("ha-switch")&&customElements.get("paper-toggle-button")&&customElements.define("ha-switch",customElements.get("paper-toggle-button"));const t=Object.getPrototypeOf(customElements.get("hui-view")),i=t.prototype.html,o=t.prototype.css;var a=["_blank","_self","_parent","_top"];class s extends t{setConfig(e){this._config={...e}}configChanged(e){const t=new Event("config-changed",{bubbles:!0,composed:!0});t.detail={config:e},this.dispatchEvent(t)}static get properties(){return{hass:{},_config:{}}}get _name(){return this._config.name||""}get _Entities(){return!this._config||this._config.entities}get _showColors(){return this._config&&this._config.showColors||!0}get _showLocation(){return this._config&&this._config.showLocation||!0}get _showMonth(){return this._config&&this._config.showMonth||!1}get _showWeekDay(){return this._config&&this._config.showWeekDay||!1}get _showLoader(){return this._config&&this._config.showLoader||!0}get _showDate(){return this._config&&this._config.showDate||!1}get _showDescription(){return this._config&&this._config.showDescription||!1}get _showNoEventsForToday(){return this._config&&this._config.showNoEventsForToday||!1}get _sortByStartTime(){return this._config&&this._config.sortByStartTime||!1}get _disableEventLink(){return this._config&&this._config.disableEventLink||!1}get _disableLocationLink(){return this._config&&this._config.disableLocationLink||!1}get _linkTarget(){return this._config&&this._config.linkTarget||"_blank"}render(){return this.hass?i`
1+
const e=(e,t,i,o)=>{o=o||{},i=null==i?{}:i;const a=new Event(t,{bubbles:void 0===o.bubbles||o.bubbles,cancelable:Boolean(o.cancelable),composed:void 0===o.composed||o.composed});return a.detail=i,e.dispatchEvent(a),a};!customElements.get("ha-switch")&&customElements.get("paper-toggle-button")&&customElements.define("ha-switch",customElements.get("paper-toggle-button"));const t=Object.getPrototypeOf(customElements.get("hui-view")),i=t.prototype.html,o=t.prototype.css;var a=["_blank","_self","_parent","_top"];class s extends t{setConfig(e){this._config={...e}}configChanged(e){const t=new Event("config-changed",{bubbles:!0,composed:!0});t.detail={config:e},this.dispatchEvent(t)}static get properties(){return{hass:{},_config:{}}}get _name(){return this._config.name||""}get _Entities(){return!this._config||this._config.entities}get _showColors(){return this._config&&this._config.showColors||!0}get _showDeclined(){return this._config&&this._config.showDeclined||!1}get _showLocation(){return this._config&&this._config.showLocation||!0}get _showMonth(){return this._config&&this._config.showMonth||!1}get _showWeekDay(){return this._config&&this._config.showWeekDay||!1}get _showLoader(){return this._config&&this._config.showLoader||!0}get _showDate(){return this._config&&this._config.showDate||!1}get _showDescription(){return this._config&&this._config.showDescription||!1}get _showNoEventsForToday(){return this._config&&this._config.showNoEventsForToday||!1}get _sortByStartTime(){return this._config&&this._config.sortByStartTime||!1}get _disableEventLink(){return this._config&&this._config.disableEventLink||!1}get _disableLocationLink(){return this._config&&this._config.disableLocationLink||!1}get _linkTarget(){return this._config&&this._config.linkTarget||"_blank"}render(){return this.hass?i`
22
<div class="card-config">
33
<div>
44
<span style="color:red;font-weight:bold">Editor Version: ${"1.1.1-alpha"}</span>
@@ -33,6 +33,13 @@ const e=(e,t,i,o)=>{o=o||{},i=null==i?{}:i;const a=new Event(t,{bubbles:void 0==
3333
@change=${this._valueChanged}
3434
>Show Colors</ha-switch
3535
>
36+
<ha-switch
37+
aria-label=${"Toggle Show Declined "+(this._showDeclined?"off":"on")}
38+
.checked=${!1!==this._showDeclined}
39+
.configValue=${"showDeclined"}
40+
@change=${this._valueChanged}
41+
>Show Declined</ha-switch
42+
>
3643
3744
<h3>Event Mode</h3>
3845
<ha-switch

dist/atomic-calendar-revive.js

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

docs/options/main-options.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ nav_order: 1
2727
| linkTarget | string | optional | v0.11.0 | `_blank` Allows custom target for links, default will open new tab. |
2828
| showCalNameInEvent | string | optional | ? | `false` Shows the event calendar name |
2929
| showFullDayProgress | string | optional | v1.7.0 | `false` Enables the progress bar for full day events |
30+
| showDeclined | string | optional | v1.9.0 | `false` Shows events that have been declined |
31+
3032

3133
# Color Options
3234

package-lock.json

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": "atomic-calendar-revive",
3-
"version": "1.8.7",
3+
"version": "1.9.0",
44
"description": "Calendar Card for Home Assistant",
55
"main": "atomic-calendar-revive.js",
66
"scripts": {

src/app-editor.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ export class AtomicCalendarReviveEditor extends LitElement {
5959
return true;
6060
}
6161

62+
get _showDeclined() {
63+
if (this._config) {
64+
return this._config.showDeclined || false;
65+
}
66+
return false;
67+
}
68+
6269
get _showLocation() {
6370
if (this._config) {
6471
return this._config.showLocation || true;
@@ -176,6 +183,13 @@ export class AtomicCalendarReviveEditor extends LitElement {
176183
@change=${this._valueChanged}
177184
>Show Colors</ha-switch
178185
>
186+
<ha-switch
187+
aria-label=${`Toggle Show Declined ${this._showDeclined ? 'off' : 'on'}`}
188+
.checked=${this._showDeclined !== false}
189+
.configValue=${'showDeclined'}
190+
@change=${this._valueChanged}
191+
>Show Declined</ha-switch
192+
>
179193
180194
<h3>Event Mode</h3>
181195
<ha-switch

src/app.js

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ class AtomicCalendarRevive extends LitElement {
122122
showFullDayProgress: false,
123123
progressBarColor: 'var(--primary-color)',
124124

125+
showDeclined: false,
126+
125127
enableModeChange: false,
126128
defaultMode: 1,
127129

@@ -779,6 +781,17 @@ class AtomicCalendarRevive extends LitElement {
779781
} else return false
780782
}
781783

784+
/**
785+
* check if event was declined
786+
* @param {event} event data
787+
* @return {bool} Returns true if the event was declined
788+
*/
789+
checkDeclined(event) {
790+
if(!event.attendees) { return false }
791+
if(!event.attendees.length > 0) { return false }
792+
return !!event.attendees.find(a => a.self == true && a.responseStatus == "declined")
793+
}
794+
782795
/**
783796
* gets events from HA Calendar to Events mode
784797
*
@@ -803,7 +816,17 @@ class AtomicCalendarRevive extends LitElement {
803816
let blacklist = typeof this._config.entities[i]["blacklist"] != 'undefined' ? this._config.entities[i]["blacklist"] : ''
804817
let whitelist = typeof this._config.entities[i]["whitelist"] != 'undefined' ? this._config.entities[i]["whitelist"] : ''
805818
let singleAPIEvent = new EventClass(singleEvent, this._config.entities[i])
806-
if ((this._config.maxEventCount === 0 || eventCount < this._config.maxEventCount) && (blacklist == '' || !this.checkFilter(singleEvent.summary, blacklist)) && (whitelist == '' || this.checkFilter(singleEvent.summary, whitelist)) && ((this._config.maxDaysToShow === 0 && singleAPIEvent.isEventRunning) || !(this._config.hideFinishedEvents && singleAPIEvent.isEventFinished))) {
819+
if (
820+
(this._config.maxEventCount === 0 || eventCount < this._config.maxEventCount)
821+
&&
822+
(blacklist == '' || !this.checkFilter(singleEvent.summary, blacklist))
823+
&&
824+
(whitelist == '' || this.checkFilter(singleEvent.summary, whitelist))
825+
&&
826+
(this._config.showDeclined || !this.checkDeclined(singleEvent))
827+
&&
828+
((this._config.maxDaysToShow === 0 && singleAPIEvent.isEventRunning) || !(this._config.hideFinishedEvents && singleAPIEvent.isEventFinished))
829+
) {
807830
singleEvents.push(singleAPIEvent);
808831
eventCount++;
809832
}
@@ -869,7 +892,17 @@ class AtomicCalendarRevive extends LitElement {
869892
var filteredEvents = eventsArray.filter((event) => {
870893
const startTime = event.start.dateTime ? moment(event.start.dateTime) : moment(event.start.date).startOf('day')
871894
const endTime = event.end.dateTime ? moment(event.end.dateTime) : moment(event.end.date).subtract(1, 'days').endOf('day')
872-
if (!moment(startTime).isAfter(m.date, 'day') && !moment(endTime).isBefore(m.date, 'day') && calendarTypes && !this.checkFilter(event.summary, calendarBlacklist))
895+
if (
896+
!moment(startTime).isAfter(m.date, 'day')
897+
&&
898+
!moment(endTime).isBefore(m.date, 'day')
899+
&&
900+
calendarTypes
901+
&&
902+
(this._config.showDeclined || !this.checkDeclined(event))
903+
&&
904+
!this.checkFilter(event.summary, calendarBlacklist)
905+
)
873906
return event
874907
})
875908
var filteredEvents = filteredEvents.map((event) => {

tracker.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"atomic-calendar-revive": {
3-
"updated_at": "2020-06-01",
4-
"version": "1.8.7",
3+
"updated_at": "2020-06-21",
4+
"version": "1.9.0",
55
"remote_location": "https://github.com/marksie1988/atomic-calendar-revive/releases/latest/dist/atomic-calendar-revive.js",
66
"visit_repo": "https://github.com/marksie1988/atomic-calendar-revive",
77
"changelog": "https://github.com/marksie1988/atomic-calendar-revive/releases/latest"

0 commit comments

Comments
 (0)