|
@@ -3,58 +3,36 @@
|
|
|
<modal title='Edit Station'>
|
|
|
<div slot='body'>
|
|
|
<label class='label'>Name</label>
|
|
|
- <div class='control is-grouped'>
|
|
|
- <p class='control is-expanded'>
|
|
|
- <input class='input' type='text' placeholder='Station Name' v-model='editing.name'>
|
|
|
- </p>
|
|
|
- <p class='control'>
|
|
|
- <a class='button is-info' @click='updateName()' href='#'>Update</a>
|
|
|
- </p>
|
|
|
- </div>
|
|
|
+ <p class='control'>
|
|
|
+ <input class='input' type='text' placeholder='Station Name' v-model='editing.name'>
|
|
|
+ </p>
|
|
|
<label class='label'>Display name</label>
|
|
|
- <div class='control is-grouped'>
|
|
|
- <p class='control is-expanded'>
|
|
|
- <input class='input' type='text' placeholder='Station Display Name' v-model='editing.displayName'>
|
|
|
- </p>
|
|
|
- <p class='control'>
|
|
|
- <a class='button is-info' @click='updateDisplayName()' href='#'>Update</a>
|
|
|
- </p>
|
|
|
- </div>
|
|
|
+ <p class='control'>
|
|
|
+ <input class='input' type='text' placeholder='Station Display Name' v-model='editing.displayName'>
|
|
|
+ </p>
|
|
|
<label class='label'>Description</label>
|
|
|
- <div class='control is-grouped'>
|
|
|
- <p class='control is-expanded'>
|
|
|
- <input class='input' type='text' placeholder='Station Display Name' v-model='editing.description'>
|
|
|
- </p>
|
|
|
- <p class='control'>
|
|
|
- <a class='button is-info' @click='updateDescription()' href='#'>Update</a>
|
|
|
- </p>
|
|
|
- </div>
|
|
|
+ <p class='control'>
|
|
|
+ <input class='input' type='text' placeholder='Station Display Name' v-model='editing.description'>
|
|
|
+ </p>
|
|
|
<label class='label'>Privacy</label>
|
|
|
- <div class='control is-grouped'>
|
|
|
- <p class='control is-expanded'>
|
|
|
- <span class='select'>
|
|
|
- <select v-model='editing.privacy'>
|
|
|
- <option :value='"public"'>Public</option>
|
|
|
- <option :value='"unlisted"'>Unlisted</option>
|
|
|
- <option :value='"private"'>Private</option>
|
|
|
- </select>
|
|
|
- </span>
|
|
|
- </p>
|
|
|
- <p class='control'>
|
|
|
- <a class='button is-info' @click='updatePrivacy()' href='#'>Update</a>
|
|
|
- </p>
|
|
|
- </div>
|
|
|
- <div class='control is-grouped' v-if="editing.type === 'community'">
|
|
|
- <p class="control is-expanded party-mode-outer">
|
|
|
- <label class="checkbox party-mode-inner">
|
|
|
- <input type="checkbox" v-model="editing.partyMode">
|
|
|
- Party mode
|
|
|
- </label>
|
|
|
- </p>
|
|
|
- <p class='control'>
|
|
|
- <a class='button is-info' @click='updatePartyMode()' href='#'>Update</a>
|
|
|
- </p>
|
|
|
- </div>
|
|
|
+ <p class='control'>
|
|
|
+ <span class='select'>
|
|
|
+ <select v-model='editing.privacy'>
|
|
|
+ <option :value='"public"'>Public</option>
|
|
|
+ <option :value='"unlisted"'>Unlisted</option>
|
|
|
+ <option :value='"private"'>Private</option>
|
|
|
+ </select>
|
|
|
+ </span>
|
|
|
+ </p>
|
|
|
+ <p class='control'>
|
|
|
+ <label class="checkbox party-mode-inner">
|
|
|
+ <input type="checkbox" v-model="editing.partyMode">
|
|
|
+ Party mode
|
|
|
+ </label>
|
|
|
+ </p>
|
|
|
+ </div>
|
|
|
+ <div slot='footer'>
|
|
|
+ <button class='button is-success' @click='update()'>Update Settings</button>
|
|
|
<button class='button is-danger' @click='deleteStation()' v-if="$parent.type === 'community'">Delete station</button>
|
|
|
</div>
|
|
|
</modal>
|
|
@@ -65,6 +43,7 @@
|
|
|
import { Toast } from 'vue-roaster';
|
|
|
import Modal from './Modal.vue';
|
|
|
import io from '../../io';
|
|
|
+ import validation from '../../validation';
|
|
|
|
|
|
export default {
|
|
|
data: function() {
|
|
@@ -81,14 +60,25 @@
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ update: function () {
|
|
|
+ if (this.$parent.station.name !== this.editing.name) this.updateName();
|
|
|
+ if (this.$parent.station.displayName !== this.editing.displayName) this.updateDisplayName();
|
|
|
+ if (this.$parent.station.description !== this.editing.description) this.updateDescription();
|
|
|
+ if (this.$parent.station.privacy !== this.editing.privacy) this.updatePrivacy();
|
|
|
+ if (this.$parent.station.partyMode !== this.editing.partyMode) this.updatePartyMode();
|
|
|
+ },
|
|
|
updateName: function () {
|
|
|
- let _this = this;
|
|
|
- this.socket.emit('stations.updateName', this.editing._id, this.editing.name, res => {
|
|
|
+ const name = this.editing.name;
|
|
|
+ if (!validation.isLength(name, 2, 16)) return Toast.methods.addToast('Name must have between 2 and 16 characters.', 8000);
|
|
|
+ if (!validation.regex.az09_.test(name)) return Toast.methods.addToast('Invalid name format. Allowed characters: a-z, 0-9 and _.', 8000);
|
|
|
+
|
|
|
+
|
|
|
+ this.socket.emit('stations.updateName', this.editing._id, name, res => {
|
|
|
if (res.status === 'success') {
|
|
|
- if (_this.$parent.station) _this.$parent.station.name = _this.editing.name;
|
|
|
+ if (this.$parent.station) _this.$parent.station.name = name;
|
|
|
else {
|
|
|
- _this.$parent.stations.forEach((station, index) => {
|
|
|
- if (station._id === _this.editing._id) return _this.$parent.stations[index].name = _this.editing.name;
|
|
|
+ this.$parent.stations.forEach((station, index) => {
|
|
|
+ if (station._id === this.editing._id) return this.$parent.stations[index].name = name;
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -96,13 +86,17 @@
|
|
|
});
|
|
|
},
|
|
|
updateDisplayName: function () {
|
|
|
- let _this = this;
|
|
|
- this.socket.emit('stations.updateDisplayName', this.editing._id, this.editing.displayName, res => {
|
|
|
+ const displayName = this.editing.displayName;
|
|
|
+ if (!validation.isLength(displayName, 2, 32)) return Toast.methods.addToast('Display name must have between 2 and 32 characters.', 8000);
|
|
|
+ if (!validation.regex.azAZ09_.test(displayName)) return Toast.methods.addToast('Invalid display name format. Allowed characters: a-z, A-Z, 0-9 and _.', 8000);
|
|
|
+
|
|
|
+
|
|
|
+ this.socket.emit('stations.updateDisplayName', this.editing._id, displayName, res => {
|
|
|
if (res.status === 'success') {
|
|
|
- if (_this.$parent.station) _this.$parent.station.displayName = _this.editing.displayName;
|
|
|
+ if (this.$parent.station) _this.$parent.station.displayName = displayName;
|
|
|
else {
|
|
|
- _this.$parent.stations.forEach((station, index) => {
|
|
|
- if (station._id === _this.editing._id) return _this.$parent.stations[index].displayName = _this.editing.displayName;
|
|
|
+ this.$parent.stations.forEach((station, index) => {
|
|
|
+ if (station._id === this.editing._id) return this.$parent.stations[index].displayName = displayName;
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -110,13 +104,21 @@
|
|
|
});
|
|
|
},
|
|
|
updateDescription: function () {
|
|
|
- let _this = this;
|
|
|
- this.socket.emit('stations.updateDescription', this.editing._id, this.editing.description, res => {
|
|
|
+ const description = this.editing.description;
|
|
|
+ if (!validation.isLength(description, 2, 200)) return Toast.methods.addToast('Description must have between 2 and 200 characters.', 8000);
|
|
|
+ let characters = description.split("");
|
|
|
+ characters = characters.filter(function(character) {
|
|
|
+ return character.charCodeAt(0) === 21328;
|
|
|
+ });
|
|
|
+ if (characters.length !== 0) return Toast.methods.addToast('Invalid description format. Swastika\'s are not allowed.', 8000);
|
|
|
+
|
|
|
+
|
|
|
+ this.socket.emit('stations.updateDescription', this.editing._id, description, res => {
|
|
|
if (res.status === 'success') {
|
|
|
- if (_this.$parent.station) _this.$parent.station.description = _this.editing.description;
|
|
|
+ if (_this.$parent.station) _this.$parent.station.description = description;
|
|
|
else {
|
|
|
_this.$parent.stations.forEach((station, index) => {
|
|
|
- if (station._id === station._id) return _this.$parent.stations[index].description = _this.editing.description;
|
|
|
+ if (station._id === station._id) return _this.$parent.stations[index].description = description;
|
|
|
});
|
|
|
}
|
|
|
return Toast.methods.addToast(res.message, 4000);
|