thelounge/client/components/Windows/NetworkEdit.vue

51 lines
1 KiB
Vue
Raw Normal View History

2019-02-18 10:18:32 +01:00
<template>
<NetworkForm
v-if="networkData"
:handle-submit="handleSubmit"
:defaults="networkData"
:disabled="disabled"
/>
2019-02-18 10:18:32 +01:00
</template>
<script>
2019-11-16 18:24:03 +01:00
import socket from "../../js/socket";
import NetworkForm from "../NetworkForm.vue";
2019-02-18 10:18:32 +01:00
export default {
name: "NetworkEdit",
components: {
NetworkForm,
2019-02-18 10:18:32 +01:00
},
data() {
return {
disabled: false,
networkData: null,
2019-02-18 10:18:32 +01:00
};
},
watch: {
"$route.params.uuid"() {
this.setNetworkData();
},
},
mounted() {
this.setNetworkData();
},
2019-02-18 10:18:32 +01:00
methods: {
setNetworkData() {
2019-11-02 19:45:00 +01:00
socket.emit("network:get", this.$route.params.uuid);
this.networkData = this.$store.getters.findNetwork(this.$route.params.uuid);
},
handleSubmit(data) {
this.disabled = true;
socket.emit("network:edit", data);
2019-02-18 10:18:32 +01:00
// TODO: move networks to vuex and update state when the network info comes in
const network = this.$store.getters.findNetwork(data.uuid);
network.name = network.channels[0].name = data.name;
2019-11-07 10:29:04 +01:00
this.$root.switchToChannel(network.channels[0]);
2019-02-18 10:18:32 +01:00
},
},
};
</script>