diff --git a/app/controllers/admin/indexes/item/settings.js b/app/controllers/admin/indexes/item/settings.js new file mode 100644 index 0000000..7378e58 --- /dev/null +++ b/app/controllers/admin/indexes/item/settings.js @@ -0,0 +1,19 @@ +import Controller from '@ember/controller'; +import { action } from '@ember/object'; +import arrayEquals from 'meilisearch-admin/utils/array-equals'; + +export default class AdminIndexesItemSettingsController extends Controller { + @action + save() { + const fields = Object.keys(this.model.stats.fieldDistribution); + const settings = Object.assign({}, this.model.settings); + + ['displayedAttributes', 'searchableAttributes'].forEach((prop) => { + if (arrayEquals(settings[prop].sort(), fields.sort())) { + settings[prop] = ['*']; + } + }); + + return this.model.index.updateSettings(settings); + } +} diff --git a/app/templates/admin/indexes/item/settings.hbs b/app/templates/admin/indexes/item/settings.hbs index df76264..f66553a 100644 --- a/app/templates/admin/indexes/item/settings.hbs +++ b/app/templates/admin/indexes/item/settings.hbs @@ -1,8 +1,8 @@ {{page-title "Settings"}} {{#let (hash td="px-4 py-2 text-left whitespace-nowrap") as |classes|}} -

Attributes

- +

Attributes

+
@@ -45,3 +45,17 @@
#
{{/let}} + +