Преглед на файлове

Property Search Controll

master
George Williams преди 5 години
родител
ревизия
9eee74b190
променени са 3 файла, в които са добавени 144 реда и са изтрити 42 реда
  1. 48
    42
      src/components/property/propertySearchPage.vue
  2. 81
    0
      src/components/shared/autoComplete.vue
  3. 15
    0
      src/store/modules/property/propertySearch.js

+ 48
- 42
src/components/property/propertySearchPage.vue Целия файл

27
       <br />
27
       <br />
28
       <div class="row">
28
       <div class="row">
29
         <div class="col-md-2 offset-4">
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
         </div>
33
         </div>
32
         <div class="col-md-2">
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
         </div>
38
         </div>
35
       </div>
39
       </div>
36
       <br />
40
       <br />
46
               aria-controls="pills-video"
50
               aria-controls="pills-video"
47
               aria-selected="true"
51
               aria-selected="true"
48
               v-on:click="SetSalesType('Sale')"
52
               v-on:click="SetSalesType('Sale')"
49
-            >For Sale</a>
53
+              >For Sale</a
54
+            >
50
           </li>
55
           </li>
51
           <li class="nav-item">
56
           <li class="nav-item">
52
             <a
57
             <a
58
               aria-controls="pills-plans"
63
               aria-controls="pills-plans"
59
               aria-selected="false"
64
               aria-selected="false"
60
               v-on:click="SetSalesType('Rent')"
65
               v-on:click="SetSalesType('Rent')"
61
-            >To Rent</a>
66
+              >To Rent</a
67
+            >
62
           </li>
68
           </li>
63
         </ul>
69
         </ul>
64
       </div>
70
       </div>
65
       <br />
71
       <br />
72
+      <div class="row">
73
+        <autoComplete class="col-md-11 offset-1" :items="suburbList" @selection="SelectedFilter" />
74
+      </div>
75
+      <br />
66
       <div class="row">
76
       <div class="row">
67
         <div class="col-md-10 offset-1">
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
         </div>
86
         </div>
85
       </div>
87
       </div>
86
       <div class="row">
88
       <div class="row">
87
         <div class="col-md-12">
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
           <h1 class="my-4" v-else>About Commercial Properties</h1>
93
           <h1 class="my-4" v-else>About Commercial Properties</h1>
90
         </div>
94
         </div>
91
         <div class="container col-md-6 text-left" v-if="propertyUsageType === 'Residential'">
95
         <div class="container col-md-6 text-left" v-if="propertyUsageType === 'Residential'">
92
           <p>
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
           </p>
101
           </p>
101
           <p>
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
           </p>
106
           </p>
107
           <p>
107
           <p>
108
             Wish to RENT your property?
108
             Wish to RENT your property?
115
         </div>
115
         </div>
116
         <div class="container col-md-6 text-left" v-else>
116
         <div class="container col-md-6 text-left" v-else>
117
           <p>
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
           </p>
123
           </p>
124
           <p>
124
           <p>
125
             Uni-Vate Properties seeks out professional, clean spaces for such companies and acts as
125
             Uni-Vate Properties seeks out professional, clean spaces for such companies and acts as
126
             mediator between the landlord/-lady and the tenants. Uni-Vate Properties provides
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
           </p>
129
           </p>
130
           <p>
130
           <p>
131
             Wish to RENT your property?
131
             Wish to RENT your property?
161
 </template>
161
 </template>
162
 <script>
162
 <script>
163
 import { mapState, mapActions } from 'vuex';
163
 import { mapState, mapActions } from 'vuex';
164
+import autoComplete from '../shared/autoComplete.vue';
164
 
165
 
165
 export default {
166
 export default {
166
   name: 'propertysearch',
167
   name: 'propertysearch',
168
+  components: {
169
+    autoComplete,
170
+  },
167
   data() {
171
   data() {
168
     return {
172
     return {
169
       propertyUsageType: 'Residential',
173
       propertyUsageType: 'Residential',
170
       salesType: 'Sale',
174
       salesType: 'Sale',
171
       searchText: '',
175
       searchText: '',
172
-      options: ['bla', 'boo', 'buz'],
173
     };
176
     };
174
   },
177
   },
175
   computed: {
178
   computed: {
176
-    ...mapState('propertySearch', ['suburbs', 'propertySearch']),
179
+    ...mapState('propertySearch', ['suburbs', 'suburbList', 'propertySearch']),
177
   },
180
   },
178
   methods: {
181
   methods: {
179
     ...mapActions('propertySearch', ['getSuburbs', 'applyFilter']),
182
     ...mapActions('propertySearch', ['getSuburbs', 'applyFilter']),
181
       this.propertyUsageType = item;
184
       this.propertyUsageType = item;
182
     },
185
     },
183
     SearchClick() {
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
       console.log(JSON.stringify(item));
188
       console.log(JSON.stringify(item));
186
       this.propertySearch.province = item.province;
189
       this.propertySearch.province = item.province;
187
       this.propertySearch.city = item.city;
190
       this.propertySearch.city = item.city;
197
     SetSalesType(value) {
200
     SetSalesType(value) {
198
       this.salesType = value;
201
       this.salesType = value;
199
     },
202
     },
203
+    SelectedFilter(item) {
204
+      this.searchText = item;
205
+    },
200
   },
206
   },
201
   mounted() {
207
   mounted() {
202
     this.getSuburbs();
208
     this.getSuburbs();

+ 81
- 0
src/components/shared/autoComplete.vue Целия файл

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 Целия файл

21
     latestProperties: [],
21
     latestProperties: [],
22
     suburbs: [],
22
     suburbs: [],
23
     searchText: '',
23
     searchText: '',
24
+    suburbList: [],
24
   },
25
   },
25
   mutations: {
26
   mutations: {
26
     updateSearch(state, propertySearch) {
27
     updateSearch(state, propertySearch) {
37
       state.propertySearch[filter] = 'All';
38
       state.propertySearch[filter] = 'All';
38
     },
39
     },
39
     setSuburbs(state, items) {
40
     setSuburbs(state, items) {
41
+      state.suburbList = [];
40
       state.suburbs = items;
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
     setFilter(state, value) {
48
     setFilter(state, value) {
43
       state.searchText = value;
49
       state.searchText = value;
77
       if (item.userName === '') {
83
       if (item.userName === '') {
78
         item.userName = 'Unknown';
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
       axios
95
       axios
81
         .get(
96
         .get(
82
           `/api/Property/Search/${item.userName}/${item.keyword}/${item.salesType}/${item.propertyUsageType}/${item.propertyType}/${item.province}/${item.city}/${item.suburb}/${item.minPrice}/${item.maxPrice}`,
97
           `/api/Property/Search/${item.userName}/${item.keyword}/${item.salesType}/${item.propertyUsageType}/${item.propertyType}/${item.province}/${item.city}/${item.suburb}/${item.minPrice}/${item.maxPrice}`,

Loading…
Отказ
Запис