Kobus Botha 5 jaren geleden
bovenliggende
commit
1c749bcd64

+ 70
- 5
src/components/property/propertyCreate.vue Bestand weergeven

@@ -46,7 +46,7 @@
46 46
                     class="form-control"
47 47
                     name="propertyUsageType"
48 48
                     id="propertyUsageType"
49
-                    v-model="property.propertyUsageType"
49
+                    v-model="propertyType"
50 50
                     @change="TypeChanged"
51 51
                   >
52 52
                     <option value="Residential">Residential</option>
@@ -55,9 +55,10 @@
55 55
                 </div>
56 56
               </div>
57 57
             </div>
58
+            <br />
58 59
             <div class="form-group row">
59 60
               <div class="col-md-4">
60
-                <label>Property Type</label>
61
+                <label>Property Type *</label>
61 62
                 <div class="input-group-prepend">
62 63
                   <span class="input-group-text" style="color: #60CBEB">
63 64
                     <b>T</b>
@@ -67,6 +68,7 @@
67 68
                     name="propertyType"
68 69
                     id="propertyType"
69 70
                     v-model="property.propertyTypeId"
71
+                    @change="PropertyTypeSelected"
70 72
                   >
71 73
                     <option value="0">Please select type</option>
72 74
                     <option v-for="item in propertyTypes" :value="item.id" :key="item.id">{{
@@ -74,6 +76,9 @@
74 76
                     }}</option>
75 77
                   </select>
76 78
                 </div>
79
+                <div v-if="showPropertyTypeError">
80
+                  <p class="alert myError">Please select a type</p>
81
+                </div>
77 82
               </div>
78 83
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
79 84
                 <label>Property Name</label>
@@ -137,7 +142,7 @@
137 142
                 </div>
138 143
               </div>
139 144
               <div class="col-md-6" style="margin-bottom: 1em">
140
-                <label>Province</label>
145
+                <label>Province *</label>
141 146
                 <div class="input-group-prepend">
142 147
                   <span class="input-group-text">
143 148
                     <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
@@ -155,10 +160,13 @@
155 160
                     }}</option>
156 161
                   </select>
157 162
                 </div>
163
+                <div v-if="showProvinceError">
164
+                  <p class="alert myError">Please select a Province</p>
165
+                </div>
158 166
               </div>
159 167
 
160 168
               <div class="col-md-6" style="margin-bottom: 1em">
161
-                <label>City</label>
169
+                <label>City *</label>
162 170
                 <div class="input-group-prepend">
163 171
                   <span class="input-group-text">
164 172
                     <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
@@ -176,9 +184,12 @@
176 184
                     }}</option>
177 185
                   </select>
178 186
                 </div>
187
+                <div v-if="showCityError">
188
+                  <p class="alert myError">Please select a City</p>
189
+                </div>
179 190
               </div>
180 191
               <div class="col-md-6" style="margin-bottom: 1em">
181
-                <label>Suburb</label>
192
+                <label>Suburb *</label>
182 193
                 <div class="input-group-prepend">
183 194
                   <span class="input-group-text">
184 195
                     <eva-icon name="home-outline" fill="#60CBEB"></eva-icon>
@@ -196,6 +207,9 @@
196 207
                     }}</option>
197 208
                   </select>
198 209
                 </div>
210
+                <div v-if="showSuburbError">
211
+                  <p class="alert myError">Please select a Suburb</p>
212
+                </div>
199 213
               </div>
200 214
               <div class="col-md-6" style="margin-bottom: 1em">
201 215
                 <label>Postal Code</label>
@@ -346,6 +360,13 @@
346 360
             >
347 361
               Save
348 362
             </button>
363
+            <div
364
+              v-if="showPropertyTypeError || showProvinceError || showCityError || showSuburbError"
365
+            >
366
+              <p class="alert myError">
367
+                Missing fields. Please fill in all required fields. Marked with *
368
+              </p>
369
+            </div>
349 370
             <div v-if="wait" id="preloader"></div>
350 371
           </form>
351 372
         </div>
@@ -386,6 +407,10 @@ export default {
386 407
         [{ indent: '-1' }, { indent: '+1' }],
387 408
       ],
388 409
       error: '',
410
+      showPropertyTypeError: false,
411
+      showProvinceError: false,
412
+      showCityError: false,
413
+      showSuburbError: false,
389 414
     };
390 415
   },
391 416
   methods: {
@@ -408,6 +433,28 @@ export default {
408 433
       this.propertyType = this.property.propertyUsageType;
409 434
     },
410 435
     SubmitData() {
436
+      if (this.property.propertyTypeId === 0) {
437
+        this.showPropertyTypeError = true;
438
+      }
439
+      if (this.property.provinceId === 0) {
440
+        this.showProvinceError = true;
441
+      }
442
+      if (this.property.cityId === 0) {
443
+        this.showCityError = true;
444
+      }
445
+      if (this.property.suburbId === 0) {
446
+        this.showSuburbError = true;
447
+      }
448
+
449
+      if (
450
+        this.showPropertyTypeError
451
+        || this.showProvinceError
452
+        || this.showCityError
453
+        || this.showSuburbError
454
+      ) {
455
+        return;
456
+      }
457
+
411 458
       this.wait = true;
412 459
       if (this.salesType === 'Sale') {
413 460
         this.property.isSale = true;
@@ -440,10 +487,20 @@ export default {
440 487
     Close() {
441 488
       this.$router.push('/property/admin/list/my');
442 489
     },
490
+    PropertyTypeSelected(item) {
491
+      if (item.target.options.selectedIndex > 0) {
492
+        this.showPropertyTypeError = false;
493
+      } else {
494
+        this.showPropertyTypeError = true;
495
+      }
496
+    },
443 497
     ProvinceSelected(item) {
444 498
       if (item.target.options.selectedIndex > 0) {
445 499
         this.selectedProvince = this.provinces[item.target.options.selectedIndex - 1].description;
446 500
         this.getCities(Object.assign({}, { province: this.selectedProvince }));
501
+        this.showProvinceError = false;
502
+      } else {
503
+        this.showProvinceError = true;
447 504
       }
448 505
     },
449 506
     CitySelected(item) {
@@ -452,10 +509,18 @@ export default {
452 509
         this.getSuburbs(
453 510
           Object.assign({}, { province: this.selectedProvince, city: this.selectedCity }),
454 511
         );
512
+        this.showCityError = false;
513
+      } else {
514
+        this.showCityError = true;
455 515
       }
456 516
     },
457 517
     getPostalCode(item) {
458 518
       this.property.addressLine3 = this.suburbs[item.target.options.selectedIndex - 1].postalCode;
519
+      if (item.target.options.selectedIndex > 0) {
520
+        this.showSuburbError = false;
521
+      } else {
522
+        this.showSuburbError = true;
523
+      }
459 524
     },
460 525
     loadedImages(values) {
461 526
       this.images = values;

+ 4
- 4
src/components/property/propertyFieldEditor.vue Bestand weergeven

@@ -47,7 +47,9 @@
47 47
           @change="SelectorSelected"
48 48
         >
49 49
           <option value="0"></option>
50
-          <option v-for="item in arrayObject" :value="item.id" :key="item.id">{{ item.description }}</option>
50
+          <option v-for="item in arrayObject" :value="item.id" :key="item.id">{{
51
+            item.description
52
+          }}</option>
51 53
         </select>
52 54
         <!-- yesno -->
53 55
         <select v-if="editType === 'yesno'" class="form-control" @change="YesNoSelected">
@@ -99,9 +101,7 @@ export default {
99 101
     },
100 102
     SelectorSelected(item) {
101 103
       if (item.target.options.selectedIndex > 0) {
102
-        this.updatedDisplay = this.arrayObject[
103
-          item.target.options.selectedIndex - 1
104
-        ].description;
104
+        this.updatedDisplay = this.arrayObject[item.target.options.selectedIndex - 1].description;
105 105
       }
106 106
     },
107 107
     YesNoSelected(item) {

+ 1
- 1
src/components/property/propertyImage.vue Bestand weergeven

@@ -28,7 +28,7 @@
28 28
         <label v-if="allowMultiple" for="checkbox" style="margin: 10px;">Main Image</label>
29 29
         <img :src="img" style="height:200px; width:150px; object-fit: cover;" />
30 30
         <br />
31
-        <span class="input-group-text" align="center" @click="removeImage(key)">
31
+        <span class="input-group-text" align="center" style="width:150px" @click="removeImage(key)">
32 32
           <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
33 33
         </span>
34 34
       </div>

+ 15
- 13
src/components/property/propertySearchFields.vue Bestand weergeven

@@ -9,11 +9,7 @@
9 9
               <b>F</b>
10 10
             </span>
11 11
           </div>
12
-          <select
13
-            class="form-control"
14
-            v-model="propertySearch.salesType"
15
-            @change="salesTypeSelected"
16
-          >
12
+          <select class="form-control" v-model="propertySearch.salesType">
17 13
             <option value="Sale">Sale</option>
18 14
             <option value="Rent">Rent</option>
19 15
           </select>
@@ -29,9 +25,11 @@
29 25
           </div>
30 26
           <select class="form-control" v-model="resType" @change="PropertyTypeSelected">
31 27
             <option>All</option>
32
-            <option v-for="(propertyType, i) in propertyTypesRes" :key="i">{{
28
+            <option v-for="(propertyType, i) in propertyTypesRes" :key="i">
29
+              {{
33 30
               propertyType.description
34
-            }}</option>
31
+              }}
32
+            </option>
35 33
           </select>
36 34
           <div class="input-group-append" @click="clearResType">
37 35
             <span class="input-group-text cursor-pointer" style="color: #60CBEB">
@@ -50,9 +48,11 @@
50 48
           </div>
51 49
           <select class="form-control" v-model="comType" @change="PropertyTypeSelected">
52 50
             <option>All</option>
53
-            <option v-for="(propertyType, i) in propertyTypesCom" :key="i">{{
51
+            <option v-for="(propertyType, i) in propertyTypesCom" :key="i">
52
+              {{
54 53
               propertyType.description
55
-            }}</option>
54
+              }}
55
+            </option>
56 56
           </select>
57 57
           <div class="input-group-append" @click="clearComType">
58 58
             <span class="input-group-text cursor-pointer" style="color: #60CBEB">
@@ -69,7 +69,7 @@
69 69
               <b>P</b>
70 70
             </span>
71 71
           </div>
72
-          <select class="form-control" @change="ProvinceSelected" v-model="propertySearch.province">
72
+          <select class="form-control" v-model="propertySearch.province">
73 73
             <option>All</option>
74 74
             <option v-for="(province, i) in provinces" :key="i">{{ province.description }}</option>
75 75
           </select>
@@ -90,7 +90,7 @@
90 90
               <b>C</b>
91 91
             </span>
92 92
           </div>
93
-          <select class="form-control" @change="CitySelected" v-model="propertySearch.city">
93
+          <select class="form-control" v-model="propertySearch.city">
94 94
             <option>All</option>
95 95
             <option v-for="(city, i) in cities" :key="i">{{ city.description }}</option>
96 96
           </select>
@@ -111,7 +111,7 @@
111 111
               <b>S</b>
112 112
             </span>
113 113
           </div>
114
-          <select class="form-control" v-model="propertySearch.suburb" @change="SuburbSeleted">
114
+          <select class="form-control" v-model="propertySearch.suburb">
115 115
             <option>All</option>
116 116
             <option v-for="(suburb, i) in suburbs" :key="i">{{ suburb.description }}</option>
117 117
           </select>
@@ -217,7 +217,9 @@ export default {
217 217
     },
218 218
     ProvinceSelected(item) {
219 219
       if (item.target.value !== 'All') {
220
-        this.getCities(Object.assign({}, { province: this.propertySearch.province }));
220
+        this.getCities(
221
+          Object.assign({}, { province: this.propertySearch.province }),
222
+        );
221 223
       }
222 224
     },
223 225
     CitySelected(item) {

+ 163
- 186
src/components/property/propertyeditPage.vue Bestand weergeven

@@ -35,13 +35,15 @@
35 35
       <div class="row mb-3">
36 36
         <div class="container col-md-10" style="text-align:left">
37 37
           <form id="mainForm">
38
+            <div class="form-goup row">
39
+              <div class="col-md-4">
40
+                <field :type="'datetime'" :mayEdit="true" />
41
+              </div>
42
+            </div>
38 43
             <div class="form-goup row">
39 44
               <div class="col-md-4">
40 45
                 <label>Usage Type</label>
41 46
                 <div class="input-group-prepend">
42
-                  <!-- <span class="input-group-text" style="color: #60CBEB">
43
-                    <b>U</b>
44
-                  </span>-->
45 47
                   <input
46 48
                     class="form-control"
47 49
                     type="text"
@@ -53,6 +55,7 @@
53 55
                 </div>
54 56
               </div>
55 57
             </div>
58
+            <br />
56 59
             <div class="form-group row">
57 60
               <div class="col-md-4">
58 61
                 <label>Sale Type</label>
@@ -64,106 +67,113 @@
64 67
                   :mayEdit="mayEdit"
65 68
                   @UpdateValue="UpdateValue"
66 69
                 />
70
+                <div v-if="showPropertyTypeError">
71
+                  <p class="alert myError">Please select a Sales Type</p>
72
+                </div>
67 73
               </div>
68 74
             </div>
69 75
             <div class="form-group row">
70 76
               <div class="col-md-4">
71
-                <label>Property Type</label>
72
-                <propField
73
-                  :display="property.propertyType ? property.propertyType.description : ''"
74
-                  :editType="'selector'"
75
-                  :arrayObject="propertyTypes"
76
-                  :propertyName="'propertyType'"
77
+                <label>Property Type *</label>
78
+                <field
79
+                  :type="'select'"
80
+                  :selectOptions="propertyTypes"
81
+                  :selectValue="'id'"
82
+                  :selectText="'description'"
83
+                  v-model="property.propertyType"
77 84
                   :mayEdit="mayEdit"
78
-                  @UpdateValue="UpdateValue"
79 85
                 />
80 86
               </div>
81 87
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
82 88
                 <label>Property Name</label>
83
-                <propField
84
-                  :display="property.propertyName"
85
-                  :editType="'text'"
86
-                  :propertyName="'propertyName'"
87
-                  :mayEdit="mayEdit"
88
-                  @UpdateValue="UpdateValue"
89
-                />
89
+                <field :type="'text'" v-model="property.propertyName" :mayEdit="mayEdit" />
90 90
               </div>
91 91
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
92 92
                 <label>Unit</label>
93
-                <propField
94
-                  :label="'Property Type'"
95
-                  :display="property.unit"
96
-                  :editType="'text'"
97
-                  :propertyName="'unit'"
98
-                  :mayEdit="mayEdit"
99
-                  @UpdateValue="UpdateValue"
100
-                />
93
+                <field :type="'text'" v-model="property.unit" :mayEdit="mayEdit" />
101 94
               </div>
102 95
             </div>
103 96
             <div class="form-group row">
104 97
               <div class="col-md-6" style="margin-bottom: 1em">
105 98
                 <label>Street Number</label>
106
-                <propField
107
-                  :display="property.addressLine1"
108
-                  :editType="'text'"
109
-                  :propertyName="'addressLine1'"
110
-                  :mayEdit="mayEdit"
111
-                  @UpdateValue="UpdateValue"
112
-                />
99
+                <field :type="'text'" v-model="property.addressLine1" :mayEdit="mayEdit" />
113 100
               </div>
114 101
               <div class="col-md-6" style="margin-bottom: 1em">
115 102
                 <label>Street Name</label>
116
-                <propField
117
-                  :display="property.addressLine2"
118
-                  :editType="'text'"
119
-                  :propertyName="'addressLine2'"
120
-                  :mayEdit="mayEdit"
121
-                  @UpdateValue="UpdateValue"
122
-                />
103
+                <field :type="'text'" v-model="property.addressLine2" :mayEdit="mayEdit" />
123 104
               </div>
124 105
               <div class="col-md-6" style="margin-bottom: 1em">
125
-                <label>Province</label>
126
-                <propField
106
+                <label>Province *</label>
107
+                <!-- <propField
127 108
                   :display="property.province ? property.province.description : ''"
128 109
                   :editType="'selector'"
129 110
                   :arrayObject="provinces"
130 111
                   :propertyName="'province'"
131 112
                   :mayEdit="mayEdit"
132 113
                   @UpdateValue="UpdateValue"
114
+                />-->
115
+                <field
116
+                  :type="'select'"
117
+                  :selectOptions="provinces"
118
+                  :selectValue="'id'"
119
+                  :selectText="'description'"
120
+                  v-model="property.province"
121
+                  :mayEdit="mayEdit"
122
+                  @change="provChanged"
133 123
                 />
124
+                <div v-if="showProvinceError">
125
+                  <p class="alert myError">Please select a Province</p>
126
+                </div>
134 127
               </div>
135
-
136 128
               <div class="col-md-6" style="margin-bottom: 1em">
137
-                <label>City</label>
138
-                <propField
129
+                <label>City *</label>
130
+                <!-- <propField
139 131
                   :display="property.city ? property.city.description : ''"
140 132
                   :editType="'selector'"
141 133
                   :arrayObject="cities"
142 134
                   :propertyName="'city'"
143 135
                   :mayEdit="mayEdit"
144 136
                   @UpdateValue="UpdateValue"
137
+                />-->
138
+                <field
139
+                  :type="'select'"
140
+                  :selectOptions="cities"
141
+                  :selectValue="'id'"
142
+                  :selectText="'description'"
143
+                  v-model="property.city"
144
+                  :mayEdit="mayEdit"
145
+                  @change="cityChanged"
145 146
                 />
147
+                <div v-if="showCityError">
148
+                  <p class="alert myError">Please select a City</p>
149
+                </div>
146 150
               </div>
147 151
               <div class="col-md-6" style="margin-bottom: 1em">
148
-                <label>Suburb</label>
149
-                <propField
152
+                <label>Suburb *</label>
153
+                <!-- <propField
150 154
                   :display="property.suburb ? property.suburb.description : ''"
151 155
                   :editType="'selector'"
152 156
                   :arrayObject="suburbs"
153 157
                   :propertyName="'suburb'"
154 158
                   :mayEdit="mayEdit"
155 159
                   @UpdateValue="UpdateValue"
160
+                />-->
161
+                <field
162
+                  :type="'select'"
163
+                  :selectOptions="suburbs"
164
+                  :selectValue="'id'"
165
+                  :selectText="'description'"
166
+                  v-model="property.suburb"
167
+                  :mayEdit="mayEdit"
168
+                  @change="suburbChanged"
156 169
                 />
170
+                <div v-if="showSuburbError">
171
+                  <p class="alert myError">Please select a suburb</p>
172
+                </div>
157 173
               </div>
158 174
               <div class="col-md-6" style="margin-bottom: 1em">
159 175
                 <label>Postal Code</label>
160
-                <propField
161
-                  :display="property.addressLine3"
162
-                  :editType="'text'"
163
-                  :propertyName="'addressLine3'"
164
-                  :mayEdit="mayEdit"
165
-                  @UpdateValue="UpdateValue"
166
-                />
176
+                <field :type="'text'" v-model="property.addressLine3" :mayEdit="mayEdit" />
167 177
               </div>
168 178
             </div>
169 179
 
@@ -171,23 +181,30 @@
171 181
               <div class="col-md-6">
172 182
                 <label v-if="salesType === 'Rental'">Rental Price</label>
173 183
                 <label v-if="salesType !== 'Rental'">Sales Price</label>
174
-                <propField
184
+                <field :type="'number'" v-model="property.price" :mayEdit="mayEdit" />
185
+                <!-- <propField
175 186
                   :display="String(property.price)"
176 187
                   :editType="'number'"
177 188
                   :propertyName="'price'"
178 189
                   :mayEdit="mayEdit"
179 190
                   @UpdateValue="UpdateValue"
180
-                />
191
+                />-->
181 192
               </div>
182 193
               <div class="col-md-6" v-if="salesType === 'Rental'">
183 194
                 <label>Per</label>
184
-                <propField
195
+                <!-- <propField
185 196
                   :display="property.pricePer"
186 197
                   :editType="'selector'"
187 198
                   :propertyName="'pricePer'"
188 199
                   :arrayObject="pricePerArr"
189 200
                   :mayEdit="mayEdit"
190 201
                   @UpdateValue="UpdateValue"
202
+                />-->
203
+                <field
204
+                  :type="'selectlist'"
205
+                  :selectOptions="pricePerArr"
206
+                  v-model="property.pricePer"
207
+                  :mayEdit="mayEdit"
191 208
                 />
192 209
               </div>
193 210
             </div>
@@ -196,13 +213,16 @@
196 213
                 <label for="Property Description">Description</label>
197 214
                 <vue-editor v-model="property.description" :editor-toolbar="customToolbar" />
198 215
                 <br />
199
-                <p>* A listing fee of R380 including VAT is payable to list your Property on the Uni-Vate website</p>
216
+                <p>
217
+                  * A listing fee of R380 including VAT is payable to list your Property on the
218
+                  Uni-Vate website
219
+                </p>
200 220
               </div>
201 221
             </div>
202 222
             <div class="form-group row" />
203 223
             <div
204 224
               class="col-md-6"
205
-              v-if="propertyType === 'Residential' & propertyOverviewFields.length > 0"
225
+              v-if="(propertyType === 'Residential') & (propertyOverviewFields.length > 0)"
206 226
             >
207 227
               <div v-for="(item, i) in propertyOverviewFields[0].fields" :key="item.id">
208 228
                 <label>{{ item.name }}</label>
@@ -243,6 +263,7 @@
243 263
                   @UpdateValue="UpdateValue"
244 264
                 />
245 265
               </div>
266
+              <br />
246 267
             </div>
247 268
             <div class="form-group row" />
248 269
             <div class="row">
@@ -255,25 +276,13 @@
255 276
             <div class="form-group row">
256 277
               <div class="col-md-12">
257 278
                 <label>Virtual Tour (URL)</label>
258
-                <propField
259
-                  :display="property.virtualTour"
260
-                  :editType="'text'"
261
-                  :propertyName="'virtualTour'"
262
-                  :mayEdit="mayEdit"
263
-                  @UpdateValue="UpdateValue"
264
-                />
279
+                <field :type="'text'" v-model="property.virtualTour" :mayEdit="mayEdit" />
265 280
               </div>
266 281
             </div>
267 282
             <div class="form-group row">
268 283
               <div class="col-md-12">
269 284
                 <label>Video (URL)</label>
270
-                <propField
271
-                  :display="property.video"
272
-                  :editType="'text'"
273
-                  :propertyName="'video'"
274
-                  :mayEdit="mayEdit"
275
-                  @UpdateValue="UpdateValue"
276
-                />
285
+                <field :type="'text'" v-model="property.video" :mayEdit="mayEdit" />
277 286
               </div>
278 287
             </div>
279 288
             <div class="form-group row">
@@ -303,6 +312,7 @@
303 312
                   class="input-group-text spanCursor"
304 313
                   align="center"
305 314
                   @click="DeleteImage(img)"
315
+                  style="width:150px"
306 316
                 >
307 317
                   <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
308 318
                 </span>
@@ -321,13 +331,27 @@
321 331
               class="btn btn-b-n"
322 332
               style="width: 85px; height:40px;"
323 333
               :disabled="!mayEdit"
324
-            >Save</button>
334
+            >
335
+              Save
336
+            </button>
325 337
             <button
326 338
               type="button"
327 339
               @click="Close()"
328 340
               class="btn btn-b-n"
329 341
               style="width: 85px; height:40px;"
330
-            >Close</button>
342
+              :disabled="
343
+                showPropertyTypeError || showProvinceError || showCityError || showSuburbError
344
+              "
345
+            >
346
+              Close
347
+            </button>
348
+            <div
349
+              v-if="showPropertyTypeError || showProvinceError || showCityError || showSuburbError"
350
+            >
351
+              <p class="alert myError">
352
+                Missing fields. Please fill in all required fields. Marked with *
353
+              </p>
354
+            </div>
331 355
             <div v-if="wait" id="preloader"></div>
332 356
           </form>
333 357
         </div>
@@ -339,9 +363,9 @@
339 363
 <script>
340 364
 import { mapState, mapActions } from 'vuex';
341 365
 import { VueEditor } from 'vue2-editor';
342
-import { setTimeout } from 'timers';
343 366
 import ImageLoad from './propertyImage.vue';
344 367
 import propField from './propertyFieldEditor.vue';
368
+import field from '../shared/fieldEditor.vue';
345 369
 
346 370
 export default {
347 371
   name: 'PropertyEdit',
@@ -349,6 +373,7 @@ export default {
349 373
     ImageLoad,
350 374
     VueEditor,
351 375
     propField,
376
+    field,
352 377
   },
353 378
   data() {
354 379
     return {
@@ -361,12 +386,7 @@ export default {
361 386
       customToolbar: [
362 387
         [{ header: [false, 1, 2, 3, 4, 5, 6] }],
363 388
         ['bold', 'italic', 'underline', 'strike'],
364
-        [
365
-          { align: '' },
366
-          { align: 'center' },
367
-          { align: 'right' },
368
-          { align: 'justify' },
369
-        ],
389
+        [{ align: '' }, { align: 'center' }, { align: 'right' }, { align: 'justify' }],
370 390
         [{ list: 'ordered' }, { list: 'bullet' }, { list: 'check' }],
371 391
         [{ script: 'sub' }, { script: 'super' }],
372 392
         [{ indent: '-1' }, { indent: '+1' }],
@@ -375,10 +395,12 @@ export default {
375 395
         { id: 1, description: 'Sale' },
376 396
         { id: 2, description: 'Rental' },
377 397
       ],
378
-      pricePerArr: [
379
-        { id: 'Month', description: 'Month' },
380
-        { id: 'Day', description: 'Day' },
381
-      ],
398
+      pricePerArr: ['Month', 'Day'],
399
+      yesno: ['Yes', 'No'],
400
+      showPropertyTypeError: false,
401
+      showProvinceError: false,
402
+      showCityError: false,
403
+      showSuburbError: false,
382 404
     };
383 405
   },
384 406
   methods: {
@@ -389,19 +411,45 @@ export default {
389 411
       'getListsForPropertyEdit',
390 412
     ]),
391 413
     ...mapActions('property', ['getPropertyTypes']),
392
-    ...mapActions('propertyEdit', [
393
-      'getSavedPropertyData',
394
-      'updateProperty',
395
-      'mayEditProperty',
396
-    ]),
414
+    ...mapActions('propertyEdit', ['getSavedPropertyData', 'updateProperty', 'mayEditProperty']),
415
+    provChanged(item) {
416
+      this.getCities(Object.assign({}, { province: item.description }));
417
+      this.property.city = null;
418
+      this.property.suburb = null;
419
+      this.property.addressLine3 = '';
420
+      this.showProvinceError = false;
421
+      this.showCityError = true;
422
+      this.showSuburbError = true;
423
+    },
424
+    cityChanged(item) {
425
+      this.getSuburbs(
426
+        Object.assign(
427
+          {},
428
+          {
429
+            province: this.property.province.description,
430
+            city: item.description,
431
+          },
432
+        ),
433
+      );
434
+      this.property.suburb = null;
435
+      this.property.addressLine3 = '';
436
+      this.showCityError = false;
437
+      this.showSuburbError = true;
438
+    },
439
+    suburbChanged(item) {
440
+      const newSuburb = this.suburbs.find(p => p.description === item.description);
441
+      this.property.addressLine3 = newSuburb.postalCode;
442
+      this.showSuburbError = false;
443
+    },
444
+    salesTypeChanged(item) {
445
+      console.log(item);
446
+    },
397 447
     UpdateValue(item) {
398 448
       if (item.isUDF) {
399 449
         if (item.isPropOverview) {
400
-          this.propertyOverviewFields[0].fields[item.arrayIndex].value =            item.value;
450
+          this.propertyOverviewFields[0].fields[item.arrayIndex].value = item.value;
401 451
         } else if (item.isPropOverview === false) {
402
-          this.propertyFields[item.arrayIndex].fields[
403
-            item.arrayItemIndex
404
-          ].value = item.value;
452
+          this.propertyFields[item.arrayIndex].fields[item.arrayItemIndex].value = item.value;
405 453
         }
406 454
       } else if (!item.isUDF) {
407 455
         if (item.fieldName) {
@@ -412,96 +460,6 @@ export default {
412 460
             } else isSaleValue = false;
413 461
             this.property.isSale = isSaleValue;
414 462
           }
415
-          if (item.fieldName === 'propertyType') {
416
-            this.property.propertyType = this.propertyTypes.find(
417
-              pt => pt.description === item.value,
418
-            );
419
-            this.property.propertyTypeId = this.property.propertyType.id;
420
-          }
421
-          if (item.fieldName === 'propertyName') {
422
-            this.property.propertyName = item.value;
423
-          }
424
-          if (item.fieldName === 'unit') {
425
-            this.property.unit = item.value;
426
-          }
427
-          if (item.fieldName === 'addressLine1') {
428
-            this.property.addressLine1 = item.value;
429
-          }
430
-          if (item.fieldName === 'addressLine2') {
431
-            this.property.addressLine2 = item.value;
432
-          }
433
-          if (item.fieldName === 'addressLine3') {
434
-            this.property.addressLine3 = item.value;
435
-          }
436
-          if (item.fieldName === 'province') {
437
-            if (item.value !== '') {
438
-              this.property.province = this.provinces.find(
439
-                p => p.description === item.value,
440
-              );
441
-              this.property.provinceId = this.property.province.id;
442
-              this.getCities(Object.assign({}, { province: item.value }));
443
-              this.property.city = null;
444
-              this.property.suburb = null;
445
-              this.property.addressLine3 = '';
446
-            } else {
447
-              this.property.province = null;
448
-              this.property.city = null;
449
-              this.property.suburb = null;
450
-              this.property.addressLine3 = '';
451
-              this.cities = [];
452
-              this.suburbs = [];
453
-            }
454
-          }
455
-          if (item.fieldName === 'city') {
456
-            if (item.value !== '') {
457
-              const newCity = this.cities.find(
458
-                p => p.description === item.value,
459
-              );
460
-              this.property.city = newCity;
461
-              this.property.cityId = newCity.id;
462
-              this.getSuburbs(
463
-                Object.assign(
464
-                  {},
465
-                  {
466
-                    province: this.property.province.description,
467
-                    city: item.value,
468
-                  },
469
-                ),
470
-              );
471
-              this.property.suburb = null;
472
-              this.property.addressLine3 = '';
473
-            } else {
474
-              this.property.city = null;
475
-              this.property.suburb = null;
476
-              this.property.addressLine3 = '';
477
-              this.suburbs = [];
478
-            }
479
-          }
480
-          if (item.fieldName === 'suburb') {
481
-            if (item.value !== '') {
482
-              const newSuburb = this.suburbs.find(
483
-                p => p.description === item.value,
484
-              );
485
-              this.property.suburb = newSuburb;
486
-              this.property.suburbId = newSuburb.id;
487
-              this.property.addressLine3 = this.property.suburb.postalCode;
488
-            } else {
489
-              this.property.suburb = null;
490
-              this.property.addressLine3 = '';
491
-            }
492
-          }
493
-          if (item.fieldName === 'price') {
494
-            this.property.price = item.value;
495
-          }
496
-          if (item.fieldName === 'pricePer') {
497
-            this.property.pricePer = item.value;
498
-          }
499
-          if (item.fieldName === 'virtualTour') {
500
-            this.property.virtualTour = item.value;
501
-          }
502
-          if (item.fieldName === 'video') {
503
-            this.property.video = item.value;
504
-          }
505 463
         }
506 464
       }
507 465
     },
@@ -509,8 +467,28 @@ export default {
509 467
       this.propertyType = this.property.propertyUsageType;
510 468
     },
511 469
     SubmitData() {
512
-      this.wait = true;
470
+      if (this.property.propertyTypeId === 0) {
471
+        this.showPropertyTypeError = true;
472
+      }
473
+      if (this.property.province === null) {
474
+        this.showProvinceError = true;
475
+      }
476
+      if (this.property.city === null) {
477
+        this.showCityError = true;
478
+      }
479
+      if (this.property.suburb === null) {
480
+        this.showSuburbError = true;
481
+      }
513 482
 
483
+      if (
484
+        this.showPropertyTypeError
485
+        || this.showProvinceError
486
+        || this.showCityError
487
+        || this.showSuburbError
488
+      ) {
489
+        return;
490
+      }
491
+      this.wait = true;
514 492
       this.newPropertyImages.propertyId = this.property.id;
515 493
       this.newPropertyImages.Images = [];
516 494
       // eslint-disable-next-line no-plusplus
@@ -524,7 +502,6 @@ export default {
524 502
           isDefault: setAsDefault,
525 503
         });
526 504
       }
527
-
528 505
       this.property.propertyImages = this.propertyImages;
529 506
       // eslint-disable-next-line no-plusplus
530 507
       for (let i = 0; i < this.property.propertyImages.length; i++) {

+ 118
- 0
src/components/shared/fieldEditor.vue Bestand weergeven

@@ -0,0 +1,118 @@
1
+<template>
2
+  <div>
3
+    <div v-if="!edit" class="input-group-prepend">
4
+      <input class="form-control" v-model="myDisplay" disabled />
5
+      <span
6
+        v-if="mayEdit"
7
+        @click="EditClick()"
8
+        class="input-group-text spanCursor"
9
+        style="color: #60CBEB"
10
+      >
11
+        <eva-icon name="edit-outline" fill="#60CBEB"></eva-icon>
12
+      </span>
13
+    </div>
14
+    <div v-if="edit" class="input-group-prepend">
15
+      <input v-if="type === 'text'" class="form-control" v-model="value" />
16
+      <input v-if="type === 'number'" type="number" class="form-control" v-model="value" />
17
+      <select v-if="type === 'select'" class="form-control" @change="selectionClick">
18
+        <option>Please select</option>
19
+        <option
20
+          v-for="option in selectOptions"
21
+          :value="option[selectValue]"
22
+          :key="option[selectValue]"
23
+          >{{ option[selectText] }}</option
24
+        >
25
+      </select>
26
+      <select v-if="type === 'selectlist'" class="form-control" v-model="value">
27
+        <option v-for="item in selectOptions" :value="item" :key="item">{{ item }}</option>
28
+      </select>
29
+      <!-- <Datetime class="form-control" v-if="type === 'datetime'" v-model="value" /> -->
30
+      <span
31
+        v-if="edit"
32
+        @click="UpdateValue()"
33
+        class="input-group-text spanCursor"
34
+        style="color: #60CBEB"
35
+      >
36
+        <eva-icon name="checkmark-outline" fill="#60CBEB"></eva-icon>
37
+      </span>
38
+      <span v-if="edit" @click="Close()" class="input-group-text spanCursor" style="color: #60CBEB">
39
+        <eva-icon name="close-outline" fill="#60CBEB"></eva-icon>
40
+      </span>
41
+    </div>
42
+  </div>
43
+</template>
44
+
45
+<script>
46
+export default {
47
+  props: ['value', 'type', 'mayEdit', 'selectOptions', 'selectValue', 'selectText', 'display'],
48
+  data() {
49
+    return {
50
+      edit: false,
51
+      myDisplay: '',
52
+    };
53
+  },
54
+  methods: {
55
+    UpdateValue() {
56
+      this.edit = false;
57
+      if (this.type !== 'select' && this.value) {
58
+        this.$emit('input', this.value);
59
+        this.$emit('change', this.value);
60
+      }
61
+    },
62
+    EditClick() {
63
+      this.edit = true;
64
+    },
65
+    Close() {
66
+      this.edit = false;
67
+    },
68
+    selectionClick(item) {
69
+      if (item.target.options.selectedIndex > 0) {
70
+        if (!this.value) {
71
+          this.myDisplay = this.selectOptions[item.target.options.selectedIndex - 1][
72
+            this.selectText
73
+          ];
74
+        }
75
+        if (this.selectOptions[item.target.options.selectedIndex - 1]) {
76
+          this.$emit('input', this.selectOptions[item.target.options.selectedIndex - 1]);
77
+          this.$emit('change', this.selectOptions[item.target.options.selectedIndex - 1]);
78
+        }
79
+      }
80
+    },
81
+  },
82
+  mounted() {
83
+    if (this.value) {
84
+      // eslint-disable-next-line vue/no-side-effects-in-computed-properties
85
+      this.myDisplay = this.value;
86
+    }
87
+    if (this.value && this.selectText) {
88
+      // eslint-disable-next-line vue/no-side-effects-in-computed-properties
89
+      this.myDisplay = this.value[this.selectText];
90
+    }
91
+    if (this.display) {
92
+      this.myDisplay = this.display;
93
+    }
94
+  },
95
+  computed: {
96
+    // eslint-disable-next-line vue/return-in-computed-property
97
+    checkValue() {
98
+      if (this.value) {
99
+        // eslint-disable-next-line vue/no-side-effects-in-computed-properties
100
+        this.myDisplay = this.value;
101
+      }
102
+      if (this.value && this.selectText) {
103
+        // eslint-disable-next-line vue/no-side-effects-in-computed-properties
104
+        this.myDisplay = this.value[this.selectText];
105
+      }
106
+      if (this.display) {
107
+        // eslint-disable-next-line vue/no-side-effects-in-computed-properties
108
+        this.myDisplay = this.display;
109
+      }
110
+    },
111
+  },
112
+  watch: {
113
+    checkValue() {
114
+      return null;
115
+    },
116
+  },
117
+};
118
+</script>

Laden…
Annuleren
Opslaan