Skip to content

Commit

Permalink
Fix due_txt logic
Browse files Browse the repository at this point in the history
  • Loading branch information
amaximus committed Feb 1, 2023
1 parent 4c47e71 commit e62b2ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Configuration parameters:<br />
| entity | **N** | - | name of the sensor of garbage_collection platform.|
| due_color | **Y**| theme's icon active color | icon color on due date. Accepts both color names and RGB values.|
| due_1_color | **Y** | due_color | icon color on the day before due date. Accepts both color names and RGB values.|
| due_txt | **Y** | `false` | For today/tomorrow pick-ups use 'Due today' or 'Due tomorrow'.|
| due_txt | **Y** | `false` | For today/tomorrow pick-ups use 'Due today' or 'Due tomorrow'. Has precendence over hide_date and hide_days. |
| icon_color | **Y** | theme's icon color | icon color. Accepts both color names and RGB values.|
| icon_size | **Y** | `25px` | size of the icon.|
| icon_cell_padding | **Y** | `35px` | padding applied to icon cell.|
Expand Down
19 changes: 13 additions & 6 deletions dist/garbage-collection-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,18 @@ class GarbageCollectionCard extends HTMLElement {

root.getElementById('friendly_name').innerHTML = attributes.friendly_name;

if (parseInt(attributes.days) < 2 && duetxt === true) {
root.getElementById('details').innerHTML = attributes.next_date;
if (parseInt(attributes.days) < 2) {
if (duetxt === true) {
root.getElementById('details').innerHTML = attributes.next_date;
} else {
root.getElementById('details').innerHTML = (hdate === false ? attributes.next_date : '') +
(hdays === false ? ' ' + attributes.days : '' )
}
} else {
root.getElementById('details').innerHTML = (hdate === false ? attributes.next_date : '') +
(hdays === false ? ' ' + attributes.days : '' )
}
if ( hdays === true && hdate === true && duetxt === false) {
if ( hdays === true && hdate === true && duetxt === false ) {
root.getElementById('details').style.display = "none";
}

Expand Down Expand Up @@ -280,9 +285,11 @@ class GarbageCollectionCard extends HTMLElement {
}
}
} else {
dday = this._stateObj.state == 0 ? "Today" : "Tomorrow";
if ( typeof this.translationJSONobj.state[dday] != "undefined" ) {
attributes.next_date = this.translationJSONobj.state[dday];
if ( typeof this.translationJSONobj != "undefined"
&& typeof this.translationJSONobj.other['in_days'] !== "undefined" ) {
attributes.days = this.translationJSONobj.other['in_days'].replace('DAYS', attributes.days);
} else {
attributes.days = `in ${attributes.days} days`;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion info.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Configuration parameters:<br />
| entity | **N** | - | name of the sensor of garbage_collection platform.|
| due_color | **Y**| theme's icon active color | icon color on due date. Accepts both color names and RGB values.|
| due_1_color | **Y** | due_color | icon color on the day before due date. Accepts both color names and RGB values.|
| due_txt | **Y** | `false` | For today/tomorrow pick-ups use 'Due today' or 'Due tomorrow'.|
| due_txt | **Y** | `false` | For today/tomorrow pick-ups use 'Due today' or 'Due tomorrow'. Has precendence over hide_date and hide_days. |
| icon_color | **Y** | theme's icon color | icon color. Accepts both color names and RGB values.|
| icon_size | **Y** | `25px` | size of the icon.|
| icon_cell_padding | **Y** | `35px` | padding applied to icon cell.|
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.22.2",
"updated_at": "2023-01-26",
"version": "1.22.3",
"updated_at": "2023-02-01",
"visit_repo": "https://github.com/amaximus/garbage-collection-card",
"changelog": "https://github.com/amaximus/garbage-collection-card/releases/1.22.2"
"changelog": "https://github.com/amaximus/garbage-collection-card/releases/1.22.3"
}
}

0 comments on commit e62b2ee

Please sign in to comment.