confidential toggle rights

This commit is contained in:
2021-11-29 11:01:51 +00:00
committed by Julien Fastré
parent 6d6f930afa
commit e4e1edff68
11 changed files with 278 additions and 21 deletions

View File

@@ -21,6 +21,7 @@
<script>
import { mapState } from 'vuex';
export default {
name: "ToggleFlags",
computed: {
@@ -28,6 +29,7 @@ export default {
intensity: state => state.accompanyingCourse.intensity,
emergency: state => state.accompanyingCourse.emergency,
confidential: state => state.accompanyingCourse.confidential,
permissions: state => state.permissions,
}),
isRegular() {
return (this.intensity === 'regular') ? true : false;
@@ -37,7 +39,7 @@ export default {
},
isConfidential() {
return (this.confidential) ? true : false;
}
},
},
methods: {
toggleIntensity() {
@@ -73,16 +75,15 @@ export default {
});
},
toggleConfidential() {
this.$store.dispatch('toggleConfidential', (!this.isConfidential))
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
}
}
this.$store.dispatch('fetchPermissions').then(() => {
if (!this.$store.getters.canTogglePermission) {
this.$toast.open({message: "Seul le référent peut modifier la confidentialité"});
} else {
this.$store.dispatch('toggleConfidential', (!this.isConfidential));
}
});
},
},
}
</script>