Skip to content

Commit 161b3b8

Browse files
committed
Finish all filters, even tags!
1 parent 511e2ed commit 161b3b8

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

FilterType.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ enum FilterType {
22
text = 'text',
33
date = 'date',
44
number = 'number',
5-
association = 'association'
5+
tags = 'tags'
66
}
77

88
export default FilterType;

PageHooks.ts

+11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ export default class PageHooks {
55
private readonly _items_callback: Function;
66
private readonly _count_callback: Function;
77

8+
private lastPage: number = 1;
9+
private lastField: SortableField|null;
10+
private lastFilters: Array<FilterWithValue> | null;
11+
812
constructor(items_callback: Function, count_callback: Function = null) {
913
this._items_callback = items_callback;
1014
this._count_callback = count_callback || null;
@@ -14,11 +18,18 @@ export default class PageHooks {
1418
return this._count_callback !== null;
1519
}
1620

21+
public refresh() {
22+
this.callForItems(this.lastPage, this.lastField, this.lastFilters);
23+
}
24+
1725
public callForItems(
1826
page: number,
1927
field: SortableField | null,
2028
filters: Array<FilterWithValue> | null
2129
): void {
30+
this.lastPage = page;
31+
this.lastField = field;
32+
this.lastFilters = filters;
2233
this._items_callback(page, field, filters);
2334
}
2435

components/PaginatedTable/Filter.svelte

+11-1
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,18 @@
119119
/>
120120
</div>
121121
</div>
122+
{:else if filter.type === FilterType.tags}
123+
<input
124+
id="input_filter_{filter.name}"
125+
class="form-control"
126+
type="text"
127+
on:change={onChange}
128+
bind:value
129+
/>
122130
{:else}
123-
<div class="badge">Unknown input type "{filter.type}"</div>
131+
<h5>
132+
<span class="badge bg-danger">Unknown input type "{filter.type}"</span>
133+
</h5>
124134
{/if}
125135
</div>
126136
</div>

0 commit comments

Comments
 (0)