96 lines
2.2 KiB
Vue
96 lines
2.2 KiB
Vue
<template>
|
|
<div class="project-detail">
|
|
<div class="header-row">
|
|
<h1>{{ projectGroup.title }}</h1>
|
|
</div>
|
|
<ul class="tabs">
|
|
<li class="tab" :class="{ active: currentTab === tab }" v-for="tab in tabs" :key="tab.name" @click="switchToTab(tab)">
|
|
{{ tab.name }}
|
|
</li>
|
|
</ul>
|
|
<component :is="currentTab.component" :projectGroup="projectGroup"></component>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import projectGroup from '@/api/project_group.js'
|
|
|
|
import ProjectGroupTabProjects from '@/components/ProjectGroupTabProjects.vue'
|
|
import ProjectGroupTabStories from '@/components/ProjectGroupTabStories.vue'
|
|
|
|
export default {
|
|
name: 'ProjectGroupDetailView',
|
|
components: {
|
|
ProjectGroupTabProjects,
|
|
ProjectGroupTabStories
|
|
},
|
|
data () {
|
|
return {
|
|
currentTab: {},
|
|
projectGroup: {},
|
|
tabs: [
|
|
{
|
|
name: 'Projects in this Group',
|
|
component: ProjectGroupTabProjects
|
|
},
|
|
{
|
|
name: 'Stories related to this Group',
|
|
component: ProjectGroupTabStories
|
|
}
|
|
]
|
|
}
|
|
},
|
|
created () {
|
|
this.getProject(this.$route.params.id)
|
|
},
|
|
methods: {
|
|
async getProject (projectGroupId) {
|
|
this.projectGroup = await projectGroup.get(projectGroupId)
|
|
if (Object.keys(this.$route.query).length !== 0) {
|
|
this.currentTab = this.tabs[1]
|
|
} else {
|
|
this.currentTab = this.tabs[0]
|
|
}
|
|
},
|
|
switchToTab (tab) {
|
|
if (tab !== this.tabs[1]) {
|
|
// If we're navigating away from the Stories tab, clear
|
|
// the query string to keep the URL intuitive when shared.
|
|
this.$router.replace({ query: {} })
|
|
}
|
|
this.currentTab = tab
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.project-detail {
|
|
.tabs {
|
|
list-style: none;
|
|
display: flex;
|
|
//margin: 20px 15% 10px 15%;
|
|
padding: 0;
|
|
border-bottom: solid 1px #ddd;
|
|
text-align: center;
|
|
|
|
.tab {
|
|
flex: 0 1 auto;
|
|
padding: 20px;
|
|
font-size: 1.2em;
|
|
cursor: pointer;
|
|
transition: 100ms ease-in-out all;
|
|
|
|
&:hover {
|
|
box-shadow: 0 -1px 0 inset #c43422;
|
|
}
|
|
|
|
&.active {
|
|
color: #c43422;
|
|
box-shadow: 0 -2px 0 inset #c43422;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|