Skip to content

Commit

Permalink
update proposal link
Browse files Browse the repository at this point in the history
  • Loading branch information
ajatprabha committed Oct 23, 2018
1 parent a0d88db commit 469b7ec
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 11 deletions.
31 changes: 27 additions & 4 deletions ui/src/components/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,30 @@
<v-divider class="mb-4"></v-divider>
<StudentProfile/>
<v-alert
:value="true"
:value="studentProjectList.length <= 0"
type="info"
>
All set for now! Now contact <router-link class="white--text" :to="{name: 'MentorList'}">mentors</router-link> regarding a
project, ask them to float it and once it is approved, you'll be able to submit a proposal for it.
project, ask them to float it and once it is approved, you'll be able to submit a proposal for it and
they'll appear down here.
</v-alert>
<div v-if="studentProjectList.length > 0">
<v-container grid-list-lg>
<v-layout column>
<v-flex>
<v-card flat>
<v-card-text><h3 class="display-1">Projects</h3></v-card-text>
<v-card-text>
<div class="mb-4" v-for="(project, i) in studentProjectList" :key="i">
<Project :project="project" :mentor="false"/>
<v-divider v-if="studentProjectList.length !== i + 1"/>
</div>
</v-card-text>
</v-card>
</v-flex>
</v-layout>
</v-container>
</div>
</v-card>
</v-flex>
</v-layout>
Expand Down Expand Up @@ -141,13 +159,17 @@
props: ['index'],
computed: {
...mapGetters('projectList', [
'mentorProjectList'
'mentorProjectList',
'studentProjectList'
]),
...mapGetters('mentorProfile', [
'mentorProfile'
]),
...mapGetters('studentProfile', [
'studentProfile'
]),
...mapGetters('proposalList', [
'studentProposalList'
])
},
methods: {
Expand Down Expand Up @@ -179,7 +201,8 @@
},
watch: {
profile (value) {
if (value.id && value.type === 'mentor-profile') this.fetchProjectList()
this.fetchProjectList()
// if (value.id && value.type === 'mentor-profile') this.fetchProjectList()
}
}
}
Expand Down
14 changes: 12 additions & 2 deletions ui/src/components/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div>
<v-icon class="mx-2" v-if="mentor" @click="dialog = true">fa-trash</v-icon>
<v-icon class="mx-2" v-if="mentor" @click="editDialog = true">fa-pencil</v-icon>
<v-btn v-if="showProposalDialogButton" @click="proposalDialog = true">Add Proposal</v-btn>
<v-btn v-if="showProposalDialogButton" @click="proposalDialog = true">{{$route.name === 'Dashboard'?'Update':'Add'}} Proposal</v-btn>
<a :href="project.github_link" target="_blank" class="dashline">
<v-icon class="mx-2">fa-github</v-icon>
</a>
Expand All @@ -25,7 +25,11 @@
<ProjectCreateUpdate :mode="'update'" :updateId="project.id" :key="project.id" @close_dialog="editDialog = false"/>
</v-dialog>
<v-dialog v-if="showProposalDialogButton" v-model="proposalDialog" max-width="900">
<ProposalCreateUpdate :mode="'apply'" :projectId="project.id" @close_dialog="proposalDialog = false"/>
<ProposalCreateUpdate
:mode="$route.name === 'Dashboard' ? 'update':'apply'"
:updateId="getProposalUpdateIdByProjectId(project.id)"
:projectId="project.id"
@close_dialog="proposalDialog = false"/>
</v-dialog>
</div>
</v-layout>
Expand Down Expand Up @@ -74,6 +78,7 @@
},
computed: {
...mapGetters('mentorList', ['mentorList']),
...mapGetters('proposalList', ['studentProposalList']),
...mapGetters('auth', ['isLoggedIn']),
chips () {
return this.project.technologies
Expand All @@ -84,11 +89,15 @@
},
methods: {
...mapActions('mentorList', ['fetchMentorList']),
...mapActions('proposalList', ['fetchProposalList']),
getMentorNameById (mentorId) {
const mentor = this.mentorList.find(mentor => mentor.id === mentorId)
if (mentor) return `${mentor.first_name} ${mentor.last_name}`
else return ''
},
getProposalUpdateIdByProjectId (projectId) {
return this.studentProposalList.find(proposal => proposal.project === projectId).id || null
},
remove () {
this.$httpClient.delete(`/api/project/projects/${this.project.id}/`).then(response => {
this.$store.dispatch('projectList/removeProjectById', this.project.id)
Expand All @@ -98,6 +107,7 @@
}
},
mounted () {
if (!this.studentProposalList.length) this.fetchProposalList()
if (!this.mentorList.length) this.fetchMentorList()
}
}
Expand Down
11 changes: 6 additions & 5 deletions ui/src/components/ProposalCreateUpdate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
if (this.mode === 'apply') this.performApply()
else this.performUpdate()
},
setFile (file) {
this.proposal.file = file
},
performApply () {
this.$httpClient.post('/api/project/student-proposal/', {
project: this.projectId,
Expand Down Expand Up @@ -109,6 +106,10 @@
this.updateProposal(_.cloneDeep(response.data))
this.proposal = response.data
this.$emit('close_dialog')
this.$store.dispatch('messages/showMessage', {
message: 'Proposal updated successfully!',
color: 'success'
}, {root: true})
}).catch(() => {
this.$store.dispatch('messages/showMessage', {
message: 'Something went wrong!',
Expand All @@ -119,10 +120,10 @@
setProposal () {
if (this.updateId) {
const proposal = this.studentProposalList.find(proposal => proposal.id === this.updateId)
if (proposal) this.proposal = proposal
if (proposal) this.proposal = _.cloneDeep(proposal)
else {
this.$httpClient.get(`/api/project/student-proposal/${this.updateId}/`).then(response => {
this.project = response.data
this.proposal = response.data
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions ui/src/store/modules/projectList.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const getters = {
projectList: (state, getters) => state.projectList[0] ? state.projectList : [],
mentorProjectList: (state, getters, rootState, rootGetters) => state.projectList
.filter(project => project.mentors.indexOf(rootGetters['mentorProfile/mentorProfile'].id) >= 0),
studentProjectList: (state, getters, rootState, rootGetters) => state.projectList
.filter(project => project.students.indexOf(rootGetters['studentProfile/studentProfile'].id) >= 0),
filteredProjectList: (state, getters) => {
if (state.filterString.length > 2 && state.filterString.replace(/\s/g, '').length) {
return state.filterString
Expand Down

0 comments on commit 469b7ec

Please sign in to comment.