Skip to content

Commit

Permalink
Add option for controlling card hide
Browse files Browse the repository at this point in the history
  • Loading branch information
amaximus committed Dec 17, 2020
1 parent e7af51b commit fb8bba1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Configuration parameters:<br />
| hass_lang_priority | **Y** | `false` | whether HASS language has priority over browser language.|
| hide_date | **Y** | `false` | hide date.|
| hide_days | **Y** | `false`| hide number of days. Automatically set to true when collection is due today or tomorrow.|
| hide_on_click | **Y** | `true`| hide the card upon click when due date is today or tomorrow.|
| hide_before | **Y** | `-1` | hide entire card until X days before event. Default: do not hide card.|
| title_size | **Y** | `17px` | font size for the sensor's friendly name.|
| details_size | **Y** | `14px` | font size for date and number of days.|
Expand Down
9 changes: 5 additions & 4 deletions dist/garbage-collection-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class GarbageCollectionCard extends HTMLElement {
hide_date: false,
hide_days: false,
hide_before: -1,
hide_on_click: true,
title_size: '17px',
details_size: '14px',
};
Expand Down Expand Up @@ -135,15 +136,15 @@ class GarbageCollectionCard extends HTMLElement {
this.style.display = "none";
}

_updateContent(attributes, hdate, hdays, hcard, duetxt) {
_updateContent(attributes, hdate, hdays, hcard, duetxt, honclick) {
const root = this.shadowRoot;
var today = new Date()
var todayYYYYMMDD = today.toISOString().split("T")[0].replace(/-/g, ".");

root.getElementById('ha_icon').icon = attributes.icon;
root.getElementById('ha_icon').className = attributes.alerted;

if (parseInt(attributes.days) < 2) {
if (parseInt(attributes.days) < 2 && honclick) {
root.getElementById('ha_card').addEventListener('click', this._ackGarbageOut.bind(this));
}

Expand Down Expand Up @@ -184,7 +185,7 @@ class GarbageCollectionCard extends HTMLElement {
const root = this.shadowRoot;
this.myhass = hass;

let { hide_date, hide_days, hide_before, due_txt } = config;
let { hide_date, hide_days, hide_before, due_txt, hide_on_click } = config;
let hide_card = false;

if (!this._firstLoad) {
Expand Down Expand Up @@ -273,7 +274,7 @@ class GarbageCollectionCard extends HTMLElement {
}
}
}
this._updateContent(attributes, hide_date, hide_days, hide_card, due_txt);
this._updateContent(attributes, hide_date, hide_days, hide_card, due_txt, hide_on_click);
}

getCardSize() {
Expand Down
1 change: 1 addition & 0 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Configuration parameters:<br />
| hass_lang_priority | **Y** | `false` | whether HASS language has priority over browser language.|
| hide_date | **Y** | `false` | hide date.|
| hide_days | **Y** | `false`| hide number of days. Automatically set to true when collection is due today or tomorrow.|
| hide_on_click | **Y** | `true`| hide the card upon click when due date is today or tomorrow.|
| hide_before | **Y** | `-1` | hide entire card until X days before event. Default: do not hide card.|
| title_size | **Y** | `17px` | font size for the sensor's friendly name.|
| details_size | **Y** | `14px` | font size for date and number of days.|
Expand Down
6 changes: 3 additions & 3 deletions tracker.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"garbage-collection-card": {
"version": "1.16.3",
"updated_at": "2020-12-16",
"version": "1.17.0",
"updated_at": "2020-12-17",
"visit_repo": "https://github.com/amaximus/garbage-collection-card",
"changelog": "https://github.com/amaximus/garbage-collection-card/releases/1.16.3"
"changelog": "https://github.com/amaximus/garbage-collection-card/releases/1.17.0"
}
}

0 comments on commit fb8bba1

Please sign in to comment.