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

View File

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

View File

@ -35,6 +35,7 @@ const store = createStore({
referrers: window.accompanyingCourseWork.referrers,
isPosting: false,
errors: [],
me: null
},
getters: {
socialAction(state) {
@ -130,6 +131,9 @@ const store = createStore({
}
},
mutations: {
setWhoAmiI(state, me) {
state.me = me;
},
setEvaluationsPicked(state, evaluations) {
state.evaluationsPicked = evaluations.map((e, index) => {
var k = Object.assign(e, {
@ -385,6 +389,19 @@ const store = createStore({
},
},
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) {
commit('updateThirdParty', payload);
},
@ -514,6 +531,7 @@ store.commit('setEvaluationsPicked', window.accompanyingCourseWork.accompanyingP
store.dispatch('getReachablesResultsForAction');
store.dispatch('getReachablesGoalsForAction');
store.dispatch('getReachablesEvaluationsForAction');
store.dispatch('getWhoAmI');
store.state.evaluationsPicked.forEach(evaluation => {
store.dispatch('fetchTemplatesAvailablesForEvaluation', evaluation.evaluation)