add/remove tabs on multiworld page
This commit is contained in:
@@ -13,8 +13,8 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
worlds: [{}, {}, {}],
|
worlds: [{}, {}],
|
||||||
worldCount: 3,
|
worldCount: 2,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
@@ -27,6 +27,18 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
async addWorld() {
|
||||||
|
const newname = await localforage.getItem(`world_${this.worldCount + 1}_setting_player_name`);
|
||||||
|
this.worlds.push({player_name: newname});
|
||||||
|
this.worldCount++;
|
||||||
|
|
||||||
|
await new Promise(r => setTimeout(r, 100));
|
||||||
|
this.worlds[this.worldCount - 1].player_name = newname;
|
||||||
|
},
|
||||||
|
async removeWorld() {
|
||||||
|
this.worldCount--;
|
||||||
|
this.worlds.pop();
|
||||||
|
},
|
||||||
async playerNameUpdated(num) {
|
async playerNameUpdated(num) {
|
||||||
await localforage.setItem(`world_${num + 1}_setting_player_name`, this.worlds[num].player_name);
|
await localforage.setItem(`world_${num + 1}_setting_player_name`, this.worlds[num].player_name);
|
||||||
},
|
},
|
||||||
@@ -64,13 +76,20 @@ export default defineComponent({
|
|||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
Generate Multiworld
|
Generate Multiworld
|
||||||
</div>
|
</div>
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs ps-3 pt-3 pe-3">
|
||||||
<li v-for="(n, idx) in worldCount" class="nav-item" role="presentation">
|
<li v-for="(n, idx) in worldCount" class="nav-item" role="presentation">
|
||||||
<button class="nav-link" :class="{active: idx == 0}" data-bs-toggle="tab"
|
<button class="nav-link" :class="{active: idx == 0}" data-bs-toggle="tab"
|
||||||
:data-bs-target="`#world_page_${n}`" type="button" role="tab">
|
:data-bs-target="`#world_page_${n}`" type="button" role="tab">
|
||||||
{{ worlds[idx]?.player_name ?? n }}
|
{{ worlds[idx]?.player_name ?? n }}
|
||||||
|
<button v-if="n == worldCount && n > 2" @click="removeWorld"
|
||||||
|
class="badge btn rounded-pill text-bg-danger">
|
||||||
|
<i class="bi bi-trash"></i>
|
||||||
|
</button>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
<button class="nav-link" type="button" role="tab" @click="addWorld">
|
||||||
|
<i class="bi bi-plus"></i>
|
||||||
|
</button>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<template v-for="(n, idx) in worldCount">
|
<template v-for="(n, idx) in worldCount">
|
||||||
|
|||||||
Reference in New Issue
Block a user