ソースを参照

Wait load on searches

master
George Williams 4年前
コミット
c0d53326da

+ 11
- 3
src/components/property/commercial/commercialSearchResults.vue ファイルの表示

@@ -37,6 +37,7 @@
37 37
             <p>Sorry no listings where found matching your search</p>
38 38
           </div>
39 39
         </div>
40
+        <div v-if="wait" id="preloader"></div>
40 41
       </div>
41 42
     </section>
42 43
   </main>
@@ -53,9 +54,12 @@ export default {
53 54
     propertyCard,
54 55
   },
55 56
   data() {
56
-    return {};
57
+    return {
58
+      wait: true,
59
+    };
57 60
   },
58 61
   mounted() {
62
+    this.wait = true;
59 63
     console.log(this.propertySearch.salesType);
60 64
 
61 65
     if (typeof this.propertySearch.propertyUsageType === "undefined") {
@@ -65,7 +69,9 @@ export default {
65 69
       this.propertySearch.userName = this.user.username;
66 70
     }
67 71
 
68
-    this.searchProperties(this.propertySearch);
72
+    this.searchProperties(this.propertySearch).then((fulfilled) => {
73
+      this.wait = false;
74
+    });
69 75
   },
70 76
   methods: {
71 77
     ...mapActions("propertySearch", [
@@ -94,7 +100,9 @@ export default {
94 100
         // eslint-disable-next-line vue/no-side-effects-in-computed-properties
95 101
         this.propertySearch.propertyUsageType = "Residential";
96 102
       }
97
-      this.searchProperties(this.propertySearch);
103
+      this.searchProperties(this.propertySearch).then((fulfilled) => {
104
+        this.wait = false;
105
+      });
98 106
       return null;
99 107
     },
100 108
   },

+ 11
- 3
src/components/property/residential/residentialSearchResults.vue ファイルの表示

@@ -37,6 +37,7 @@
37 37
             <p>Sorry no listings where found matching your search</p>
38 38
           </div>
39 39
         </div>
40
+        <div v-if="wait" id="preloader"></div>
40 41
       </div>
41 42
     </section>
42 43
   </main>
@@ -53,9 +54,12 @@ export default {
53 54
     propertyCard,
54 55
   },
55 56
   data() {
56
-    return {};
57
+    return {
58
+      wait: true,
59
+    };
57 60
   },
58 61
   mounted() {
62
+    this.wait = true;
59 63
     console.log(this.propertySearch.salesType);
60 64
 
61 65
     if (typeof this.propertySearch.propertyUsageType === "undefined") {
@@ -65,7 +69,9 @@ export default {
65 69
       this.propertySearch.userName = this.user.username;
66 70
     }
67 71
 
68
-    this.searchProperties(this.propertySearch);
72
+    this.searchProperties(this.propertySearch).then((fulfilled) => {
73
+      this.wait = false;
74
+    });
69 75
   },
70 76
   methods: {
71 77
     ...mapActions("propertySearch", [
@@ -94,7 +100,9 @@ export default {
94 100
         // eslint-disable-next-line vue/no-side-effects-in-computed-properties
95 101
         this.propertySearch.propertyUsageType = "Residential";
96 102
       }
97
-      this.searchProperties(this.propertySearch);
103
+      this.searchProperties(this.propertySearch).then((fulfilled) => {
104
+        this.wait = false;
105
+      });
98 106
       return null;
99 107
     },
100 108
   },

+ 31
- 26
src/store/modules/property/propertySearch.js ファイルの表示

@@ -75,33 +75,38 @@ export default {
75 75
       commit("onClearFilter", filter);
76 76
     },
77 77
     searchProperties({ commit }, item) {
78
-      if (item.keyword === "") {
79
-        item.keyword = "All";
80
-      }
81
-      if (log.isLoggedIn()) {
82
-        item.userName = log.getUser().username;
83
-      } else if (item.userName === "") {
84
-        item.userName = "Unknown";
85
-      }
86
-      if (item.suburb === "") {
87
-        item.suburb = "All";
88
-      }
89
-      if (item.city === "") {
90
-        item.city = "All";
91
-      }
92
-      if (item.province === "") {
93
-        item.province = "All";
94
-      }
95
-      console.log(
96
-        `/api/Property/Search/${item.userName}/${item.keyword}/${item.salesType}/${item.propertyUsageType}/${item.propertyType}/${item.province}/${item.city}/${item.suburb}/${item.minPrice}/${item.maxPrice}/${item.availableFrom}/${item.propertyId}`
97
-      );
98
-
99
-      axios
100
-        .get(
78
+      return new Promise((resolve, reject) => {
79
+        if (item.keyword === "") {
80
+          item.keyword = "All";
81
+        }
82
+        if (log.isLoggedIn()) {
83
+          item.userName = log.getUser().username;
84
+        } else if (item.userName === "") {
85
+          item.userName = "Unknown";
86
+        }
87
+        if (item.suburb === "") {
88
+          item.suburb = "All";
89
+        }
90
+        if (item.city === "") {
91
+          item.city = "All";
92
+        }
93
+        if (item.province === "") {
94
+          item.province = "All";
95
+        }
96
+        console.log(
101 97
           `/api/Property/Search/${item.userName}/${item.keyword}/${item.salesType}/${item.propertyUsageType}/${item.propertyType}/${item.province}/${item.city}/${item.suburb}/${item.minPrice}/${item.maxPrice}/${item.availableFrom}/${item.propertyId}`
102
-        )
103
-        .then(result => commit("updateSearch", result.data))
104
-        .catch(console.error);
98
+        );
99
+
100
+        axios
101
+          .get(
102
+            `/api/Property/Search/${item.userName}/${item.keyword}/${item.salesType}/${item.propertyUsageType}/${item.propertyType}/${item.province}/${item.city}/${item.suburb}/${item.minPrice}/${item.maxPrice}/${item.availableFrom}/${item.propertyId}`
103
+          )
104
+          .then(result => {
105
+            commit("updateSearch", result.data);
106
+            resolve();
107
+          })
108
+          .catch(errro => reject(new Error(error.message)));
109
+      });
105 110
     },
106 111
     searchLatestProperties({ commit }) {
107 112
       axios

読み込み中…
キャンセル
保存