Skip to content

Commit

Permalink
Add label filter to tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMStraub committed Aug 21, 2023
1 parent be2632f commit cda4c1a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/components/GrampsjsTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class GrampsjsTasks extends GrampsjsTranslateMixin(LitElement) {
margin-right: 8px;
}
.filters {
margin-bottom: 32px;
}
.taskbar {
padding-left: 10px;
display: flex;
Expand Down Expand Up @@ -135,6 +139,14 @@ class GrampsjsTasks extends GrampsjsTranslateMixin(LitElement) {

_renderTaskBar() {
return html`
<div class="filters">
<grampsjs-filters .strings="${this.strings}" objectType="source">
<grampsjs-filter-tags
.strings="${this.strings}"
></grampsjs-filter-tags>
</grampsjs-filters>
</div>
<div class="taskbar">
<mwc-checkbox
id="select-all"
Expand Down
11 changes: 11 additions & 0 deletions src/views/GrampsjsViewTasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class GrampsjsViewTasks extends GrampsjsView {
_data: {type: Array},
canAdd: {type: Boolean},
canEdit: {type: Boolean},
_filters: {type: Array},
_todoTagHandle: {type: String},
}
}
Expand All @@ -34,6 +35,7 @@ export class GrampsjsViewTasks extends GrampsjsView {
this.canEdit = false
this._data = []
this._todoTagHandle = ''
this._filters = []
this._boundFetchData = this._fetchData.bind(this)
}

Expand All @@ -45,6 +47,7 @@ export class GrampsjsViewTasks extends GrampsjsView {
.strings="${this.strings}"
.data="${this._data}"
@tasks:update-attribute="${this._handleUpdateAttribute}"
@filters:changed="${this._handleFiltersChanged}"
?canEdit="${this.canEdit}"
></grampsjs-tasks>
Expand Down Expand Up @@ -72,6 +75,7 @@ export class GrampsjsViewTasks extends GrampsjsView {
name: 'HasTag',
values: ['ToDo'],
},
...this._filters,
],
}
const uri = `/api/sources/?rules=${encodeURIComponent(
Expand Down Expand Up @@ -111,6 +115,13 @@ export class GrampsjsViewTasks extends GrampsjsView {
fireEvent(this, 'db:changed')
}

_handleFiltersChanged(e) {
this._filters = e.detail.filters
e.preventDefault()
e.stopPropagation()
this._fetchData()
}

firstUpdated() {
if ('__lang__' in this.strings) {
// don't load before we have strings
Expand Down

0 comments on commit cda4c1a

Please sign in to comment.