diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue index 6f33a8deb..238446e90 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/App.vue @@ -1,5 +1,11 @@ @@ -8,6 +14,7 @@ import ConcernedGroups from "./components/ConcernedGroups.vue"; import SocialIssuesAcc from "./components/SocialIssuesAcc.vue"; import Location from "./components/Location.vue"; +import { mapState } from "vuex"; export default { name: "App", @@ -17,5 +24,46 @@ export default { SocialIssuesAcc, Location, }, + computed: { + ...mapState(["activity"]), + concernedGroupsModel() { + return { + persons: this.activity.persons, + thirdParties: this.activity.thirdParties, + users: this.activity.users, + }; + }, + suggestedEntities() { + return this.$store.getters.suggestedEntities || []; + }, + }, + methods: { + sameEntity(left, right) { + return left.id === right.id && left.type === right.type; + }, + syncConcernedGroupType(currentList, nextList) { + nextList.forEach((nextEntity) => { + if ( + !currentList.some((current) => this.sameEntity(current, nextEntity)) + ) { + this.$store.dispatch("addPersonsInvolved", { result: nextEntity }); + } + }); + + currentList.forEach((currentEntity) => { + if (!nextList.some((next) => this.sameEntity(next, currentEntity))) { + this.$store.dispatch("removePersonInvolved", currentEntity); + } + }); + }, + updateConcernedGroups(value) { + this.syncConcernedGroupType(this.activity.persons, value.persons); + this.syncConcernedGroupType( + this.activity.thirdParties, + value.thirdParties, + ); + this.syncConcernedGroupType(this.activity.users, value.users); + }, + }, }; diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue index 6b275b4b9..ec18c3537 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups.vue @@ -7,44 +7,35 @@ :bloc="bloc" :bloc-width="getBlocWidth" :set-persons-in-bloc="setPersonsInBloc" + :remove-person-involved="removePersonInvolved" /> -
- -
- diff --git a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups/PersonsBloc.vue b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups/PersonsBloc.vue index 3bb6a84aa..f58fad001 100644 --- a/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups/PersonsBloc.vue +++ b/src/Bundle/ChillActivityBundle/Resources/public/vuejs/Activity/components/ConcernedGroups/PersonsBloc.vue @@ -25,11 +25,11 @@ export default { components: { PersonBadge, }, - props: ["bloc", "setPersonsInBloc", "blocWidth"], + props: ["bloc", "setPersonsInBloc", "blocWidth", "removePersonInvolved"], methods: { removePerson(item) { console.log("@@ CLICK remove person: item", item); - this.$store.dispatch("removePersonInvolved", item); + this.removePersonInvolved(item); this.setPersonsInBloc(); }, }, diff --git a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue index d1374714b..fb8cfc525 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue +++ b/src/Bundle/ChillCalendarBundle/Resources/public/vuejs/Calendar/App.vue @@ -3,16 +3,16 @@

Utilisateur principal

-
- +
+
- +
@@ -181,6 +186,16 @@ export default { computed: { ...mapGetters(["getMainUser"]), ...mapState(["activity"]), + concernedGroupsModel() { + return { + persons: this.activity.persons, + thirdParties: this.activity.thirdParties, + users: this.activity.users, + }; + }, + suggestedEntities() { + return this.$store.getters.suggestedEntities || []; + }, events() { return this.$store.getters.getEventSources; }, @@ -241,6 +256,32 @@ export default { }, }, methods: { + sameEntity(left, right) { + return left.id === right.id && left.type === right.type; + }, + syncConcernedGroupType(currentList, nextList) { + nextList.forEach((nextEntity) => { + if ( + !currentList.some((current) => this.sameEntity(current, nextEntity)) + ) { + this.$store.dispatch("addPersonsInvolved", { result: nextEntity }); + } + }); + + currentList.forEach((currentEntity) => { + if (!nextList.some((next) => this.sameEntity(next, currentEntity))) { + this.$store.dispatch("removePersonInvolved", currentEntity); + } + }); + }, + updateConcernedGroups(value) { + this.syncConcernedGroupType(this.activity.persons, value.persons); + this.syncConcernedGroupType( + this.activity.thirdParties, + value.thirdParties, + ); + this.syncConcernedGroupType(this.activity.users, value.users); + }, setMainUser({ entity }) { const user = entity; console.log("setMainUser APP", entity); @@ -275,9 +316,7 @@ export default { }, removeMainUser(user) { console.log("removeMainUser APP", user); - window.alert(this.$t("main_user_is_mandatory")); - return; }, onDatesSet(event) { console.log("onDatesSet", event);