From b8f948f984989fb6279d33ed26a9366bee40af21 Mon Sep 17 00:00:00 2001 From: Stanislav Romanov Date: Sat, 7 May 2022 11:49:31 +0300 Subject: [PATCH] Add settings of searchable attributes --- app/models/index.js | 17 ++++++++ app/routes/admin/indexes/item/settings.js | 1 + app/templates/admin/indexes/item/settings.hbs | 39 +++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/app/models/index.js b/app/models/index.js index 1daa854..5ef217d 100644 --- a/app/models/index.js +++ b/app/models/index.js @@ -45,6 +45,23 @@ export default class Index { }); } + getSearchableAttributes() { + return query(`${this.indexPath}/settings/searchable-attributes`); + } + + updateSearchableAttributes(value) { + return query(`${this.indexPath}/settings/searchable-attributes`, { + method: 'POST', + body: JSON.stringify(value), + }); + } + + resetSearchableAttributes() { + return query(`${this.indexPath}/settings/searchable-attributes`, { + method: 'DELETE', + }); + } + getSortableAttributes() { return query(`${this.indexPath}/settings/sortable-attributes`).then( (result) => new TrackedArray(result) diff --git a/app/routes/admin/indexes/item/settings.js b/app/routes/admin/indexes/item/settings.js index f8f7bb6..7d598f2 100644 --- a/app/routes/admin/indexes/item/settings.js +++ b/app/routes/admin/indexes/item/settings.js @@ -43,6 +43,7 @@ export default class AdminIndexesItemSettingsRoute extends Route { index, stats, displayedAttributes: index.getDisplayedAttributes(), + searchableAttributes: index.getSearchableAttributes(), }); } } diff --git a/app/templates/admin/indexes/item/settings.hbs b/app/templates/admin/indexes/item/settings.hbs index cfb2018..a840bc5 100644 --- a/app/templates/admin/indexes/item/settings.hbs +++ b/app/templates/admin/indexes/item/settings.hbs @@ -38,6 +38,45 @@ @onClick={{fn this.reset 'resetDisplayedAttributes'}} /> + +
+ {{#each @model.index.fields as |item|}} + {{#let + (or + (eq @model.searchableAttributes.firstObject '*') + (includes item @model.searchableAttributes) + ) as |checked| + }} + + {{/let}} + {{/each}} +
+
+
{{!--