Przeglądaj źródła

Prop Edit. & Carousel WIP

master
George Williams 5 lat temu
rodzic
commit
8b5ec4ed3f

+ 1
- 0
src/components/admin/misc/carousel.vue Wyświetl plik

@@ -0,0 +1 @@
1
+<!-- Work in Progress -->

+ 98
- 0
src/components/admin/misc/carouselList.vue Wyświetl plik

@@ -0,0 +1,98 @@
1
+<template>
2
+  <!-- eslint-disable max-len -->
3
+  <div>
4
+    <div class="container">
5
+      <!-- <section class="intro-single"> -->
6
+      <div class="container">
7
+        <br />
8
+        <br />
9
+        <div class="row">
10
+          <div class="col-md-12 col-lg-8">
11
+            <!-- <div class="title-single-box"> -->
12
+            <!-- <h1 class="title-single">Property Types</h1> -->
13
+            <!-- </div> -->
14
+            <div class="title-box-d">
15
+              <h1 class="title-d" style="text-align:left; font-size: 250%">Carousel Items</h1>
16
+            </div>
17
+            <br />
18
+          </div>
19
+        </div>
20
+      </div>
21
+      <!-- </section> -->
22
+    </div>
23
+    <div class="container">
24
+      <button type="button" @click="New()" class="btn btn-b-n" style="width: 85px; height:40px;">New</button>
25
+    </div>
26
+    <div class="container">
27
+      <table class="table table-bordered">
28
+        <thead>
29
+          <tr>
30
+            <th>Image</th>
31
+            <th>Header</th>
32
+            <th>Type</th>
33
+            <th></th>
34
+            <th></th>
35
+          </tr>
36
+        </thead>
37
+        <tbody>
38
+          <tr v-for="(item, i) in carouselList" :key="i">
39
+            <td>
40
+              <img :src="item.image" style="height:100px; width:100px; object-fit: cover;" />
41
+            </td>
42
+            <td>{{ item.header }}</td>
43
+            <td v-if="item.propertyId">Property</td>
44
+            <td v-else>Timeshare Week</td>
45
+            <td>
46
+              <button
47
+                type="button"
48
+                @click="Edit(item.id)"
49
+                class="btn"
50
+                style="margin:2px; color: #60CBEB"
51
+              >Edit</button>
52
+            </td>
53
+            <td>
54
+              <button
55
+                type="button"
56
+                @click="Delete(item.id)"
57
+                class="btn"
58
+                style="margin:2px; color: #60CBEB"
59
+              >Delete</button>
60
+            </td>
61
+          </tr>
62
+        </tbody>
63
+      </table>
64
+    </div>
65
+    <br />
66
+  </div>
67
+</template>
68
+
69
+<script>
70
+import { mapState, mapActions } from 'vuex';
71
+
72
+export default {
73
+  name: 'CarouselList',
74
+  data() {
75
+    return {};
76
+  },
77
+  methods: {
78
+    ...mapActions('carousel', ['getCarouselList', 'deleteCarousel']),
79
+    New() {
80
+      this.$router.push('/carousel/details/0');
81
+    },
82
+    Edit(itemID) {
83
+      this.$router.push({
84
+        path: `/carousel/details/${itemID}`,
85
+      });
86
+    },
87
+    Delete(id) {
88
+      this.deleteCarousel(id);
89
+    },
90
+  },
91
+  mounted() {
92
+    this.getCarouselList();
93
+  },
94
+  computed: {
95
+    ...mapState('carousel', ['carouselList']),
96
+  },
97
+};
98
+</script>

+ 13
- 1
src/components/home/carouselSection.vue Wyświetl plik

@@ -98,5 +98,17 @@
98 98
   </div>
99 99
 </template>
100 100
 <script>
101
-export default {};
101
+import { mapState, mapActions } from 'vuex';
102
+
103
+export default {
104
+  methods: {
105
+    ...mapActions('carousel', ['getCarouselList']),
106
+  },
107
+  mounted() {
108
+    this.getCarouselList();
109
+  },
110
+  computed: {
111
+    ...mapState('carousel', ['carouselList']),
112
+  },
113
+};
102 114
 </script>

+ 2
- 9
src/components/property/propertyCreate.vue Wyświetl plik

@@ -21,7 +21,7 @@
21 21
           />
22 22
         </div>
23 23
         <div class="sinse-box" style="opacity:0.7; border: white solid 3px; border-radius: 15px">
24
-          <h3 class="sinse-title">List {{ propertyType }} {{ salesType }} Property CREATE PAGE</h3>
24
+          <h3 class="sinse-title">List {{ propertyType }} {{ salesType }} Property</h3>
25 25
         </div>
26 26
       </div>
27 27
       <br />
@@ -349,13 +349,6 @@
349 349
               class="btn btn-b-n"
350 350
               style="width: 85px; height:40px;"
351 351
             >Save</button>
352
-            <button
353
-              v-if="isEdit"
354
-              type="button"
355
-              @click="Close()"
356
-              class="btn btn-b-n"
357
-              style="width: 85px; height:40px;"
358
-            >Close</button>
359 352
             <div v-if="wait" id="preloader"></div>
360 353
           </form>
361 354
         </div>
@@ -372,7 +365,7 @@ import UserField from './propertyUserField.vue';
372 365
 import ImageLoad from './propertyImage.vue';
373 366
 
374 367
 export default {
375
-  name: 'PropertyEdit',
368
+  name: 'PropertyCreate',
376 369
   components: {
377 370
     UserField,
378 371
     ImageLoad,

+ 35
- 17
src/components/property/propertyFieldEditor.vue Wyświetl plik

@@ -1,4 +1,5 @@
1 1
 <template>
2
+  <!-- eslint-disable max-len -->
2 3
   <div>
3 4
     <div>
4 5
       <div v-if="!edit" class="input-group-prepend">
@@ -10,7 +11,7 @@
10 11
           v-model="display"
11 12
           disabled
12 13
         />
13
-        <span @click="EditClick()" class="input-group-text" style="color: #60CBEB">
14
+        <span v-if="mayEdit" @click="EditClick()" class="input-group-text" style="color: #60CBEB">
14 15
           <eva-icon name="edit-outline" fill="#60CBEB"></eva-icon>
15 16
         </span>
16 17
       </div>
@@ -22,7 +23,7 @@
22 23
           type="text"
23 24
           name="currentField.name"
24 25
           id="currentField.id"
25
-          v-model="display"
26
+          v-model="updatedDisplay"
26 27
         />
27 28
         <!-- Number -->
28 29
         <input
@@ -31,7 +32,7 @@
31 32
           type="number"
32 33
           name="currentField.name"
33 34
           id="currentField.id"
34
-          v-model="display"
35
+          v-model="updatedDisplay"
35 36
         />
36 37
         <!-- Selector -->
37 38
         <select
@@ -40,7 +41,7 @@
40 41
           v-model="selectorSelection"
41 42
           @change="SelectorSelected"
42 43
         >
43
-          <option value="0">Please select type</option>
44
+          <option value="0"></option>
44 45
           <option v-for="item in arrayObject" :value="item.id" :key="item.id">{{ item.description }}</option>
45 46
         </select>
46 47
         <!-- yesno -->
@@ -49,7 +50,7 @@
49 50
           <option value="yes">Yes</option>
50 51
           <option value="no">No</option>
51 52
         </select>
52
-        <span @click="Save()" class="input-group-text" style="color: #60CBEB">
53
+        <span @click="UpdateValue()" class="input-group-text" style="color: #60CBEB">
53 54
           <eva-icon name="checkmark-outline" fill="#60CBEB"></eva-icon>
54 55
         </span>
55 56
         <span @click="Close()" class="input-group-text" style="color: #60CBEB">
@@ -65,46 +66,63 @@ export default {
65 66
   name: 'propertyFieldEdit',
66 67
   props: {
67 68
     display: String,
68
-    arrayObject: [],
69
+    arrayObject: { type: Array, default: () => [] },
69 70
     canEdit: Boolean,
70 71
     editType: String,
72
+    propertyName: String,
73
+    propertyId: Number,
74
+    userDefinedId: Number,
75
+    isUDF: Boolean,
76
+    isPropOverview: Boolean,
77
+    arrayIndex: Number,
78
+    arrayItemIndex: Number,
79
+    mayEdit: Boolean,
71 80
   },
72 81
   data() {
73 82
     return {
74 83
       edit: false,
75 84
       selectorSelection: Object,
85
+      updatedDisplay: '',
76 86
     };
77 87
   },
78 88
   methods: {
79 89
     EditClick() {
80 90
       this.edit = true;
81 91
     },
82
-    Save() {
83
-      this.edit = false;
84
-
85
-      // Need to emit the parent controller
86
-    },
87 92
     Close() {
88 93
       this.edit = false;
89 94
     },
90 95
     SelectorSelected(item) {
91 96
       if (item.target.options.selectedIndex > 0) {
92
-        this.display = this.arrayObject[
97
+        this.updatedDisplay = this.arrayObject[
93 98
           item.target.options.selectedIndex - 1
94 99
         ].description;
95
-        console.log(
96
-          this.arrayObject[item.target.options.selectedIndex - 1].description,
97
-        );
98 100
       }
99 101
     },
100 102
     YesNoSelected(item) {
101 103
       if (item.target.options.selectedIndex === 1) {
102
-        this.display = 'Yes';
104
+        this.updatedDisplay = 'Yes';
103 105
       }
104 106
       if (item.target.options.selectedIndex === 2) {
105
-        this.display = 'No';
107
+        this.updatedDisplay = 'No';
106 108
       }
107 109
     },
110
+    UpdateValue() {
111
+      this.edit = false;
112
+      this.$emit('UpdateValue', {
113
+        fieldName: this.propertyName,
114
+        value: this.updatedDisplay,
115
+        propertyId: this.propertyId,
116
+        userDefinedId: this.userDefinedId,
117
+        isUDF: this.isUDF,
118
+        isPropOverview: this.isPropOverview,
119
+        arrayIndex: this.arrayIndex,
120
+        arrayItemIndex: this.arrayItemIndex,
121
+      });
122
+    },
123
+  },
124
+  mounted() {
125
+    this.updatedDisplay = this.display;
108 126
   },
109 127
 };
110 128
 </script>

+ 5
- 1
src/components/property/propertyImage.vue Wyświetl plik

@@ -11,6 +11,7 @@
11 11
           name="images[]"
12 12
           @change="imagesAdd"
13 13
           multiple
14
+          :disabled="!mayEdit"
14 15
         />
15 16
       </label>
16 17
     </div>
@@ -21,7 +22,9 @@
21 22
         <label for="checkbox" style="margin: 10px;">Main Image</label>
22 23
         <img :src="img" style="height:200px; width:150px; object-fit: cover;" />
23 24
         <br />
24
-        <a class="fa fa-times del" @click="removeImage(key)" />
25
+        <span class="input-group-text" align="center" @click="removeImage(key)">
26
+          <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
27
+        </span>
25 28
       </div>
26 29
       <br />
27 30
     </div>
@@ -32,6 +35,7 @@
32 35
 export default {
33 36
   props: {
34 37
     loadedImages: Function,
38
+    mayEdit: { type: Boolean, default: () => true },
35 39
   },
36 40
   data() {
37 41
     return {

+ 0
- 7
src/components/property/propertyUserField.vue Wyświetl plik

@@ -65,12 +65,5 @@ export default {
65 65
       return '';
66 66
     },
67 67
   },
68
-  // Testing editing
69
-  // created() {
70
-  //   this.setFields = [];
71
-  //   for (let i = 0; i < this.fields.length; i++) {
72
-  //     this.setFields[i] = this.fields[i].value;
73
-  //   }
74
-  // },
75 68
 };
76 69
 </script>

+ 342
- 125
src/components/property/propertyeditPage.vue Wyświetl plik

@@ -53,49 +53,117 @@
53 53
                 </div>
54 54
               </div>
55 55
             </div>
56
+            <div class="form-group row">
57
+              <div class="col-md-4">
58
+                <label>Sale Type</label>
59
+                <propField
60
+                  :display="property.isSale ? 'Sale' : 'Rental'"
61
+                  :editType="'selector'"
62
+                  :arrayObject="salesTypeArr"
63
+                  :propertyName="'isSale'"
64
+                  :mayEdit="mayEdit"
65
+                  @UpdateValue="UpdateValue"
66
+                />
67
+              </div>
68
+            </div>
56 69
             <div class="form-group row">
57 70
               <div class="col-md-4">
58 71
                 <label>Property Type</label>
59 72
                 <propField
60
-                  :display="property.propertyType.description"
61
-                  :editType="'Selector'"
73
+                  :display="property.propertyType ? property.propertyType.description : ''"
74
+                  :editType="'selector'"
62 75
                   :arrayObject="propertyTypes"
76
+                  :propertyName="'propertyType'"
77
+                  :mayEdit="mayEdit"
78
+                  @UpdateValue="UpdateValue"
63 79
                 />
64 80
               </div>
65 81
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
66 82
                 <label>Property Name</label>
67
-                <propField :display="property.proeprtyName" :editType="'text'" />
83
+                <propField
84
+                  :display="property.propertyName"
85
+                  :editType="'text'"
86
+                  :propertyName="'propertyName'"
87
+                  :mayEdit="mayEdit"
88
+                  @UpdateValue="UpdateValue"
89
+                />
68 90
               </div>
69 91
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
70 92
                 <label>Unit</label>
71
-                <propField :label="'Property Type'" :display="property.unit" :editType="'text'" />
93
+                <propField
94
+                  :label="'Property Type'"
95
+                  :display="property.unit"
96
+                  :editType="'text'"
97
+                  :propertyName="'unit'"
98
+                  :mayEdit="mayEdit"
99
+                  @UpdateValue="UpdateValue"
100
+                />
72 101
               </div>
73 102
             </div>
74 103
             <div class="form-group row">
75 104
               <div class="col-md-6" style="margin-bottom: 1em">
76 105
                 <label>Street Number</label>
77
-                <propField :display="property.addressLine1" :editType="'text'" />
106
+                <propField
107
+                  :display="property.addressLine1"
108
+                  :editType="'text'"
109
+                  :propertyName="'addressLine1'"
110
+                  :mayEdit="mayEdit"
111
+                  @UpdateValue="UpdateValue"
112
+                />
78 113
               </div>
79 114
               <div class="col-md-6" style="margin-bottom: 1em">
80 115
                 <label>Street Name</label>
81
-                <propField :display="property.addressLine2" :editType="'text'" />
116
+                <propField
117
+                  :display="property.addressLine2"
118
+                  :editType="'text'"
119
+                  :propertyName="'addressLine2'"
120
+                  :mayEdit="mayEdit"
121
+                  @UpdateValue="UpdateValue"
122
+                />
82 123
               </div>
83 124
               <div class="col-md-6" style="margin-bottom: 1em">
84 125
                 <label>Province</label>
85
-                <propField :display="property.province.description" :editType="'selector'" />
126
+                <propField
127
+                  :display="property.province ? property.province.description : ''"
128
+                  :editType="'selector'"
129
+                  :arrayObject="provinces"
130
+                  :propertyName="'province'"
131
+                  :mayEdit="mayEdit"
132
+                  @UpdateValue="UpdateValue"
133
+                />
86 134
               </div>
87 135
 
88 136
               <div class="col-md-6" style="margin-bottom: 1em">
89 137
                 <label>City</label>
90
-                <propField :display="property.city.description" :editType="'selector'" />
138
+                <propField
139
+                  :display="property.city ? property.city.description : ''"
140
+                  :editType="'selector'"
141
+                  :arrayObject="cities"
142
+                  :propertyName="'city'"
143
+                  :mayEdit="mayEdit"
144
+                  @UpdateValue="UpdateValue"
145
+                />
91 146
               </div>
92 147
               <div class="col-md-6" style="margin-bottom: 1em">
93 148
                 <label>Suburb</label>
94
-                <propField :display="property.suburb.description" :editType="'selector'" />
149
+                <propField
150
+                  :display="property.suburb ? property.suburb.description : ''"
151
+                  :editType="'selector'"
152
+                  :arrayObject="suburbs"
153
+                  :propertyName="'suburb'"
154
+                  :mayEdit="mayEdit"
155
+                  @UpdateValue="UpdateValue"
156
+                />
95 157
               </div>
96 158
               <div class="col-md-6" style="margin-bottom: 1em">
97 159
                 <label>Postal Code</label>
98
-                <propField :display="property.addressLine3" :editType="'text'" />
160
+                <propField
161
+                  :display="property.addressLine3"
162
+                  :editType="'text'"
163
+                  :propertyName="'addressLine3'"
164
+                  :mayEdit="mayEdit"
165
+                  @UpdateValue="UpdateValue"
166
+                />
99 167
               </div>
100 168
             </div>
101 169
 
@@ -103,11 +171,24 @@
103 171
               <div class="col-md-6">
104 172
                 <label v-if="salesType === 'Rental'">Rental Price</label>
105 173
                 <label v-if="salesType !== 'Rental'">Sales Price</label>
106
-                <propField :display="property.price" :editType="'number'" />
174
+                <propField
175
+                  :display="String(property.price)"
176
+                  :editType="'number'"
177
+                  :propertyName="'price'"
178
+                  :mayEdit="mayEdit"
179
+                  @UpdateValue="UpdateValue"
180
+                />
107 181
               </div>
108 182
               <div class="col-md-6" v-if="salesType === 'Rental'">
109 183
                 <label>Per</label>
110
-                <propField :display="property.pricePer" :editType="'text'" />
184
+                <propField
185
+                  :display="property.pricePer"
186
+                  :editType="'selector'"
187
+                  :propertyName="'pricePer'"
188
+                  :arrayObject="pricePerArr"
189
+                  :mayEdit="mayEdit"
190
+                  @UpdateValue="UpdateValue"
191
+                />
111 192
               </div>
112 193
             </div>
113 194
             <div class="form-group row">
@@ -123,14 +204,24 @@
123 204
               class="col-md-6"
124 205
               v-if="propertyType === 'Residential' & propertyOverviewFields.length > 0"
125 206
             >
126
-              <div v-for="item in propertyOverviewFields[0].fields" :key="item.id">
207
+              <div v-for="(item, i) in propertyOverviewFields[0].fields" :key="item.id">
127 208
                 <label>{{ item.name }}</label>
128
-                <propField :display="item.value" :editType="item.type" />
209
+                <propField
210
+                  :display="item.value"
211
+                  :editType="item.type"
212
+                  :propertyId="item.itemID"
213
+                  :userDefinedId="item.id"
214
+                  :isUDF="Boolean('true')"
215
+                  :isPropOverview="Boolean('true')"
216
+                  :mayEdit="mayEdit"
217
+                  :arrayIndex="i"
218
+                  @UpdateValue="UpdateValue"
219
+                />
129 220
               </div>
130 221
             </div>
131 222
 
132 223
             <div class="form-group row" />
133
-            <div v-for="group in propertyFields" :key="group.id">
224
+            <div v-for="(group, i) in propertyFields" :key="group.id">
134 225
               <div class="row">
135 226
                 <div class="col-sm-12">
136 227
                   <div class="title-box-d">
@@ -138,16 +229,20 @@
138 229
                   </div>
139 230
                 </div>
140 231
               </div>
141
-              <div v-for="field in group.fields" :key="field.id">
232
+              <div v-for="(field, ii) in group.fields" :key="field.id">
142 233
                 <label>{{ field.name }}</label>
143
-                <propField :display="field.value" :editType="field.type" />
234
+                <propField
235
+                  :display="field.value"
236
+                  :editType="field.type"
237
+                  :propertyId="field.itemID"
238
+                  :userDefinedId="field.id"
239
+                  :isUDF="Boolean('true')"
240
+                  :arrayIndex="i"
241
+                  :arrayItemIndex="ii"
242
+                  :mayEdit="mayEdit"
243
+                  @UpdateValue="UpdateValue"
244
+                />
144 245
               </div>
145
-              <!-- <UserField
146
-                :fields="item.fields"
147
-                :id="item.name"
148
-                @UpdateUserDefinedFields="UpdateUserDefinedFields"
149
-                :fieldValues="item.fields"
150
-              />-->
151 246
             </div>
152 247
             <div class="form-group row" />
153 248
             <div class="row">
@@ -160,13 +255,25 @@
160 255
             <div class="form-group row">
161 256
               <div class="col-md-12">
162 257
                 <label>Virtual Tour (URL)</label>
163
-                <propField :display="property.virtualTour" :editType="'text'" />
258
+                <propField
259
+                  :display="property.virtualTour"
260
+                  :editType="'text'"
261
+                  :propertyName="'virtualTour'"
262
+                  :mayEdit="mayEdit"
263
+                  @UpdateValue="UpdateValue"
264
+                />
164 265
               </div>
165 266
             </div>
166 267
             <div class="form-group row">
167 268
               <div class="col-md-12">
168 269
                 <label>Video (URL)</label>
169
-                <propField :display="property.video" :editType="'text'" />
270
+                <propField
271
+                  :display="property.video"
272
+                  :editType="'text'"
273
+                  :propertyName="'video'"
274
+                  :mayEdit="mayEdit"
275
+                  @UpdateValue="UpdateValue"
276
+                />
170 277
               </div>
171 278
             </div>
172 279
             <div class="form-group row">
@@ -176,20 +283,46 @@
176 283
               </div>
177 284
             </div>
178 285
             <div class="form-group row">
179
-              <div class="col-md-6" v-for="(img, i) in propertyImages" :key="i">
180
-                <img :src="img" style="height:200px; width:150px; object-fit: cover;" />
286
+              <div class="col-md-2" v-for="(img, i) in propertyImages" :key="i">
287
+                <input
288
+                  v-if="mayEdit"
289
+                  type="checkbox"
290
+                  id="checkbox"
291
+                  v-model="img.isDefault"
292
+                  :disabled="img.isDeleted"
293
+                />
294
+                <label v-if="mayEdit" for="checkbox" style="margin: 10px;">Main Image</label>
295
+                <br />
296
+                <img
297
+                  :src="img.image"
298
+                  style="height:200px; width:150px; object-fit: cover;"
299
+                  :class="[img.isDeleted ? 'opacity' : '']"
300
+                />
301
+                <span
302
+                  v-if="!img.isDeleted && mayEdit"
303
+                  class="input-group-text"
304
+                  align="center"
305
+                  @click="DeleteImage(img)"
306
+                >
307
+                  <eva-icon name="trash-2-outline" fill="#60CBEB"></eva-icon>Delete
308
+                </span>
181 309
               </div>
182 310
             </div>
183
-            <ImageLoad :loadedImages="loadedImages" @DefaultImage="UpdateDefaultImage" />
311
+
312
+            <ImageLoad
313
+              :loadedImages="loadedImages"
314
+              @DefaultImage="UpdateDefaultImage"
315
+              :mayEdit="mayEdit"
316
+            />
184 317
             <button
185 318
               v-if="!wait"
186 319
               type="button"
187 320
               @click="SubmitData()"
188 321
               class="btn btn-b-n"
189 322
               style="width: 85px; height:40px;"
323
+              :disabled="!mayEdit"
190 324
             >Save</button>
191 325
             <button
192
-              v-if="isEdit"
193 326
               type="button"
194 327
               @click="Close()"
195 328
               class="btn btn-b-n"
@@ -221,8 +354,6 @@ export default {
221 354
     return {
222 355
       propertyType: 'Residential',
223 356
       salesType: 'Rental',
224
-      selectedProvince: '',
225
-      selectedCity: '',
226 357
       images: [],
227 358
       propertyFieldValues: [],
228 359
       defaultImage: 0,
@@ -240,115 +371,198 @@ export default {
240 371
         [{ script: 'sub' }, { script: 'super' }],
241 372
         [{ indent: '-1' }, { indent: '+1' }],
242 373
       ],
243
-      isEdit: false,
374
+      salesTypeArr: [
375
+        { id: 1, description: 'Sale' },
376
+        { id: 2, description: 'Rental' },
377
+      ],
378
+      pricePerArr: [
379
+        { id: 'Month', description: 'Month' },
380
+        { id: 'Day', description: 'Day' },
381
+      ],
244 382
     };
245 383
   },
246 384
   methods: {
247
-    ...mapActions('searchTab', ['getProvince', 'getCities', 'getSuburbs']),
248
-    ...mapActions('property', [
249
-      'getPropertyTypes',
250
-      'getPropertyOverviewFields',
251
-      'getPropertyFields',
252
-      'saveProperty',
253
-      'getProperty',
254
-      'getPropertyImages',
255
-      'clearProperty',
256
-      'clearPropertyImages',
257
-      'getPropertyEditDisplay',
258
-      'getPropertySavedOverviewFields',
259
-      'getPropertySavedFields',
385
+    ...mapActions('searchTab', [
386
+      'getProvince',
387
+      'getCities',
388
+      'getSuburbs',
389
+      'getListsForPropertyEdit',
390
+    ]),
391
+    ...mapActions('property', ['getPropertyTypes']),
392
+    ...mapActions('propertyEdit', [
260 393
       'getSavedPropertyData',
394
+      'updateProperty',
395
+      'mayEditProperty',
261 396
     ]),
397
+    UpdateValue(item) {
398
+      if (item.isUDF) {
399
+        if (item.isPropOverview) {
400
+          this.propertyOverviewFields[0].fields[item.arrayIndex].value =            item.value;
401
+        } else if (item.isPropOverview === false) {
402
+          this.propertyFields[item.arrayIndex].fields[
403
+            item.arrayItemIndex
404
+          ].value = item.value;
405
+        }
406
+      } else if (!item.isUDF) {
407
+        if (item.fieldName) {
408
+          if (item.fieldName === 'isSale') {
409
+            let isSaleValue = false;
410
+            if (item.value === 'Sale') {
411
+              isSaleValue = true;
412
+            } else isSaleValue = false;
413
+            this.property.isSale = isSaleValue;
414
+          }
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
+        }
506
+      }
507
+    },
262 508
     TypeChanged() {
263 509
       this.propertyType = this.property.propertyUsageType;
264 510
     },
265 511
     SubmitData() {
266 512
       this.wait = true;
267
-      if (this.salesType === 'Sale') {
268
-        this.property.isSale = true;
269
-      }
513
+
514
+      this.newPropertyImages.propertyId = this.property.id;
515
+      this.newPropertyImages.Images = [];
270 516
       // eslint-disable-next-line no-plusplus
271 517
       for (let i = 0; i < this.images.length; i++) {
272 518
         let setAsDefault = false;
273 519
         if (i === this.defaultImage) {
274 520
           setAsDefault = true;
275 521
         }
276
-        this.property.propertyImages.push({
522
+        this.newPropertyImages.images.push({
277 523
           image: this.images[i],
278 524
           isDefault: setAsDefault,
279 525
         });
280 526
       }
281
-      this.property.propertyUserFields = this.propertyFieldValues;
282 527
 
283
-      if (this.property.id === 0) {
284
-        this.property.userId = this.user.id;
285
-        this.saveProperty(this.property);
286
-        setTimeout(
287
-          () => this.$router.push({
288
-              path: '/property/Search',
289
-              query: {
290
-                salesType: this.salesType,
291
-                propertyUsageType: this.propertyType,
292
-              },
293
-            }),
294
-          3000,
295
-        );
296
-      } else {
297
-        setTimeout(() => this.$router.push('/property/admin/list/my'), 3000);
528
+      this.property.propertyImages = this.propertyImages;
529
+      // eslint-disable-next-line no-plusplus
530
+      for (let i = 0; i < this.property.propertyImages.length; i++) {
531
+        this.property.propertyImages[i].image = '';
298 532
       }
533
+      this.property.propertyOverviewFields = this.propertyOverviewFields;
534
+      this.property.propertyFields = this.propertyFields;
535
+      this.updateProperty({
536
+        property: this.property,
537
+        images: this.newPropertyImages,
538
+      });
539
+
540
+      // console.log(JSON.stringify(this.newPropertyImages));
541
+
542
+      // Need to change to promis.
543
+      setTimeout(
544
+        () => this.$router.push({
545
+            path: '/property/admin/list/my',
546
+          }),
547
+        5000,
548
+      );
299 549
     },
300 550
     Close() {
301 551
       this.$router.push('/property/admin/list/my');
302 552
     },
303
-    ProvinceSelected(item) {
304
-      if (item.target.options.selectedIndex > 0) {
305
-        this.selectedProvince = this.provinces[
306
-          item.target.options.selectedIndex - 1
307
-        ].description;
308
-        this.getCities(Object.assign({}, { province: this.selectedProvince }));
309
-      }
310
-    },
311
-    CitySelected(item) {
312
-      if (item.target.options.selectedIndex > 0) {
313
-        this.selectedCity = this.cities[
314
-          item.target.options.selectedIndex - 1
315
-        ].description;
316
-        this.getSuburbs(
317
-          Object.assign(
318
-            {},
319
-            { province: this.selectedProvince, city: this.selectedCity },
320
-          ),
321
-        );
322
-      }
323
-    },
324
-    getPostalCode(item) {
325
-      this.property.addressLine3 = this.suburbs[
326
-        item.target.options.selectedIndex - 1
327
-      ].postalCode;
328
-    },
329 553
     loadedImages(values) {
330 554
       this.images = values;
331 555
     },
332
-    UpdateUserDefinedFields(item) {
333
-      let update = false;
334
-      this.propertyFieldValues.forEach((element) => {
335
-        if (element.userDefinedFieldId === item.userDefinedFieldId) {
336
-          element.value = item.value;
337
-          update = true;
338
-        }
339
-      });
340
-      if (!update) {
341
-        this.propertyFieldValues.push(item);
342
-      }
343
-    },
344 556
     UpdateDefaultImage(item) {
345 557
       this.defaultImage = item;
346 558
     },
559
+    DeleteImage(image) {
560
+      this.propertyImages.find(item => item.id === image.id).isDeleted = true;
561
+    },
347 562
   },
348 563
   mounted() {
564
+    // Need to check this can remove unused code
349 565
     this.wait = false;
350
-    this.clearProperty();
351
-    this.clearPropertyImages();
352 566
     this.images = [];
353 567
     this.defaultImage = 0;
354 568
 
@@ -369,39 +583,32 @@ export default {
369 583
 
370 584
     this.getPropertyTypes(this.propertyType);
371 585
 
372
-    this.getProvince();
373
-    if (this.$route.query.id) {
374
-      this.getSavedPropertyData(
375
-        Object.assign({}, { id: this.$route.query.id, type: this.propertyType }),
376
-      );
377
-      this.isEdit = true;
378
-    } else {
379
-      this.getPropertyOverviewFields();
380
-      this.getPropertyFields(this.propertyType);
381
-    }
586
+    this.getListsForPropertyEdit(this.$route.query.id);
587
+
588
+    this.getSavedPropertyData(
589
+      Object.assign({}, { id: this.$route.query.id, type: this.propertyType }),
590
+    );
591
+
592
+    this.mayEditProperty(this.$route.query.id);
382 593
   },
383 594
   computed: {
384 595
     ...mapState('searchTab', ['provinces', 'cities', 'suburbs']),
385
-    ...mapState('property', [
386
-      'propertyTypes',
596
+    ...mapState('property', ['propertyTypes']),
597
+    ...mapState('propertyEdit', [
387 598
       'propertyOverviewFields',
388 599
       'propertyFields',
389 600
       'property',
390 601
       'propertyImages',
602
+      'mayEdit',
603
+      'newPropertyImages',
391 604
     ]),
392 605
     ...mapState('authentication', ['user']),
393 606
     SalesTypeChanged() {
394
-      // eslint-disable-next-line vue/no-side-effects-in-computed-properties
395
-      // this.propertyType = this.$route.params.propType;
396
-      // eslint-disable-next-line vue/no-side-effects-in-computed-properties
397
-      this.salesType = this.$route.params.saleType;
398 607
       if (this.property && this.property.propertyUsageType) {
399 608
         // eslint-disable-next-line vue/no-side-effects-in-computed-properties
400 609
         this.propertyType = this.property.propertyUsageType;
401
-      }
402
-
403
-      if (!this.$route.query.id) {
404
-        this.getPropertyFields(this.propertyType);
610
+        // eslint-disable-next-line vue/no-side-effects-in-computed-properties
611
+        this.salesType = this.property.isSale ? 'Sale' : 'Rental';
405 612
       }
406 613
 
407 614
       this.getPropertyTypes(this.propertyType);
@@ -416,3 +623,13 @@ export default {
416 623
   },
417 624
 };
418 625
 </script>
626
+
627
+<style>
628
+span {
629
+  cursor: pointer;
630
+}
631
+.opacity {
632
+  opacity: 0.5;
633
+  filter: alpha(opacity=50);
634
+}
635
+</style>

+ 1
- 0
src/components/shared/navBar.vue Wyświetl plik

@@ -165,6 +165,7 @@
165 165
                   @click="routerGoTo('/searchLog')"
166 166
                 >Search Logs</a>
167 167
                 <a class="dropdown-item cursor-pointer" @click="routerGoTo('/Offers')">Offers</a>
168
+                <a class="dropdown-item cursor-pointer" @click="routerGoTo('/Carousel')">Carousel</a>
168 169
               </div>
169 170
             </li>
170 171
             <li class="nav-item dropdown" v-if="!isLoggedIn">

+ 12
- 0
src/router/index.js Wyświetl plik

@@ -48,6 +48,8 @@ import searchLog from '../components/admin/logs/SearchLogs.vue';
48 48
 // import store from '../store';
49 49
 
50 50
 import TemplatePage from '../components/communication/templatePage.vue';
51
+import CarouselList from '../components/admin/misc/carouselList.vue';
52
+import CarouselDetail from '../components/admin/misc/carousel.vue';
51 53
 
52 54
 Vue.use(Router);
53 55
 
@@ -262,5 +264,15 @@ export default new Router({
262 264
       name: 'SearchLog',
263 265
       component: searchLog,
264 266
     },
267
+    {
268
+      path: '/carousel',
269
+      name: 'carousel',
270
+      component: CarouselList,
271
+    },
272
+    {
273
+      path: '/carousel/details/:id',
274
+      name: 'CarouselDetails',
275
+      component: CarouselDetail,
276
+    },
265 277
   ],
266 278
 });

+ 4
- 0
src/store/index.js Wyświetl plik

@@ -22,6 +22,8 @@ import PropertySearch from './modules/property/propertySearch';
22 22
 import SearchLog from './modules/logs/searchLog';
23 23
 import Template from './modules/communication/template';
24 24
 import Info from './modules/communication/info';
25
+import PropertyEdit from './modules/property/propertyEdit';
26
+import Carousel from './modules/misc/carousel';
25 27
 
26 28
 Vue.use(Vuex);
27 29
 /* eslint no-param-reassign: ["error", { "props": false }] */
@@ -48,5 +50,7 @@ export default new Vuex.Store({
48 50
     searchLog: SearchLog,
49 51
     template: Template,
50 52
     info: Info,
53
+    propertyEdit: PropertyEdit,
54
+    carousel: Carousel,
51 55
   },
52 56
 });

+ 31
- 0
src/store/modules/misc/carousel.js Wyświetl plik

@@ -0,0 +1,31 @@
1
+import axios from 'axios';
2
+
3
+export default {
4
+  namespaced: true,
5
+  state: {
6
+    carouselList: [],
7
+  },
8
+  mutations: {
9
+    setCarouselList(state, items) {
10
+      state.carouselList = items;
11
+    },
12
+    removeCarousel(state, id) {
13
+      state.carouselList.pop(state.carouselList.find(p => p.id === id));
14
+    },
15
+  },
16
+  getters: {},
17
+  actions: {
18
+    getCarouselList({ commit }) {
19
+      axios
20
+        .get('/api/Carousel')
21
+        .then(result => commit('setCarouselList', result.data))
22
+        .catch(console.error);
23
+    },
24
+    deleteCarousel({ commit }, id) {
25
+      axios
26
+        .delete(`/api/Carousel/${id}`)
27
+        .then(commit('removeCarousel', id))
28
+        .catch(console.error);
29
+    },
30
+  },
31
+};

+ 3
- 3
src/store/modules/property/property.js Wyświetl plik

@@ -103,7 +103,7 @@ export default {
103 103
     },
104 104
     getPropertyImages({ commit }, id) {
105 105
       axios
106
-        .get(`/api/PropertyImage/getPropertyImages/${id}`)
106
+        .get(`/api/PropertyImage/GetImagesByProperty/${id}`)
107 107
         .then(result => commit('setPropertyImages', result.data))
108 108
         .catch(console.error);
109 109
     },
@@ -164,12 +164,12 @@ export default {
164 164
       commit('clearPropertyImages');
165 165
 
166 166
       axios
167
-        .get(`/api/Property/getproperty/${item.id}`)
167
+        .get(`/api/Property/getProperty/${item.id}`)
168 168
         .then(result => commit('setProperty', result.data))
169 169
         .catch(console.error);
170 170
 
171 171
       axios
172
-        .get(`/api/PropertyImage/getPropertyImages/${item.id}`)
172
+        .get(`/api/PropertyImage/GetProperySavedImages/${item.id}`)
173 173
         .then(result => commit('setPropertyImages', result.data))
174 174
         .catch(console.error);
175 175
 

+ 143
- 0
src/store/modules/property/propertyEdit.js Wyświetl plik

@@ -0,0 +1,143 @@
1
+import axios from 'axios';
2
+
3
+export default {
4
+  namespaced: true,
5
+  state: {
6
+    property: {
7
+      createdBy: '',
8
+      propertyTypeId: 0,
9
+      propertyName: '',
10
+      unit: '',
11
+      operationalCosts: 0.0,
12
+      price: 0,
13
+      pricePer: '',
14
+      isSale: false,
15
+      description: '',
16
+      shortDescription: '',
17
+      addressLine1: '',
18
+      addressLine2: '',
19
+      addressLine3: '',
20
+      suburbId: 0,
21
+      cityId: 0,
22
+      provinceId: 0,
23
+      published: false,
24
+      propertyUserFields: [],
25
+      propertyImages: [],
26
+      newImages: [],
27
+      id: 0,
28
+      virtualTour: '',
29
+      video: '',
30
+      userId: 0,
31
+    },
32
+    propertyImages: [],
33
+    propertyTypes: [],
34
+    propertyTypesRes: [],
35
+    propertyTypesCom: [],
36
+    propertyOverviewFields: [],
37
+    propertyFields: [],
38
+    mayEdit: false,
39
+    newPropertyImages: {
40
+      propertyId: 0,
41
+      images: [],
42
+    },
43
+  },
44
+  mutations: {
45
+    setProperty(state, property) {
46
+      state.property = property;
47
+    },
48
+    setPropertyImages(state, images) {
49
+      state.propertyImages = images;
50
+    },
51
+    setPropertyOverviewFields(state, fields) {
52
+      state.propertyOverviewFields = fields;
53
+    },
54
+    setPropertyFields(state, fields) {
55
+      state.propertyFields = fields;
56
+    },
57
+    setMayEdit(state, data) {
58
+      state.mayEdit = data;
59
+    },
60
+    clearProperty(state) {
61
+      state.property = {
62
+        createdBy: '',
63
+        propertyTypeId: 0,
64
+        propertyName: '',
65
+        unit: '',
66
+        operationalCosts: 0.0,
67
+        price: 0,
68
+        pricePer: '',
69
+        isSale: false,
70
+        description: '',
71
+        shortDescription: '',
72
+        addressLine1: '',
73
+        addressLine2: '',
74
+        addressLine3: '',
75
+        suburbId: 0,
76
+        cityId: 0,
77
+        provinceId: 0,
78
+        published: false,
79
+        propertyOverviewFields: [],
80
+        propertyFields: [],
81
+        propertyImages: [],
82
+        newImages: [],
83
+        id: 0,
84
+        virtualTour: '',
85
+        video: '',
86
+        userId: 0,
87
+      };
88
+    },
89
+    clearPropertyImages(state) {
90
+      state.propertyImages = [];
91
+    },
92
+    ClearNewImages(state) {
93
+      state.newPropertyImages = {
94
+        propertyId: 0,
95
+        images: [],
96
+      };
97
+    },
98
+  },
99
+  getters: {},
100
+  actions: {
101
+    getSavedPropertyData({ commit }, item) {
102
+      commit('clearProperty');
103
+      commit('clearPropertyImages');
104
+
105
+      axios
106
+        .get(`/api/Property/getProperty/${item.id}`)
107
+        .then(result => commit('setProperty', result.data))
108
+        .catch(console.error);
109
+
110
+      axios
111
+        .get(`/api/PropertyImage/GetProperySavedImages/${item.id}`)
112
+        .then(result => commit('setPropertyImages', result.data))
113
+        .catch(console.error);
114
+
115
+      axios
116
+        .get(`/api/PropertyFields/GetSavedValues/Residential/Property Overview/${item.id}`)
117
+        .then(response => commit('setPropertyOverviewFields', response.data))
118
+        .catch(console.error);
119
+
120
+      axios
121
+        .get(`/api/PropertyFields/GetSavedValues/${item.type}/All/${item.id}`)
122
+        .then(response => commit('setPropertyFields', response.data))
123
+        .catch(console.error);
124
+    },
125
+    updateProperty({ commit }, item) {
126
+      axios
127
+        .post('/api/PropertyImage', item.images)
128
+        .then(commit('ClearNewImages'))
129
+        .catch(console.error);
130
+
131
+      axios
132
+        .put('/api/Property', item.property)
133
+        .then(commit('setProperty', item.property))
134
+        .catch(console.error);
135
+    },
136
+    mayEditProperty({ commit }, id) {
137
+      axios
138
+        .get(`/api/property/MayEditProperty/${id}`)
139
+        .then(response => commit('setMayEdit', response.data))
140
+        .catch(console.error);
141
+    },
142
+  },
143
+};

+ 16
- 0
src/store/modules/searchTab.js Wyświetl plik

@@ -36,5 +36,21 @@ export default {
36 36
         .get(`/api/Suburb/${item.province}/${item.city}`)
37 37
         .then(result => commit('setSuburbs', result.data));
38 38
     },
39
+    getListsForPropertyEdit({ commit }, propertyId) {
40
+      axios
41
+        .get('/api/province')
42
+        .then(result => commit('setProvince', result.data))
43
+        .catch(console.error);
44
+
45
+      axios
46
+        .get(`/api/City/GetByProperty/${propertyId}`)
47
+        .then(result => commit('setCities', result.data))
48
+        .catch(console.error);
49
+
50
+      axios
51
+        .get(`/api/Suburb/GetByProperty/${propertyId}`)
52
+        .then(result => commit('setSuburbs', result.data))
53
+        .catch(console.error);
54
+    },
39 55
   },
40 56
 };

Ładowanie…
Anuluj
Zapisz