123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- <template>
- <modal title="Edit News">
- <div slot="body">
- <label class="label">Title</label>
- <p class="control">
- <input
- v-model="editing.title"
- class="input"
- type="text"
- placeholder="News Title"
- autofocus
- />
- </p>
- <label class="label">Description</label>
- <p class="control">
- <input
- v-model="editing.description"
- class="input"
- type="text"
- placeholder="News Description"
- />
- </p>
- <div class="columns">
- <div class="column">
- <label class="label">Bugs</label>
- <p class="control has-addons">
- <input
- id="edit-bugs"
- class="input"
- type="text"
- placeholder="Bug"
- @keyup.enter="addChangeClick('bugs')"
- />
- <a
- class="button is-info"
- href="#"
- @click="addChangeClick('bugs')"
- >Add</a
- >
- </p>
- <span
- v-for="(bug, index) in editing.bugs"
- class="tag is-info"
- :key="index"
- >
- {{ bug }}
- <button
- class="delete is-info"
- @click="removeChangeClick('bugs', index)"
- />
- </span>
- </div>
- <div class="column">
- <label class="label">Features</label>
- <p class="control has-addons">
- <input
- id="edit-features"
- class="input"
- type="text"
- placeholder="Feature"
- @keyup.enter="addChangeClick('features')"
- />
- <a
- class="button is-info"
- href="#"
- @click="addChangeClick('features')"
- >Add</a
- >
- </p>
- <span
- v-for="(feature, index) in editing.features"
- class="tag is-info"
- :key="index"
- >
- {{ feature }}
- <button
- class="delete is-info"
- @click="removeChangeClick('features', index)"
- />
- </span>
- </div>
- </div>
- <div class="columns">
- <div class="column">
- <label class="label">Improvements</label>
- <p class="control has-addons">
- <input
- id="edit-improvements"
- class="input"
- type="text"
- placeholder="Improvement"
- @keyup.enter="addChangeClick('improvements')"
- />
- <a
- class="button is-info"
- href="#"
- @click="addChangeClick('improvements')"
- >Add</a
- >
- </p>
- <span
- v-for="(improvement, index) in editing.improvements"
- class="tag is-info"
- :key="index"
- >
- {{ improvement }}
- <button
- class="delete is-info"
- @click="removeChangeClick('improvements', index)"
- />
- </span>
- </div>
- <div class="column">
- <label class="label">Upcoming</label>
- <p class="control has-addons">
- <input
- id="edit-upcoming"
- class="input"
- type="text"
- placeholder="Upcoming"
- @keyup.enter="addChangeClick('upcoming')"
- />
- <a
- class="button is-info"
- href="#"
- @click="addChangeClick('upcoming')"
- >Add</a
- >
- </p>
- <span
- v-for="(upcoming, index) in editing.upcoming"
- class="tag is-info"
- :key="index"
- >
- {{ upcoming }}
- <button
- class="delete is-info"
- @click="removeChangeClick('upcoming', index)"
- />
- </span>
- </div>
- </div>
- </div>
- <div slot="footer">
- <button class="button is-success" @click="updateNews(false)">
- <i class="material-icons save-changes">done</i>
- <span> Save</span>
- </button>
- <button class="button is-success" @click="updateNews(true)">
- <i class="material-icons save-changes">done</i>
- <span> Save and close</span>
- </button>
- <button
- class="button is-danger"
- @click="
- closeModal({
- sector: 'admin',
- modal: 'editNews'
- })
- "
- >
- <span> Close</span>
- </button>
- </div>
- </modal>
- </template>
- <script>
- import { mapActions, mapState } from "vuex";
- import Toast from "toasters";
- import io from "../../io";
- import Modal from "./Modal.vue";
- export default {
- components: { Modal },
- computed: {
- ...mapState("admin/news", {
- editing: state => state.editing
- })
- },
- methods: {
- addChange(type) {
- const change = document.getElementById(`edit-${type}`).value.trim();
- if (this.editing[type].indexOf(change) !== -1)
- return new Toast({
- content: `Tag already exists`,
- timeout: 3000
- });
- if (change) this.addChange({ type, change });
- else
- new Toast({
- content: `${type} cannot be empty`,
- timeout: 3000
- });
- document.getElementById(`edit-${type}`).value = "";
- return true;
- },
- removeChange(type, index) {
- this.removeChange({ type, index });
- },
- updateNews(close) {
- this.socket.emit(
- "news.update",
- this.editing._id,
- this.editing,
- res => {
- new Toast({ content: res.message, timeout: 4000 });
- if (res.status === "success") {
- if (close)
- this.closeModal({
- sector: "admin",
- modal: "editNews"
- });
- }
- }
- );
- },
- ...mapActions("modals", ["closeModal"]),
- ...mapActions("admin/news", ["addChange", "removeChange"])
- },
- mounted() {
- io.getSocket(socket => {
- this.socket = socket;
- });
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "styles/global.scss";
- input[type="range"] {
- -webkit-appearance: none;
- width: 100%;
- margin: 7.3px 0;
- }
- input[type="range"]:focus {
- outline: none;
- }
- input[type="range"]::-webkit-slider-runnable-track {
- width: 100%;
- height: 5.2px;
- cursor: pointer;
- box-shadow: 0;
- background: $light-grey-2;
- border-radius: 0;
- border: 0;
- }
- input[type="range"]::-webkit-slider-thumb {
- box-shadow: 0;
- border: 0;
- height: 19px;
- width: 19px;
- border-radius: 15px;
- background: $primary-color;
- cursor: pointer;
- -webkit-appearance: none;
- margin-top: -6.5px;
- }
- input[type="range"]::-moz-range-track {
- width: 100%;
- height: 5.2px;
- cursor: pointer;
- box-shadow: 0;
- background: $light-grey-2;
- border-radius: 0;
- border: 0;
- }
- input[type="range"]::-moz-range-thumb {
- box-shadow: 0;
- border: 0;
- height: 19px;
- width: 19px;
- border-radius: 15px;
- background: $primary-color;
- cursor: pointer;
- -webkit-appearance: none;
- margin-top: -6.5px;
- }
- input[type="range"]::-ms-track {
- width: 100%;
- height: 5.2px;
- cursor: pointer;
- box-shadow: 0;
- background: $light-grey-2;
- border-radius: 1.3px;
- }
- input[type="range"]::-ms-fill-lower {
- background: $light-grey-2;
- border: 0;
- border-radius: 0;
- box-shadow: 0;
- }
- input[type="range"]::-ms-fill-upper {
- background: $light-grey-2;
- border: 0;
- border-radius: 0;
- box-shadow: 0;
- }
- input[type="range"]::-ms-thumb {
- box-shadow: 0;
- border: 0;
- height: 15px;
- width: 15px;
- border-radius: 15px;
- background: $primary-color;
- cursor: pointer;
- -webkit-appearance: none;
- margin-top: 1.5px;
- }
- .controls {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .artist-genres {
- display: flex;
- justify-content: space-between;
- }
- #volumeSlider {
- margin-bottom: 15px;
- }
- .has-text-centered {
- padding: 10px;
- }
- .thumbnail-preview {
- display: flex;
- margin: 0 auto 25px auto;
- max-width: 200px;
- width: 100%;
- }
- .modal-card-body,
- .modal-card-foot {
- border-top: 0;
- }
- .label,
- .checkbox,
- h5 {
- font-weight: normal;
- }
- .video-container {
- display: flex;
- flex-direction: column;
- align-items: center;
- padding: 10px;
- iframe {
- pointer-events: none;
- }
- }
- .save-changes {
- color: $white;
- }
- .tag:not(:last-child) {
- margin-right: 5px;
- }
- </style>
|