diff --git a/app/controllers/admin/indexes/item/documents/index.js b/app/controllers/admin/indexes/item/documents/index.js index 474bd85..be89251 100644 --- a/app/controllers/admin/indexes/item/documents/index.js +++ b/app/controllers/admin/indexes/item/documents/index.js @@ -28,26 +28,36 @@ export default class AdminIndexesItemDocumentsIndexController extends Controller return this.model.data.offset + this.model.data.hits.length; } - get sortedFields() { - const fields = Object.keys(this.model.stats.fieldDistribution); - const primaryKey = this.model.index.primaryKey ?? 'id'; - const sortedArray = fields - .filter((item) => item !== primaryKey) - .sort((a, b) => { - if (a > b || a.charAt(0) === '_') { - return 1; - } + get sortValues() { + const result = []; - if (a < b) { - return -1; - } + this.model.sortableAttributes.forEach((item) => { + result.push(`${item}:asc`, `${item}:desc`); + }); - return 0; - }); - - return [primaryKey].concat(sortedArray); + return result; } + // get sortedFields() { + // const fields = Object.keys(this.model.stats.fieldDistribution); + // const primaryKey = this.model.index.primaryKey ?? 'id'; + // const sortedArray = fields + // .filter((item) => item !== primaryKey) + // .sort((a, b) => { + // if (a > b || a.charAt(0) === '_') { + // return 1; + // } + + // if (a < b) { + // return -1; + // } + + // return 0; + // }); + + // return [primaryKey].concat(sortedArray); + // } + @action searchTextChanged(value) { this.q = value === '' ? null : value; diff --git a/app/templates/admin/indexes/item/documents/index.hbs b/app/templates/admin/indexes/item/documents/index.hbs index afb7214..166f09a 100644 --- a/app/templates/admin/indexes/item/documents/index.hbs +++ b/app/templates/admin/indexes/item/documents/index.hbs @@ -1,9 +1,43 @@ - + + Create new document + + +
+ +
+ + + + {{if this.sort this.sort 'Sort'}} + + + {{#each this.sortValues as |item|}} + +
+ {{item}} +
+
+ {{/each}} +
+
+
+
{{!--
@@ -17,14 +51,6 @@
--}} - - Create new document - - {{#if (gt @model.data.estimatedTotalHits 0)}}