EditNews.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <modal title="Edit News">
  3. <div slot="body">
  4. <label class="label">Title</label>
  5. <p class="control">
  6. <input
  7. v-model="$parent.editing.title"
  8. class="input"
  9. type="text"
  10. placeholder="News Title"
  11. autofocus
  12. />
  13. </p>
  14. <label class="label">Description</label>
  15. <p class="control">
  16. <input
  17. v-model="$parent.editing.description"
  18. class="input"
  19. type="text"
  20. placeholder="News Description"
  21. />
  22. </p>
  23. <div class="columns">
  24. <div class="column">
  25. <label class="label">Bugs</label>
  26. <p class="control has-addons">
  27. <input
  28. id="edit-bugs"
  29. class="input"
  30. type="text"
  31. placeholder="Bug"
  32. @keyup.enter="addChange('bugs')"
  33. />
  34. <a
  35. class="button is-info"
  36. href="#"
  37. @click="addChange('bugs')"
  38. >Add</a
  39. >
  40. </p>
  41. <span
  42. v-for="(bug, index) in $parent.editing.bugs"
  43. class="tag is-info"
  44. :key="index"
  45. >
  46. {{ bug }}
  47. <button
  48. class="delete is-info"
  49. @click="removeChange('bugs', index)"
  50. />
  51. </span>
  52. </div>
  53. <div class="column">
  54. <label class="label">Features</label>
  55. <p class="control has-addons">
  56. <input
  57. id="edit-features"
  58. class="input"
  59. type="text"
  60. placeholder="Feature"
  61. @keyup.enter="addChange('features')"
  62. />
  63. <a
  64. class="button is-info"
  65. href="#"
  66. @click="addChange('features')"
  67. >Add</a
  68. >
  69. </p>
  70. <span
  71. v-for="(feature, index) in $parent.editing.features"
  72. class="tag is-info"
  73. :key="index"
  74. >
  75. {{ feature }}
  76. <button
  77. class="delete is-info"
  78. @click="removeChange('features', index)"
  79. />
  80. </span>
  81. </div>
  82. </div>
  83. <div class="columns">
  84. <div class="column">
  85. <label class="label">Improvements</label>
  86. <p class="control has-addons">
  87. <input
  88. id="edit-improvements"
  89. class="input"
  90. type="text"
  91. placeholder="Improvement"
  92. @keyup.enter="addChange('improvements')"
  93. />
  94. <a
  95. class="button is-info"
  96. href="#"
  97. @click="addChange('improvements')"
  98. >Add</a
  99. >
  100. </p>
  101. <span
  102. v-for="(improvement, index) in $parent.editing
  103. .improvements"
  104. class="tag is-info"
  105. :key="index"
  106. >
  107. {{ improvement }}
  108. <button
  109. class="delete is-info"
  110. @click="removeChange('improvements', index)"
  111. />
  112. </span>
  113. </div>
  114. <div class="column">
  115. <label class="label">Upcoming</label>
  116. <p class="control has-addons">
  117. <input
  118. id="edit-upcoming"
  119. class="input"
  120. type="text"
  121. placeholder="Upcoming"
  122. @keyup.enter="addChange('upcoming')"
  123. />
  124. <a
  125. class="button is-info"
  126. href="#"
  127. @click="addChange('upcoming')"
  128. >Add</a
  129. >
  130. </p>
  131. <span
  132. v-for="(upcoming, index) in $parent.editing.upcoming"
  133. class="tag is-info"
  134. :key="index"
  135. >
  136. {{ upcoming }}
  137. <button
  138. class="delete is-info"
  139. @click="removeChange('upcoming', index)"
  140. />
  141. </span>
  142. </div>
  143. </div>
  144. </div>
  145. <div slot="footer">
  146. <button
  147. class="button is-success"
  148. @click="$parent.updateNews(false)"
  149. >
  150. <i class="material-icons save-changes">done</i>
  151. <span>&nbsp;Save</span>
  152. </button>
  153. <button class="button is-success" @click="$parent.updateNews(true)">
  154. <i class="material-icons save-changes">done</i>
  155. <span>&nbsp;Save and close</span>
  156. </button>
  157. <button class="button is-danger" @click="$parent.toggleModal()">
  158. <span>&nbsp;Close</span>
  159. </button>
  160. </div>
  161. </modal>
  162. </template>
  163. <script>
  164. import { Toast } from "vue-roaster";
  165. import Modal from "./Modal.vue";
  166. export default {
  167. components: { Modal },
  168. methods: {
  169. addChange: function(type) {
  170. let change = $(`#edit-${type}`)
  171. .val()
  172. .trim();
  173. if (this.$parent.editing[type].indexOf(change) !== -1)
  174. return Toast.methods.addToast(`Tag already exists`, 3000);
  175. if (change) this.$parent.editing[type].push(change);
  176. else Toast.methods.addToast(`${type} cannot be empty`, 3000);
  177. },
  178. removeChange: function(type, index) {
  179. this.$parent.editing[type].splice(index, 1);
  180. }
  181. },
  182. events: {
  183. closeModal: function() {
  184. this.$parent.toggleModal();
  185. }
  186. }
  187. };
  188. </script>
  189. <style lang="scss" scoped>
  190. input[type="range"] {
  191. -webkit-appearance: none;
  192. width: 100%;
  193. margin: 7.3px 0;
  194. }
  195. input[type="range"]:focus {
  196. outline: none;
  197. }
  198. input[type="range"]::-webkit-slider-runnable-track {
  199. width: 100%;
  200. height: 5.2px;
  201. cursor: pointer;
  202. box-shadow: 0;
  203. background: #c2c0c2;
  204. border-radius: 0;
  205. border: 0;
  206. }
  207. input[type="range"]::-webkit-slider-thumb {
  208. box-shadow: 0;
  209. border: 0;
  210. height: 19px;
  211. width: 19px;
  212. border-radius: 15px;
  213. background: #03a9f4;
  214. cursor: pointer;
  215. -webkit-appearance: none;
  216. margin-top: -6.5px;
  217. }
  218. input[type="range"]::-moz-range-track {
  219. width: 100%;
  220. height: 5.2px;
  221. cursor: pointer;
  222. box-shadow: 0;
  223. background: #c2c0c2;
  224. border-radius: 0;
  225. border: 0;
  226. }
  227. input[type="range"]::-moz-range-thumb {
  228. box-shadow: 0;
  229. border: 0;
  230. height: 19px;
  231. width: 19px;
  232. border-radius: 15px;
  233. background: #03a9f4;
  234. cursor: pointer;
  235. -webkit-appearance: none;
  236. margin-top: -6.5px;
  237. }
  238. input[type="range"]::-ms-track {
  239. width: 100%;
  240. height: 5.2px;
  241. cursor: pointer;
  242. box-shadow: 0;
  243. background: #c2c0c2;
  244. border-radius: 1.3px;
  245. }
  246. input[type="range"]::-ms-fill-lower {
  247. background: #c2c0c2;
  248. border: 0;
  249. border-radius: 0;
  250. box-shadow: 0;
  251. }
  252. input[type="range"]::-ms-fill-upper {
  253. background: #c2c0c2;
  254. border: 0;
  255. border-radius: 0;
  256. box-shadow: 0;
  257. }
  258. input[type="range"]::-ms-thumb {
  259. box-shadow: 0;
  260. border: 0;
  261. height: 15px;
  262. width: 15px;
  263. border-radius: 15px;
  264. background: #03a9f4;
  265. cursor: pointer;
  266. -webkit-appearance: none;
  267. margin-top: 1.5px;
  268. }
  269. .controls {
  270. display: flex;
  271. flex-direction: column;
  272. align-items: center;
  273. }
  274. .artist-genres {
  275. display: flex;
  276. justify-content: space-between;
  277. }
  278. #volumeSlider {
  279. margin-bottom: 15px;
  280. }
  281. .has-text-centered {
  282. padding: 10px;
  283. }
  284. .thumbnail-preview {
  285. display: flex;
  286. margin: 0 auto 25px auto;
  287. max-width: 200px;
  288. width: 100%;
  289. }
  290. .modal-card-body,
  291. .modal-card-foot {
  292. border-top: 0;
  293. }
  294. .label,
  295. .checkbox,
  296. h5 {
  297. font-weight: normal;
  298. }
  299. .video-container {
  300. display: flex;
  301. flex-direction: column;
  302. align-items: center;
  303. padding: 10px;
  304. iframe {
  305. pointer-events: none;
  306. }
  307. }
  308. .save-changes {
  309. color: #fff;
  310. }
  311. .tag:not(:last-child) {
  312. margin-right: 5px;
  313. }
  314. </style>