Skip to content

Commit

Permalink
Bugfix/inconsistency in the initiative name (#176)
Browse files Browse the repository at this point in the history
* changed project data fallback for projectBar and breadcrumps

* id correction

* users list timing loading fix and data refresh for initiatives

* added data reset on loadProject if no data exist
  • Loading branch information
ladeniva2 authored Jul 12, 2023
1 parent 7763edd commit d93c631
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion frontend/components/BreadCrumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export default {
initiative: 'project/getProjectData',
portfolioInnovationName: 'portfolio/getName',
getPortfolios: 'solution/getPortfoliosList',
draft: 'project/getProjectData',
published: 'project/getPublished',
}),
pureRoute() {
if (this.$route && this.$route.name) {
Expand Down Expand Up @@ -139,7 +141,7 @@ export default {
idToName(route) {
switch (route) {
case 'organisation-initiatives-id':
return this.initiative.name
return this.$route.name.includes('published') ? this.published.name : this.draft.name
case 'organisation-portfolio-innovation-solutions-id':
return this.solutionName
// case 'organisation-portfolio-innovation-id':
Expand Down
8 changes: 6 additions & 2 deletions frontend/components/common/ProjectBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</div>
</el-col>
<el-col v-if="isPublished" :span="2" class="InfoSection">
<favorite :id="project.id" :favorite="favorite" />
<favorite :id="id" :favorite="favorite" />
</el-col>
</el-row>
</el-col>
Expand Down Expand Up @@ -113,7 +113,11 @@ export default {
return this.user ? this.user.favorite.includes(toInteger(this.$route.params.id)) : undefined
},
project() {
return this.published && this.published.name ? this.published : this.draft
if (this.route === 'organisation-initiatives-id-published') {
return this.published
} else {
return this.draft
}
},
isPublished() {
return !!(this.published && this.published.name)
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/_organisation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default {
components: {},
middleware: ['profile'],
async fetch({ store, params }) {
store.dispatch('system/loadUserProfiles')
await Promise.all([
store.dispatch('system/loadUserProfiles'),
store.dispatch('system/loadStaticData'),
store.dispatch('system/loadDonors'),
store.dispatch('countries/loadMapData'),
Expand Down
11 changes: 8 additions & 3 deletions frontend/store/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,10 @@ export const getters = {

export const actions = {
async loadProject({ state, commit, dispatch, rootGetters }, id) {
const userProject = rootGetters['projects/getUserProjectList'].find((p) => p.id === id)
const { data } =
userProject && userProject.id ? { data: userProject } : await this.$axios.get(`/api/projects/${id}/`)
// const userProject = rootGetters['projects/getUserProjectList'].find((p) => p.id === id)
// const { data } =
// userProject && userProject.id ? { data: userProject } : await this.$axios.get(`/api/projects/${id}/`)
const { data } = await this.$axios.get(`/api/projects/${id}/`)
commit('SET_ORIGINAL', Object.freeze(data))
const clean = cleanState()
let unicefDonor = rootGetters['system/getUnicefDonor']
Expand All @@ -188,12 +189,16 @@ export const actions = {
const draft = { ...clean, ...apiReadParser(data.draft) }
draft.donors.forEach((d) => donorsToFetch.add(d))
commit('INIT_PROJECT', draft)
} else {
commit('INIT_PROJECT', clean)
}
// if (data.published) {
if (data.published && !isEmpty(data.published)) {
const published = { ...clean, ...apiReadParser(data.published) }
published.donors.forEach((d) => donorsToFetch.add(d))
commit('SET_PUBLISHED', Object.freeze(published))
} else {
commit('SET_PUBLISHED', clean)
}
const country = data.draft ? data.draft.country : data.published.country
await Promise.all([
Expand Down

0 comments on commit d93c631

Please sign in to comment.