Parcourir la source

Property Search Controll

master
George Williams il y a 5 ans
Parent
révision
9eee74b190

+ 48
- 42
src/components/property/propertySearchPage.vue Voir le fichier

@@ -27,10 +27,14 @@
27 27
       <br />
28 28
       <div class="row">
29 29
         <div class="col-md-2 offset-4">
30
-          <button type="button" @click="SetType('Residential')" class="btn btn-b-n">Residential</button>
30
+          <button type="button" @click="SetType('Residential')" class="btn btn-b-n">
31
+            Residential
32
+          </button>
31 33
         </div>
32 34
         <div class="col-md-2">
33
-          <button type="button" @click="SetType('Commercial')" class="btn btn-b-n">Commercial</button>
35
+          <button type="button" @click="SetType('Commercial')" class="btn btn-b-n">
36
+            Commercial
37
+          </button>
34 38
         </div>
35 39
       </div>
36 40
       <br />
@@ -46,7 +50,8 @@
46 50
               aria-controls="pills-video"
47 51
               aria-selected="true"
48 52
               v-on:click="SetSalesType('Sale')"
49
-            >For Sale</a>
53
+              >For Sale</a
54
+            >
50 55
           </li>
51 56
           <li class="nav-item">
52 57
             <a
@@ -58,51 +63,46 @@
58 63
               aria-controls="pills-plans"
59 64
               aria-selected="false"
60 65
               v-on:click="SetSalesType('Rent')"
61
-            >To Rent</a>
66
+              >To Rent</a
67
+            >
62 68
           </li>
63 69
         </ul>
64 70
       </div>
65 71
       <br />
72
+      <div class="row">
73
+        <autoComplete class="col-md-11 offset-1" :items="suburbList" @selection="SelectedFilter" />
74
+      </div>
75
+      <br />
66 76
       <div class="row">
67 77
         <div class="col-md-10 offset-1">
68
-          <div class="input-group-prepend">
69
-            <span class="input-group-text" style="color: #60CBEB">
70
-              <b v-if="salesType === 'Sale'">S</b>
71
-              <b v-else>R</b>
72
-            </span>
73
-            <select class="form-control browser-default custom-select" v-model="searchText">
74
-              <option value="0">Please select</option>
75
-              <option v-for="item in suburbs" :value="item.id" :key="item.id">{{item.display}}</option>
76
-            </select>
77
-            <button
78
-              type="button"
79
-              class="input-group-text fa fa-search"
80
-              style="color: #60CBEB"
81
-              @click="SearchClick"
82
-            ></button>
83
-          </div>
78
+          <button
79
+            type="button"
80
+            class="input-group-text fa fa-search"
81
+            style="color: #60CBEB"
82
+            @click="SearchClick"
83
+          >
84
+            Search
85
+          </button>
84 86
         </div>
85 87
       </div>
86 88
       <div class="row">
87 89
         <div class="col-md-12">
88
-          <h1 class="my-4" v-if="propertyUsageType === 'Residential'">About Residential Properties</h1>
90
+          <h1 class="my-4" v-if="propertyUsageType === 'Residential'">
91
+            About Residential Properties
92
+          </h1>
89 93
           <h1 class="my-4" v-else>About Commercial Properties</h1>
90 94
         </div>
91 95
         <div class="container col-md-6 text-left" v-if="propertyUsageType === 'Residential'">
92 96
           <p>
93
-            Uni-Vate Properties understands the necessity in property-seekers
94
-            to find that perfect fit;
95
-            a home that meets, and exceeds the individual's needs. That is why,
96
-            our dedicated team sources
97
-            a range of property types, whether that home is a rental option near
98
-            a University for a student
99
-            just starting out, or a family home fit for entertaining.
97
+            Uni-Vate Properties understands the necessity in property-seekers to find that perfect
98
+            fit; a home that meets, and exceeds the individual's needs. That is why, our dedicated
99
+            team sources a range of property types, whether that home is a rental option near a
100
+            University for a student just starting out, or a family home fit for entertaining.
100 101
           </p>
101 102
           <p>
102
-            Looking to sell your residential property, instead? Uni-Vate
103
-            Properties prides itself on
104
-            professionalism and the right expertise, to help you secure the
105
-            best possible deal for your home.
103
+            Looking to sell your residential property, instead? Uni-Vate Properties prides itself on
104
+            professionalism and the right expertise, to help you secure the best possible deal for
105
+            your home.
106 106
           </p>
107 107
           <p>
108 108
             Wish to RENT your property?
@@ -115,17 +115,17 @@
115 115
         </div>
116 116
         <div class="container col-md-6 text-left" v-else>
117 117
           <p>
118
-            Commercial properties are characteristically any larger properties that
119
-            generate profit through leasing or rental activities. These properties
120
-            are typically used to conduct business and provide companies with cut-and-dry
121
-            leasing agreements, which keep their involvement in the maintenance of the property
122
-            to a minimum, so they may focus on the growth of their company.
118
+            Commercial properties are characteristically any larger properties that generate profit
119
+            through leasing or rental activities. These properties are typically used to conduct
120
+            business and provide companies with cut-and-dry leasing agreements, which keep their
121
+            involvement in the maintenance of the property to a minimum, so they may focus on the
122
+            growth of their company.
123 123
           </p>
124 124
           <p>
125 125
             Uni-Vate Properties seeks out professional, clean spaces for such companies and acts as
126 126
             mediator between the landlord/-lady and the tenants. Uni-Vate Properties provides
127
-            value-adding service to clients and conducts business with a high standard
128
-            and integrity.
127
+            value-adding service to clients and conducts business with a high standard and
128
+            integrity.
129 129
           </p>
130 130
           <p>
131 131
             Wish to RENT your property?
@@ -161,19 +161,22 @@
161 161
 </template>
162 162
 <script>
163 163
 import { mapState, mapActions } from 'vuex';
164
+import autoComplete from '../shared/autoComplete.vue';
164 165
 
165 166
 export default {
166 167
   name: 'propertysearch',
168
+  components: {
169
+    autoComplete,
170
+  },
167 171
   data() {
168 172
     return {
169 173
       propertyUsageType: 'Residential',
170 174
       salesType: 'Sale',
171 175
       searchText: '',
172
-      options: ['bla', 'boo', 'buz'],
173 176
     };
174 177
   },
175 178
   computed: {
176
-    ...mapState('propertySearch', ['suburbs', 'propertySearch']),
179
+    ...mapState('propertySearch', ['suburbs', 'suburbList', 'propertySearch']),
177 180
   },
178 181
   methods: {
179 182
     ...mapActions('propertySearch', ['getSuburbs', 'applyFilter']),
@@ -181,7 +184,7 @@ export default {
181 184
       this.propertyUsageType = item;
182 185
     },
183 186
     SearchClick() {
184
-      const item = this.suburbs.find(s => s.id === this.searchText);
187
+      const item = this.suburbs.find(s => s.display === this.searchText);
185 188
       console.log(JSON.stringify(item));
186 189
       this.propertySearch.province = item.province;
187 190
       this.propertySearch.city = item.city;
@@ -197,6 +200,9 @@ export default {
197 200
     SetSalesType(value) {
198 201
       this.salesType = value;
199 202
     },
203
+    SelectedFilter(item) {
204
+      this.searchText = item;
205
+    },
200 206
   },
201 207
   mounted() {
202 208
     this.getSuburbs();

+ 81
- 0
src/components/shared/autoComplete.vue Voir le fichier

@@ -0,0 +1,81 @@
1
+<template>
2
+  <div class="autocomplete">
3
+    <input type="text" v-model="search" @input="onChange" class="form-control" />
4
+    <ul v-show="isOpen" class="autocomplete-results">
5
+      <li
6
+        v-for="(result, i) in results"
7
+        :key="i"
8
+        class="autocomplete-result"
9
+        @click="setResult(result)"
10
+      >
11
+        {{ result }}
12
+      </li>
13
+    </ul>
14
+  </div>
15
+</template>
16
+
17
+<script>
18
+export default {
19
+  props: {
20
+    items: {
21
+      type: Array,
22
+      required: false,
23
+      default: () => [],
24
+    },
25
+  },
26
+  data() {
27
+    return {
28
+      search: '',
29
+      results: [],
30
+      isOpen: false,
31
+    };
32
+  },
33
+  methods: {
34
+    onChange() {
35
+      if (this.search.length >= 3) {
36
+        this.isOpen = true;
37
+        this.filterResults();
38
+      } else {
39
+        this.isOpen = false;
40
+      }
41
+    },
42
+    filterResults() {
43
+      this.results = this.items.filter(
44
+        item => item.toLowerCase().indexOf(this.search.toLowerCase()) > -1,
45
+      );
46
+    },
47
+    setResult(result) {
48
+      this.search = result;
49
+      this.isOpen = false;
50
+      this.$emit('selection', this.search);
51
+    },
52
+  },
53
+};
54
+</script>
55
+
56
+<style>
57
+.autocomplete {
58
+  position: relative;
59
+  width: 130px;
60
+}
61
+
62
+.autocomplete-results {
63
+  padding: 0;
64
+  margin: 0;
65
+  border: 1px solid #eeeeee;
66
+  height: 120px;
67
+  overflow: auto;
68
+}
69
+
70
+.autocomplete-result {
71
+  list-style: none;
72
+  text-align: left;
73
+  padding: 4px 2px;
74
+  cursor: pointer;
75
+}
76
+
77
+.autocomplete-result:hover {
78
+  background-color: #60cbeb;
79
+  color: white;
80
+}
81
+</style>

+ 15
- 0
src/store/modules/property/propertySearch.js Voir le fichier

@@ -21,6 +21,7 @@ export default {
21 21
     latestProperties: [],
22 22
     suburbs: [],
23 23
     searchText: '',
24
+    suburbList: [],
24 25
   },
25 26
   mutations: {
26 27
     updateSearch(state, propertySearch) {
@@ -37,7 +38,12 @@ export default {
37 38
       state.propertySearch[filter] = 'All';
38 39
     },
39 40
     setSuburbs(state, items) {
41
+      state.suburbList = [];
40 42
       state.suburbs = items;
43
+      // eslint-disable-next-line no-plusplus
44
+      for (let i = 0; i < state.suburbs.length; i++) {
45
+        state.suburbList.push(state.suburbs[i].display);
46
+      }
41 47
     },
42 48
     setFilter(state, value) {
43 49
       state.searchText = value;
@@ -77,6 +83,15 @@ export default {
77 83
       if (item.userName === '') {
78 84
         item.userName = 'Unknown';
79 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
+      }
80 95
       axios
81 96
         .get(
82 97
           `/api/Property/Search/${item.userName}/${item.keyword}/${item.salesType}/${item.propertyUsageType}/${item.propertyType}/${item.province}/${item.city}/${item.suburb}/${item.minPrice}/${item.maxPrice}`,

Chargement…
Annuler
Enregistrer