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.

templateDetailNew.vue 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <!-- eslint-disable max-len -->
  3. <div style="padding:10px;">
  4. <div
  5. class="container"
  6. style="border:silver solid thin;border-radius:10px;background-color:rgba(235,235,235,0.75);padding:20px;"
  7. >
  8. <div class="row">
  9. <div class="col-md-12">
  10. <div class="d-flex">
  11. <div class="p-2 mr-auto">
  12. <h2>Template - Detail</h2>
  13. </div>
  14. <div class="p-2">
  15. <div class="btn btn-primary myBackground" v-if="!editable" @click="onEdit()">
  16. Edit
  17. </div>
  18. </div>
  19. <div class="p-2">
  20. <div class="btn btn-primary myBackground" @click="onClose()">Save/Close</div>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="col-md-12">
  25. <hr />
  26. </div>
  27. <div class="col-md-12 text-left">
  28. <div class="input-group mb-3">
  29. <label v-if="!item.name" for="name" class="uniSelectLabel">
  30. Name
  31. </label>
  32. <input
  33. class="form-control uniInput"
  34. type="text"
  35. step="any"
  36. name="name"
  37. v-model="item.name"
  38. :disabled="!CanEdit"
  39. />
  40. </div>
  41. </div>
  42. <div class="col-md-12">
  43. <hr />
  44. </div>
  45. <div class="col-md-12 text-left">
  46. <div class="input-group mb-3">
  47. <label for="subject" class="uniSelectLabel">Subject</label>
  48. <input
  49. class="form-control uniInput"
  50. type="text"
  51. step="any"
  52. name="subject"
  53. v-model="item.subject"
  54. :disabled="!CanEdit"
  55. />
  56. </div>
  57. </div>
  58. <div class="col-md-12">
  59. <ul class="nav nav-tabs" id="myTab" role="tablist">
  60. <li class="nav-item">
  61. <a
  62. class="nav-link active"
  63. id="directions-tab"
  64. data-toggle="tab"
  65. href="#directions"
  66. role="tab"
  67. aria-controls="directions"
  68. aria-selected="false"
  69. >Html</a
  70. >
  71. </li>
  72. <li class="nav-item">
  73. <a
  74. class="nav-link"
  75. id="resort-layout-tab"
  76. data-toggle="tab"
  77. href="#resort-layout"
  78. role="tab"
  79. aria-controls="resort-layout"
  80. aria-selected="true"
  81. >Preview</a
  82. >
  83. </li>
  84. </ul>
  85. <div
  86. class="tab-content"
  87. id="myTabContent"
  88. style="background-color:rgba(255,255,255,0.75);padding:10px;border:silver solid thin;border-radius:10px;"
  89. >
  90. <div
  91. class="tab-pane fade show active"
  92. style="background-color:rgba(255,255,255,0.75);padding:10px;"
  93. id="directions"
  94. role="tabpanel"
  95. aria-labelledby="directions-tab"
  96. >
  97. <div class="text-left">
  98. <label for="Sleeps maximum">Body</label>
  99. <div class="input-group mb-3">
  100. <textarea
  101. class="form-control uniInput"
  102. id="bodyInput"
  103. ref="bodyInput"
  104. type="text"
  105. rows="10"
  106. step="any"
  107. name="body"
  108. v-model="item.body"
  109. :disabled="!CanEdit"
  110. />
  111. </div>
  112. </div>
  113. </div>
  114. <div
  115. class="tab-pane fade"
  116. id="resort-layout"
  117. role="tabpanel"
  118. aria-labelledby="resort-layout-tab"
  119. >
  120. <div class="no-style" v-html="item.body"></div>
  121. </div>
  122. </div>
  123. </div>
  124. <div class="col-md-12">
  125. <hr />
  126. </div>
  127. <div class="col-md-12">
  128. <div class="d-flex">
  129. <div class="p-2 mr-auto">
  130. <h2>Coded Fields</h2>
  131. </div>
  132. <!-- <div class="p-2">
  133. <div class="btn btn-primary myBackground" @click="addClose()" v-if="CanEdit">
  134. {{ btnCaption }}
  135. </div>
  136. </div> -->
  137. </div>
  138. </div>
  139. <div class="col-md-12">
  140. <TemplateInnerItem @onItemAdd="onItemAdd" />
  141. </div>
  142. <!-- <div class="col-md-12">
  143. <hr />
  144. </div>
  145. <div class="col-md-12">
  146. <ListView
  147. :items="PlaceHolders"
  148. :hideSearch="true"
  149. :showNew="false"
  150. :deleteable="CanEdit"
  151. :allowMultipleSelect="true"
  152. @onDelete="onItemDelete"
  153. />
  154. </div> -->
  155. </div>
  156. </div>
  157. </div>
  158. </template>
  159. <script>
  160. import { mapActions } from "vuex";
  161. import ListView from "../shared/listView.vue";
  162. import TemplateInnerItem from "./templateInnerItem.vue";
  163. export default {
  164. data() {
  165. return {
  166. showNew: false,
  167. openFields: false
  168. };
  169. },
  170. created() {
  171. this.item.body =
  172. '<HTML> <BODY style="font-family: Poppins, sans-serif; color: #555555;"> <div> [Name] </div> <br/> <div> Please note that a timeshare week has been loaded for sale. </div> <br /> <div> <table class="table table-striped"> <thead> <tr> <th scope="col">Resort</th> <th scope="col">Unit</th> <th scope="col">Module</th> </tr> </thead> <tbody> <tr> <td>[Resort]</td> <td>[UnitNumber]</td> <td>[Module]</td> </tr> </tbody> </table> <div> <br /> <div> Regards, <br/> <img src="http://training.provision-sa.com:89/images/test/uvprop.png" /> </div> </BODY> </HTML>';
  173. },
  174. components: {
  175. ListView,
  176. TemplateInnerItem
  177. },
  178. props: {
  179. item: {},
  180. placeHolders: [],
  181. editable: {
  182. default: false
  183. }
  184. },
  185. computed: {
  186. CanEdit() {
  187. return this.editable || this.item.id === 0 || this.openFields;
  188. },
  189. btnCaption() {
  190. return this.showNew ? "Close" : "New";
  191. },
  192. ItemList() {
  193. return this.item.placeHolders;
  194. },
  195. PlaceHolders() {
  196. return this.placeHolders;
  197. }
  198. },
  199. methods: {
  200. ...mapActions("template", ["addItem", "editItem"]),
  201. addClose() {
  202. if (this.showNew) {
  203. this.showNew = false;
  204. } else this.showNew = true;
  205. },
  206. onClose() {
  207. if (this.item.id > 0) {
  208. // edit
  209. this.editItem(this.item);
  210. } else {
  211. // add.
  212. this.addItem(this.item);
  213. }
  214. this.$emit("onClose");
  215. },
  216. onItemDelete(item) {
  217. this.item.placeHolders = _.remove(this.item.placeHolders, x => x !== item);
  218. },
  219. onEdit() {
  220. this.openFields = true;
  221. },
  222. onItemAdd(item) {
  223. // const myList = this.item.placeHolders ? this.item.placeHolders : [];
  224. // myList.push({
  225. // name: item.name,
  226. // boundTo: item.property,
  227. // boundToClassDisplay: item.class.name,
  228. // boundToClass: item.class.fullName
  229. // });
  230. // this.placeHolders = myList;
  231. // this.item.placeHolders = this.placeHolders;
  232. var placeHolder = "[" + item.property + "]";
  233. console.log(placeHolder);
  234. // will give the current postion of the cursor
  235. var curPos = document.getElementById("bodyInput").selectionStart;
  236. // will get the value of the text area
  237. let x = $("#bodyInput").val();
  238. // will get the value of the input box
  239. let text_to_insert = placeHolder;
  240. // setting the updated value in the text area
  241. $("#bodyInput").val(x.slice(0, curPos) + text_to_insert + x.slice(curPos));
  242. }
  243. }
  244. };
  245. </script>
  246. <style>
  247. .no-style {
  248. background: #fff;
  249. border: none;
  250. color: #000;
  251. display: block;
  252. font: initial;
  253. height: auto;
  254. letter-spacing: normal;
  255. line-height: normal;
  256. margin: 0;
  257. padding: 0;
  258. text-transform: none;
  259. visibility: visible;
  260. width: auto;
  261. word-spacing: normal;
  262. z-index: auto;
  263. text-align: left;
  264. }
  265. </style>