Skip to content

Commit

Permalink
fix(calendar): Fix update calendar event
Browse files Browse the repository at this point in the history
  • Loading branch information
gnovaro committed Mar 11, 2024
1 parent 4c098ad commit a62cc53
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 27 deletions.
36 changes: 20 additions & 16 deletions public/asset/js/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

const options = {
focus: true
}
};

const myModal = new bootstrap.Modal(document.getElementById('sheduleEventModal'), options);

window.Calendar = {
Expand All @@ -19,44 +20,47 @@ window.Calendar = {
},
read: function(id)
{
fetch(route_calendar_controller + "/event/update/" + id, {
fetch( "/calendar/event/update/" + id, {
method: 'get',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then((response) => {
return response.json()
return response.json();
}).then((data) => {
let calendarEvent = data.calendar;
let regExDate = /^\d{4}-\d{2}-\d{2}/;
let regExTime = /\d{2}:\d{2}/;
$('#form_delete').removeClass("invisible").addClass("visible").prop('action', route_calendar_controller + "/event/delete/" + data.id);
$('.event_id').val(data.id);
$('#form_delete').removeClass("invisible")
.addClass("visible")
.prop('action', route_calendar_controller + "/event/delete/" + calendarEvent.id);
$('#calendar_event_id').val(calendarEvent.id);

$('#title').val(data.title);
$('#title').val(calendarEvent.title);

$('#end_date').val((data.end_date).match(regExDate)[0]);
$('#end_date').val((calendarEvent.end_date).match(regExDate)[0]);

$('#is_all_day').prop('checked', (data.is_all_day == 1) ? true : false);
$('#is_all_day').prop('checked', (calendarEvent.is_all_day == 1) ? true : false);

$('#start_time').val((data.start_date).match(regExTime)[0]);
$('#end_time').val((data.end_date).match(regExTime)[0]);
$('#description').val(data.description);
$('#meeting').val(data.meeting);
$('#address').val(data.address);
$('#start_time').val((calendarEvent.start_date).match(regExTime)[0]);
$('#end_time').val((calendarEvent.end_date).match(regExTime)[0]);
$('#description').val(calendarEvent.description);
$('#meeting').val(calendarEvent.meeting);
$('#address').val(calendarEvent.address);

let guest_list = $("#guest_list");
for(let i = 0; i < data.guests.length; i++) {
for(let i = 0; i < calendarEvent.guests.length; i++) {
let option = document.createElement("option");
let guest = data.guests[i];
let guest = calendarEvent.guests[i];
option.textContent = guest;
option.value = guest;
guest_list.append(option);
}

myModal.show();
}).catch((error) => {
console.log(error)
console.log(error);
});
},
addGuest: function ()
Expand Down
4 changes: 3 additions & 1 deletion resources/views/calendar/calendar.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ class="las la-chevron-right"></i></a>
<div class="d-flex flex-column">
@foreach ( $events->whereBetween('start_date', [$startOfCalendar->copy()->startOfDay(), $startOfCalendar->copy()->endOfDay()]) as $event)
<div class="badge text-bg-secondary mb-1 text-wrap">
<span role="button" onclick="Calendar.read('{{ $event->id }}')">{{ $event->title }}</span>
<span role="button" onclick="Calendar.read('{{ $event->id }}')">
{{ $event->title }}
</span>
<span>
<a href="{{ url("/calendar/$event->id/export") }}" class="text-white">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
Expand Down
29 changes: 20 additions & 9 deletions resources/views/calendar/modal/event_create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{ __('Add event') }}</h5>
<h5 class="modal-title">{{ __('Event') }}</h5>
<div class="d-flex justify-content-between align-items-center">
<form method="POST" id="form_delete" class="invisible">
@csrf
Expand All @@ -15,7 +15,7 @@
</div>
<form id="event_form" action="{{ route('calendar.save') }}" method="POST">
@csrf
<input type="hidden" name="id" class="event_id">
<input type="hidden" name="id" id="calendar_event_id" value="">
<div class="modal-body">
<div class="row">
<div class="col">
Expand All @@ -26,7 +26,7 @@
<div>
<div class="row">
<div class="col">
<label for="date" class="form-label">{{ __('Start Date') }}</label>
<label for="date" class="form-label">{{ __('Start date') }}</label>
<div class="input-group mb-2">
<span class="input-group-text"><i class="las la-calendar"></i></span>
<input type="date" name="date" id="date" required class="form-control">
Expand Down Expand Up @@ -64,7 +64,8 @@
<div class="row">
<div class="col">
<label for="description" class="form-label">{{ __('Description') }}</label>
<textarea class="form-control mb-2" name="description" id="description" cols="30" rows="5"></textarea>
<textarea class="form-control mb-2" name="description" id="description"
cols="30" rows="5"></textarea>
</div>
</div>
<div class="row">
Expand Down Expand Up @@ -96,11 +97,21 @@
<i class="las la-plus-circle"></i>
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#" onclick="$('#meeting').val('https://meet.jit.si/{{ str_slug(\Illuminate\Support\Facades\Auth::user()->company->name, '-') }}/{{ base64_encode((string) time()) }}')">Jitsi Meet</a></li>
<li><a class="dropdown-item" href="#" onclick="$('#meeting').val('https://zoom.us/j/')">Zoom</a></li>
<li><a class="dropdown-item" href="#" onclick="$('#meeting').val('https://meet.google.com/')">Google Meet</a></li>
<li><a class="dropdown-item" href="#" onclick="$('#meeting').val('https://teams.microsoft.com/')">Microsoft Teams</a></li>
<li><a class="dropdown-item" href="#" onclick="$('#meeting').val('https://whereby.com/')">Whereby</a></li>
<li>
<a class="dropdown-item" href="#" onclick="$('#meeting').val('https://meet.jit.si/{{ str_slug(\Illuminate\Support\Facades\Auth::user()->company->name, '-') }}/{{ base64_encode((string) time()) }}')">Jitsi Meet</a>
</li>
<li>
<a class="dropdown-item" href="#" onclick="$('#meeting').val('https://zoom.us/j/')">Zoom</a>
</li>
<li>
<a class="dropdown-item" href="#" onclick="$('#meeting').val('https://meet.google.com/')">Google Meet</a>
</li>
<li>
<a class="dropdown-item" href="#" onclick="$('#meeting').val('https://teams.microsoft.com/')">Microsoft Teams</a>
</li>
<li>
<a class="dropdown-item" href="#" onclick="$('#meeting').val('https://whereby.com/')">Whereby</a>
</li>
</ul>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php

const APP_VERSION = '3.8.1';
const APP_VERSION = '3.8.2';

0 comments on commit a62cc53

Please sign in to comment.