Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve mission name usage experience #590

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Allow restoring last mission name
  • Loading branch information
rafaellehmkuhl committed Nov 24, 2023
commit 6bab7c0c6d3252e9a8ed550ea172145399032a8a
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 }
})
Loading