| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import * as _ from 'lodash'
- import { baseOrganizationState, organizationState } from '~/types/interfaces'
- export const state = () => ({
- id: null,
- name: '',
- product: '',
- modules: [],
- hasChildren: false,
- networks: [],
- website: '',
- subDomain: '',
- parents: []
- })
- export const mutations = {
- setId (state:organizationState, id:number) {
- state.id = id
- },
- setName (state:organizationState, name:string) {
- state.name = name
- },
- setProduct (state:organizationState, product:string) {
- state.product = product
- },
- setModules (state:organizationState, modules:Array<string>) {
- state.modules = modules
- },
- setHasChildren (state:organizationState, hasChildren:boolean) {
- state.hasChildren = hasChildren
- },
- setNetworks (state:organizationState, networks:Array<string>) {
- state.networks = networks
- },
- setParents (state:organizationState, parents:Array<organizationState>) {
- state.parents = parents
- },
- setWebsite (state:organizationState, website:string) {
- state.website = website
- },
- setSubDomain (state:organizationState, subDomain:string) {
- state.subDomain = subDomain
- },
- addParent (state:organizationState, parent:organizationState) {
- state.parents.push(parent)
- }
- }
- export const actions = {
- setProfile (context:any, profile:any) {
- context.commit('setId', profile.id)
- context.commit('setName', profile.name)
- context.commit('setProduct', profile.product)
- context.commit('setWebsite', profile.website)
- context.commit('setSubDomain', profile.subDomain)
- context.commit('setModules', profile.modules)
- context.commit('setHasChildren', profile.hasChildren)
- context.commit('setNetworks', profile.networks)
- _.each(profile.parents, (parent) => {
- const p:baseOrganizationState = {
- id: parent.id,
- name: parent.name,
- website: parent.website,
- subDomain: parent.subDomain
- }
- context.commit('addParent', p)
- })
- }
- }
|