Browse Source

Commiting myweeks

master
Kobus 5 years ago
parent
commit
58f39a2443

+ 1
- 0
src/components/admin/misc/carousel.vue View File

1
+<!-- Work in Progress -->

+ 98
- 0
src/components/admin/misc/carouselList.vue View File

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 View File

98
   </div>
98
   </div>
99
 </template>
99
 </template>
100
 <script>
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
 </script>
114
 </script>

+ 2
- 9
src/components/property/propertyCreate.vue View File

21
           />
21
           />
22
         </div>
22
         </div>
23
         <div class="sinse-box" style="opacity:0.7; border: white solid 3px; border-radius: 15px">
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
         </div>
25
         </div>
26
       </div>
26
       </div>
27
       <br />
27
       <br />
349
               class="btn btn-b-n"
349
               class="btn btn-b-n"
350
               style="width: 85px; height:40px;"
350
               style="width: 85px; height:40px;"
351
             >Save</button>
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
             <div v-if="wait" id="preloader"></div>
352
             <div v-if="wait" id="preloader"></div>
360
           </form>
353
           </form>
361
         </div>
354
         </div>
372
 import ImageLoad from './propertyImage.vue';
365
 import ImageLoad from './propertyImage.vue';
373
 
366
 
374
 export default {
367
 export default {
375
-  name: 'PropertyEdit',
368
+  name: 'PropertyCreate',
376
   components: {
369
   components: {
377
     UserField,
370
     UserField,
378
     ImageLoad,
371
     ImageLoad,

+ 35
- 17
src/components/property/propertyFieldEditor.vue View File

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

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

11
           name="images[]"
11
           name="images[]"
12
           @change="imagesAdd"
12
           @change="imagesAdd"
13
           multiple
13
           multiple
14
+          :disabled="!mayEdit"
14
         />
15
         />
15
       </label>
16
       </label>
16
     </div>
17
     </div>
21
         <label for="checkbox" style="margin: 10px;">Main Image</label>
22
         <label for="checkbox" style="margin: 10px;">Main Image</label>
22
         <img :src="img" style="height:200px; width:150px; object-fit: cover;" />
23
         <img :src="img" style="height:200px; width:150px; object-fit: cover;" />
23
         <br />
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
       </div>
28
       </div>
26
       <br />
29
       <br />
27
     </div>
30
     </div>
32
 export default {
35
 export default {
33
   props: {
36
   props: {
34
     loadedImages: Function,
37
     loadedImages: Function,
38
+    mayEdit: { type: Boolean, default: () => true },
35
   },
39
   },
36
   data() {
40
   data() {
37
     return {
41
     return {

+ 0
- 7
src/components/property/propertyUserField.vue View File

65
       return '';
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
 </script>
69
 </script>

+ 342
- 125
src/components/property/propertyeditPage.vue View File

53
                 </div>
53
                 </div>
54
               </div>
54
               </div>
55
             </div>
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
             <div class="form-group row">
69
             <div class="form-group row">
57
               <div class="col-md-4">
70
               <div class="col-md-4">
58
                 <label>Property Type</label>
71
                 <label>Property Type</label>
59
                 <propField
72
                 <propField
60
-                  :display="property.propertyType.description"
61
-                  :editType="'Selector'"
73
+                  :display="property.propertyType ? property.propertyType.description : ''"
74
+                  :editType="'selector'"
62
                   :arrayObject="propertyTypes"
75
                   :arrayObject="propertyTypes"
76
+                  :propertyName="'propertyType'"
77
+                  :mayEdit="mayEdit"
78
+                  @UpdateValue="UpdateValue"
63
                 />
79
                 />
64
               </div>
80
               </div>
65
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
81
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
66
                 <label>Property Name</label>
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
               </div>
90
               </div>
69
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
91
               <div v-if="propertyType === 'Commercial'" class="col-md-4">
70
                 <label>Unit</label>
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
               </div>
101
               </div>
73
             </div>
102
             </div>
74
             <div class="form-group row">
103
             <div class="form-group row">
75
               <div class="col-md-6" style="margin-bottom: 1em">
104
               <div class="col-md-6" style="margin-bottom: 1em">
76
                 <label>Street Number</label>
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
               </div>
113
               </div>
79
               <div class="col-md-6" style="margin-bottom: 1em">
114
               <div class="col-md-6" style="margin-bottom: 1em">
80
                 <label>Street Name</label>
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
               </div>
123
               </div>
83
               <div class="col-md-6" style="margin-bottom: 1em">
124
               <div class="col-md-6" style="margin-bottom: 1em">
84
                 <label>Province</label>
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
               </div>
134
               </div>
87
 
135
 
88
               <div class="col-md-6" style="margin-bottom: 1em">
136
               <div class="col-md-6" style="margin-bottom: 1em">
89
                 <label>City</label>
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
               </div>
146
               </div>
92
               <div class="col-md-6" style="margin-bottom: 1em">
147
               <div class="col-md-6" style="margin-bottom: 1em">
93
                 <label>Suburb</label>
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
               </div>
157
               </div>
96
               <div class="col-md-6" style="margin-bottom: 1em">
158
               <div class="col-md-6" style="margin-bottom: 1em">
97
                 <label>Postal Code</label>
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
               </div>
167
               </div>
100
             </div>
168
             </div>
101
 
169
 
103
               <div class="col-md-6">
171
               <div class="col-md-6">
104
                 <label v-if="salesType === 'Rental'">Rental Price</label>
172
                 <label v-if="salesType === 'Rental'">Rental Price</label>
105
                 <label v-if="salesType !== 'Rental'">Sales Price</label>
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
               </div>
181
               </div>
108
               <div class="col-md-6" v-if="salesType === 'Rental'">
182
               <div class="col-md-6" v-if="salesType === 'Rental'">
109
                 <label>Per</label>
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
               </div>
192
               </div>
112
             </div>
193
             </div>
113
             <div class="form-group row">
194
             <div class="form-group row">
123
               class="col-md-6"
204
               class="col-md-6"
124
               v-if="propertyType === 'Residential' & propertyOverviewFields.length > 0"
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
                 <label>{{ item.name }}</label>
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
               </div>
220
               </div>
130
             </div>
221
             </div>
131
 
222
 
132
             <div class="form-group row" />
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
               <div class="row">
225
               <div class="row">
135
                 <div class="col-sm-12">
226
                 <div class="col-sm-12">
136
                   <div class="title-box-d">
227
                   <div class="title-box-d">
138
                   </div>
229
                   </div>
139
                 </div>
230
                 </div>
140
               </div>
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
                 <label>{{ field.name }}</label>
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
               </div>
245
               </div>
145
-              <!-- <UserField
146
-                :fields="item.fields"
147
-                :id="item.name"
148
-                @UpdateUserDefinedFields="UpdateUserDefinedFields"
149
-                :fieldValues="item.fields"
150
-              />-->
151
             </div>
246
             </div>
152
             <div class="form-group row" />
247
             <div class="form-group row" />
153
             <div class="row">
248
             <div class="row">
160
             <div class="form-group row">
255
             <div class="form-group row">
161
               <div class="col-md-12">
256
               <div class="col-md-12">
162
                 <label>Virtual Tour (URL)</label>
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
               </div>
265
               </div>
165
             </div>
266
             </div>
166
             <div class="form-group row">
267
             <div class="form-group row">
167
               <div class="col-md-12">
268
               <div class="col-md-12">
168
                 <label>Video (URL)</label>
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
               </div>
277
               </div>
171
             </div>
278
             </div>
172
             <div class="form-group row">
279
             <div class="form-group row">
176
               </div>
283
               </div>
177
             </div>
284
             </div>
178
             <div class="form-group row">
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
               </div>
309
               </div>
182
             </div>
310
             </div>
183
-            <ImageLoad :loadedImages="loadedImages" @DefaultImage="UpdateDefaultImage" />
311
+
312
+            <ImageLoad
313
+              :loadedImages="loadedImages"
314
+              @DefaultImage="UpdateDefaultImage"
315
+              :mayEdit="mayEdit"
316
+            />
184
             <button
317
             <button
185
               v-if="!wait"
318
               v-if="!wait"
186
               type="button"
319
               type="button"
187
               @click="SubmitData()"
320
               @click="SubmitData()"
188
               class="btn btn-b-n"
321
               class="btn btn-b-n"
189
               style="width: 85px; height:40px;"
322
               style="width: 85px; height:40px;"
323
+              :disabled="!mayEdit"
190
             >Save</button>
324
             >Save</button>
191
             <button
325
             <button
192
-              v-if="isEdit"
193
               type="button"
326
               type="button"
194
               @click="Close()"
327
               @click="Close()"
195
               class="btn btn-b-n"
328
               class="btn btn-b-n"
221
     return {
354
     return {
222
       propertyType: 'Residential',
355
       propertyType: 'Residential',
223
       salesType: 'Rental',
356
       salesType: 'Rental',
224
-      selectedProvince: '',
225
-      selectedCity: '',
226
       images: [],
357
       images: [],
227
       propertyFieldValues: [],
358
       propertyFieldValues: [],
228
       defaultImage: 0,
359
       defaultImage: 0,
240
         [{ script: 'sub' }, { script: 'super' }],
371
         [{ script: 'sub' }, { script: 'super' }],
241
         [{ indent: '-1' }, { indent: '+1' }],
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
   methods: {
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
       'getSavedPropertyData',
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
     TypeChanged() {
508
     TypeChanged() {
263
       this.propertyType = this.property.propertyUsageType;
509
       this.propertyType = this.property.propertyUsageType;
264
     },
510
     },
265
     SubmitData() {
511
     SubmitData() {
266
       this.wait = true;
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
       // eslint-disable-next-line no-plusplus
516
       // eslint-disable-next-line no-plusplus
271
       for (let i = 0; i < this.images.length; i++) {
517
       for (let i = 0; i < this.images.length; i++) {
272
         let setAsDefault = false;
518
         let setAsDefault = false;
273
         if (i === this.defaultImage) {
519
         if (i === this.defaultImage) {
274
           setAsDefault = true;
520
           setAsDefault = true;
275
         }
521
         }
276
-        this.property.propertyImages.push({
522
+        this.newPropertyImages.images.push({
277
           image: this.images[i],
523
           image: this.images[i],
278
           isDefault: setAsDefault,
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
     Close() {
550
     Close() {
301
       this.$router.push('/property/admin/list/my');
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
     loadedImages(values) {
553
     loadedImages(values) {
330
       this.images = values;
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
     UpdateDefaultImage(item) {
556
     UpdateDefaultImage(item) {
345
       this.defaultImage = item;
557
       this.defaultImage = item;
346
     },
558
     },
559
+    DeleteImage(image) {
560
+      this.propertyImages.find(item => item.id === image.id).isDeleted = true;
561
+    },
347
   },
562
   },
348
   mounted() {
563
   mounted() {
564
+    // Need to check this can remove unused code
349
     this.wait = false;
565
     this.wait = false;
350
-    this.clearProperty();
351
-    this.clearPropertyImages();
352
     this.images = [];
566
     this.images = [];
353
     this.defaultImage = 0;
567
     this.defaultImage = 0;
354
 
568
 
369
 
583
 
370
     this.getPropertyTypes(this.propertyType);
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
   computed: {
594
   computed: {
384
     ...mapState('searchTab', ['provinces', 'cities', 'suburbs']),
595
     ...mapState('searchTab', ['provinces', 'cities', 'suburbs']),
385
-    ...mapState('property', [
386
-      'propertyTypes',
596
+    ...mapState('property', ['propertyTypes']),
597
+    ...mapState('propertyEdit', [
387
       'propertyOverviewFields',
598
       'propertyOverviewFields',
388
       'propertyFields',
599
       'propertyFields',
389
       'property',
600
       'property',
390
       'propertyImages',
601
       'propertyImages',
602
+      'mayEdit',
603
+      'newPropertyImages',
391
     ]),
604
     ]),
392
     ...mapState('authentication', ['user']),
605
     ...mapState('authentication', ['user']),
393
     SalesTypeChanged() {
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
       if (this.property && this.property.propertyUsageType) {
607
       if (this.property && this.property.propertyUsageType) {
399
         // eslint-disable-next-line vue/no-side-effects-in-computed-properties
608
         // eslint-disable-next-line vue/no-side-effects-in-computed-properties
400
         this.propertyType = this.property.propertyUsageType;
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
       this.getPropertyTypes(this.propertyType);
614
       this.getPropertyTypes(this.propertyType);
416
   },
623
   },
417
 };
624
 };
418
 </script>
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>

+ 3
- 1
src/components/shared/navBar.vue View File

119
               </div>
119
               </div>
120
             </li>
120
             </li>
121
 
121
 
122
-            <li v-if="isLoggedIn" class="nav-item dropdown">
122
+            <li class="nav-item dropdown">
123
               <a
123
               <a
124
                 class="nav-link dropdown-toggle"
124
                 class="nav-link dropdown-toggle"
125
                 href="#"
125
                 href="#"
128
                 data-toggle="dropdown"
128
                 data-toggle="dropdown"
129
                 aria-haspopup="true"
129
                 aria-haspopup="true"
130
                 aria-expanded="false"
130
                 aria-expanded="false"
131
+                v-if="isLoggedIn"
131
               >Admin</a>
132
               >Admin</a>
132
               <div class="dropdown-menu" aria-labelledby="navbarDropdown">
133
               <div class="dropdown-menu" aria-labelledby="navbarDropdown">
133
                 <a class="dropdown-item cursor-pointer" @click="routerGoTo('/status/list')">Status</a>
134
                 <a class="dropdown-item cursor-pointer" @click="routerGoTo('/status/list')">Status</a>
164
                   @click="routerGoTo('/searchLog')"
165
                   @click="routerGoTo('/searchLog')"
165
                 >Search Logs</a>
166
                 >Search Logs</a>
166
                 <a class="dropdown-item cursor-pointer" @click="routerGoTo('/Offers')">Offers</a>
167
                 <a class="dropdown-item cursor-pointer" @click="routerGoTo('/Offers')">Offers</a>
168
+                <a class="dropdown-item cursor-pointer" @click="routerGoTo('/Carousel')">Carousel</a>
167
               </div>
169
               </div>
168
             </li>
170
             </li>
169
             <li class="nav-item dropdown" v-if="!isLoggedIn">
171
             <li class="nav-item dropdown" v-if="!isLoggedIn">

+ 12
- 0
src/router/index.js View File

48
 // import store from '../store';
48
 // import store from '../store';
49
 
49
 
50
 import TemplatePage from '../components/communication/templatePage.vue';
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
 Vue.use(Router);
54
 Vue.use(Router);
53
 
55
 
267
     name: 'SearchLog',
269
     name: 'SearchLog',
268
     component: searchLog,
270
     component: searchLog,
269
   },
271
   },
272
+  {
273
+    path: '/carousel',
274
+    name: 'carousel',
275
+    component: CarouselList,
276
+  },
277
+  {
278
+    path: '/carousel/details/:id',
279
+    name: 'CarouselDetails',
280
+    component: CarouselDetail,
281
+  },
270
   ],
282
   ],
271
 });
283
 });

+ 4
- 0
src/store/index.js View File

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

+ 31
- 0
src/store/modules/misc/carousel.js View File

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 View File

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

+ 143
- 0
src/store/modules/property/propertyEdit.js View File

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 View File

36
         .get(`/api/Suburb/${item.province}/${item.city}`)
36
         .get(`/api/Suburb/${item.province}/${item.city}`)
37
         .then(result => commit('setSuburbs', result.data));
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
 };

Loading…
Cancel
Save