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