mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
rdv: add main user in fullcalendar form
This commit is contained in:
parent
a70d5cc263
commit
dbf72774c2
@ -45,14 +45,6 @@ class CalendarType extends AbstractType
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('mainUser', EntityType::class, [
|
||||
'required' => true,
|
||||
'class' => User::class,
|
||||
'choice_label' => function (User $entity) {
|
||||
return $entity->getUsernameCanonical();
|
||||
},
|
||||
// TODO 'empty_data' =>
|
||||
])
|
||||
->add('comment', CommentType::class, [
|
||||
'required' => false
|
||||
])
|
||||
@ -73,6 +65,24 @@ class CalendarType extends AbstractType
|
||||
])
|
||||
;
|
||||
|
||||
|
||||
$builder->add('mainUser', HiddenType::class);
|
||||
$builder->get('mainUser')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (?User $user): int {
|
||||
if (NULL !== $user) {
|
||||
$res = $user->getId();
|
||||
} else {
|
||||
$res = -1; //TODO cannot be null in any ways...
|
||||
}
|
||||
return $res;
|
||||
},
|
||||
function (?int $userId): User {
|
||||
return $this->om->getRepository(user::class)->findOneBy(['id' => (int) $userId]);
|
||||
}
|
||||
))
|
||||
;
|
||||
|
||||
$builder->add('startDate', HiddenType::class);
|
||||
$builder->get('startDate')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
@ -149,7 +159,7 @@ class CalendarType extends AbstractType
|
||||
$builder->add('calendarRange', HiddenType::class);
|
||||
$builder->get('calendarRange')
|
||||
->addModelTransformer(new CallbackTransformer(
|
||||
function (?CalendarRange $calendarRange): int {
|
||||
function (?CalendarRange $calendarRange): ?int {
|
||||
if (NULL !== $calendarRange) {
|
||||
$res = $calendarRange->getId();
|
||||
} else {
|
||||
@ -157,8 +167,13 @@ class CalendarType extends AbstractType
|
||||
}
|
||||
return $res;
|
||||
},
|
||||
function (?string $calendarRangeId): CalendarRange {
|
||||
return $this->om->getRepository(CalendarRange::class)->findOneBy(['id' => (int) $calendarRangeId]);
|
||||
function (?string $calendarRangeId): ?CalendarRange {
|
||||
if (NULL !== $calendarRangeId) {
|
||||
$res = $this->om->getRepository(CalendarRange::class)->findOneBy(['id' => (int) $calendarRangeId]);
|
||||
} else {
|
||||
$res = NULL;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
))
|
||||
;
|
||||
|
@ -30,7 +30,7 @@ const currentEvent = {
|
||||
start: window.startDate,
|
||||
end: window.endDate
|
||||
}],
|
||||
id: -1
|
||||
id: window.mainUser
|
||||
};
|
||||
|
||||
export default {
|
||||
@ -45,7 +45,8 @@ export default {
|
||||
errorMsg: [],
|
||||
users: {
|
||||
loaded: [],
|
||||
selected: []
|
||||
selected: [],
|
||||
logged: null
|
||||
},
|
||||
calendarEvents: {
|
||||
loaded: [],
|
||||
@ -88,10 +89,14 @@ export default {
|
||||
}
|
||||
},
|
||||
onDateSelect(payload) {
|
||||
Object.assign(payload, {users: this.users});
|
||||
this.$store.dispatch('createEvent', payload);
|
||||
},
|
||||
onEventChange(payload) {
|
||||
console.log(payload.event);
|
||||
console.log(payload.event.extendedProps);
|
||||
console.log(payload.event.source);
|
||||
console.log(payload.event.source.id);
|
||||
console.log(this.calendarOptions.eventSources)
|
||||
this.$store.dispatch('updateEvent', payload);
|
||||
},
|
||||
|
@ -113,6 +113,9 @@ const store = createStore({
|
||||
startDateInput.value = payload.startStr;
|
||||
let endDateInput = document.getElementById("chill_calendarbundle_calendar_endDate");
|
||||
endDateInput.value = payload.endStr;
|
||||
//TODO specify the mainUserInput value if not from a source
|
||||
let mainUserInput = document.getElementById("chill_calendarbundle_calendar_mainUser");
|
||||
mainUserInput.value = payload.users.logged.id;
|
||||
commit('setEvents', payload);
|
||||
},
|
||||
updateEvent({ commit }, payload) {
|
||||
@ -122,7 +125,10 @@ const store = createStore({
|
||||
let endDateInput = document.getElementById("chill_calendarbundle_calendar_endDate");
|
||||
endDateInput.value = payload.event.end.toISOString();
|
||||
let calendarRangeInput = document.getElementById("chill_calendarbundle_calendar_calendarRange");
|
||||
calendarRangeInput.value = payload.event.extendedProps.calendarRangeId;
|
||||
calendarRangeInput.value = Number(payload.event.extendedProps.calendarRangeId);
|
||||
let mainUserInput = document.getElementById("chill_calendarbundle_calendar_mainUser");
|
||||
mainUserInput.value = Number(payload.event.source.id);
|
||||
//TODO check if working when reiszing an event
|
||||
commit('setEvents', payload);
|
||||
},
|
||||
|
||||
|
@ -94,9 +94,13 @@ export default {
|
||||
|
||||
this.users.loaded = users;
|
||||
this.options = users;
|
||||
|
||||
console.log(users)
|
||||
console.log(calendarEvents)
|
||||
|
||||
this.calendarEvents.loaded = calendarEvents;
|
||||
whoami().then(me => new Promise((resolve, reject) => {
|
||||
this.users.logged = me;
|
||||
let currentUser = users.find(u => u.id === me.id);
|
||||
this.value = currentUser;
|
||||
this.selectUsers(currentUser);
|
||||
|
@ -27,6 +27,7 @@
|
||||
window.entity = {{ entity_json|json_encode|raw }};
|
||||
window.startDate = {{ entity.startDate|date('Y-m-d H:i:s')|json_encode|raw }};
|
||||
window.endDate = {{ entity.endDate|date('Y-m-d H:i:s')|json_encode|raw }};
|
||||
window.mainUser = {{ entity.mainUser.id }};
|
||||
</script>
|
||||
{{ encore_entry_script_tags('vue_calendar') }}
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user