Fixed: [vue] add condition to use dropdown or single button

This commit is contained in:
Mathieu Jaumotte 2023-05-23 18:10:29 +02:00
parent ef6a5e0b6b
commit 53aa887da5
3 changed files with 31 additions and 12 deletions

View File

@ -298,12 +298,7 @@
</li> </li>
<li> <li>
<!-- <button v-if="AmIRefferer"
{% if accompanyingCourse.hasUser and accompanyingCourse.user is not same as(app.user) %}
{{ work.accompanyingPeriod.user }}
-->
<button
v-if="false"
class="btn btn-notify" class="btn btn-notify"
@click="goToGenerateNotification(false)" @click="goToGenerateNotification(false)"
></button> ></button>
@ -463,6 +458,7 @@ export default {
'isPosting', 'isPosting',
'errors', 'errors',
'templatesAvailablesForAction', 'templatesAvailablesForAction',
'me',
]), ]),
...mapGetters([ ...mapGetters([
'hasResultsForAction', 'hasResultsForAction',
@ -520,6 +516,10 @@ export default {
this.$store.commit('setPersonsPickedIds', v); this.$store.commit('setPersonsPickedIds', v);
} }
}, },
AmIRefferer() {
return (!(this.work.accompanyingPeriod.user && this.me
&& (this.work.accompanyingPeriod.user.id !== this.me.id)));
}
}, },
methods: { methods: {
toggleSelect() { toggleSelect() {

View File

@ -116,12 +116,8 @@
></list-workflow-modal> ></list-workflow-modal>
</li> </li>
<li> <li>
<!--
{% if accompanyingCourse.hasUser and accompanyingCourse.user is not same as(app.user) %}
{{ work.accompanyingPeriod.user }}
-->
<button <button
v-if="false" v-if="AmIRefferer"
class="btn btn-notify" class="btn btn-notify"
@click="goToGenerateDocumentNotification(d, false)"> @click="goToGenerateDocumentNotification(d, false)">
</button> </button>
@ -282,8 +278,13 @@ export default {
computed: { computed: {
...mapState([ ...mapState([
'isPosting', 'isPosting',
'work' 'work',
'me',
]), ]),
AmIRefferer() {
return (!(this.$store.state.work.accompanyingPeriod.user && this.$store.state.me
&& (this.$store.state.work.accompanyingPeriod.user.id !== this.$store.state.me.id)));
},
getTemplatesAvailables() { getTemplatesAvailables() {
return this.$store.getters.getTemplatesAvailablesForEvaluation(this.evaluation.evaluation); return this.$store.getters.getTemplatesAvailablesForEvaluation(this.evaluation.evaluation);
}, },

View File

@ -35,6 +35,7 @@ const store = createStore({
referrers: window.accompanyingCourseWork.referrers, referrers: window.accompanyingCourseWork.referrers,
isPosting: false, isPosting: false,
errors: [], errors: [],
me: null
}, },
getters: { getters: {
socialAction(state) { socialAction(state) {
@ -130,6 +131,9 @@ const store = createStore({
} }
}, },
mutations: { mutations: {
setWhoAmiI(state, me) {
state.me = me;
},
setEvaluationsPicked(state, evaluations) { setEvaluationsPicked(state, evaluations) {
state.evaluationsPicked = evaluations.map((e, index) => { state.evaluationsPicked = evaluations.map((e, index) => {
var k = Object.assign(e, { var k = Object.assign(e, {
@ -385,6 +389,19 @@ const store = createStore({
}, },
}, },
actions: { actions: {
getWhoAmI({ commit }) {
let url = `/api/1.0/main/whoami.json`;
window.fetch(url)
.then(response => {
if (response.ok) {
return response.json();
}
throw { m: 'Error while retriving results for goal', s: response.status, b: response.body };
})
.then(data => {
commit('setWhoAmiI', data);
});
},
updateThirdParty({ commit }, payload) { updateThirdParty({ commit }, payload) {
commit('updateThirdParty', payload); commit('updateThirdParty', payload);
}, },
@ -514,6 +531,7 @@ store.commit('setEvaluationsPicked', window.accompanyingCourseWork.accompanyingP
store.dispatch('getReachablesResultsForAction'); store.dispatch('getReachablesResultsForAction');
store.dispatch('getReachablesGoalsForAction'); store.dispatch('getReachablesGoalsForAction');
store.dispatch('getReachablesEvaluationsForAction'); store.dispatch('getReachablesEvaluationsForAction');
store.dispatch('getWhoAmI');
store.state.evaluationsPicked.forEach(evaluation => { store.state.evaluationsPicked.forEach(evaluation => {
store.dispatch('fetchTemplatesAvailablesForEvaluation', evaluation.evaluation) store.dispatch('fetchTemplatesAvailablesForEvaluation', evaluation.evaluation)