mirror of
https://github.com/thelounge/thelounge
synced 2024-11-29 15:30:22 +00:00
Fix network editing in vue and use absolute urls in router links.
This commit is contained in:
parent
2049a16d64
commit
8fa42c5c48
6 changed files with 37 additions and 8 deletions
|
@ -4,7 +4,7 @@
|
||||||
<SidebarToggle />
|
<SidebarToggle />
|
||||||
</div>
|
</div>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<router-link id="back-to-help" to="help">« Help</router-link>
|
<router-link id="back-to-help" to="/help">« Help</router-link>
|
||||||
|
|
||||||
<template
|
<template
|
||||||
v-if="
|
v-if="
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<small class="pull-right">
|
<small class="pull-right">
|
||||||
v{{ $root.serverConfiguration.version }} (<router-link
|
v{{ $root.serverConfiguration.version }} (<router-link
|
||||||
id="view-changelog"
|
id="view-changelog"
|
||||||
to="changelog"
|
to="/changelog"
|
||||||
>release notes</router-link
|
>release notes</router-link
|
||||||
>)
|
>)
|
||||||
</small>
|
</small>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<NetworkForm
|
<NetworkForm
|
||||||
v-if="$store.state.currentNetworkConfig"
|
v-if="networkData"
|
||||||
:handle-submit="handleSubmit"
|
:handle-submit="handleSubmit"
|
||||||
:defaults="$store.state.currentNetworkConfig"
|
:defaults="networkData"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
@ -21,9 +21,21 @@ export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
networkData: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
"$route.params.uuid"() {
|
||||||
|
this.setNetworkData();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.setNetworkData();
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
setNetworkData() {
|
||||||
|
this.networkData = this.$root.findNetwork(this.$route.params.uuid);
|
||||||
|
},
|
||||||
handleSubmit(data) {
|
handleSubmit(data) {
|
||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
socket.emit("network:edit", data);
|
socket.emit("network:edit", data);
|
||||||
|
@ -32,7 +44,6 @@ export default {
|
||||||
// TODO: move networks to vuex and update state when the network info comes in
|
// TODO: move networks to vuex and update state when the network info comes in
|
||||||
const network = this.$root.networks.find((n) => n.uuid === data.uuid);
|
const network = this.$root.networks.find((n) => n.uuid === data.uuid);
|
||||||
network.name = network.channels[0].name = data.name;
|
network.name = network.channels[0].name = data.name;
|
||||||
|
|
||||||
sidebar.find(`.network[data-uuid="${data.uuid}"] .chan.lobby .name`).click();
|
sidebar.find(`.network[data-uuid="${data.uuid}"] .chan.lobby .name`).click();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -290,8 +290,8 @@ function addFocusItem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addEditNetworkItem() {
|
function addEditNetworkItem() {
|
||||||
function edit(itemData) {
|
function edit(networkUuid) {
|
||||||
socket.emit("network:get", itemData);
|
vueApp.$router.push("/edit-network/" + networkUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
addContextMenuItem({
|
addContextMenuItem({
|
||||||
|
|
|
@ -9,6 +9,7 @@ const Connect = require("../components/Windows/Connect.vue").default;
|
||||||
const Settings = require("../components/Windows/Settings.vue").default;
|
const Settings = require("../components/Windows/Settings.vue").default;
|
||||||
const Help = require("../components/Windows/Help.vue").default;
|
const Help = require("../components/Windows/Help.vue").default;
|
||||||
const Changelog = require("../components/Windows/Changelog.vue").default;
|
const Changelog = require("../components/Windows/Changelog.vue").default;
|
||||||
|
const NetworkEdit = require("../components/Windows/NetworkEdit.vue").default;
|
||||||
const RoutedChat = require("../components/RoutedChat.vue").default;
|
const RoutedChat = require("../components/RoutedChat.vue").default;
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
|
@ -53,6 +54,14 @@ const router = new VueRouter({
|
||||||
windowName: "Changelog",
|
windowName: "Changelog",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/edit-network/:uuid",
|
||||||
|
component: NetworkEdit,
|
||||||
|
meta: {
|
||||||
|
isChat: false,
|
||||||
|
windowName: "NetworkEdit",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/chan-*",
|
path: "/chan-*",
|
||||||
component: RoutedChat,
|
component: RoutedChat,
|
||||||
|
|
|
@ -102,12 +102,21 @@ const vueApp = new Vue({
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
findNetwork(uuid) {
|
||||||
|
for (const network of this.networks) {
|
||||||
|
if (network.uuid === uuid) {
|
||||||
|
return network;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
switchToChannel(channel) {
|
switchToChannel(channel) {
|
||||||
if (this.activeChannel && this.activeChannel.channel.id === channel.id) {
|
if (this.activeChannel && this.activeChannel.channel.id === channel.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$router.push("chan-" + channel.id);
|
this.$router.push("/chan-" + channel.id);
|
||||||
},
|
},
|
||||||
switchOutOfChannel(channel) {
|
switchOutOfChannel(channel) {
|
||||||
// When switching out of a channel, mark everything as read
|
// When switching out of a channel, mark everything as read
|
||||||
|
|
Loading…
Reference in a new issue