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,
title: this.$t('label.' + String(columnKey).toLowerCase()),
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) {

View File

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

View File

@ -76,17 +76,17 @@ export default {
{
dataIndex: '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',
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',
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: [],

View File

@ -79,7 +79,7 @@ export default {
{
dataIndex: '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%'
},
{

View File

@ -151,7 +151,7 @@ export default {
{
dataIndex: '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%'
},
{

View File

@ -135,18 +135,18 @@ export default {
this.columns.push({
dataIndex: 'name',
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({
dataIndex: '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({
dataIndex: 'cpusockets',
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 = []

View File

@ -183,13 +183,13 @@ export default {
this.columns.push({
dataIndex: '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({
dataIndex: '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) {