ui: Fix sorter across different components (#8046)

This PR fixes sorting in tables by columns in the UI
This commit is contained in:
Vishesh 2023-10-10 11:07:28 +05:30 committed by GitHub
parent b58ffec4cd
commit 66e5d41a15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 12 deletions

View File

@ -155,7 +155,7 @@ export default {
key: columnKey, key: columnKey,
title: this.$t('label.' + String(columnKey).toLowerCase()), title: this.$t('label.' + String(columnKey).toLowerCase()),
dataIndex: columnKey, dataIndex: columnKey,
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') } sorter: (a, b) => { return genericCompare(a[columnKey] || '', b[columnKey] || '') }
}) })
} }
if (this.columns.length > 0) { if (this.columns.length > 0) {

View File

@ -861,7 +861,7 @@ export default {
key: key, key: key,
title: this.$t('label.' + String(title).toLowerCase()), title: this.$t('label.' + String(title).toLowerCase()),
dataIndex: key, dataIndex: key,
sorter: function (a, b) { return genericCompare(a[key] || '', b[key] || '') } sorter: (a, b) => genericCompare(a[key] || '', b[key] || '')
}) })
this.selectedColumns.push(key) this.selectedColumns.push(key)
} }

View File

@ -76,17 +76,17 @@ export default {
{ {
dataIndex: 'name', dataIndex: 'name',
title: this.$t('label.name'), title: this.$t('label.name'),
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') } sorter: (a, b) => genericCompare(a?.name || '', b?.name || '')
}, },
{ {
dataIndex: 'type', dataIndex: 'type',
title: this.$t('label.type'), title: this.$t('label.type'),
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') } sorter: (a, b) => genericCompare(a?.type || '', b?.type || '')
}, },
{ {
dataIndex: 'description', dataIndex: 'description',
title: this.$t('label.description'), title: this.$t('label.description'),
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') } sorter: (a, b) => genericCompare(a?.description || '', b?.description || '')
} }
], ],
selectedRowKeys: [], selectedRowKeys: [],

View File

@ -79,7 +79,7 @@ export default {
{ {
dataIndex: 'name', dataIndex: 'name',
title: this.$t('label.name'), title: this.$t('label.name'),
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }, sorter: (a, b) => genericCompare(a?.name || '', b?.name || ''),
width: '40%' width: '40%'
}, },
{ {

View File

@ -151,7 +151,7 @@ export default {
{ {
dataIndex: 'name', dataIndex: 'name',
title: this.$t('label.name'), title: this.$t('label.name'),
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') }, sorter: (a, b) => genericCompare(a?.name || '', b?.name || ''),
width: '40%' width: '40%'
}, },
{ {

View File

@ -135,18 +135,18 @@ export default {
this.columns.push({ this.columns.push({
dataIndex: 'name', dataIndex: 'name',
title: this.$t('label.hypervisor'), title: this.$t('label.hypervisor'),
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') } sorter: (a, b) => genericCompare(a?.name || '', b?.name || '')
}) })
this.columns.push({ this.columns.push({
dataIndex: 'hosts', dataIndex: 'hosts',
title: this.$t('label.hosts'), title: this.$t('label.hosts'),
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') } sorter: (a, b) => genericCompare(a?.hosts || '', b?.hosts || '')
}) })
this.columns.push({ this.columns.push({
dataIndex: 'cpusockets', dataIndex: 'cpusockets',
title: this.$t('label.cpu.sockets'), title: this.$t('label.cpu.sockets'),
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') } sorter: (a, b) => genericCompare(a?.cpusockets || '', b?.cpusockets || '')
}) })
this.items = [] this.items = []

View File

@ -183,13 +183,13 @@ export default {
this.columns.push({ this.columns.push({
dataIndex: 'name', dataIndex: 'name',
title: this.$t('label.name'), title: this.$t('label.name'),
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') } sorter: (a, b) => genericCompare(a?.name || '', b?.name || '')
}) })
this.columns.push({ this.columns.push({
dataIndex: 'value', dataIndex: 'value',
title: this.$t('label.value'), title: this.$t('label.value'),
sorter: function (a, b) { return genericCompare(a[this.dataIndex] || '', b[this.dataIndex] || '') } sorter: (a, b) => genericCompare(a?.value || '', b?.value || '')
}) })
}, },
getRowClassName (record, index) { getRowClassName (record, index) {