Parcourir la source

Dispose property objects when closing edit page

master
GJWilliams87 il y a 4 ans
Parent
révision
e8fc671aaf
1 fichiers modifiés avec 106 ajouts et 36 suppressions
  1. 106
    36
      src/components/property/editProperty/editProperty.vue

+ 106
- 36
src/components/property/editProperty/editProperty.vue Voir le fichier

@@ -6,7 +6,7 @@
6 6
           <div class="col-12">
7 7
             <h1>Property Details</h1>
8 8
           </div>
9
-          <main id="main" style="margin-top:-20px">
9
+          <main id="main" style="margin-top: -20px">
10 10
             <div class="container pt-5 pb-5">
11 11
               <div class="row my-3">
12 12
                 <div class="col-md-6">
@@ -26,14 +26,18 @@
26 26
                     v-model="property.statusString"
27 27
                     @change="StatusChanged"
28 28
                   >
29
-                    <option v-for="(item, i) in Statuses" :key="i">{{ item }}</option>
29
+                    <option v-for="(item, i) in Statuses" :key="i">
30
+                      {{ item }}
31
+                    </option>
30 32
                   </select>
31 33
                 </div>
32 34
               </div>
33 35
               <div class="row my-3">
34 36
                 <div class="col-md-6">
35 37
                   <div v-if="!property.propertyName">
36
-                    <label for="propertyName" class="uniSelectLabel">PROPERTY NAME</label>
38
+                    <label for="propertyName" class="uniSelectLabel"
39
+                      >PROPERTY NAME</label
40
+                    >
37 41
                   </div>
38 42
                   <input
39 43
                     class="form-control uniInput"
@@ -45,7 +49,9 @@
45 49
                 </div>
46 50
                 <div class="col-md-6">
47 51
                   <div v-if="!property.propertyRef">
48
-                    <label for="propertyName" class="uniSelectLabel">PROPERTY REFERENCE</label>
52
+                    <label for="propertyName" class="uniSelectLabel"
53
+                      >PROPERTY REFERENCE</label
54
+                    >
49 55
                   </div>
50 56
                   <input
51 57
                     class="form-control uniInput"
@@ -66,12 +72,19 @@
66 72
                     :disabled="!canEdit"
67 73
                   >
68 74
                     <option value="0">Please select type *</option>
69
-                    <option v-for="item in propertyTypes" :value="item.id" :key="item.id">
75
+                    <option
76
+                      v-for="item in propertyTypes"
77
+                      :value="item.id"
78
+                      :key="item.id"
79
+                    >
70 80
                       {{ item.description }}
71 81
                     </option>
72 82
                   </select>
73 83
                 </div>
74
-                <div v-if="property.propertyUsageType === 'Commercial'" class="col-md-2">
84
+                <div
85
+                  v-if="property.propertyUsageType === 'Commercial'"
86
+                  class="col-md-2"
87
+                >
75 88
                   <div v-if="!property.unit">
76 89
                     <label for="unit" class="uniSelectLabel">UNIT</label>
77 90
                   </div>
@@ -95,7 +108,7 @@
95 108
                   <input
96 109
                     type="checkbox"
97 110
                     v-model="property.showAddress"
98
-                    style="margin-right: 10px; margin-top: 10px;"
111
+                    style="margin-right: 10px; margin-top: 10px"
99 112
                     :disabled="!canEdit"
100 113
                   />
101 114
                   <label>Show address on listing</label>
@@ -107,7 +120,11 @@
107 120
                         <label
108 121
                           for="price"
109 122
                           class="uniSelectLabel"
110
-                          style="text-transform:uppercase; margin-left:17px; background-color:white"
123
+                          style="
124
+                            text-transform: uppercase;
125
+                            margin-left: 17px;
126
+                            background-color: white;
127
+                          "
111 128
                           >{{ property.salesTypeString }} Price</label
112 129
                         >
113 130
                       </div>
@@ -149,7 +166,8 @@
149 166
                   <div
150 167
                     class="row my-3"
151 168
                     v-if="
152
-                      property.statusString === 'Sold' || property.statusString === 'Rented Out'
169
+                      property.statusString === 'Sold' ||
170
+                      property.statusString === 'Rented Out'
153 171
                     "
154 172
                   >
155 173
                     <div class="col-md-12">
@@ -169,7 +187,9 @@
169 187
                   <div class="row my-3">
170 188
                     <div class="col-md-12">
171 189
                       <div v-if="!property.streetNumber">
172
-                        <label for="streetNumber" class="uniSelectLabel">STREET NUMBER</label>
190
+                        <label for="streetNumber" class="uniSelectLabel"
191
+                          >STREET NUMBER</label
192
+                        >
173 193
                       </div>
174 194
                       <input
175 195
                         class="form-control uniInput"
@@ -184,7 +204,9 @@
184 204
                   <div class="row my-3">
185 205
                     <div class="col-md-12">
186 206
                       <div v-if="!property.streetName">
187
-                        <label for="streetName" class="uniSelectLabel">STREET NAME</label>
207
+                        <label for="streetName" class="uniSelectLabel"
208
+                          >STREET NAME</label
209
+                        >
188 210
                       </div>
189 211
                       <input
190 212
                         class="form-control uniInput"
@@ -199,7 +221,9 @@
199 221
                   <div class="row my-3">
200 222
                     <div class="col-md-12">
201 223
                       <div v-if="!property.suburb">
202
-                        <label for="suburb" class="uniSelectLabel">SUBURB</label>
224
+                        <label for="suburb" class="uniSelectLabel"
225
+                          >SUBURB</label
226
+                        >
203 227
                       </div>
204 228
                       <input
205 229
                         class="form-control uniInput"
@@ -229,7 +253,9 @@
229 253
                   <div class="row my-3">
230 254
                     <div class="col-md-12">
231 255
                       <div v-if="!property.province">
232
-                        <label for="province" class="uniSelectLabel">PROVINCE</label>
256
+                        <label for="province" class="uniSelectLabel"
257
+                          >PROVINCE</label
258
+                        >
233 259
                       </div>
234 260
                       <input
235 261
                         class="form-control uniInput"
@@ -244,7 +270,9 @@
244 270
                   <div class="row my-3">
245 271
                     <div class="col-md-12">
246 272
                       <div v-if="!property.postalCode">
247
-                        <label for="postalCode" class="uniSelectLabel">POSTAL CODE</label>
273
+                        <label for="postalCode" class="uniSelectLabel"
274
+                          >POSTAL CODE</label
275
+                        >
248 276
                       </div>
249 277
                       <input
250 278
                         class="form-control uniInput"
@@ -259,7 +287,9 @@
259 287
                   <div class="row my-3">
260 288
                     <div class="col-md-12">
261 289
                       <div v-if="!property.country">
262
-                        <label for="country" class="uniSelectLabel">COUNTRY</label>
290
+                        <label for="country" class="uniSelectLabel"
291
+                          >COUNTRY</label
292
+                        >
263 293
                       </div>
264 294
                       <input
265 295
                         class="form-control uniInput"
@@ -273,7 +303,11 @@
273 303
                   </div>
274 304
                   <div class="row my-3">
275 305
                     <div class="col-md-12">
276
-                      <button type="button" @click="clearAddress()" class="btn-solid-blue">
306
+                      <button
307
+                        type="button"
308
+                        @click="clearAddress()"
309
+                        class="btn-solid-blue"
310
+                      >
277 311
                         Clear Address
278 312
                       </button>
279 313
                     </div>
@@ -282,8 +316,13 @@
282 316
               </div>
283 317
               <div class="row">
284 318
                 <div class="col-md-12">
285
-                  <label for="Property Description" style="font-family:'muli'">Description:</label>
286
-                  <vue-editor v-model="property.description" :editor-toolbar="customToolbar" />
319
+                  <label for="Property Description" style="font-family: 'muli'"
320
+                    >Description:</label
321
+                  >
322
+                  <vue-editor
323
+                    v-model="property.description"
324
+                    :editor-toolbar="customToolbar"
325
+                  />
287 326
                   <br />
288 327
                 </div>
289 328
               </div>
@@ -291,8 +330,16 @@
291 330
                 <div class="section-header">
292 331
                   <h2>Property Information</h2>
293 332
                 </div>
294
-                <div class="row mb-3" v-for="item in propertyFields" :key="item.id">
295
-                  <div class="col-md-6" v-for="field in item.fields" :key="field.id">
333
+                <div
334
+                  class="row mb-3"
335
+                  v-for="item in propertyFields"
336
+                  :key="item.id"
337
+                >
338
+                  <div
339
+                    class="col-md-6"
340
+                    v-for="field in item.fields"
341
+                    :key="field.id"
342
+                  >
296 343
                     <div v-if="field.type === 'number'">
297 344
                       {{ field.name }}
298 345
                       <input
@@ -313,7 +360,11 @@
313 360
                     </div>
314 361
                     <div v-else-if="field.type === 'yesno'">
315 362
                       {{ field.name }}
316
-                      <input type="checkbox" v-model="field.value" :disabled="!canEdit" />
363
+                      <input
364
+                        type="checkbox"
365
+                        v-model="field.value"
366
+                        :disabled="!canEdit"
367
+                      />
317 368
                     </div>
318 369
                     <div v-else class="display:none"></div>
319 370
                   </div>
@@ -345,7 +396,9 @@
345 396
               </div>
346 397
               <div class="row mt-3">
347 398
                 <div class="col-md-12 mt-2">
348
-                  <label v-if="!property.video" class="uniSelectLabel">Video (URL)</label>
399
+                  <label v-if="!property.video" class="uniSelectLabel"
400
+                    >Video (URL)</label
401
+                  >
349 402
                   <float-label label="Video (URL)">
350 403
                     <input
351 404
                       class="form-control uniInput"
@@ -374,10 +427,20 @@
374 427
                 @DeleteImage="DeleteImage"
375 428
                 :mayEdit="canEdit"
376 429
               />
377
-              <button v-if="!wait" type="button" @click="SubmitData()" class="btn-solid-blue">
430
+              <button
431
+                v-if="!wait"
432
+                type="button"
433
+                @click="SubmitData()"
434
+                class="btn-solid-blue"
435
+              >
378 436
                 Save
379 437
               </button>
380
-              <button v-if="!wait" type="button" @click="Close()" class="btn-solid-blue">
438
+              <button
439
+                v-if="!wait"
440
+                type="button"
441
+                @click="Close()"
442
+                class="btn-solid-blue"
443
+              >
381 444
                 Close
382 445
               </button>
383 446
               <div v-if="!addressSet">
@@ -405,7 +468,7 @@ export default {
405 468
   components: {
406 469
     mapSection,
407 470
     ImageLoad,
408
-    VueEditor
471
+    VueEditor,
409 472
   },
410 473
   data() {
411 474
     return {
@@ -417,11 +480,16 @@ export default {
417 480
       customToolbar: [
418 481
         [{ header: [false, 1, 2, 3, 4, 5, 6] }],
419 482
         ["bold", "italic", "underline", "strike"],
420
-        [{ align: "" }, { align: "center" }, { align: "right" }, { align: "justify" }],
483
+        [
484
+          { align: "" },
485
+          { align: "center" },
486
+          { align: "right" },
487
+          { align: "justify" },
488
+        ],
421 489
         [{ list: "ordered" }, { list: "bullet" }, { list: "check" }],
422 490
         [{ script: "sub" }, { script: "super" }],
423
-        [{ indent: "-1" }, { indent: "+1" }]
424
-      ]
491
+        [{ indent: "-1" }, { indent: "+1" }],
492
+      ],
425 493
     };
426 494
   },
427 495
   methods: {
@@ -429,7 +497,7 @@ export default {
429 497
       "getProperty",
430 498
       "getPropertyTypes",
431 499
       "getPropertyFields",
432
-      "updateProperty"
500
+      "updateProperty",
433 501
     ]),
434 502
     StatusChanged(item) {
435 503
       if (
@@ -492,7 +560,7 @@ export default {
492 560
         }
493 561
         this.property.newImages.push({
494 562
           image: this.images[i],
495
-          isDefault: setAsDefault
563
+          isDefault: setAsDefault,
496 564
         });
497 565
       }
498 566
 
@@ -500,11 +568,13 @@ export default {
500 568
 
501 569
       //console.log(JSON.stringify(this.property));
502 570
 
503
-      this.updateProperty(this.property).then(fulfilled => {
571
+      this.updateProperty(this.property).then((fulfilled) => {
504 572
         this.$router.push("/PropertyAdmin");
505 573
       });
506 574
     },
507 575
     Close() {
576
+      this.property = {};
577
+      this.propertyImages = [];
508 578
       this.$router.push("/PropertyAdmin");
509 579
     },
510 580
     updateLocation(place) {
@@ -521,10 +591,10 @@ export default {
521 591
     },
522 592
     DeleteImage(item) {
523 593
       this.propertyImages[item].isDeleted = true;
524
-    }
594
+    },
525 595
   },
526 596
   mounted() {
527
-    this.getProperty(this.$route.params.id).then(fulfilled => {
597
+    this.getProperty(this.$route.params.id).then((fulfilled) => {
528 598
       this.wait = false;
529 599
       if (
530 600
         this.property.statusString === "Offer Pending" ||
@@ -543,7 +613,7 @@ export default {
543 613
       "propertyTypes",
544 614
       "propertyImages",
545 615
       "propertyFields",
546
-      "statuses"
616
+      "statuses",
547 617
     ]),
548 618
     savedImages() {
549 619
       const list = [];
@@ -563,8 +633,8 @@ export default {
563 633
         }
564 634
       }
565 635
       return list;
566
-    }
567
-  }
636
+    },
637
+  },
568 638
 };
569 639
 </script>
570 640
 

Chargement…
Annuler
Enregistrer