You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

editProperty.vue 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. <template>
  2. <div>
  3. <main id="main">
  4. <section id="services">
  5. <div class="container">
  6. <div class="col-12">
  7. <h1>Property Details</h1>
  8. </div>
  9. <main id="main" style="margin-top:-20px">
  10. <div class="container pt-5 pb-5">
  11. <div class="row my-3">
  12. <div class="col-md-6">
  13. <select
  14. class="form-control uniSelect"
  15. v-model="property.propertyUsageType"
  16. @change="UpdateUsageType"
  17. :disabled="!canEdit"
  18. >
  19. <option>Commercial</option>
  20. <option>Residential</option>
  21. </select>
  22. </div>
  23. <div class="col-md-6">
  24. <select
  25. class="form-control uniSelect"
  26. v-model="property.statusString"
  27. @change="StatusChanged"
  28. >
  29. <option v-for="(item, i) in statuses" :key="i">{{ item }}</option>
  30. </select>
  31. </div>
  32. </div>
  33. <div class="row my-3">
  34. <div class="col-md-6">
  35. <div v-if="!property.propertyName">
  36. <label for="propertyName" class="uniSelectLabel">PROPERTY NAME</label>
  37. </div>
  38. <input
  39. class="form-control uniInput"
  40. type="text"
  41. name="propertyName"
  42. v-model="property.propertyName"
  43. :disabled="!canEdit"
  44. />
  45. </div>
  46. <div class="col-md-6">
  47. <div v-if="!property.propertyRef">
  48. <label for="propertyName" class="uniSelectLabel">PROPERTY REFERENCE</label>
  49. </div>
  50. <input
  51. class="form-control uniInput"
  52. type="text"
  53. name="propertyRef"
  54. v-model="property.propertyRef"
  55. :disabled="!canEdit"
  56. />
  57. </div>
  58. </div>
  59. <div class="row my-3">
  60. <div class="col-md-6">
  61. <select
  62. class="form-control uniSelect"
  63. name="propertyType"
  64. id="propertyType"
  65. v-model="property.propertyTypeId"
  66. :disabled="!canEdit"
  67. >
  68. <option value="0">Please select type *</option>
  69. <option v-for="item in propertyTypes" :value="item.id" :key="item.id">
  70. {{
  71. item.description
  72. }}
  73. </option>
  74. </select>
  75. </div>
  76. <div v-if="property.propertyUsageType === 'Commercial'" class="col-md-2">
  77. <div v-if="!property.unit">
  78. <label for="unit" class="uniSelectLabel">UNIT</label>
  79. </div>
  80. <input
  81. class="form-control uniInput"
  82. type="text"
  83. name="unit"
  84. id="unit"
  85. v-model="property.unit"
  86. :disabled="!canEdit"
  87. />
  88. </div>
  89. </div>
  90. <div class="row my-3">
  91. <div class="col-md-6">
  92. <mapSection
  93. v-on:map-location="updateLocation"
  94. :savedCoords="property.propertCoords"
  95. :canEdit="canEdit"
  96. />
  97. <input
  98. type="checkbox"
  99. v-model="property.showAddress"
  100. style="margin-right: 10px; margin-top: 10px;"
  101. :disabled="!canEdit"
  102. />
  103. <label>Show address on listing</label>
  104. </div>
  105. <div class="col-md-6">
  106. <div class="row">
  107. <div class="col-md-6">
  108. <div v-if="property.price < 1">
  109. <label
  110. for="price"
  111. class="uniSelectLabel"
  112. style="text-transform:uppercase; margin-left:17px; background-color:white"
  113. >{{ property.salesTypeString }} Price</label>
  114. </div>
  115. <input
  116. class="form-control uniInput"
  117. type="number"
  118. name="price"
  119. id="price"
  120. v-model="property.price"
  121. :disabled="!canEdit"
  122. />
  123. </div>
  124. <div v-if="!property.isSale" class="col-md-6">
  125. <select
  126. class="form-control uniSelect"
  127. name="propertyType"
  128. id="propertyType"
  129. v-model="property.pricePer"
  130. :disabled="!canEdit"
  131. >
  132. <option value>Please select</option>
  133. <option value="Month">Month</option>
  134. <option value="Day">Day</option>
  135. </select>
  136. </div>
  137. </div>
  138. <div class="row my-3">
  139. <div class="col-md-12">
  140. <input
  141. type="date"
  142. class="form-control uniInput"
  143. name="date"
  144. v-model="property.dateAvailableString"
  145. :disabled="!canEdit"
  146. />
  147. </div>
  148. </div>
  149. <div class="row my-3">
  150. <br />
  151. </div>
  152. <div class="row my-3">
  153. <div class="col-md-12">
  154. <div v-if="!property.streetNumber">
  155. <label for="streetNumber" class="uniSelectLabel">STREET NUMBER</label>
  156. </div>
  157. <input
  158. class="form-control uniInput"
  159. type="text"
  160. name="streetNumber"
  161. id="unit"
  162. v-model="property.streetNumber"
  163. :disabled="!canEdit"
  164. />
  165. </div>
  166. </div>
  167. <div class="row my-3">
  168. <div class="col-md-12">
  169. <div v-if="!property.streetName">
  170. <label for="streetName" class="uniSelectLabel">STREET NAME</label>
  171. </div>
  172. <input
  173. class="form-control uniInput"
  174. type="text"
  175. name="streetName"
  176. id="unit"
  177. v-model="property.streetName"
  178. :disabled="!canEdit"
  179. />
  180. </div>
  181. </div>
  182. <div class="row my-3">
  183. <div class="col-md-12">
  184. <div v-if="!property.suburb">
  185. <label for="suburb" class="uniSelectLabel">SUBURB</label>
  186. </div>
  187. <input
  188. class="form-control uniInput"
  189. type="text"
  190. name="suburb"
  191. id="unit"
  192. v-model="property.suburb"
  193. :disabled="!canEdit"
  194. />
  195. </div>
  196. </div>
  197. <div class="row my-3">
  198. <div class="col-md-12">
  199. <div v-if="!property.city">
  200. <label for="city" class="uniSelectLabel">CITY</label>
  201. </div>
  202. <input
  203. class="form-control uniInput"
  204. type="text"
  205. name="city"
  206. id="unit"
  207. v-model="property.city"
  208. :disabled="!canEdit"
  209. />
  210. </div>
  211. </div>
  212. <div class="row my-3">
  213. <div class="col-md-12">
  214. <div v-if="!property.province">
  215. <label for="province" class="uniSelectLabel">PROVINCE</label>
  216. </div>
  217. <input
  218. class="form-control uniInput"
  219. type="text"
  220. name="province"
  221. id="unit"
  222. v-model="property.province"
  223. :disabled="!canEdit"
  224. />
  225. </div>
  226. </div>
  227. <div class="row my-3">
  228. <div class="col-md-12">
  229. <div v-if="!property.postalCode">
  230. <label for="postalCode" class="uniSelectLabel">POSTAL CODE</label>
  231. </div>
  232. <input
  233. class="form-control uniInput"
  234. type="text"
  235. name="postalCode"
  236. id="unit"
  237. v-model="property.postalCode"
  238. :disabled="!canEdit"
  239. />
  240. </div>
  241. </div>
  242. <div class="row my-3">
  243. <div class="col-md-12">
  244. <div v-if="!property.country">
  245. <label for="country" class="uniSelectLabel">COUNTRY</label>
  246. </div>
  247. <input
  248. class="form-control uniInput"
  249. type="text"
  250. name="country"
  251. id="unit"
  252. v-model="property.country"
  253. :disabled="!canEdit"
  254. />
  255. </div>
  256. </div>
  257. <div class="row my-3">
  258. <div class="col-md-12">
  259. <button
  260. type="button"
  261. @click="clearAddress()"
  262. class="btn-solid-blue"
  263. >Clear Address</button>
  264. </div>
  265. </div>
  266. </div>
  267. </div>
  268. <div class="row">
  269. <div class="col-md-12">
  270. <label for="Property Description" style="font-family:'muli'">Description:</label>
  271. <vue-editor v-model="property.description" :editor-toolbar="customToolbar" />
  272. <br />
  273. </div>
  274. </div>
  275. <div class="row">
  276. <div class="section-header">
  277. <h2>Property Information</h2>
  278. </div>
  279. <div class="row mb-3" v-for="item in propertyFields" :key="item.id">
  280. <div class="col-md-6" v-for="field in item.fields" :key="field.id">
  281. <div v-if="field.type === 'number'">
  282. {{ field.name }}
  283. <input
  284. type="number"
  285. class="form-control uniInput"
  286. v-model="field.value"
  287. :disabled="!canEdit"
  288. />
  289. </div>
  290. <div v-else-if="field.type === 'text'">
  291. {{ field.name }}
  292. <input
  293. type="text"
  294. class="form-control uniInput"
  295. v-model="field.value"
  296. :disabled="!canEdit"
  297. />
  298. </div>
  299. <div v-else-if="field.type === 'yesno'">
  300. {{ field.name }}
  301. <input
  302. type="checkbox"
  303. v-model="field.value"
  304. :disabled="!canEdit"
  305. />
  306. </div>
  307. <div v-else class="display:none"></div>
  308. </div>
  309. </div>
  310. </div>
  311. <div class="row">
  312. <div class="col-sm-12">
  313. <div class="section-header">
  314. <h2>Media</h2>
  315. </div>
  316. </div>
  317. </div>
  318. <div class="form-group row">
  319. <div class="col-md-12">
  320. <label class="uniSelectLabel">Virtual Tour (URL)</label>
  321. <div class="input-group-prepend">
  322. <input
  323. class="form-control uniInput"
  324. type="link"
  325. name="vtlink"
  326. id="vtlink"
  327. v-model="property.virtualTour"
  328. :disabled="!canEdit"
  329. />
  330. </div>
  331. </div>
  332. </div>
  333. <div class="row">
  334. <div class="col-md-12">
  335. <label class="uniSelectLabel">Video (URL)</label>
  336. <div class="input-group-prepend">
  337. <input
  338. class="form-control uniInput"
  339. type="link"
  340. name="vlink"
  341. id="vlink"
  342. v-model="property.video"
  343. :disabled="!canEdit"
  344. />
  345. </div>
  346. </div>
  347. </div>
  348. <div class="row mt-3">
  349. <div class="col-md-6">
  350. <div class="content-header">
  351. <h2>Images</h2>
  352. </div>
  353. <div class="input-group-prepend"></div>
  354. </div>
  355. </div>
  356. <ImageLoad
  357. :savedImages="propertyImages"
  358. :loadedImages="loadedImages"
  359. @DefaultImage="UpdateDefaultImage"
  360. @DeleteImage="DeleteImage"
  361. :mayEdit="canEdit"
  362. />
  363. <button v-if="!wait" type="button" @click="SubmitData()" class="btn-solid-blue">Save</button>
  364. <button v-if="!wait" type="button" @click="Close()" class="btn-solid-blue">Close</button>
  365. <div v-if="!addressSet">
  366. <p class="alert myError">Please enter an address.</p>
  367. </div>
  368. <div v-if="wait" id="preloader"></div>
  369. </div>
  370. </main>
  371. </div>
  372. </section>
  373. </main>
  374. </div>
  375. </template>
  376. <script>
  377. /* eslint-disable */
  378. import { VueEditor } from "vue2-editor";
  379. import { mapState, mapActions } from "vuex";
  380. import mapSection from "../mapSection";
  381. import ImageLoad from "../propertyImage";
  382. import _ from "lodash";
  383. export default {
  384. name: "PropertyEditPage",
  385. components: {
  386. mapSection,
  387. ImageLoad,
  388. VueEditor,
  389. },
  390. data() {
  391. return {
  392. addressSet: true,
  393. defaultImage: 0,
  394. images: [],
  395. wait: false,
  396. canEdit: true,
  397. customToolbar: [
  398. [{ header: [false, 1, 2, 3, 4, 5, 6] }],
  399. ["bold", "italic", "underline", "strike"],
  400. [
  401. { align: "" },
  402. { align: "center" },
  403. { align: "right" },
  404. { align: "justify" },
  405. ],
  406. [{ list: "ordered" }, { list: "bullet" }, { list: "check" }],
  407. [{ script: "sub" }, { script: "super" }],
  408. [{ indent: "-1" }, { indent: "+1" }],
  409. ],
  410. };
  411. },
  412. methods: {
  413. ...mapActions("property", [
  414. "getProperty",
  415. "getPropertyTypes",
  416. "getPropertyFields",
  417. "updateProperty",
  418. ]),
  419. StatusChanged(item) {
  420. if (
  421. item.target.value === "Offer Pending" ||
  422. item.target.value === "Sold" ||
  423. item.target.value === "Rented Out"
  424. ) {
  425. this.canEdit = false;
  426. } else {
  427. this.canEdit = true;
  428. }
  429. if (item.target.value === "For Rent") {
  430. this.property.isSale = false;
  431. }
  432. if (item.target.value === "For Sale") {
  433. this.property.isSale = true;
  434. }
  435. },
  436. clearAddress() {
  437. this.addressSet = false;
  438. this.property.streetNumber = undefined;
  439. this.property.streetName = undefined;
  440. this.property.suburb = undefined;
  441. this.property.city = undefined;
  442. this.property.province = undefined;
  443. this.property.country = undefined;
  444. this.property.postalCode = undefined;
  445. this.property.addressUrl = undefined;
  446. this.property.propertCoords = undefined;
  447. },
  448. UpdateUsageType() {
  449. this.getPropertyTypes(this.property.propertyUsageType);
  450. this.getPropertyFields(this.property.propertyUsageType);
  451. },
  452. UpdateDefaultImage(item) {
  453. this.defaultImage = item;
  454. for (let i = 0; i < this.propertyImages.length; i++) {
  455. if (i === item) {
  456. this.propertyImages[i].isDefault = true;
  457. } else {
  458. this.propertyImages[i].isDefault = false;
  459. }
  460. }
  461. },
  462. loadedImages(values) {
  463. this.images = values;
  464. },
  465. SubmitData() {
  466. this.wait = true;
  467. this.property.propertyFields = this.propertyFields;
  468. if (this.images.length > 0) {
  469. this.property.newImages = [];
  470. }
  471. // eslint-disable-next-line no-plusplus
  472. for (let i = 0; i < this.images.length; i++) {
  473. let setAsDefault = false;
  474. if (i === this.defaultImage) {
  475. setAsDefault = true;
  476. }
  477. this.property.newImages.push({
  478. image: this.images[i],
  479. isDefault: setAsDefault,
  480. });
  481. }
  482. this.property.propertyImages = this.propertyImages;
  483. //console.log(JSON.stringify(this.property));
  484. this.updateProperty(this.property).then((fulfilled) => {
  485. this.$router.push("/PropertyAdmin");
  486. });
  487. },
  488. Close() {
  489. this.$router.push("/PropertyAdmin");
  490. },
  491. updateLocation(place) {
  492. this.addressSet = true;
  493. this.property.streetNumber = place.streetNumber;
  494. this.property.streetName = place.streetName;
  495. this.property.suburb = place.suburb;
  496. this.property.city = place.city;
  497. this.property.province = place.province;
  498. this.property.country = place.country;
  499. this.property.postalCode = place.postalCode;
  500. this.property.addressUrl = place.url;
  501. this.property.propertCoords = place.coords;
  502. },
  503. DeleteImage(item) {
  504. this.propertyImages[item].isDeleted = true;
  505. },
  506. },
  507. mounted() {
  508. this.getProperty(this.$route.params.id).then((fulfilled) => {
  509. this.wait = false;
  510. if (
  511. this.property.statusString === "Offer Pending" ||
  512. this.property.statusString === "Sold" ||
  513. this.property.statusString === "Rented Out"
  514. ) {
  515. this.canEdit = false;
  516. } else {
  517. this.canEdit = true;
  518. }
  519. });
  520. },
  521. computed: {
  522. ...mapState("property", [
  523. "property",
  524. "propertyTypes",
  525. "propertyImages",
  526. "propertyFields",
  527. "statuses",
  528. ]),
  529. savedImages() {
  530. const list = [];
  531. for (let i = 0; i < this.propertyImages.length; i++) {
  532. list.push(this.proeprtyImages[i].image);
  533. }
  534. return list;
  535. },
  536. },
  537. };
  538. </script>
  539. <style lang="scss" scoped></style>