You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
595 B

  1. import Vue from 'vue'
  2. declare module 'vue/types/vue' {
  3. interface Vue {
  4. $translateRole(role: string, mappings: object): string
  5. }
  6. }
  7. type RoleMapping = {
  8. projectAdmin: string,
  9. annotator: string,
  10. annotationApprover: string,
  11. undefined: string
  12. }
  13. Vue.prototype.$translateRole = (role: string, mapping: RoleMapping) => {
  14. if (role === 'project_admin') {
  15. return mapping.projectAdmin
  16. } else if (role === 'annotator') {
  17. return mapping.annotator
  18. } else if (role === 'annotation_approver') {
  19. return mapping.annotationApprover
  20. } else {
  21. return mapping.undefined
  22. }
  23. }