organization.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import * as _ from 'lodash'
  2. import { baseOrganizationState, organizationState } from '~/types/interfaces'
  3. export const state = () => ({
  4. id: null,
  5. parametersId: null,
  6. name: '',
  7. product: '',
  8. currentActivityYear: '',
  9. modules: [],
  10. hasChildren: false,
  11. legalStatus: '',
  12. showAdherentList: false,
  13. networks: [],
  14. website: '',
  15. subDomain: '',
  16. parents: []
  17. })
  18. export const mutations = {
  19. setId (state: organizationState, id: number) {
  20. state.id = id
  21. },
  22. setParametersId (state: organizationState, parametersId: number) {
  23. state.parametersId = parametersId
  24. },
  25. setName (state: organizationState, name: string) {
  26. state.name = name
  27. },
  28. setProduct (state: organizationState, product: string) {
  29. state.product = product
  30. },
  31. setCurrentActivityYear (state: organizationState, currentActivityYear: number) {
  32. state.currentActivityYear = currentActivityYear
  33. },
  34. setModules (state: organizationState, modules: Array<string>) {
  35. state.modules = modules
  36. },
  37. setHasChildren (state: organizationState, hasChildren: boolean) {
  38. state.hasChildren = hasChildren
  39. },
  40. setShowAdherentList(state:organizationState, showAdherentList:boolean) {
  41. state.showAdherentList = showAdherentList
  42. },
  43. setLegalStatus(state:organizationState, legalStatus:string) {
  44. state.legalStatus = legalStatus
  45. },
  46. setNetworks(state:organizationState, networks:Array<string>) {
  47. state.networks = networks
  48. },
  49. setParents (state: organizationState, parents: Array<organizationState>) {
  50. state.parents = parents
  51. },
  52. setWebsite (state: organizationState, website: string) {
  53. state.website = website
  54. },
  55. setSubDomain (state: organizationState, subDomain: string) {
  56. state.subDomain = subDomain
  57. },
  58. addParent (state: organizationState, parent: organizationState) {
  59. state.parents.push(parent)
  60. }
  61. }
  62. export const actions = {
  63. setProfile (context: any, profile: any) {
  64. context.commit('setId', profile.id)
  65. context.commit('setParametersId', profile.parametersId)
  66. context.commit('setName', profile.name)
  67. context.commit('setProduct', profile.product)
  68. context.commit('setCurrentActivityYear', profile.currentYear)
  69. context.commit('setWebsite', profile.website)
  70. context.commit('setSubDomain', profile.subDomain)
  71. context.commit('setModules', profile.modules)
  72. context.commit('setHasChildren', profile.hasChildren)
  73. context.commit('setLegalStatus', profile.legalStatus)
  74. context.commit('setShowAdherentList', profile.showAdherentList)
  75. context.commit('setNetworks', profile.networks)
  76. _.each(profile.parents, (parent) => {
  77. const p: baseOrganizationState = {
  78. id: parent.id,
  79. name: parent.name,
  80. website: parent.website,
  81. subDomain: parent.subDomain
  82. }
  83. context.commit('addParent', p)
  84. })
  85. }
  86. }