From e45fa9bf5027eb0d8e951297e205a5108b1d7009 Mon Sep 17 00:00:00 2001 From: Stefani Meneghetti Date: Tue, 26 Jul 2022 10:18:45 -0300 Subject: [PATCH 1/6] feat: start academic calendar popup --- app/Http/Livewire/AuraAcademicCalendar.php | 23 +++++++++++ app/Http/Livewire/AuraWidget.php | 14 +++++-- .../livewire/aura-academic-calendar.blade.php | 41 +++++++++++++++++++ .../views/livewire/aura-widget.blade.php | 6 +++ 4 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 app/Http/Livewire/AuraAcademicCalendar.php create mode 100644 resources/views/livewire/aura-academic-calendar.blade.php diff --git a/app/Http/Livewire/AuraAcademicCalendar.php b/app/Http/Livewire/AuraAcademicCalendar.php new file mode 100644 index 0000000..0ac5b6c --- /dev/null +++ b/app/Http/Livewire/AuraAcademicCalendar.php @@ -0,0 +1,23 @@ +emitUp('toggleCalendarPopup'); + } + + public function changeMonth($direction) + { + // + } +} diff --git a/app/Http/Livewire/AuraWidget.php b/app/Http/Livewire/AuraWidget.php index cb994ae..4b531fa 100644 --- a/app/Http/Livewire/AuraWidget.php +++ b/app/Http/Livewire/AuraWidget.php @@ -16,6 +16,9 @@ class AuraWidget extends Component public $password; public $widgetSettings; public $user; + public $academicCalendar; + + protected $listeners = ['toggleCalendarPopup']; public function mount() { @@ -70,6 +73,10 @@ public function mount() $this->user['token'] = null; } } + + $this->academicCalendar = [ + 'display-popup' => false + ]; } public function render() @@ -77,8 +84,6 @@ public function render() return view('livewire.aura-widget'); } - - public function sendMessage(){ if ($this->inputMessage == ""){ @@ -293,5 +298,8 @@ public function loadHistory(){ } $this->widgetSettings['history_loaded'] = true; } - + + public function toggleCalendarPopup() { + $this->academicCalendar['display-popup'] = !$this->academicCalendar['display-popup']; + } } diff --git a/resources/views/livewire/aura-academic-calendar.blade.php b/resources/views/livewire/aura-academic-calendar.blade.php new file mode 100644 index 0000000..970f53d --- /dev/null +++ b/resources/views/livewire/aura-academic-calendar.blade.php @@ -0,0 +1,41 @@ +
+ + +

Calendário Acadêmico

+ + + + +
+
+
+
+ + +
+
+ +
+
Dom
+
Seg
+
Ter
+
Qua
+
Qui
+
Sex
+
Sáb
+
+ +
+ {{-- Generated Calendar --}} +
+
+
diff --git a/resources/views/livewire/aura-widget.blade.php b/resources/views/livewire/aura-widget.blade.php index da82570..8599b20 100644 --- a/resources/views/livewire/aura-widget.blade.php +++ b/resources/views/livewire/aura-widget.blade.php @@ -1,3 +1,7 @@ +
+@if($academicCalendar['display-popup']) + @livewire('aura-academic-calendar') +@else
@if($widgetSettings['type'] == 'button') @@ -192,3 +196,5 @@
@endif
+@endif + From 004d75afb570dcbb73b3ec696fdfb766443266be Mon Sep 17 00:00:00 2001 From: Stefani Meneghetti Date: Wed, 27 Jul 2022 09:29:29 -0300 Subject: [PATCH 2/6] feat: calendar style --- public/css/aura-calendar.css | 163 ++++++++++++++++++ .../livewire/aura-academic-calendar.blade.php | 73 ++++---- 2 files changed, 200 insertions(+), 36 deletions(-) create mode 100644 public/css/aura-calendar.css diff --git a/public/css/aura-calendar.css b/public/css/aura-calendar.css new file mode 100644 index 0000000..40d08d8 --- /dev/null +++ b/public/css/aura-calendar.css @@ -0,0 +1,163 @@ +.page { + background-color: #ECECEC; + height: 100%; + width: 100%; + overflow: scroll; + padding: 10px 15px 0 10px; +} + +.page--dark { + background-color: #041C26; +} + +.title { + color: #2F7B9A; + font-size: 28px; + padding-top: 10px; +} + +.calendar { + background-color: #D9D9D9; + border-radius: 5px; + padding: 15px; + margin-top: 25px; + max-width: 400px; +} + +.calendar--dark { + background-color: #153E4B; + color: #ECECEC; +} + +.calendar-header { + display: flex; + justify-content: space-between; + align-items: center; + padding-bottom: 3px; + border-bottom: 1px solid #888; +} + +.calendar-info { + font-weight: bold; +} + +.calendar-week-days { + margin-top: 12px; +} + +.calendar-week-days, .week { + display: flex; + justify-content: space-around; +} + +.day { + flex: 1; + padding: 5px; + width: 100%; + margin: 5px; + border-radius: 5px; + display: flex; + align-items: center; + justify-content: center; + padding-top: 10.52%; + position: relative; +} + +.day--no-background { + background-color: transparent; +} + +.day--not-weekend { + background-color: #F1F1F2; +} + +.calendar--dark .day--not-weekend { + background-color: #D9D9D9; +} + + +.day--weekend, .calendar--dark .day--weekend { + background-color: #2F7B9A; + color: #BDD0D7; +} + +.day--event, .calendar--dark .day--event { + background-color: #FFEFD2; + color: #BDD0D7; +} +.day span { + position: absolute; + top:50%; + left:50%; + transform:translate(-50%, -50%); + color: #333333; + font-weight: 600; +} + +.day--weekend span { + color: #CCCAD2; +} + +.change-month { + background-color: transparent; + border: none; + cursor: pointer; + margin: 5px; +} + +.change-month:active, .change-month:focus { + outline: none; +} + +.events { + margin-top: 20px; +} + +.event { + padding: 5px 0; +} + +.event span { + font-weight: bold; +} + +.calendar--dark .change-month, .page--dark .select_label { + color: #ECECEC; +} + +.events--dark { + color: #ECECEC; +} + +.select_campus { + display: block; + max-width: 400px; + width: 100%; + padding: 8px; + border: none; + border-radius: 5px; + background-color: #D9D9D9; +} + +.page--dark .select_campus { + display: block; + max-width: 400px; + width: 100%; + padding: 8px; + background-color: #153E4B; + color: #ECECEC; +} + +.popup-header { + display: flex; + justify-content: flex-end; + align-items: center; +} + +.close-btn { + font-size: 20px; + padding: 0 10px; + background-color: #D9D9D9; + border-radius: 5px; + border: solid 1px #777; +} diff --git a/resources/views/livewire/aura-academic-calendar.blade.php b/resources/views/livewire/aura-academic-calendar.blade.php index 970f53d..8efccdd 100644 --- a/resources/views/livewire/aura-academic-calendar.blade.php +++ b/resources/views/livewire/aura-academic-calendar.blade.php @@ -1,41 +1,42 @@ -
+
+ - -

Calendário Acadêmico

- - - + +

Calendário Acadêmico

-
-
-
-
- - -
-
- -
-
Dom
-
Seg
-
Ter
-
Qua
-
Qui
-
Sex
-
Sáb
+ + + +
+
+
+
+ +
- -
- {{-- Generated Calendar --}} -
+ +
+
Dom
+
Seg
+
Ter
+
Qua
+
Qui
+
Sex
+
Sáb
+
+ +
+ {{-- Generated Calendar --}} +
+
From 6ef3cb2c16a8ba8ea2a5499f1ac00a8521fa1e98 Mon Sep 17 00:00:00 2001 From: Stefani Meneghetti Date: Wed, 27 Jul 2022 16:03:57 -0300 Subject: [PATCH 3/6] feat: generate calendar --- app/Http/Livewire/AuraAcademicCalendar.php | 73 ++++++++++++++++++- .../livewire/aura-academic-calendar.blade.php | 16 +++- 2 files changed, 85 insertions(+), 4 deletions(-) diff --git a/app/Http/Livewire/AuraAcademicCalendar.php b/app/Http/Livewire/AuraAcademicCalendar.php index 0ac5b6c..6f8bd45 100644 --- a/app/Http/Livewire/AuraAcademicCalendar.php +++ b/app/Http/Livewire/AuraAcademicCalendar.php @@ -6,9 +6,63 @@ class AuraAcademicCalendar extends Component { + public $months; + public $calendar; + public function render() { - return view('livewire.aura-academic-calendar'); + return view('livewire.aura-academic-calendar', [ + 'year' => $this->calendar['year'], + 'month' => $this->calendar['month'] + ]); + } + + public function mount() + { + $this->months = [ + "Janeiro", + "Fevereiro", + "Março", + "Abril", + "Maio", + "Junho", + "Julho", + "Agosto", + "Setembro", + "Outubro", + "Novembro", + "Dezembro" + ]; + + $this->calendar = [ + 'year' => date('Y'), + 'month' => date('n') - 1, + 'array' => [] + ]; + + $this->generateCalendar(date('m'), date('Y')); + } + + public function generateCalendar($month, $year) + { + $date = $year.'-'.$month.'-01'; + + $monthArray = []; + while (date('m', strtotime($date)) == $month) { + $week = []; + + for ($i = 0; $i < 7; $i++) { + $day = ['', $i]; + if ($i == date('w', strtotime($date)) && date('m', strtotime($date)) == $month) { + $day[0] = date('d', strtotime($date)); + + $date = date('Y-m-d', strtotime("+1 days",strtotime($date))); + } + array_push($week, $day); + } + array_push($monthArray, $week); + } + $this->calendar['array'] = $monthArray; } public function closePopup() @@ -18,6 +72,21 @@ public function closePopup() public function changeMonth($direction) { - // + if ($direction == 'prev') { + $this->calendar['month'] -= 1; + if ($this->calendar['month'] < 0) { + $this->calendar['year'] -= 1; + $this->calendar['month'] = 11; + } + + } else { + $this->calendar['month'] += 1; + + if ($this->calendar['month'] > 11) { + $this->calendar['year'] += 1; + $this->calendar['month'] = 0; + } + } + $this->generateCalendar($this->calendar['month'] + 1, $this->calendar['year']); } } diff --git a/resources/views/livewire/aura-academic-calendar.blade.php b/resources/views/livewire/aura-academic-calendar.blade.php index 8efccdd..8cf6368 100644 --- a/resources/views/livewire/aura-academic-calendar.blade.php +++ b/resources/views/livewire/aura-academic-calendar.blade.php @@ -18,7 +18,7 @@
-
+
{{ $months[$calendar['month']] }}/{{ $year }}
@@ -36,7 +36,19 @@
- {{-- Generated Calendar --}} + @foreach($calendar['array'] as $week) +
+ @foreach($week as $day) +
strlen($day[0]) != 0, + 'day--weekend' => strlen($day[0]) != 0 && $day[1] >= 6 + ])> + {{ $day[0] }} +
+ @endforeach +
+ @endforeach
From b6df6691e5d71b10e629cc4c0418f67fa10368d9 Mon Sep 17 00:00:00 2001 From: Stefani Meneghetti Date: Fri, 29 Jul 2022 10:01:22 -0300 Subject: [PATCH 4/6] feat: add events to the academic calendar popup --- .../API/V0/AcademicCalendarController.php | 16 +++++----- app/Http/Livewire/AuraAcademicCalendar.php | 30 ++++++++++++++++++- public/css/aura-calendar.css | 10 +++++-- .../livewire/aura-academic-calendar.blade.php | 27 ++++++++++++++--- .../views/livewire/aura-widget.blade.php | 2 +- 5 files changed, 69 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/API/V0/AcademicCalendarController.php b/app/Http/Controllers/API/V0/AcademicCalendarController.php index 958d1ad..dd47f16 100644 --- a/app/Http/Controllers/API/V0/AcademicCalendarController.php +++ b/app/Http/Controllers/API/V0/AcademicCalendarController.php @@ -26,23 +26,25 @@ public function __construct() { ]; } - public function getCalendars() { - $calendars = AcademicCalendar::all(); + public function getCalendars($campus = null) { + $calendars = AcademicCalendar::where('title', 'LIKE', '%' . $campus . '%')->get(); return $calendars; } - public function getCurrentMonthCalendar() { + public function getCurrentMonthCalendar($campus = null) { $currentMonth = $this->months[(int) date('n') - 1]; $currentYear = (int) date('Y'); - $calendar = $this->getCalendars(); + $calendar = $this->getCalendars($campus); $currentMonthCalendar = $this->getCalendarEventsByMonth($calendar, $currentMonth, $currentYear); return $currentMonthCalendar; } - public function getCalendarEventsByMonth($calendars, $month, $year) { + public function getCalendarEventsByMonth($month, $year, $campus = null) { + $calendars = $this->getCalendars($campus); + $currentMonthEvents = []; foreach ($calendars as $calendar) { foreach ($calendar['data'] as $key => $calendarMonth) { @@ -68,11 +70,11 @@ public function getCurrentDateEvents() { } // Recebe uma data no formato y-m-d - public function getCalendarEventsByDate($date) { + public function getCalendarEventsByDate($date, $campus = null) { $dateCalendar = []; $date = strtotime($date); - $calendar = $this->getCalendars(); + $calendar = $this->getCalendars($campus); $month = $this->months[(int) date('n', $date) - 1]; $year = date('Y', $date); $monthCalendars = $this->getCalendarEventsByMonth($calendar, $month, $year); diff --git a/app/Http/Livewire/AuraAcademicCalendar.php b/app/Http/Livewire/AuraAcademicCalendar.php index 6f8bd45..c3570e2 100644 --- a/app/Http/Livewire/AuraAcademicCalendar.php +++ b/app/Http/Livewire/AuraAcademicCalendar.php @@ -1,6 +1,8 @@ months = [ "Janeiro", @@ -40,6 +45,10 @@ public function mount() 'array' => [] ]; + $this->campus = 'chapeco'; + $this->theme = $theme; + + $this->getCalendarEvents(); $this->generateCalendar(date('m'), date('Y')); } @@ -87,6 +96,25 @@ public function changeMonth($direction) $this->calendar['month'] = 0; } } + $this->getCalendarEvents(); $this->generateCalendar($this->calendar['month'] + 1, $this->calendar['year']); } + + public function getCalendarEvents() { + $acController = new AcademicCalendarController(); + + $campus = [ + 'chapeco' => 'Chapecó', + 'laranjeiras_do_sul' => 'Laranjeiras do Sul', + 'erechim' => 'Erechim', + 'cerro_largo' => 'Cerro Largo', + 'realeza' => 'Realeza', + 'passo_fundo' => 'Passo Fundo' + ]; + + $this->academicCalendar = $acController->getCalendarEventsByMonth($this->months[$this->calendar['month']], $this->calendar['year'], $campus[$this->campus]); + if (count($this->academicCalendar)) { + $this->academicCalendar = $this->academicCalendar[0]; + } + } } diff --git a/public/css/aura-calendar.css b/public/css/aura-calendar.css index 40d08d8..131e17b 100644 --- a/public/css/aura-calendar.css +++ b/public/css/aura-calendar.css @@ -157,7 +157,11 @@ .close-btn { font-size: 20px; padding: 0 10px; - background-color: #D9D9D9; - border-radius: 5px; - border: solid 1px #777; + color: #2F7B9A; + background-color: transparent; + border: none; +} + +.page--dark .close-btn { + color: #D9D9D9; } diff --git a/resources/views/livewire/aura-academic-calendar.blade.php b/resources/views/livewire/aura-academic-calendar.blade.php index 8cf6368..57f8616 100644 --- a/resources/views/livewire/aura-academic-calendar.blade.php +++ b/resources/views/livewire/aura-academic-calendar.blade.php @@ -1,4 +1,4 @@ -
+