Add settings of searchable attributes

This commit is contained in:
Stanislav Romanov 2022-05-07 11:49:31 +03:00
parent 696c19c3a7
commit b8f948f984
3 changed files with 57 additions and 0 deletions

View file

@ -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)

View file

@ -43,6 +43,7 @@ export default class AdminIndexesItemSettingsRoute extends Route {
index,
stats,
displayedAttributes: index.getDisplayedAttributes(),
searchableAttributes: index.getSearchableAttributes(),
});
}
}

View file

@ -38,6 +38,45 @@
@onClick={{fn this.reset 'resetDisplayedAttributes'}}
/>
</div>
<label class="text-xl mb-2 block">
Searchable attributes
</label>
<div class="mb-2">
{{#each @model.index.fields as |item|}}
{{#let
(or
(eq @model.searchableAttributes.firstObject '*')
(includes item @model.searchableAttributes)
) as |checked|
}}
<Badge
@label={{item}}
@icon={{if checked this.Check this.CircleMedium}}
@style={{if checked 'success'}}
class="cursor-pointer"
{{on 'click' (fn this.setAttributeValue 'searchableAttributes' item)}}
/>
{{/let}}
{{/each}}
</div>
<div class="mb-4">
<Button
@text="Update"
@style="primary"
@size="small"
@onClick={{fn
this.update
'updateSearchableAttributes'
@model.searchableAttributes
}}
/>
<Button
@text="Reset"
@size="small"
@style="outline"
@onClick={{fn this.reset 'resetSearchableAttributes'}}
/>
</div>
{{!--
<RoyalTable @data={{@model.attributes}} as |Row data|>
<Row as |Column|>