From 4ee4e865ee800725a88b7ab8160fa60ea578f546 Mon Sep 17 00:00:00 2001 From: utchoang Date: Tue, 15 Feb 2022 08:11:24 +0700 Subject: [PATCH 1/4] fix filter menu --- ui/src/components/view/SearchView.vue | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ui/src/components/view/SearchView.vue b/ui/src/components/view/SearchView.vue index 6876c2009bec..d4ef7d5ca348 100644 --- a/ui/src/components/view/SearchView.vue +++ b/ui/src/components/view/SearchView.vue @@ -59,6 +59,7 @@ initialValue: fieldValues[field.name] || null }]" showSearch + :dropdownMatchSelectWidth="false" optionFilterProp="children" :filterOption="(input, option) => { return option.componentOptions.propsData.label.toLowerCase().indexOf(input.toLowerCase()) >= 0 @@ -309,25 +310,25 @@ export default { if (zoneIndex > -1) { const zones = response.filter(item => item.type === 'zoneid') if (zones && zones.length > 0) { - this.fields[zoneIndex].opts = zones[0].data + this.fields[zoneIndex].opts = this.sortArray(zones[0].data) } } if (domainIndex > -1) { const domain = response.filter(item => item.type === 'domainid') if (domain && domain.length > 0) { - this.fields[domainIndex].opts = domain[0].data + this.fields[domainIndex].opts = this.sortArray(domain[0].data) } } if (podIndex > -1) { const pod = response.filter(item => item.type === 'podid') if (pod && pod.length > 0) { - this.fields[podIndex].opts = pod[0].data + this.fields[podIndex].opts = this.sortArray(pod[0].data) } } if (clusterIndex > -1) { const cluster = response.filter(item => item.type === 'clusterid') if (cluster && cluster.length > 0) { - this.fields[clusterIndex].opts = cluster[0].data + this.fields[clusterIndex].opts = this.sortArray(cluster[0].data) } } this.$forceUpdate() @@ -347,6 +348,14 @@ export default { this.fillFormFieldValues() }) }, + sortArray (data) { + return data.sort(function (a, b) { + if (a.name < b.name) { return -1 } + if (a.name > b.name) { return 1 } + + return 0 + }) + }, fillFormFieldValues () { this.fieldValues = {} if (Object.keys(this.$route.query).length > 0) { From 7593a7b5e9cd8ad2f89ec251054b9a0d4ad4375e Mon Sep 17 00:00:00 2001 From: utchoang Date: Tue, 15 Feb 2022 12:56:31 +0700 Subject: [PATCH 2/4] fixes --- ui/src/components/view/SearchView.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/components/view/SearchView.vue b/ui/src/components/view/SearchView.vue index d4ef7d5ca348..9287a07436e6 100644 --- a/ui/src/components/view/SearchView.vue +++ b/ui/src/components/view/SearchView.vue @@ -83,7 +83,7 @@ - {{ $t(opt.name) }} + {{ $t(opt.path || opt.name) }} From 10842eb8c40a9c4fd0a059d3ce6a48dbfc3d3760 Mon Sep 17 00:00:00 2001 From: utchoang Date: Tue, 15 Feb 2022 14:54:50 +0700 Subject: [PATCH 3/4] fixes --- ui/src/components/view/SearchView.vue | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/src/components/view/SearchView.vue b/ui/src/components/view/SearchView.vue index 9287a07436e6..1d0675d11e26 100644 --- a/ui/src/components/view/SearchView.vue +++ b/ui/src/components/view/SearchView.vue @@ -310,25 +310,25 @@ export default { if (zoneIndex > -1) { const zones = response.filter(item => item.type === 'zoneid') if (zones && zones.length > 0) { - this.fields[zoneIndex].opts = this.sortArray(zones[0].data) + this.fields[zoneIndex].opts = this.sortArray('name', zones[0].data) } } if (domainIndex > -1) { const domain = response.filter(item => item.type === 'domainid') if (domain && domain.length > 0) { - this.fields[domainIndex].opts = this.sortArray(domain[0].data) + this.fields[domainIndex].opts = this.sortArray('path', domain[0].data) } } if (podIndex > -1) { const pod = response.filter(item => item.type === 'podid') if (pod && pod.length > 0) { - this.fields[podIndex].opts = this.sortArray(pod[0].data) + this.fields[podIndex].opts = this.sortArray('name', pod[0].data) } } if (clusterIndex > -1) { const cluster = response.filter(item => item.type === 'clusterid') if (cluster && cluster.length > 0) { - this.fields[clusterIndex].opts = this.sortArray(cluster[0].data) + this.fields[clusterIndex].opts = this.sortArray('name', cluster[0].data) } } this.$forceUpdate() @@ -348,10 +348,10 @@ export default { this.fillFormFieldValues() }) }, - sortArray (data) { + sortArray (key, data) { return data.sort(function (a, b) { - if (a.name < b.name) { return -1 } - if (a.name > b.name) { return 1 } + if (a[key] < b[key]) { return -1 } + if (a[key] > b[key]) { return 1 } return 0 }) From 8cec205fde44766cc2dbf2b9426d5cb10ddcf46a Mon Sep 17 00:00:00 2001 From: utchoang Date: Wed, 16 Feb 2022 07:48:48 +0700 Subject: [PATCH 4/4] fixes --- ui/src/components/view/SearchView.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/src/components/view/SearchView.vue b/ui/src/components/view/SearchView.vue index 1d0675d11e26..76f517017b62 100644 --- a/ui/src/components/view/SearchView.vue +++ b/ui/src/components/view/SearchView.vue @@ -310,25 +310,25 @@ export default { if (zoneIndex > -1) { const zones = response.filter(item => item.type === 'zoneid') if (zones && zones.length > 0) { - this.fields[zoneIndex].opts = this.sortArray('name', zones[0].data) + this.fields[zoneIndex].opts = this.sortArray(zones[0].data) } } if (domainIndex > -1) { const domain = response.filter(item => item.type === 'domainid') if (domain && domain.length > 0) { - this.fields[domainIndex].opts = this.sortArray('path', domain[0].data) + this.fields[domainIndex].opts = this.sortArray(domain[0].data, 'path') } } if (podIndex > -1) { const pod = response.filter(item => item.type === 'podid') if (pod && pod.length > 0) { - this.fields[podIndex].opts = this.sortArray('name', pod[0].data) + this.fields[podIndex].opts = this.sortArray(pod[0].data) } } if (clusterIndex > -1) { const cluster = response.filter(item => item.type === 'clusterid') if (cluster && cluster.length > 0) { - this.fields[clusterIndex].opts = this.sortArray('name', cluster[0].data) + this.fields[clusterIndex].opts = this.sortArray(cluster[0].data) } } this.$forceUpdate() @@ -348,7 +348,7 @@ export default { this.fillFormFieldValues() }) }, - sortArray (key, data) { + sortArray (data, key = 'name') { return data.sort(function (a, b) { if (a[key] < b[key]) { return -1 } if (a[key] > b[key]) { return 1 }