Skip to content

Commit

Permalink
linked url with goal modal (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
pallabez authored Sep 10, 2023
1 parent fbb8480 commit 623b9c2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 20 deletions.
17 changes: 17 additions & 0 deletions app/router.options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { RouterConfig } from '@nuxt/schema'

export default {
routes: (_routes) => [
{
name: 'home',
path: '/',
component: async () => await import('~/pages/index.vue').then(r => r.default || r),
children: [
{
path: '/goal/:goalId',
component: async () => await import('~/pages/goal/[id].vue')
}
]
}
]
} as RouterConfig
5 changes: 2 additions & 3 deletions components/GoalFormModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<v-icon icon="mdi-close" />
</v-btn>
<v-toolbar-title>Goal Form</v-toolbar-title>
<!-- <v-spacer></v-spacer> -->
</v-toolbar>
<GoalForm />
</v-card>
Expand All @@ -29,14 +28,14 @@ export default {
GoalForm,
},
props: ["visible", "closeCreateGoalModal"],
props: ["visible", "closeGoalModal"],
computed: {
show: {
get() {
return this.visible;
},
set() {
this.closeCreateGoalModal();
this.closeGoalModal();
},
},
},
Expand Down
15 changes: 0 additions & 15 deletions components/GoalList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,18 @@
v-for="goalId in recentlyCreated.data"
:key="goalId"
:goal-id="goalId"
:openCreateGoalModal="openCreateGoalModal"
/>
</tbody>
</v-table>

<GoalFormModal
:visible="showCreateGoalModal"
:closeCreateGoalModal="closeCreateGoalModal"
/>
</v-container>
</template>

<script lang="ts" setup>
import { useGoalsStore } from "~/store/goals";
import { storeToRefs } from "pinia";
import { ref } from "vue";
const goalStore = useGoalsStore();
const { recentlyCreated } = storeToRefs(goalStore);
const showCreateGoalModal = ref(false);
const openCreateGoalModal = (goalId: number) => {
showCreateGoalModal.value = true;
};
const closeCreateGoalModal = () => {
showCreateGoalModal.value = false;
};
</script>

<style scoped></style>
6 changes: 4 additions & 2 deletions components/GoalListTabEdit.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<template>
<tr v-if="goal">
<td @click="openCreateGoalModal(state.id)">{{ state.title }}</td>
<nuxt-link :to="`/goal/${props.goalId}`">
{{ state.title }}
</nuxt-link>
<td>{{ state.status || "---" }}</td>
<td>
<v-menu v-model="state.assigneeMenu" location="bottom">
Expand Down Expand Up @@ -39,7 +41,7 @@ import { reactive, ref } from "vue";
import { goalRepo } from "~/models/Goal";
import { useGoalsStore } from "~/store/goals";
import { useUsersStore } from "~/store/users";
const props = defineProps(["goalId", "openCreateGoalModal"]);
const props = defineProps(["goalId"]);
const goalStore = useGoalsStore();
const userStore = useUsersStore();
Expand Down
15 changes: 15 additions & 0 deletions pages/goal/[id].vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<GoalFormModal
:visible="showCreateGoalModal"
:close-goal-modal="closeGoalModal"
/>
</template>

<script setup lang="ts">
const showCreateGoalModal = ref(true);
const router = useRouter()
const closeGoalModal = () => {
router.push('/')
};
</script>
1 change: 1 addition & 0 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<v-container>
<GoalTabPost />
<GoalList />
<router-view />
</v-container>
</template>

Expand Down

0 comments on commit 623b9c2

Please sign in to comment.