From f206536f383ee432ec8e94f0a22d8af85f8ce459 Mon Sep 17 00:00:00 2001 From: Westly Wright Date: Fri, 3 Mar 2017 16:06:40 -0700 Subject: [PATCH] Add sortable table to labels component --- app/components/labels-section/component.js | 28 ++++++++++----- app/components/labels-section/template.hbs | 41 ++++++++++------------ 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/app/components/labels-section/component.js b/app/components/labels-section/component.js index 4c3f3ebfb..d323134a2 100644 --- a/app/components/labels-section/component.js +++ b/app/components/labels-section/component.js @@ -1,21 +1,33 @@ import Ember from 'ember'; import ManageLabels from 'ui/mixins/manage-labels'; -import Sortable from 'ui/mixins/sortable'; -export default Ember.Component.extend(ManageLabels, Sortable, { +export default Ember.Component.extend(ManageLabels, { model : null, labelSource : Ember.computed.alias('model.labels'), - sortableContent : Ember.computed.alias('labelArray'), sortBy : 'kind', showKind : true, descending : true, - sorts: { - kind : ['type','key'], - key : ['key'], - value : ['value','key'], - }, + headers: [ + { + name: 'kind', + sort: ['type','key'], + translationKey: 'labelsSection.kind', + width: '90', + }, + { + name: 'key', + sort: ['key'], + translationKey: 'labelsSection.key', + width: '350', + }, + { + name: 'value', + sort: ['value','key'], + translationKey: 'labelsSection.value', + }, + ], labelsObserver: Ember.observer('model.labels', function () { this.initLabels(this.get('labelSource')); diff --git a/app/components/labels-section/template.hbs b/app/components/labels-section/template.hbs index 464506ae9..89625f0f4 100644 --- a/app/components/labels-section/template.hbs +++ b/app/components/labels-section/template.hbs @@ -1,22 +1,19 @@ - - - {{#if labelArray.length}} - - {{#if showKind}}{{sortable-th sortable=this action="changeSort" name="kind" label='labelsSection.kind' width="90"}}{{/if}} - {{sortable-th sortable=this action="changeSort" name="key" label='labelsSection.key' width="350"}} - {{sortable-th sortable=this action="changeSort" name="value" label='labelsSection.value'}} - - {{/if}} - - - {{#each arranged as |label|}} - - {{#if showKind}}{{/if}} - - - - {{else}} - - {{/each}} - -
{{uc-first label.type}}{{label.key}}{{pretty-json value=label.value}}
{{t 'labelsSection.noData'}}
+{{#sortable-table + classNames="grid fixed mb-0 sortable-table" + bulkActions=false + paging=false + search=false + sortBy=sortBy + descending=descending + headers=headers + body=labelArray + as |label kind| +}} + {{#if (eq kind "row")}} + {{#if showKind}}{{uc-first label.type}}{{/if}} + {{label.key}} + {{pretty-json value=label.value}} + {{else if (eq kind "norows")}} + {{t 'labelsSection.noData'}} + {{/if}} +{{/sortable-table}} \ No newline at end of file