mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
calendar app: change mainUser if mainUser is selected
This commit is contained in:
parent
7dcd5be735
commit
3fbdcdc431
@ -329,6 +329,7 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection|User[]
|
* @return Collection|User[]
|
||||||
|
* @Serializer\Groups({"calendar:read", "read"})
|
||||||
*/
|
*/
|
||||||
public function getUsers(): Collection
|
public function getUsers(): Collection
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,7 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
|||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Table(name="chill_calendar.invite")
|
* @ORM\Table(name="chill_calendar.invite")
|
||||||
@ -47,17 +48,20 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface
|
|||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
* @ORM\GeneratedValue
|
* @ORM\GeneratedValue
|
||||||
* @ORM\Column(type="integer")
|
* @ORM\Column(type="integer")
|
||||||
|
* @Serializer\Groups(groups={"calendar:read", "read"})
|
||||||
*/
|
*/
|
||||||
private ?int $id = null;
|
private ?int $id = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="text", nullable=false, options={"default": "pending"})
|
* @ORM\Column(type="text", nullable=false, options={"default": "pending"})
|
||||||
|
* @Serializer\Groups(groups={"calendar:read", "read"})
|
||||||
*/
|
*/
|
||||||
private string $status = self::PENDING;
|
private string $status = self::PENDING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||||
* @ORM\JoinColumn(nullable=false)
|
* @ORM\JoinColumn(nullable=false)
|
||||||
|
* @Serializer\Groups(groups={"calendar:read", "read"})
|
||||||
*/
|
*/
|
||||||
private ?User $user = null;
|
private ?User $user = null;
|
||||||
|
|
||||||
|
@ -162,19 +162,15 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// show an alert if changing mainUser
|
||||||
|
if (this.$store.state.activity.mainUser !== null
|
||||||
|
&& payload.event.extendedProps.userId !== this.$store.state.activity.mainUser.id) {
|
||||||
|
if (!window.confirm(this.$t('this_calendar_range_will_change_main_user'))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.$store.dispatch('associateCalendarToRange', {range: payload.event});
|
this.$store.dispatch('associateCalendarToRange', {range: payload.event});
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
this.previousSelectedEvent = this.selectedEvent;
|
|
||||||
this.previousSelectedEventColor = payload.event.extendedProps.sourceColor;
|
|
||||||
this.selectedEvent = payload.event;
|
|
||||||
this.unSelectPreviousEvent(this.previousSelectedEvent);
|
|
||||||
payload.event.setProp('backgroundColor', '#3788d8');
|
|
||||||
payload.event.setProp('borderColor', '#3788d8');
|
|
||||||
payload.event.setProp('title', 'Choisir cette plage');
|
|
||||||
payload.event.setProp('textColor', '#ffffff');
|
|
||||||
*/
|
|
||||||
},
|
},
|
||||||
onEventMouseEnter(payload) {
|
onEventMouseEnter(payload) {
|
||||||
payload.event.setProp('borderColor', '#444444');
|
payload.event.setProp('borderColor', '#444444');
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
|
import {personMessages} from 'ChillPersonAssets/vuejs/_js/i18n'
|
||||||
import { calendarUserSelectorMessages } from '../_components/CalendarUserSelector/js/i18n';
|
import {calendarUserSelectorMessages} from '../_components/CalendarUserSelector/js/i18n';
|
||||||
import { activityMessages } from 'ChillActivityAssets/vuejs/Activity/i18n';
|
import {activityMessages} from 'ChillActivityAssets/vuejs/Activity/i18n';
|
||||||
|
|
||||||
const appMessages = {
|
const appMessages = {
|
||||||
fr: {
|
fr: {
|
||||||
choose_your_date: "Sélectionnez votre plage",
|
choose_your_date: "Sélectionnez votre plage",
|
||||||
activity: {
|
activity: {
|
||||||
add_persons: "Ajouter des personnes concernées",
|
add_persons: "Ajouter des personnes concernées",
|
||||||
bloc_persons: "Usagers",
|
bloc_persons: "Usagers",
|
||||||
bloc_persons_associated: "Usagers du parcours",
|
bloc_persons_associated: "Usagers du parcours",
|
||||||
bloc_persons_not_associated: "Tiers non-pro.",
|
bloc_persons_not_associated: "Tiers non-pro.",
|
||||||
bloc_thirdparty: "Tiers professionnels",
|
bloc_thirdparty: "Tiers professionnels",
|
||||||
bloc_users: "T(M)S",
|
bloc_users: "T(M)S",
|
||||||
}
|
},
|
||||||
}
|
this_calendar_range_will_change_main_user: "Cette plage de disponibilité n'est pas celle de l'utilisateur principal. Si vous continuez, l'utilisateur principal sera adapté. Êtes-vous sur·e ?",
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(appMessages.fr, personMessages.fr);
|
Object.assign(appMessages.fr, personMessages.fr);
|
||||||
@ -21,5 +23,5 @@ Object.assign(appMessages.fr, calendarUserSelectorMessages.fr);
|
|||||||
Object.assign(appMessages.fr, activityMessages.fr);
|
Object.assign(appMessages.fr, activityMessages.fr);
|
||||||
|
|
||||||
export {
|
export {
|
||||||
appMessages
|
appMessages
|
||||||
};
|
};
|
||||||
|
@ -89,7 +89,7 @@ export default {
|
|||||||
aThirdParties.value = removeIdFromValue(aThirdParties.value, payload.id);
|
aThirdParties.value = removeIdFromValue(aThirdParties.value, payload.id);
|
||||||
break;
|
break;
|
||||||
case 'user':
|
case 'user':
|
||||||
let aUsers = document.getElementById("chill_activitybundle_activity_invites");
|
let aUsers = document.getElementById("chill_activitybundle_activity_users");
|
||||||
aUsers.value = removeIdFromValue(aUsers.value, payload.id);
|
aUsers.value = removeIdFromValue(aUsers.value, payload.id);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@ -107,7 +107,7 @@ export default {
|
|||||||
//mainUserInput.value = payload.users.logged.id;
|
//mainUserInput.value = payload.users.logged.id;
|
||||||
commit('setEvents', payload);
|
commit('setEvents', payload);
|
||||||
},
|
},
|
||||||
associateCalendarToRange({ commit, dispatch }, {range}) {
|
associateCalendarToRange({ state, commit, dispatch }, {range}) {
|
||||||
console.log('### action associateCAlendarToRange', range);
|
console.log('### action associateCAlendarToRange', range);
|
||||||
let startDateInput = document.getElementById("chill_activitybundle_activity_startDate");
|
let startDateInput = document.getElementById("chill_activitybundle_activity_startDate");
|
||||||
startDateInput.value = datetimeToISO(range.start);
|
startDateInput.value = datetimeToISO(range.start);
|
||||||
@ -116,21 +116,33 @@ export default {
|
|||||||
let calendarRangeInput = document.getElementById("chill_activitybundle_activity_calendarRange");
|
let calendarRangeInput = document.getElementById("chill_activitybundle_activity_calendarRange");
|
||||||
calendarRangeInput.value = Number(range.extendedProps.calendarRangeId);
|
calendarRangeInput.value = Number(range.extendedProps.calendarRangeId);
|
||||||
|
|
||||||
//dispatch('setMainUser', payload.event.source);
|
const userId = range.extendedProps.userId;
|
||||||
//let mainUserInput = document.getElementById("chill_activitybundle_activity_mainUser");
|
if (state.activity.mainUser !== null && state.activity.mainUser.id !== userId) {
|
||||||
//mainUserInput.value = Number(payload.event.source.id);
|
dispatch('setMainUser', state.usersData.get(userId).user);
|
||||||
|
|
||||||
|
// TODO: remove persons involved with this user
|
||||||
|
}
|
||||||
|
|
||||||
commit('associateCalendarToRange', {range});
|
commit('associateCalendarToRange', {range});
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
},
|
},
|
||||||
setMainUser({ commit }, mainUser) {
|
setMainUser({ commit }, mainUser) {
|
||||||
console.log('rawMainuser', toRaw(mainUser));
|
console.log('setMainUser', mainUser);
|
||||||
const event = new CustomEvent('pick-entity-type-action', {detail: {
|
let mainUserInput = document.getElementById("chill_activitybundle_activity_mainUser");
|
||||||
|
mainUserInput.value = Number(mainUser.id);
|
||||||
|
|
||||||
|
commit('setMainUser', mainUser);
|
||||||
|
|
||||||
|
/*
|
||||||
|
const event = new CustomEvent('pick-entity-type-action', {detail: {
|
||||||
name: "chill_activitybundle_activity_mainUser",
|
name: "chill_activitybundle_activity_mainUser",
|
||||||
entity: toRaw(mainUser),
|
entity: toRaw(mainUser),
|
||||||
action: 'add'
|
action: 'add'
|
||||||
}});
|
}});
|
||||||
document.dispatchEvent(event);
|
document.dispatchEvent(event);
|
||||||
commit('setMainUser', mainUser);
|
commit('setMainUser', mainUser);
|
||||||
|
|
||||||
|
*/
|
||||||
},
|
},
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
|
@ -46,6 +46,10 @@ export default {
|
|||||||
console.log('activity', state.activity);
|
console.log('activity', state.activity);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setMainUser(state, user) {
|
||||||
|
state.activity.mainUser = user;
|
||||||
|
},
|
||||||
|
|
||||||
// ConcernedGroups
|
// ConcernedGroups
|
||||||
addPersonsInvolved(state, payload) {
|
addPersonsInvolved(state, payload) {
|
||||||
//console.log('### mutation addPersonsInvolved', payload.result.type);
|
//console.log('### mutation addPersonsInvolved', payload.result.type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user