EditNews.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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="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="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="addChangeClick('bugs')"
  33. />
  34. <a
  35. class="button is-info"
  36. href="#"
  37. @click="addChangeClick('bugs')"
  38. >Add</a
  39. >
  40. </p>
  41. <span
  42. v-for="(bug, index) in editing.bugs"
  43. class="tag is-info"
  44. :key="index"
  45. >
  46. {{ bug }}
  47. <button
  48. class="delete is-info"
  49. @click="removeChangeClick('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="addChangeClick('features')"
  62. />
  63. <a
  64. class="button is-info"
  65. href="#"
  66. @click="addChangeClick('features')"
  67. >Add</a
  68. >
  69. </p>
  70. <span
  71. v-for="(feature, index) in editing.features"
  72. class="tag is-info"
  73. :key="index"
  74. >
  75. {{ feature }}
  76. <button
  77. class="delete is-info"
  78. @click="removeChangeClick('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="addChangeClick('improvements')"
  93. />
  94. <a
  95. class="button is-info"
  96. href="#"
  97. @click="addChangeClick('improvements')"
  98. >Add</a
  99. >
  100. </p>
  101. <span
  102. v-for="(improvement, index) in editing.improvements"
  103. class="tag is-info"
  104. :key="index"
  105. >
  106. {{ improvement }}
  107. <button
  108. class="delete is-info"
  109. @click="removeChangeClick('improvements', index)"
  110. />
  111. </span>
  112. </div>
  113. <div class="column">
  114. <label class="label">Upcoming</label>
  115. <p class="control has-addons">
  116. <input
  117. id="edit-upcoming"
  118. class="input"
  119. type="text"
  120. placeholder="Upcoming"
  121. @keyup.enter="addChangeClick('upcoming')"
  122. />
  123. <a
  124. class="button is-info"
  125. href="#"
  126. @click="addChangeClick('upcoming')"
  127. >Add</a
  128. >
  129. </p>
  130. <span
  131. v-for="(upcoming, index) in editing.upcoming"
  132. class="tag is-info"
  133. :key="index"
  134. >
  135. {{ upcoming }}
  136. <button
  137. class="delete is-info"
  138. @click="removeChangeClick('upcoming', index)"
  139. />
  140. </span>
  141. </div>
  142. </div>
  143. </div>
  144. <div slot="footer">
  145. <button class="button is-success" @click="updateNews(false)">
  146. <i class="material-icons save-changes">done</i>
  147. <span>&nbsp;Save</span>
  148. </button>
  149. <button class="button is-success" @click="updateNews(true)">
  150. <i class="material-icons save-changes">done</i>
  151. <span>&nbsp;Save and close</span>
  152. </button>
  153. <button
  154. class="button is-danger"
  155. @click="
  156. closeModal({
  157. sector: 'admin',
  158. modal: 'editNews'
  159. })
  160. "
  161. >
  162. <span>&nbsp;Close</span>
  163. </button>
  164. </div>
  165. </modal>
  166. </template>
  167. <script>
  168. import { mapActions, mapState } from "vuex";
  169. import Toast from "toasters";
  170. import io from "../../io";
  171. import Modal from "./Modal.vue";
  172. export default {
  173. components: { Modal },
  174. computed: {
  175. ...mapState("admin/news", {
  176. editing: state => state.editing
  177. })
  178. },
  179. methods: {
  180. addChange(type) {
  181. const change = document.getElementById(`edit-${type}`).value.trim();
  182. if (this.editing[type].indexOf(change) !== -1)
  183. return new Toast({
  184. content: `Tag already exists`,
  185. timeout: 3000
  186. });
  187. if (change) this.addChange({ type, change });
  188. else
  189. new Toast({
  190. content: `${type} cannot be empty`,
  191. timeout: 3000
  192. });
  193. document.getElementById(`edit-${type}`).value = "";
  194. return true;
  195. },
  196. removeChange(type, index) {
  197. this.removeChange({ type, index });
  198. },
  199. updateNews(close) {
  200. this.socket.emit(
  201. "news.update",
  202. this.editing._id,
  203. this.editing,
  204. res => {
  205. new Toast({ content: res.message, timeout: 4000 });
  206. if (res.status === "success") {
  207. if (close)
  208. this.closeModal({
  209. sector: "admin",
  210. modal: "editNews"
  211. });
  212. }
  213. }
  214. );
  215. },
  216. ...mapActions("modals", ["closeModal"]),
  217. ...mapActions("admin/news", ["addChange", "removeChange"])
  218. },
  219. mounted() {
  220. io.getSocket(socket => {
  221. this.socket = socket;
  222. });
  223. }
  224. };
  225. </script>
  226. <style lang="scss" scoped>
  227. @import "styles/global.scss";
  228. input[type="range"] {
  229. -webkit-appearance: none;
  230. width: 100%;
  231. margin: 7.3px 0;
  232. }
  233. input[type="range"]:focus {
  234. outline: none;
  235. }
  236. input[type="range"]::-webkit-slider-runnable-track {
  237. width: 100%;
  238. height: 5.2px;
  239. cursor: pointer;
  240. box-shadow: 0;
  241. background: $light-grey-2;
  242. border-radius: 0;
  243. border: 0;
  244. }
  245. input[type="range"]::-webkit-slider-thumb {
  246. box-shadow: 0;
  247. border: 0;
  248. height: 19px;
  249. width: 19px;
  250. border-radius: 15px;
  251. background: $primary-color;
  252. cursor: pointer;
  253. -webkit-appearance: none;
  254. margin-top: -6.5px;
  255. }
  256. input[type="range"]::-moz-range-track {
  257. width: 100%;
  258. height: 5.2px;
  259. cursor: pointer;
  260. box-shadow: 0;
  261. background: $light-grey-2;
  262. border-radius: 0;
  263. border: 0;
  264. }
  265. input[type="range"]::-moz-range-thumb {
  266. box-shadow: 0;
  267. border: 0;
  268. height: 19px;
  269. width: 19px;
  270. border-radius: 15px;
  271. background: $primary-color;
  272. cursor: pointer;
  273. -webkit-appearance: none;
  274. margin-top: -6.5px;
  275. }
  276. input[type="range"]::-ms-track {
  277. width: 100%;
  278. height: 5.2px;
  279. cursor: pointer;
  280. box-shadow: 0;
  281. background: $light-grey-2;
  282. border-radius: 1.3px;
  283. }
  284. input[type="range"]::-ms-fill-lower {
  285. background: $light-grey-2;
  286. border: 0;
  287. border-radius: 0;
  288. box-shadow: 0;
  289. }
  290. input[type="range"]::-ms-fill-upper {
  291. background: $light-grey-2;
  292. border: 0;
  293. border-radius: 0;
  294. box-shadow: 0;
  295. }
  296. input[type="range"]::-ms-thumb {
  297. box-shadow: 0;
  298. border: 0;
  299. height: 15px;
  300. width: 15px;
  301. border-radius: 15px;
  302. background: $primary-color;
  303. cursor: pointer;
  304. -webkit-appearance: none;
  305. margin-top: 1.5px;
  306. }
  307. .controls {
  308. display: flex;
  309. flex-direction: column;
  310. align-items: center;
  311. }
  312. .artist-genres {
  313. display: flex;
  314. justify-content: space-between;
  315. }
  316. #volumeSlider {
  317. margin-bottom: 15px;
  318. }
  319. .has-text-centered {
  320. padding: 10px;
  321. }
  322. .thumbnail-preview {
  323. display: flex;
  324. margin: 0 auto 25px auto;
  325. max-width: 200px;
  326. width: 100%;
  327. }
  328. .modal-card-body,
  329. .modal-card-foot {
  330. border-top: 0;
  331. }
  332. .label,
  333. .checkbox,
  334. h5 {
  335. font-weight: normal;
  336. }
  337. .video-container {
  338. display: flex;
  339. flex-direction: column;
  340. align-items: center;
  341. padding: 10px;
  342. iframe {
  343. pointer-events: none;
  344. }
  345. }
  346. .save-changes {
  347. color: $white;
  348. }
  349. .tag:not(:last-child) {
  350. margin-right: 5px;
  351. }
  352. </style>