Selaa lähdekoodia

Patient > calendar - ajax based select2 pros listing [wip]

Vijayakrishnan 4 vuotta sitten
vanhempi
commit
905c9b2904

+ 15 - 0
app/Http/Controllers/HomeController.php

@@ -674,6 +674,21 @@ WHERE measurement.label NOT IN ('SBP', 'DBP')
             $pros->whereIn('id', $accessibleProIds);
         }
         $suggestedPros = $pros->orderBy('name_last')->orderBy('name_first')->get();
+
+        // for calendar select2
+        if($request->input('json')) {
+            $jsonPros = $suggestedPros->map(function($_pro) {
+                return [
+                    "id" => $_pro->id,
+                    "text" => $_pro->displayName(),
+                    "initials" => $_pro->initials(),
+                ];
+            });
+            return json_encode([
+                "results" => $jsonPros
+            ]);
+        }
+
         return view('app/pro-suggest', compact('suggestedPros'));
     }
 

+ 2 - 1
public/css/style.css

@@ -1663,4 +1663,5 @@ form.non-interactive .form-content {
 }
 form.non-interactive .form-content * {
     pointer-events: none;
-}
+}
+#eventPros { max-height: 28px; opacity: 0;}

+ 13 - 0
resources/views/app/patient/appointment-calendar.blade.php

@@ -455,6 +455,19 @@
                                 });
                             $('#eventPros')
                                 .select2({
+
+                                    // ajax driven pros listing
+                                    ajax: {
+                                        url: '/pro-suggest',
+                                        dataType: 'json',
+                                        data: function (params) {
+                                            return {
+                                                term: params.term,
+                                                json: true
+                                            };
+                                        }
+                                    },
+
                                     closeOnSelect: false,
 
                                     // dropdown options