Skip to content

Commit

Permalink
Finish all filters, even tags!
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierstoval committed Apr 13, 2022
1 parent 40f8f3c commit d902821
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion FilterType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ enum FilterType {
text = 'text',
date = 'date',
number = 'number',
association = 'association'
tags = 'tags'
}

export default FilterType;
11 changes: 11 additions & 0 deletions PageHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export default class PageHooks {
private readonly _items_callback: Function;
private readonly _count_callback: Function;

private lastPage: number = 1;
private lastField: SortableField|null;
private lastFilters: Array<FilterWithValue> | null;

constructor(items_callback: Function, count_callback: Function = null) {
this._items_callback = items_callback;
this._count_callback = count_callback || null;
Expand All @@ -14,11 +18,18 @@ export default class PageHooks {
return this._count_callback !== null;
}

public refresh() {
this.callForItems(this.lastPage, this.lastField, this.lastFilters);
}

public callForItems(
page: number,
field: SortableField | null,
filters: Array<FilterWithValue> | null
): void {
this.lastPage = page;
this.lastField = field;
this.lastFilters = filters;
this._items_callback(page, field, filters);
}

Expand Down
12 changes: 11 additions & 1 deletion components/PaginatedTable/Filter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,18 @@
/>
</div>
</div>
{:else if filter.type === FilterType.tags}
<input
id="input_filter_{filter.name}"
class="form-control"
type="text"
on:change={onChange}
bind:value
/>
{:else}
<div class="badge">Unknown input type "{filter.type}"</div>
<h5>
<span class="badge bg-danger">Unknown input type "{filter.type}"</span>
</h5>
{/if}
</div>
</div>

0 comments on commit d902821

Please sign in to comment.