mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch '334-current-user-activity-suggestion' into 'master'
Resolve "Quand on crée un échange, l'utilisateur courant doit toujours être suggéré" Closes #334 See merge request Chill-Projet/chill-bundles!786
This commit is contained in:
commit
b0993f4062
6
.changes/unreleased/Feature-20250130-115958.yaml
Normal file
6
.changes/unreleased/Feature-20250130-115958.yaml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
kind: Feature
|
||||||
|
body: Suggest current user when creating an activity
|
||||||
|
time: 2025-01-30T11:59:58.608842881+01:00
|
||||||
|
custom:
|
||||||
|
Issue: "334"
|
||||||
|
SchemaChange: No schema change
|
@ -12,6 +12,8 @@ This runs eslint **not** taking the baseline into account, thus showing all exis
|
|||||||
A script was also added to package.json allowing you to execute ``yarn run eslint``.
|
A script was also added to package.json allowing you to execute ``yarn run eslint``.
|
||||||
This will run eslint, but **taking the baseline into account**, thus only alerting to newly created errors.
|
This will run eslint, but **taking the baseline into account**, thus only alerting to newly created errors.
|
||||||
|
|
||||||
|
The eslint command is configured to also run ``prettier`` which will simply format the code to look more uniform (takes care indentation for example).
|
||||||
|
|
||||||
Interesting options that can be used in combination with eslint are:
|
Interesting options that can be used in combination with eslint are:
|
||||||
|
|
||||||
- ``--quiet`` to only get errors and silence the warnings
|
- ``--quiet`` to only get errors and silence the warnings
|
||||||
|
@ -2,6 +2,7 @@ import "es6-promise/auto";
|
|||||||
import { createStore } from "vuex";
|
import { createStore } from "vuex";
|
||||||
import { postLocation } from "./api";
|
import { postLocation } from "./api";
|
||||||
import prepareLocations from "./store.locations.js";
|
import prepareLocations from "./store.locations.js";
|
||||||
|
import { makeFetch } from "ChillMainAssets/lib/api/apiMethods";
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== "production";
|
const debug = process.env.NODE_ENV !== "production";
|
||||||
//console.log('window.activity', window.activity);
|
//console.log('window.activity', window.activity);
|
||||||
@ -23,6 +24,7 @@ const removeIdFromValue = (string, id) => {
|
|||||||
const store = createStore({
|
const store = createStore({
|
||||||
strict: debug,
|
strict: debug,
|
||||||
state: {
|
state: {
|
||||||
|
me: null,
|
||||||
activity: window.activity,
|
activity: window.activity,
|
||||||
socialIssuesOther: [],
|
socialIssuesOther: [],
|
||||||
socialActionsList: [],
|
socialActionsList: [],
|
||||||
@ -79,15 +81,25 @@ const store = createStore({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
suggestedUser(state) {
|
suggestedUser(state) {
|
||||||
|
// console.log('current user', state.me)
|
||||||
const existingUserIds = state.activity.users.map((p) => p.id);
|
const existingUserIds = state.activity.users.map((p) => p.id);
|
||||||
return state.activity.activityType.usersVisible === 0
|
let suggestedUsers =
|
||||||
|
state.activity.activityType.usersVisible === 0
|
||||||
? []
|
? []
|
||||||
: [state.activity.accompanyingPeriod.user].filter(
|
: [state.activity.accompanyingPeriod.user].filter(
|
||||||
(u) => u !== null && !existingUserIds.includes(u.id),
|
(u) => u !== null && !existingUserIds.includes(u.id),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Add the current user from the state
|
||||||
|
if (state.me && !existingUserIds.includes(state.me.id)) {
|
||||||
|
suggestedUsers.push(state.me);
|
||||||
|
}
|
||||||
|
console.log("suggested users", suggestedUsers);
|
||||||
|
|
||||||
|
return suggestedUsers;
|
||||||
},
|
},
|
||||||
suggestedResources(state) {
|
suggestedResources(state) {
|
||||||
const resources = state.activity.accompanyingPeriod.resources;
|
// const resources = state.activity.accompanyingPeriod.resources;
|
||||||
const existingPersonIds = state.activity.persons.map((p) => p.id);
|
const existingPersonIds = state.activity.persons.map((p) => p.id);
|
||||||
const existingThirdPartyIds = state.activity.thirdParties.map(
|
const existingThirdPartyIds = state.activity.thirdParties.map(
|
||||||
(p) => p.id,
|
(p) => p.id,
|
||||||
@ -111,6 +123,9 @@ const store = createStore({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
setWhoAmI(state, me) {
|
||||||
|
state.me = me;
|
||||||
|
},
|
||||||
// SocialIssueAcc
|
// SocialIssueAcc
|
||||||
addIssueInList(state, issue) {
|
addIssueInList(state, issue) {
|
||||||
//console.log('add issue list', issue.id);
|
//console.log('add issue list', issue.id);
|
||||||
@ -326,9 +341,17 @@ const store = createStore({
|
|||||||
}
|
}
|
||||||
commit("updateLocation", value);
|
commit("updateLocation", value);
|
||||||
},
|
},
|
||||||
|
getWhoAmI({ commit }) {
|
||||||
|
const url = `/api/1.0/main/whoami.json`;
|
||||||
|
makeFetch("GET", url).then((user) => {
|
||||||
|
commit("setWhoAmI", user);
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
store.dispatch("getWhoAmI");
|
||||||
|
|
||||||
prepareLocations(store);
|
prepareLocations(store);
|
||||||
|
|
||||||
export default store;
|
export default store;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user