From 4816efb3ff04608a1df39dff2ec7a8adee9d23ac Mon Sep 17 00:00:00 2001 From: Stanislav Romanov Date: Fri, 2 Sep 2022 12:00:15 +0300 Subject: [PATCH] Add all index settings to form --- app/models/index.js | 86 ++------- app/templates/admin/indexes/item/settings.hbs | 180 +----------------- 2 files changed, 19 insertions(+), 247 deletions(-) diff --git a/app/models/index.js b/app/models/index.js index 3abcac3..3865987 100644 --- a/app/models/index.js +++ b/app/models/index.js @@ -1,6 +1,4 @@ import query from '../utils/query'; -// import { TrackedArray } from 'tracked-built-ins'; -// import { trackedFunction } from 'ember-resources/util/function'; import Document from './document'; import { dasherize } from '@ember/string'; @@ -11,6 +9,22 @@ export default class Index { } } + get settingNames() { + return [ + 'displayedAttributes', + 'distinctAttribute', + 'faceting', + 'filterableAttributes', + 'pagination', + 'rankingRules', + 'searchableAttributes', + 'sortableAttributes', + 'stopWords', + 'synonyms', + 'typoTolerance', + ]; + } + get path() { return `indexes/${this.uid}`; } @@ -83,72 +97,4 @@ export default class Index { method: 'DELETE', }); } - - getDisplayedAttributes() { - return query(`${this.path}/settings/displayed-attributes`); - } - - updateDisplayedAttributes(value) { - return query(`${this.path}/settings/displayed-attributes`, { - method: 'PUT', - body: JSON.stringify(value), - }); - } - - resetDisplayedAttributes() { - return query(`${this.path}/settings/displayed-attributes`, { - method: 'DELETE', - }); - } - - getDistinctAttribute() { - return query(`${this.path}/settings/distinct-attribute`); - } - - updateDistinctAttribute(value) { - return query(`${this.path}/settings/distinct-attribute`, { - method: 'PUT', - body: JSON.stringify(value), - }); - } - - resetDistinctAttribute() { - return query(`${this.path}/settings/distinct-attribute`, { - method: 'DELETE', - }); - } - - // getSearchableAttributes() { - // return query(`${this.path}/settings/searchable-attributes`); - // } - - // updateSearchableAttributes(value) { - // return query(`${this.path}/settings/searchable-attributes`, { - // method: 'POST', - // body: JSON.stringify(value), - // }); - // } - - // resetSearchableAttributes() { - // return query(`${this.path}/settings/searchable-attributes`, { - // method: 'DELETE', - // }); - // } - - // get fields() { - // return this.stats.value - // ? Object.keys(this.stats.value.fieldDistribution) - // : []; - // } - - // getSettings() { - // return query(`${this.path}/settings`); - // } - - // stats = trackedFunction(this, () => query(`${this.path}/stats`)); - // displayedAttributes = trackedFunction(this, () => - // query(`${this.path}/settings/displayed-attributes`).then( - // (arr) => new TrackedArray(arr) - // ) - // ); } diff --git a/app/templates/admin/indexes/item/settings.hbs b/app/templates/admin/indexes/item/settings.hbs index cbba176..bc55029 100644 --- a/app/templates/admin/indexes/item/settings.hbs +++ b/app/templates/admin/indexes/item/settings.hbs @@ -1,177 +1,3 @@ - - - - -{{!-- -
- {{#each @model.index.fields as |item|}} - {{#let - (or - (eq @model.displayedAttributes.firstObject '*') - (includes item @model.displayedAttributes) - ) as |checked| - }} - - {{/let}} - {{/each}} -
-
-
- -
- {{#each @model.index.fields as |item|}} - {{#let - (or - (eq @model.searchableAttributes.firstObject '*') - (includes item @model.searchableAttributes) - ) as |checked| - }} - - {{/let}} - {{/each}} -
-
-
--}} -{{!-- - - - - - - - - - - - - - - - - - - - {{option}} - -
- -
- {{#each @model.settings.rankingRules as |item|}} -
- - {{item}} - -
- {{/each}} -
- {{#if this.rankingRulesFields.length}} - - {{option}} - - {{/if}} -
- - -