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[]
|
||||
* @Serializer\Groups({"calendar:read", "read"})
|
||||
*/
|
||||
public function getUsers(): Collection
|
||||
{
|
||||
|
@ -19,6 +19,7 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use LogicException;
|
||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* @ORM\Table(name="chill_calendar.invite")
|
||||
@ -47,17 +48,20 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
* @Serializer\Groups(groups={"calendar:read", "read"})
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text", nullable=false, options={"default": "pending"})
|
||||
* @Serializer\Groups(groups={"calendar:read", "read"})
|
||||
*/
|
||||
private string $status = self::PENDING;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
* @Serializer\Groups(groups={"calendar:read", "read"})
|
||||
*/
|
||||
private ?User $user = null;
|
||||
|
||||
|
@ -162,19 +162,15 @@ export default {
|
||||
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.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) {
|
||||
payload.event.setProp('borderColor', '#444444');
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
|
||||
import { calendarUserSelectorMessages } from '../_components/CalendarUserSelector/js/i18n';
|
||||
import { activityMessages } from 'ChillActivityAssets/vuejs/Activity/i18n';
|
||||
import {personMessages} from 'ChillPersonAssets/vuejs/_js/i18n'
|
||||
import {calendarUserSelectorMessages} from '../_components/CalendarUserSelector/js/i18n';
|
||||
import {activityMessages} from 'ChillActivityAssets/vuejs/Activity/i18n';
|
||||
|
||||
const appMessages = {
|
||||
fr: {
|
||||
@ -12,7 +12,9 @@ const appMessages = {
|
||||
bloc_persons_not_associated: "Tiers non-pro.",
|
||||
bloc_thirdparty: "Tiers professionnels",
|
||||
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 ?",
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ export default {
|
||||
aThirdParties.value = removeIdFromValue(aThirdParties.value, payload.id);
|
||||
break;
|
||||
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);
|
||||
break;
|
||||
};
|
||||
@ -107,7 +107,7 @@ export default {
|
||||
//mainUserInput.value = payload.users.logged.id;
|
||||
commit('setEvents', payload);
|
||||
},
|
||||
associateCalendarToRange({ commit, dispatch }, {range}) {
|
||||
associateCalendarToRange({ state, commit, dispatch }, {range}) {
|
||||
console.log('### action associateCAlendarToRange', range);
|
||||
let startDateInput = document.getElementById("chill_activitybundle_activity_startDate");
|
||||
startDateInput.value = datetimeToISO(range.start);
|
||||
@ -116,14 +116,24 @@ export default {
|
||||
let calendarRangeInput = document.getElementById("chill_activitybundle_activity_calendarRange");
|
||||
calendarRangeInput.value = Number(range.extendedProps.calendarRangeId);
|
||||
|
||||
//dispatch('setMainUser', payload.event.source);
|
||||
//let mainUserInput = document.getElementById("chill_activitybundle_activity_mainUser");
|
||||
//mainUserInput.value = Number(payload.event.source.id);
|
||||
const userId = range.extendedProps.userId;
|
||||
if (state.activity.mainUser !== null && state.activity.mainUser.id !== userId) {
|
||||
dispatch('setMainUser', state.usersData.get(userId).user);
|
||||
|
||||
// TODO: remove persons involved with this user
|
||||
}
|
||||
|
||||
commit('associateCalendarToRange', {range});
|
||||
return Promise.resolve();
|
||||
},
|
||||
setMainUser({ commit }, mainUser) {
|
||||
console.log('rawMainuser', toRaw(mainUser));
|
||||
console.log('setMainUser', mainUser);
|
||||
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",
|
||||
entity: toRaw(mainUser),
|
||||
@ -131,6 +141,8 @@ export default {
|
||||
}});
|
||||
document.dispatchEvent(event);
|
||||
commit('setMainUser', mainUser);
|
||||
|
||||
*/
|
||||
},
|
||||
|
||||
// Location
|
||||
|
@ -46,6 +46,10 @@ export default {
|
||||
console.log('activity', state.activity);
|
||||
},
|
||||
|
||||
setMainUser(state, user) {
|
||||
state.activity.mainUser = user;
|
||||
},
|
||||
|
||||
// ConcernedGroups
|
||||
addPersonsInvolved(state, payload) {
|
||||
//console.log('### mutation addPersonsInvolved', payload.result.type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user