diff --git a/app/assets/javascripts/components/saved_annotations/saved_annotation_list.ts b/app/assets/javascripts/components/saved_annotations/saved_annotation_list.ts
index 4e7501fdf3..940bc0d601 100644
--- a/app/assets/javascripts/components/saved_annotations/saved_annotation_list.ts
+++ b/app/assets/javascripts/components/saved_annotations/saved_annotation_list.ts
@@ -5,6 +5,8 @@ import "components/pagination";
import { searchQueryState } from "state/SearchQuery";
import { DodonaElement } from "components/meta/dodona_element";
import { i18n } from "i18n/i18n";
+import { FilterOptions } from "components/search/filter_element";
+import { search } from "search";
/**
* This component represents a list of saved annotations
@@ -43,7 +45,19 @@ export class SavedAnnotationList extends DodonaElement {
return pagination;
}
+ lastFilters: FilterOptions[] = [];
+ get filters(): FilterOptions[] {
+ const filters = savedAnnotationState.getFilters(this.queryParams, this.arrayQueryParams);
+ if (filters === undefined) {
+ // return last filters if the updated filters are not yet available
+ return this.lastFilters;
+ }
+ this.lastFilters = filters;
+ return filters;
+ }
+
render(): TemplateResult {
+ search.updateFilters(this.filters);
return this.savedAnnotations.length > 0 ? html`
diff --git a/app/assets/javascripts/components/search/dropdown_filter.ts b/app/assets/javascripts/components/search/dropdown_filter.ts
index fb5bc8a16e..e5e189696c 100644
--- a/app/assets/javascripts/components/search/dropdown_filter.ts
+++ b/app/assets/javascripts/components/search/dropdown_filter.ts
@@ -1,8 +1,12 @@
import { html, TemplateResult } from "lit";
import { customElement, property } from "lit/decorators.js";
-import { FilterCollection, Label, FilterCollectionElement } from "components/search/filter_collection_element";
+import {
+ Label,
+ FilterElement,
+ AccentColor
+} from "components/search/filter_element";
import { i18n } from "i18n/i18n";
-import { DodonaElement } from "components/meta/dodona_element";
+import { FilterCollection } from "components/search/filter_collection";
/**
* This component inherits from FilterCollectionElement.
@@ -10,19 +14,15 @@ import { DodonaElement } from "components/meta/dodona_element";
*
* @element d-dropdown-filter
*
- * @prop {(s: Label) => string} color - a function that fetches the color associated with each label
- * @prop {string} type - The type of the filter collection, used to determine the dropdown button text
+ * @prop {AccentColor} color - the color associated with the filter
* @prop {string} param - the searchQuery param to be used for this filter
* @prop {boolean} multi - whether one or more labels can be selected at the same time
- * @prop {(l: Label) => string} paramVal - a function that extracts the value that should be used in a searchQuery for a selected label
* @prop {[Label]} labels - all labels that could potentially be selected
*/
@customElement("d-dropdown-filter")
-export class DropdownFilter extends FilterCollectionElement {
- @property()
- color: (s: Label) => string;
- @property()
- type: string;
+export class DropdownFilter extends FilterElement {
+ @property({ type: String })
+ color: AccentColor;
@property({ state: true })
filter = "";
@@ -35,16 +35,16 @@ export class DropdownFilter extends FilterCollectionElement {
return this.showFilter ? this.labels.filter(s => s.name.toLowerCase().includes(this.filter.toLowerCase())) : this.labels;
}
- render(): TemplateResult {
- if (this.labels.length === 0) {
- return html``;
- }
+ get disabled(): boolean {
+ return this.labels.length === 0 || (!this.multi && this.labels.length === 1);
+ }
+ render(): TemplateResult {
return html`