activity/location: refactor

Refactor the way for loading locations:

* fix showing the default location
* fix when there is not thirdparty default location
* separate api queries instead of inlines;
* use the store instead of the mounted
* refactored for a possible re-use in calendar
This commit is contained in:
2021-12-14 23:20:47 +01:00
parent 3a9fac08c3
commit de790d11a8
4 changed files with 139 additions and 119 deletions

View File

@@ -1,6 +1,10 @@
import 'es6-promise/auto';
import { createStore } from 'vuex';
import { postLocation } from 'ChillActivityAssets/vuejs/Activity/api';
import {
getLocations, getLocationTypeByDefaultFor,
getUserCurrentLocation
} from "../../../../../ChillActivityBundle/Resources/public/vuejs/Activity/api";
const debug = process.env.NODE_ENV !== 'production';
@@ -82,7 +86,7 @@ const store = createStore({
}
},
mutations: {
// ConcernedGroups
addPersonsInvolved(state, payload) {
//console.log('### mutation addPersonsInvolved', payload.result.type);
@@ -94,7 +98,7 @@ const store = createStore({
state.activity.thirdParties.push(payload.result);
break;
case 'user':
state.activity.users.push(payload.result);
state.activity.users.push(payload.result);
break;
};
},
@@ -108,7 +112,7 @@ const store = createStore({
state.activity.thirdParties = state.activity.thirdParties.filter(thirdparty => thirdparty !== payload);
break;
case 'user':
state.activity.users = state.activity.users.filter(user => user !== payload);
state.activity.users = state.activity.users.filter(user => user !== payload);
break;
};
},
@@ -217,9 +221,7 @@ const store = createStore({
hiddenLocation.value = value.id;
}
commit("updateLocation", value);
}
}
});