Skip to content

Commit

Permalink
Merge pull request #84 from andersstorhaug/show-without-due
Browse files Browse the repository at this point in the history
Add options for `show_chores_without_due` and `show_tasks_without_due`
  • Loading branch information
isabellaalstrom authored Nov 3, 2022
2 parents 8e73500 + 6815c99 commit dcdd04b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ views:
| title | string | **Optional** | `"Todo"` | The title of the card. |
| show_quantity | number | **Optional** | | The number of items you want to show in the card. The rest are either hidden or show in the overflow. |
| show_days | number | **Optional** | | E.g. `0` to only show items that are due today, overdue or have no due date. If not specified, shows all items. |
| show_chores_without_due | bool | **Optional** | `true` | Show chores that do not have a due date. |
| show_tasks_without_due | bool | **Optional** | `true` | Show tasks that do not have a due date. |
| user_id | number | **Optional** | `1` | Id of the Grocy user performing the items. Default if not specified is `1`. See further instructions [here](#user_id). |
| custom_translation | string-list | **Optional** | | List of translations of string values used in the card (see below). |
| filter | string/list | **Optional** | | Only show items that contains this filter in the name. When filter is a list, filters are applied as OR. |
Expand Down
22 changes: 13 additions & 9 deletions grocy-chores-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class GrocyChoresCard extends LitElement {
show_quantity: 5,
show_assigned: true,
show_overflow: true,
show_chores_without_due: true,
show_tasks_without_due: true,
use_icons: true,
use_long_date: true,
due_in_days_threshold: 7,
Expand Down Expand Up @@ -421,16 +423,16 @@ class GrocyChoresCard extends LitElement {

_isItemVisible(item) {
let visible = false;
if (item.__due_in_days == null || this.show_days == null || item.__due_in_days < 0 || item.__due_in_days <= this.show_days) {
visible = true;
if (this.filter !== undefined) {
visible = this._checkMatchNameFilter(item);
}

visible ||= item.__due_in_days == null;
visible &&= item.__type === "chore" ? this.show_chores_without_due : true;
visible &&= item.__type === "task" ? this.show_tasks_without_due : true;

if (visible && this.filter_user !== undefined) {
visible = this._checkMatchUserFilter(item);
}
}
visible ||= item.__due_in_days < 0;
visible ||= item.__due_in_days <= this.show_days;

visible &&= this.filter !== undefined ? this._checkMatchNameFilter(item) : true;
visible &&= this.filter_user !== undefined ? this._checkMatchUserFilter(item) : true;

return visible;
}
Expand Down Expand Up @@ -613,6 +615,8 @@ class GrocyChoresCard extends LitElement {
this.remove_filter = this.config.remove_filter ?? false;
this.show_quantity = this.config.show_quantity || null;
this.show_days = this.config.show_days ?? null;
this.show_chores_without_due = this.config.show_chores_without_due ?? true;
this.show_tasks_without_due = this.config.show_tasks_without_due ?? true;
this.show_assigned = this.config.show_assigned ?? true;
this.show_track_button = this.config.show_track_button ?? true;
this.show_last_tracked = this.config.show_last_tracked ?? true;
Expand Down

0 comments on commit dcdd04b

Please sign in to comment.