Skip to content

Commit

Permalink
Allow restoring last mission name
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Nov 24, 2023
1 parent d16e87d commit 6bab7c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@
<v-card class="pa-2">
<v-card-title>Mission configuration</v-card-title>
<v-card-text>
<v-text-field v-model="store.missionName" hide-details="auto" label="Mission name" />
<div class="flex">
<v-text-field
v-model="store.missionName"
label="Mission name"
append-inner-icon="mdi-restore"
@click:append-inner="store.missionName = store.lastMissionName"
/>
</div>
</v-card-text>
</v-card>
</v-dialog>
Expand Down
7 changes: 5 additions & 2 deletions src/stores/mission.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { useStorage } from '@vueuse/core'
import { defineStore } from 'pinia'
import { reactive, ref } from 'vue'
import { reactive, ref, watch } from 'vue'

import type { Waypoint, WaypointCoordinates } from '@/types/mission'

export const useMissionStore = defineStore('mission', () => {
const missionName = ref('')
const lastMissionName = useStorage('cockpit-last-mission-name', '')
const missionStartTime = useStorage('cockpit-mission-start-time', new Date())

watch(missionName, () => (lastMissionName.value = missionName.value))

const currentPlanningWaypoints = reactive<Waypoint[]>([])

const moveWaypoint = (id: string, newCoordinates: WaypointCoordinates): void => {
Expand All @@ -21,5 +24,5 @@ export const useMissionStore = defineStore('mission', () => {
)
}

return { missionName, missionStartTime, currentPlanningWaypoints, moveWaypoint }
return { missionName, lastMissionName, missionStartTime, currentPlanningWaypoints, moveWaypoint }
})

0 comments on commit 6bab7c0

Please sign in to comment.