Эх сурвалжийг харах

Calendar based new-appt. [WIP 3]

Vijayakrishnan 4 жил өмнө
parent
commit
80aeb5084a

+ 16 - 3
resources/views/app/patient/manage-appointment.blade.php

@@ -9,7 +9,7 @@
         </h4>
     </div>
     <hr class="mt-2 mb-3">
-    <div class="d-flex align-items-start">
+    <div class="d-flex align-items-start appt-form">
         <div class="appt-form-col pr-2">
             <div class="mb-3">
                 <label class="text-secondary mb-1">Patient</label>
@@ -66,7 +66,16 @@
                     navLinks: true,
                     dayMaxEvents: true,
                     events: function(info, successCallback, failureCallback) {
-                        $.get('/api/appointment/getAllAppointmentsForPro?start=1990-01-01&end=2025-01-01&timeZone=CENTRAL', function(_data) {
+                        let proUid = $('.appt-form [name="proUid"]').val();
+                        if(!proUid) successCallback([]); // no events if no pro selected
+                        let timeZone = $('.appt-form [name="timeZone"]').val();
+                        if(!timeZone) successCallback([]); // no events if no tz selected
+                        $.get('/api/appointment/getAllAppointmentsForPro' +
+                            '?proUid=' + proUid +
+                            '&start=' + info.startStr.substr(0, 10) +
+                            '&end=' + info.endStr.substr(0, 10) +
+                            '&timeZone=' + timeZone, function(_data) {
+                        // $.get('/api/appointment/getAllAppointmentsForPro?start=1990-01-01&end=2025-01-01&timeZone=CENTRAL', function(_data) {
                             if(_data && _data.success) {
                                 successCallback(_data.data);
                             }
@@ -81,8 +90,12 @@
                     }
                 });
                 calendarObject.render();
+
+                $(document).on('change', '.appt-form [name="proUid"], .appt-form [name="timeZone"]', function() {
+                    calendarObject.refetchEvents();
+                });
             }
-            addMCInitializer('patient-manage-appointment-' + Math.random() * 10000, init);
+            addMCInitializer('patient-manage-appointment', init);
         })();
     </script>
 @endsection