reset input fields after selection on stage loader
This commit is contained in:
parent
8c79cb27b2
commit
9bf381813c
2 changed files with 54 additions and 32 deletions
|
@ -1,17 +1,16 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="select-wrapper">
|
<div class="select-wrapper">
|
||||||
<select @change="onValueChanged" autocomplete="off" v-model="selectedValue">
|
<select @change="onValueChanged" autocomplete="off">
|
||||||
<option v-if="placeholder != null" value="placeholder" selected disabled>
|
<option v-if="placeholder != null" value="placeholder" selected disabled>
|
||||||
{{
|
{{ placeholder }}
|
||||||
placeholder
|
|
||||||
}}
|
|
||||||
</option>
|
</option>
|
||||||
<optgroup v-for="optGroup in optGroups" :label="optGroup.label">
|
<optgroup v-for="optGroup in optGroups" :label="optGroup.label">
|
||||||
<option
|
<option
|
||||||
v-for="option in optGroup.options"
|
v-for="option in optGroup.options"
|
||||||
:value="option.value"
|
:value="option.value"
|
||||||
:selected="selectedValue && option.value === selectedValue && !resetOnSelect"
|
:selected="selectedValue && option.value === selectedValue"
|
||||||
>{{ option.label }}</option>
|
>{{ option.label }}</option
|
||||||
|
>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,18 +22,19 @@ export default {
|
||||||
selectedValue: { type: String },
|
selectedValue: { type: String },
|
||||||
placeholder: { type: String },
|
placeholder: { type: String },
|
||||||
optGroups: { type: Array },
|
optGroups: { type: Array },
|
||||||
onChange: { type: Function }
|
onChange: { type: Function },
|
||||||
},
|
},
|
||||||
|
computed: {},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
generation: 2
|
generation: 2,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onValueChanged(e) {
|
onValueChanged(e) {
|
||||||
this.onChange(e.target.value);
|
this.onChange(e.target.value);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -35,20 +35,30 @@
|
||||||
<div class="config">
|
<div class="config">
|
||||||
<span>Route:</span>
|
<span>Route:</span>
|
||||||
<ul class="level-select">
|
<ul class="level-select">
|
||||||
<li v-for="(level, index) in selectedRoute">
|
<draggable :list="selectedRoute" :move="checkMove">
|
||||||
<div class="route-drag">≡</div>
|
<li v-for="(level, index) in selectedRoute">
|
||||||
<GroupSelectComponent
|
<div class="route-drag">≡</div>
|
||||||
:selectedValue="level.value"
|
|
||||||
:optGroups="stageLoaderLevelOptions"
|
<GroupSelectComponent
|
||||||
:onChange="e => onStageLoaderLevelChanged(index, e)"
|
:selectedValue="level.value"
|
||||||
/>
|
:optGroups="stageLoaderLevelOptions"
|
||||||
<button @click="onLevelDeleted(index)" type="button" class="route-remove">×</button>
|
:onChange="(e) => onStageLoaderLevelChanged(index, e)"
|
||||||
</li>
|
/>
|
||||||
|
<button
|
||||||
|
@click="onLevelDeleted(index)"
|
||||||
|
type="button"
|
||||||
|
class="route-remove"
|
||||||
|
>
|
||||||
|
×
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</draggable>
|
||||||
<GroupSelectComponent
|
<GroupSelectComponent
|
||||||
placeholder="Choose a level.."
|
placeholder="Choose a level.."
|
||||||
:optGroups="stageLoaderLevelOptions"
|
:optGroups="stageLoaderLevelOptions"
|
||||||
:onChange="onStageLoaderLevelSelected"
|
:onChange="onStageLoaderLevelSelected"
|
||||||
selectedValue="placeholder"
|
selectedValue="placeholder"
|
||||||
|
:key="generation"
|
||||||
/>
|
/>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -60,8 +70,8 @@
|
||||||
placeholder="Load a preset.."
|
placeholder="Load a preset.."
|
||||||
:optGroups="stageLoaderPresetOptions"
|
:optGroups="stageLoaderPresetOptions"
|
||||||
:onChange="onStageLoaderPresetSelected"
|
:onChange="onStageLoaderPresetSelected"
|
||||||
:resetOnSelect="true"
|
|
||||||
selectedValue="placeholder"
|
selectedValue="placeholder"
|
||||||
|
:key="generation"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -77,9 +87,15 @@ import GroupSelectComponent from "./GroupSelectComponent";
|
||||||
import stageLoaderLevels from "../data/stageLoaderLevels.json";
|
import stageLoaderLevels from "../data/stageLoaderLevels.json";
|
||||||
import stageLoaderPresets from "../data/stageLoaderPresets.json";
|
import stageLoaderPresets from "../data/stageLoaderPresets.json";
|
||||||
|
|
||||||
|
// Lib
|
||||||
|
import draggable from "vuedraggable";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
fastCodes: { type: Object }
|
fastCodes: { type: Object },
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
draggable,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -89,28 +105,29 @@ export default {
|
||||||
removeDialogueOptions: [
|
removeDialogueOptions: [
|
||||||
{ value: "yes", label: "Always" },
|
{ value: "yes", label: "Always" },
|
||||||
{ value: "pv5", label: "Not in Pinna 5" },
|
{ value: "pv5", label: "Not in Pinna 5" },
|
||||||
{ value: "no", label: "Don't include" }
|
{ value: "no", label: "Don't include" },
|
||||||
],
|
],
|
||||||
skippableFMVsOptions: [
|
skippableFMVsOptions: [
|
||||||
{ value: "yes", label: "Always" },
|
{ value: "yes", label: "Always" },
|
||||||
{ value: "pp", label: "Not in Pinna" },
|
{ value: "pp", label: "Not in Pinna" },
|
||||||
{ value: "no", label: "Don't include" }
|
{ value: "no", label: "Don't include" },
|
||||||
],
|
],
|
||||||
levelOrderOptions: [
|
levelOrderOptions: [
|
||||||
{ value: "list", label: "As specified" },
|
{ value: "list", label: "As specified" },
|
||||||
{ value: "shuffle", label: "Random, no duplicates" },
|
{ value: "shuffle", label: "Random, no duplicates" },
|
||||||
{ value: "random", label: "Fully random" }
|
{ value: "random", label: "Fully random" },
|
||||||
],
|
],
|
||||||
postGameOptions: [
|
postGameOptions: [
|
||||||
{ value: "0F00", label: "Return to title screen" },
|
{ value: "0F00", label: "Return to title screen" },
|
||||||
{ value: "0109", label: "Load the flooded plaza" },
|
{ value: "0109", label: "Load the flooded plaza" },
|
||||||
{ value: "3400", label: "Load post-Corona plaza" },
|
{ value: "3400", label: "Load post-Corona plaza" },
|
||||||
{ value: "3C00", label: "Load the Bowser fight" }
|
{ value: "3C00", label: "Load the Bowser fight" },
|
||||||
],
|
],
|
||||||
removeDialogSelection: null,
|
removeDialogSelection: null,
|
||||||
skippableFMVsSelection: null,
|
skippableFMVsSelection: null,
|
||||||
levelOrderSelection: null,
|
levelOrderSelection: null,
|
||||||
postGameSelection: null
|
postGameSelection: null,
|
||||||
|
generation: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -127,19 +144,22 @@ export default {
|
||||||
this.postGameSelection = e;
|
this.postGameSelection = e;
|
||||||
},
|
},
|
||||||
onStageLoaderLevelSelected(e) {
|
onStageLoaderLevelSelected(e) {
|
||||||
|
this.generation++;
|
||||||
this.selectedRoute.push({
|
this.selectedRoute.push({
|
||||||
value: e
|
value: e,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onStageLoaderLevelChanged(index, e) {
|
onStageLoaderLevelChanged(index, e) {
|
||||||
this.selectedRoute[index] = {
|
this.selectedRoute[index] = {
|
||||||
value: e
|
value: e,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLevelDeleted(e) {
|
onLevelDeleted(e) {
|
||||||
this.selectedRoute.splice(e, 1);
|
this.selectedRoute.splice(e, 1);
|
||||||
},
|
},
|
||||||
onStageLoaderPresetSelected(e) {
|
onStageLoaderPresetSelected(e) {
|
||||||
|
this.generation++;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.selectedRoute?.length > 0 &&
|
this.selectedRoute?.length > 0 &&
|
||||||
!confirm("Loading a preset will erase your current list. Continue?")
|
!confirm("Loading a preset will erase your current list. Continue?")
|
||||||
|
@ -166,8 +186,11 @@ export default {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.selectedRoute = [];
|
this.selectedRoute = [];
|
||||||
}
|
},
|
||||||
}
|
checkMove(e) {
|
||||||
|
window.console.log("Future index: " + e.draggedContext.futureIndex);
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -198,7 +221,6 @@ ul li {
|
||||||
|
|
||||||
.route-drag {
|
.route-drag {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.route-remove {
|
.route-remove {
|
||||||
|
@ -209,4 +231,4 @@ ul li {
|
||||||
color: red;
|
color: red;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue