UPD: Profile management

This commit is contained in:
Robert Kossessa
2024-01-27 03:46:35 +01:00
parent 7c6d75b3fb
commit 96b305b74d
2 changed files with 22 additions and 12 deletions

View File

@@ -49,8 +49,8 @@
<CollapsibleContent>
<ProfileButton
v-for="(profile, index) in tagProfiles" :key="profile.id" v-model="tagProfiles[index]"
:selected="currentProfile===profile.id"
@select="currentProfile=profile.id" />
:selected="currentProfileId===profile.id"
@select="currentProfileId=profile.id" />
</CollapsibleContent>
</Collapsible>
</div>
@@ -60,7 +60,7 @@
<script setup>
import { Separator } from '@/components/ui/separator/index.js'
import { ChevronRight, Plus, Search } from 'lucide-vue-next'
import { computed, ref } from 'vue'
import { computed, ref, watch } from 'vue'
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
import ScrambleText from '@/components/effects/ScrambleText.vue'
import { store } from '@/store.js'
@@ -68,18 +68,17 @@ import ProfileButton from '@/components/ProfileButton.vue'
const maxProfiles = 32
const editingId = ref(null)
const profiles = computed({
get: () => store.device.profiles,
set: val => store.device.profiles = val,
})
const currentProfileId = computed({
get: () => store.currentProfileId,
set: val => store.currentProfileId = val,
})
const filter = ref('')
const collapse = ref({})
const currentProfile = ref(null)
const profileTitles = ref({})
const filteredProfiles = computed(() => {
if (!filter.value) {
return profiles.value
@@ -104,10 +103,15 @@ const filteredProfilesByTag = computed(() => {
})
return map
})
watch(profiles, () => {
if (!currentProfileId.value && profiles.value.length > 0)
currentProfileId.value = profiles.value[0].id
})
</script>
<style scoped>
[data-state=open] > .chevrot {
transform: rotate(90deg);
}
</style>

View File

@@ -1,9 +1,15 @@
import { reactive } from 'vue'
import { computed, reactive } from 'vue'
export const store = reactive({
device: {
profiles: [],
activeProfile: null,
activeProfileId: null,
activeProfile: computed(() => {
return store.device.profiles.find(p => p.id === store.device.activeProfileId)
}),
},
currentProfile: null,
currentProfileId: null,
currentProfile: computed(() => {
return store.device.profiles.find(p => p.id === store.currentProfileId)
}),
})