You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by mj...@apache.org on 2018/11/08 08:42:27 UTC

[incubator-dubbo-ops] branch develop updated: Fix not clear filter options

This is an automated email from the ASF dual-hosted git repository.

mjk pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-ops.git


The following commit(s) were added to refs/heads/develop by this push:
     new 8365bc2  Fix not clear filter options
8365bc2 is described below

commit 8365bc234122f464255d3a6726b2f8835922ba4c
Author: Jinkai Ma <ma...@vip.qq.com>
AuthorDate: Thu Nov 8 16:42:11 2018 +0800

    Fix not clear filter options
    
    Value length less than 4, the search filter options won’t clear.
---
 .../src/components/ServiceSearch.vue               | 37 ++++++++++++----------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/dubbo-admin-frontend/src/components/ServiceSearch.vue b/dubbo-admin-frontend/src/components/ServiceSearch.vue
index 7b9dd51..43b5cf4 100644
--- a/dubbo-admin-frontend/src/components/ServiceSearch.vue
+++ b/dubbo-admin-frontend/src/components/ServiceSearch.vue
@@ -98,6 +98,7 @@
         {id: 1, title: 'IP', value: 'ip'},
         {id: 2, title: 'application', value: 'application'}
       ],
+      timerID: null,
       loading: false,
       selected: 0,
       serviceItem: [],
@@ -151,28 +152,32 @@
     },
     watch: {
       input (val) {
-        if (val === undefined || val === '' || val === null || val.length < 4) {
-          this.typeAhead = []
-          return
-        }
-        val && val !== this.select && this.querySelections(val)
+        this.querySelections(val)
       }
     },
     methods: {
       querySelections (v) {
-        this.loading = true
+        if (this.timerID) {
+          clearTimeout(this.timerID)
+        }
         // Simulated ajax query
-        setTimeout(() => {
-          if (this.selected === 0) {
-            this.typeAhead = this.serviceItem.filter(e => {
-              return (e || '').toLowerCase().indexOf((v || '').toLowerCase()) > -1
-            })
-          } else if (this.selected === 2) {
-            this.typeAhead = this.appItem.filter(e => {
-              return (e || '').toLowerCase().indexOf((v || '').toLowerCase()) > -1
-            })
+        this.timerID = setTimeout(() => {
+          if (v && v.length >= 4) {
+            this.loading = true
+            if (this.selected === 0) {
+              this.typeAhead = this.serviceItem.filter(e => {
+                return (e || '').toLowerCase().indexOf((v || '').toLowerCase()) > -1
+              })
+            } else if (this.selected === 2) {
+              this.typeAhead = this.appItem.filter(e => {
+                return (e || '').toLowerCase().indexOf((v || '').toLowerCase()) > -1
+              })
+            }
+            this.loading = false
+            this.timerID = null
+          } else {
+            this.typeAhead = []
           }
-          this.loading = false
         }, 500)
       },
       getHref: function (service, app, group, version) {