Kobus Botha 5 years ago
parent
commit
1c749bcd64

+ 70
- 5
src/components/property/propertyCreate.vue View File

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

+ 4
- 4
src/components/property/propertyFieldEditor.vue View File

47
           @change="SelectorSelected"
47
           @change="SelectorSelected"
48
         >
48
         >
49
           <option value="0"></option>
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
         </select>
53
         </select>
52
         <!-- yesno -->
54
         <!-- yesno -->
53
         <select v-if="editType === 'yesno'" class="form-control" @change="YesNoSelected">
55
         <select v-if="editType === 'yesno'" class="form-control" @change="YesNoSelected">
99
     },
101
     },
100
     SelectorSelected(item) {
102
     SelectorSelected(item) {
101
       if (item.target.options.selectedIndex > 0) {
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
     YesNoSelected(item) {
107
     YesNoSelected(item) {

+ 1
- 1
src/components/property/propertyImage.vue View File

28
         <label v-if="allowMultiple" for="checkbox" style="margin: 10px;">Main Image</label>
28
         <label v-if="allowMultiple" for="checkbox" style="margin: 10px;">Main Image</label>
29
         <img :src="img" style="height:200px; width:150px; object-fit: cover;" />
29
         <img :src="img" style="height:200px; width:150px; object-fit: cover;" />
30
         <br />
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
           <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
32
           <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
33
         </span>
33
         </span>
34
       </div>
34
       </div>

+ 15
- 13
src/components/property/propertySearchFields.vue View File

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

+ 163
- 186
src/components/property/propertyeditPage.vue View File

35
       <div class="row mb-3">
35
       <div class="row mb-3">
36
         <div class="container col-md-10" style="text-align:left">
36
         <div class="container col-md-10" style="text-align:left">
37
           <form id="mainForm">
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
             <div class="form-goup row">
43
             <div class="form-goup row">
39
               <div class="col-md-4">
44
               <div class="col-md-4">
40
                 <label>Usage Type</label>
45
                 <label>Usage Type</label>
41
                 <div class="input-group-prepend">
46
                 <div class="input-group-prepend">
42
-                  <!-- <span class="input-group-text" style="color: #60CBEB">
43
-                    <b>U</b>
44
-                  </span>-->
45
                   <input
47
                   <input
46
                     class="form-control"
48
                     class="form-control"
47
                     type="text"
49
                     type="text"
53
                 </div>
55
                 </div>
54
               </div>
56
               </div>
55
             </div>
57
             </div>
58
+            <br />
56
             <div class="form-group row">
59
             <div class="form-group row">
57
               <div class="col-md-4">
60
               <div class="col-md-4">
58
                 <label>Sale Type</label>
61
                 <label>Sale Type</label>
64
                   :mayEdit="mayEdit"
67
                   :mayEdit="mayEdit"
65
                   @UpdateValue="UpdateValue"
68
                   @UpdateValue="UpdateValue"
66
                 />
69
                 />
70
+                <div v-if="showPropertyTypeError">
71
+                  <p class="alert myError">Please select a Sales Type</p>
72
+                </div>
67
               </div>
73
               </div>
68
             </div>
74
             </div>
69
             <div class="form-group row">
75
             <div class="form-group row">
70
               <div class="col-md-4">
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
                   :mayEdit="mayEdit"
84
                   :mayEdit="mayEdit"
78
-                  @UpdateValue="UpdateValue"
79
                 />
85
                 />
80
               </div>
86
               </div>
81
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
87
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
82
                 <label>Property Name</label>
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
               </div>
90
               </div>
91
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
91
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
92
                 <label>Unit</label>
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
               </div>
94
               </div>
102
             </div>
95
             </div>
103
             <div class="form-group row">
96
             <div class="form-group row">
104
               <div class="col-md-6" style="margin-bottom: 1em">
97
               <div class="col-md-6" style="margin-bottom: 1em">
105
                 <label>Street Number</label>
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
               </div>
100
               </div>
114
               <div class="col-md-6" style="margin-bottom: 1em">
101
               <div class="col-md-6" style="margin-bottom: 1em">
115
                 <label>Street Name</label>
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
               </div>
104
               </div>
124
               <div class="col-md-6" style="margin-bottom: 1em">
105
               <div class="col-md-6" style="margin-bottom: 1em">
125
-                <label>Province</label>
126
-                <propField
106
+                <label>Province *</label>
107
+                <!-- <propField
127
                   :display="property.province ? property.province.description : ''"
108
                   :display="property.province ? property.province.description : ''"
128
                   :editType="'selector'"
109
                   :editType="'selector'"
129
                   :arrayObject="provinces"
110
                   :arrayObject="provinces"
130
                   :propertyName="'province'"
111
                   :propertyName="'province'"
131
                   :mayEdit="mayEdit"
112
                   :mayEdit="mayEdit"
132
                   @UpdateValue="UpdateValue"
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
               </div>
127
               </div>
135
-
136
               <div class="col-md-6" style="margin-bottom: 1em">
128
               <div class="col-md-6" style="margin-bottom: 1em">
137
-                <label>City</label>
138
-                <propField
129
+                <label>City *</label>
130
+                <!-- <propField
139
                   :display="property.city ? property.city.description : ''"
131
                   :display="property.city ? property.city.description : ''"
140
                   :editType="'selector'"
132
                   :editType="'selector'"
141
                   :arrayObject="cities"
133
                   :arrayObject="cities"
142
                   :propertyName="'city'"
134
                   :propertyName="'city'"
143
                   :mayEdit="mayEdit"
135
                   :mayEdit="mayEdit"
144
                   @UpdateValue="UpdateValue"
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
               </div>
150
               </div>
147
               <div class="col-md-6" style="margin-bottom: 1em">
151
               <div class="col-md-6" style="margin-bottom: 1em">
148
-                <label>Suburb</label>
149
-                <propField
152
+                <label>Suburb *</label>
153
+                <!-- <propField
150
                   :display="property.suburb ? property.suburb.description : ''"
154
                   :display="property.suburb ? property.suburb.description : ''"
151
                   :editType="'selector'"
155
                   :editType="'selector'"
152
                   :arrayObject="suburbs"
156
                   :arrayObject="suburbs"
153
                   :propertyName="'suburb'"
157
                   :propertyName="'suburb'"
154
                   :mayEdit="mayEdit"
158
                   :mayEdit="mayEdit"
155
                   @UpdateValue="UpdateValue"
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
               </div>
173
               </div>
158
               <div class="col-md-6" style="margin-bottom: 1em">
174
               <div class="col-md-6" style="margin-bottom: 1em">
159
                 <label>Postal Code</label>
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
               </div>
177
               </div>
168
             </div>
178
             </div>
169
 
179
 
171
               <div class="col-md-6">
181
               <div class="col-md-6">
172
                 <label v-if="salesType === 'Rental'">Rental Price</label>
182
                 <label v-if="salesType === 'Rental'">Rental Price</label>
173
                 <label v-if="salesType !== 'Rental'">Sales Price</label>
183
                 <label v-if="salesType !== 'Rental'">Sales Price</label>
174
-                <propField
184
+                <field :type="'number'" v-model="property.price" :mayEdit="mayEdit" />
185
+                <!-- <propField
175
                   :display="String(property.price)"
186
                   :display="String(property.price)"
176
                   :editType="'number'"
187
                   :editType="'number'"
177
                   :propertyName="'price'"
188
                   :propertyName="'price'"
178
                   :mayEdit="mayEdit"
189
                   :mayEdit="mayEdit"
179
                   @UpdateValue="UpdateValue"
190
                   @UpdateValue="UpdateValue"
180
-                />
191
+                />-->
181
               </div>
192
               </div>
182
               <div class="col-md-6" v-if="salesType === 'Rental'">
193
               <div class="col-md-6" v-if="salesType === 'Rental'">
183
                 <label>Per</label>
194
                 <label>Per</label>
184
-                <propField
195
+                <!-- <propField
185
                   :display="property.pricePer"
196
                   :display="property.pricePer"
186
                   :editType="'selector'"
197
                   :editType="'selector'"
187
                   :propertyName="'pricePer'"
198
                   :propertyName="'pricePer'"
188
                   :arrayObject="pricePerArr"
199
                   :arrayObject="pricePerArr"
189
                   :mayEdit="mayEdit"
200
                   :mayEdit="mayEdit"
190
                   @UpdateValue="UpdateValue"
201
                   @UpdateValue="UpdateValue"
202
+                />-->
203
+                <field
204
+                  :type="'selectlist'"
205
+                  :selectOptions="pricePerArr"
206
+                  v-model="property.pricePer"
207
+                  :mayEdit="mayEdit"
191
                 />
208
                 />
192
               </div>
209
               </div>
193
             </div>
210
             </div>
196
                 <label for="Property Description">Description</label>
213
                 <label for="Property Description">Description</label>
197
                 <vue-editor v-model="property.description" :editor-toolbar="customToolbar" />
214
                 <vue-editor v-model="property.description" :editor-toolbar="customToolbar" />
198
                 <br />
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
               </div>
220
               </div>
201
             </div>
221
             </div>
202
             <div class="form-group row" />
222
             <div class="form-group row" />
203
             <div
223
             <div
204
               class="col-md-6"
224
               class="col-md-6"
205
-              v-if="propertyType === 'Residential' & propertyOverviewFields.length > 0"
225
+              v-if="(propertyType === 'Residential') & (propertyOverviewFields.length > 0)"
206
             >
226
             >
207
               <div v-for="(item, i) in propertyOverviewFields[0].fields" :key="item.id">
227
               <div v-for="(item, i) in propertyOverviewFields[0].fields" :key="item.id">
208
                 <label>{{ item.name }}</label>
228
                 <label>{{ item.name }}</label>
243
                   @UpdateValue="UpdateValue"
263
                   @UpdateValue="UpdateValue"
244
                 />
264
                 />
245
               </div>
265
               </div>
266
+              <br />
246
             </div>
267
             </div>
247
             <div class="form-group row" />
268
             <div class="form-group row" />
248
             <div class="row">
269
             <div class="row">
255
             <div class="form-group row">
276
             <div class="form-group row">
256
               <div class="col-md-12">
277
               <div class="col-md-12">
257
                 <label>Virtual Tour (URL)</label>
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
               </div>
280
               </div>
266
             </div>
281
             </div>
267
             <div class="form-group row">
282
             <div class="form-group row">
268
               <div class="col-md-12">
283
               <div class="col-md-12">
269
                 <label>Video (URL)</label>
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
               </div>
286
               </div>
278
             </div>
287
             </div>
279
             <div class="form-group row">
288
             <div class="form-group row">
303
                   class="input-group-text spanCursor"
312
                   class="input-group-text spanCursor"
304
                   align="center"
313
                   align="center"
305
                   @click="DeleteImage(img)"
314
                   @click="DeleteImage(img)"
315
+                  style="width:150px"
306
                 >
316
                 >
307
                   <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
317
                   <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
308
                 </span>
318
                 </span>
321
               class="btn btn-b-n"
331
               class="btn btn-b-n"
322
               style="width: 85px; height:40px;"
332
               style="width: 85px; height:40px;"
323
               :disabled="!mayEdit"
333
               :disabled="!mayEdit"
324
-            >Save</button>
334
+            >
335
+              Save
336
+            </button>
325
             <button
337
             <button
326
               type="button"
338
               type="button"
327
               @click="Close()"
339
               @click="Close()"
328
               class="btn btn-b-n"
340
               class="btn btn-b-n"
329
               style="width: 85px; height:40px;"
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
             <div v-if="wait" id="preloader"></div>
355
             <div v-if="wait" id="preloader"></div>
332
           </form>
356
           </form>
333
         </div>
357
         </div>
339
 <script>
363
 <script>
340
 import { mapState, mapActions } from 'vuex';
364
 import { mapState, mapActions } from 'vuex';
341
 import { VueEditor } from 'vue2-editor';
365
 import { VueEditor } from 'vue2-editor';
342
-import { setTimeout } from 'timers';
343
 import ImageLoad from './propertyImage.vue';
366
 import ImageLoad from './propertyImage.vue';
344
 import propField from './propertyFieldEditor.vue';
367
 import propField from './propertyFieldEditor.vue';
368
+import field from '../shared/fieldEditor.vue';
345
 
369
 
346
 export default {
370
 export default {
347
   name: 'PropertyEdit',
371
   name: 'PropertyEdit',
349
     ImageLoad,
373
     ImageLoad,
350
     VueEditor,
374
     VueEditor,
351
     propField,
375
     propField,
376
+    field,
352
   },
377
   },
353
   data() {
378
   data() {
354
     return {
379
     return {
361
       customToolbar: [
386
       customToolbar: [
362
         [{ header: [false, 1, 2, 3, 4, 5, 6] }],
387
         [{ header: [false, 1, 2, 3, 4, 5, 6] }],
363
         ['bold', 'italic', 'underline', 'strike'],
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
         [{ list: 'ordered' }, { list: 'bullet' }, { list: 'check' }],
390
         [{ list: 'ordered' }, { list: 'bullet' }, { list: 'check' }],
371
         [{ script: 'sub' }, { script: 'super' }],
391
         [{ script: 'sub' }, { script: 'super' }],
372
         [{ indent: '-1' }, { indent: '+1' }],
392
         [{ indent: '-1' }, { indent: '+1' }],
375
         { id: 1, description: 'Sale' },
395
         { id: 1, description: 'Sale' },
376
         { id: 2, description: 'Rental' },
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
   methods: {
406
   methods: {
389
       'getListsForPropertyEdit',
411
       'getListsForPropertyEdit',
390
     ]),
412
     ]),
391
     ...mapActions('property', ['getPropertyTypes']),
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
     UpdateValue(item) {
447
     UpdateValue(item) {
398
       if (item.isUDF) {
448
       if (item.isUDF) {
399
         if (item.isPropOverview) {
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
         } else if (item.isPropOverview === false) {
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
       } else if (!item.isUDF) {
454
       } else if (!item.isUDF) {
407
         if (item.fieldName) {
455
         if (item.fieldName) {
412
             } else isSaleValue = false;
460
             } else isSaleValue = false;
413
             this.property.isSale = isSaleValue;
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
       this.propertyType = this.property.propertyUsageType;
467
       this.propertyType = this.property.propertyUsageType;
510
     },
468
     },
511
     SubmitData() {
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
       this.newPropertyImages.propertyId = this.property.id;
492
       this.newPropertyImages.propertyId = this.property.id;
515
       this.newPropertyImages.Images = [];
493
       this.newPropertyImages.Images = [];
516
       // eslint-disable-next-line no-plusplus
494
       // eslint-disable-next-line no-plusplus
524
           isDefault: setAsDefault,
502
           isDefault: setAsDefault,
525
         });
503
         });
526
       }
504
       }
527
-
528
       this.property.propertyImages = this.propertyImages;
505
       this.property.propertyImages = this.propertyImages;
529
       // eslint-disable-next-line no-plusplus
506
       // eslint-disable-next-line no-plusplus
530
       for (let i = 0; i < this.property.propertyImages.length; i++) {
507
       for (let i = 0; i < this.property.propertyImages.length; i++) {

+ 118
- 0
src/components/shared/fieldEditor.vue View File

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>

Loading…
Cancel
Save