moving instruments/categories to global state

practiced-songs
Matthew Huntington 11 months ago
parent 7d9f05a758
commit c7e780f716

@ -7,15 +7,18 @@
import Timer from './components/timer.vue'
import Status from './components/status.vue'
import { currentWorkingCategory, currentWorkingInstrument } from './libs/state.js'
import {
currentWorkingCategory,
currentWorkingInstrument,
instruments,
categories
} from './libs/state.js'
const timerRunning = ref(false)
const micThresholdExceeded = ref(false)
const summaryRef = ref(null)
const statusRef = ref(null)
const showCategoryRef = ref(null)
const instruments = ref([])
const categories = ref([])
const refreshPage = (session) => {
summaryRef.value.loadData()
@ -64,18 +67,12 @@
/>
</section>
<section id="summary">
<Summary
ref="summaryRef"
:instruments="instruments"
:categories="categories"
/>
<Summary ref="summaryRef" />
</section>
<section id="category">
<ShowCategory
v-if="currentWorkingInstrument"
ref="showCategoryRef"
:instruments="instruments"
:categories="categories"
/>
</section>
<section id="songs">

@ -1,23 +1,27 @@
<script setup>
import { defineProps } from 'vue';
const props = defineProps(['instruments', 'categories'])
import { currentWorkingCategory, currentWorkingInstrument } from '../libs/state.js'
import {
currentWorkingCategory,
currentWorkingInstrument,
instruments,
categories
} from '../libs/state.js'
const selectFirstInstrumentOfCategory = () => {
currentWorkingCategory.value = props.categories.find(category => category.instrument === currentWorkingInstrument.value.name)
currentWorkingCategory.value = categories.value.find(category => category.instrument === currentWorkingInstrument.value.name)
}
</script>
<template>
<select @change="selectFirstInstrumentOfCategory" v-model="currentWorkingInstrument">
<option :value="instrument" v-for="instrument in props.instruments">
<option :value="instrument" v-for="instrument in instruments">
{{instrument.name}}
</option>
</select>
<select v-model="currentWorkingCategory">
<option
v-for="category in props.categories.filter(currentCategory => currentCategory.instrument === currentWorkingInstrument.name)"
v-for="category in categories.filter(currentCategory => currentCategory.instrument === currentWorkingInstrument.name)"
:value="category">
{{category.category}}
</option>

@ -2,9 +2,10 @@
import { formatSeconds } from '../libs/time.js'
import CategoryChooser from './category_chooser.vue'
import { onMounted, ref, watch, defineProps } from 'vue'
import { currentWorkingCategory, currentWorkingInstrument } from '../libs/state.js'
const props = defineProps(['categories', 'instruments'])
import {
currentWorkingCategory,
currentWorkingInstrument
} from '../libs/state.js'
const categorySessions = ref([])
@ -25,9 +26,7 @@
<template>
<h2>Show Category</h2>
<CategoryChooser
:instruments="props.instruments"
:categories="props.categories" />
<CategoryChooser />
<table>
<thead>
<tr>

@ -1,7 +1,11 @@
<script setup>
import { onMounted, ref, defineExpose } from 'vue'
import { currentWorkingCategory, currentWorkingInstrument } from '../libs/state.js'
const props = defineProps(['instruments', 'categories'])
import {
currentWorkingCategory,
currentWorkingInstrument,
instruments,
categories
} from '../libs/state.js'
const summary = ref([])
@ -13,9 +17,9 @@
onMounted(loadData)
const setWorkingCategory = (choice) => {
const chosenCategory = props.categories.find(category => category.id === choice.category_id)
const chosenCategory = categories.value.find(category => category.id === choice.category_id)
currentWorkingCategory.value = chosenCategory
currentWorkingInstrument.value = props.instruments.find(instrument => instrument.name === chosenCategory.instrument)
currentWorkingInstrument.value = instruments.value.find(instrument => instrument.name === chosenCategory.instrument)
}
defineExpose({loadData})

@ -4,8 +4,6 @@
const micThresholdExceeded = defineModel('micThresholdExceeded')
const timerRunning = defineModel('timerRunning')
const props = defineProps(['categories', 'instruments'])
const { proxy } = getCurrentInstance();
onMounted(()=>{
@ -228,9 +226,7 @@
<input @change="updateSavedPreviousSeconds" v-model="totalSeconds" type="number"/>
<label>Practice Category</label>
<CategoryChooser
:instruments="instruments"
:categories="categories" />
<CategoryChooser />
<input type="submit"/>
<label>Comments</label>

@ -2,3 +2,5 @@ import { ref } from 'vue'
export const copiedSongs = ref([])
export const currentWorkingCategory = ref(null)
export const currentWorkingInstrument = ref(null)
export const instruments = ref([])
export const categories = ref([])

Loading…
Cancel
Save