| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 | <template>	<modal title="Report">		<div slot="body">			<div class="columns song-types">				<div					v-if="$parent.previousSong !== null"					class="column song-type"				>					<div						class="card is-fullwidth"						:class="{ 'is-highlight-active': isPreviousSongActive }"						@click="highlight('previousSong')"					>						<header class="card-header">							<p class="card-header-title">								Previous Song							</p>						</header>						<div class="card-content">							<article class="media">								<figure class="media-left">									<p class="image is-64x64">										<img											:src="												$parent.previousSong.thumbnail											"											onerror='this.src="/assets/notes-transparent.png"'										/>									</p>								</figure>								<div class="media-content">									<div class="content">										<p>											<strong>{{												$parent.previousSong.title											}}</strong>											<br />											<small>{{												$parent.previousSong.artists.split(													" ,"												)											}}</small>										</p>									</div>								</div>							</article>						</div>						<a							href="#"							class="absolute-a"							@click="highlight('previousSong')"						/>					</div>				</div>				<div v-if="$parent.currentSong !== {}" class="column song-type">					<div						class="card is-fullwidth"						:class="{ 'is-highlight-active': isCurrentSongActive }"						@click="highlight('currentSong')"					>						<header class="card-header">							<p class="card-header-title">								Current Song							</p>						</header>						<div class="card-content">							<article class="media">								<figure class="media-left">									<p class="image is-64x64">										<img											:src="$parent.currentSong.thumbnail"											onerror='this.src="/assets/notes-transparent.png"'										/>									</p>								</figure>								<div class="media-content">									<div class="content">										<p>											<strong>{{												$parent.currentSong.title											}}</strong>											<br />											<small>{{												$parent.currentSong.artists.split(													" ,"												)											}}</small>										</p>									</div>								</div>							</article>						</div>						<a							href="#"							class="absolute-a"							@click="highlight('currentSong')"						/>					</div>				</div>			</div>			<div class="edit-report-wrapper">				<div class="columns is-multiline">					<div						v-for="(issue, index) in issues"						class="column is-half"						:key="index"					>						<label class="label">{{ issue.name }}</label>						<p							v-for="(reason, index) in issue.reasons"							class="control"							:key="index"						>							<label class="checkbox">								<input									type="checkbox"									@click="toggleIssue(issue.name, reason)"								/>								{{ reason }}							</label>						</p>					</div>					<div class="column">						<label class="label">Other</label>						<textarea							v-model="report.description"							class="textarea"							maxlength="400"							placeholder="Any other details..."							@keyup="updateCharactersRemaining()"						/>						<div class="textarea-counter">							{{ charactersRemaining }}						</div>					</div>				</div>			</div>		</div>		<div slot="footer">			<a class="button is-success" @click="create()" href="#">				<i class="material-icons save-changes">done</i>				<span> Create</span>			</a>			<a				class="button is-danger"				href="#"				@click="					closeModal({						sector: 'station',						modal: 'report'					})				"			>				<span> Cancel</span>			</a>		</div>	</modal></template><script>import { mapActions } from "vuex";import { Toast } from "vue-roaster";import Modal from "./Modal.vue";import io from "../../io";export default {	components: { Modal },	data() {		return {			charactersRemaining: 400,			isPreviousSongActive: false,			isCurrentSongActive: true,			report: {				resolved: false,				songId: this.$parent.currentSong.songId,				description: "",				issues: [					{ name: "Video", reasons: [] },					{ name: "Title", reasons: [] },					{ name: "Duration", reasons: [] },					{ name: "Artists", reasons: [] },					{ name: "Thumbnail", reasons: [] }				]			},			issues: [				{					name: "Video",					reasons: [						"Doesn't exist",						"It's private",						"It's not available in my country"					]				},				{					name: "Title",					reasons: ["Incorrect", "Inappropriate"]				},				{					name: "Duration",					reasons: [						"Skips too soon",						"Skips too late",						"Starts too soon",						"Starts too late"					]				},				{					name: "Artists",					reasons: ["Incorrect", "Inappropriate"]				},				{					name: "Thumbnail",					reasons: ["Incorrect", "Inappropriate", "Doesn't exist"]				}			]		};	},	mounted() {		const _this = this;		io.getSocket(socket => {			_this.socket = socket;		});	},	methods: {		create() {			const _this = this;			console.log(this.report);			_this.socket.emit("reports.create", _this.report, res => {				Toast.methods.addToast(res.message, 4000);				if (res.status === "success")					_this.closeModal({						sector: "station",						modal: "report"					});			});		},		updateCharactersRemaining() {			this.charactersRemaining =				400 - document.getElementsByClassName("textarea").value.length;		},		highlight(type) {			if (type === "currentSong") {				this.report.songId = this.$parent.currentSong.songId;				this.isPreviousSongActive = false;				this.isCurrentSongActive = true;			} else if (type === "previousSong") {				this.report.songId = this.$parent.previousSong.songId;				this.isCurrentSongActive = false;				this.isPreviousSongActive = true;			}		},		toggleIssue(name, reason) {			for (let z = 0; z < this.report.issues.length; z += 1) {				if (this.report.issues[z].name === name) {					if (this.report.issues[z].reasons.indexOf(reason) > -1) {						this.report.issues[z].reasons.splice(							this.report.issues[z].reasons.indexOf(reason),							1						);					} else this.report.issues[z].reasons.push(reason);				}			}		},		...mapActions("modals", ["closeModal"])	}};</script><style lang="scss" scoped>h6 {	margin-bottom: 15px;}.song-type:first-of-type {	padding-left: 0;}.song-type:last-of-type {	padding-right: 0;}.media-content {	display: flex;	align-items: center;	height: 64px;}.radio-controls .control {	display: flex;	align-items: center;}.textarea-counter {	text-align: right;}@media screen and (min-width: 769px) {	.radio-controls .control-label {		padding-top: 0 !important;	}}.edit-report-wrapper {	padding: 20px;}.is-highlight-active {	border: 3px #03a9f4 solid;}</style>
 |