Преглед изворни кода

Typical day - dont show empty table

Vijayakrishnan пре 3 година
родитељ
комит
53baf06f3f

+ 68 - 35
resources/views/app/patient/segment-templates/typical_day_lifestyle/summary.blade.php

@@ -32,11 +32,29 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
     $point->lastChildReview->data = json_decode($point->lastChildReview->data, true);
     $contentData = $point->lastChildReview->data;
 }
+$hasTypicalDayData = false;
+if(@$contentData["lines"] && count($contentData["lines"])) {
+    foreach(@$contentData["lines"] as $line) {
+        if(!!@$line['S'] && (!!@$line['I'] || !!@$line['P'])) {
+            $hasTypicalDayData = true;
+            break;
+        }
+    }
+}
+$hasDailyAggregates = (
+    @$contentData["estimated_daily_calories"]["S"] ||
+    @$contentData["estimated_daily_calories"]["P"] ||
+    @$contentData["estimated_daily_protein_grams"]["S"] ||
+    @$contentData["estimated_daily_protein_grams"]["P"] ||
+    @$contentData["estimated_daily_vegetable_servings"]["S"] ||
+    @$contentData["estimated_daily_vegetable_servings"]["P"] ||
+    @$contentData["estimated_daily_hours_of_sleep"]["S"] ||
+    @$contentData["estimated_daily_hours_of_sleep"]["P"]
+);
 ?>
 <div class="events-none form-read-mode">
-    <p class="mb-2 font-weight-bold">Typical Day</p>
-
-    @if(@$contentData["lines"] && count($contentData["lines"]))
+    @if($hasTypicalDayData)
+        <div class="mb-1 font-weight-bold">Typical Day</div>
         <table class="table table-sm table-bordered mb-3">
             <thead class="bg-light">
             <tr>
@@ -46,6 +64,7 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
             </thead>
             <tbody>
             @foreach(@$contentData["lines"] as $line)
+                @if($line['S'])
                 <tr>
                     <td><pre class="m-0">{{$line['S']}}&nbsp;</pre></td>
                     <td>
@@ -57,42 +76,56 @@ if ($point->lastChildReview && $point->lastChildReview->data) {
                         </div>
                     </td>
                 </tr>
+                @endif
             @endforeach
             </tbody>
         </table>
     @endif
 
-    <p class="mb-2 font-weight-bold">Daily Aggregates</p>
+    @if($hasTypicalDayData)
+        <div class="mb-1 font-weight-bold">Daily Aggregates</div>
+        <table class="table table-sm table-bordered mb-2">
+            <thead class="bg-light">
+            <tr>
+                <th class="border-bottom-0 text-secondary width-200px">Subject</th>
+                <th class="border-bottom-0 text-secondary">Current</th>
+                <th class="border-bottom-0 text-secondary w-50">Target</th>
+            </tr>
+            </thead>
+            <tbody>
+            @if(@$contentData["estimated_daily_calories"]["S"] || @$contentData["estimated_daily_calories"]["P"])
+            <tr>
+                <td class="pl-1 align-middle bg-light">Est. Daily Calories</td>
+                <td><pre class="m-0">{{@$contentData["estimated_daily_calories"]["S"]}}</pre></td>
+                <td><pre class="m-0">{{@$contentData["estimated_daily_calories"]["P"]}}</pre></td>
+            </tr>
+            @endif
+            @if(@$contentData["estimated_daily_protein_grams"]["S"] || @$contentData["estimated_daily_protein_grams"]["P"])
+            <tr>
+                <td class="pl-1 align-middle bg-light">Est. Daily Protein Grams</td>
+                <td><pre class="m-0">{{@$contentData["estimated_daily_protein_grams"]["S"]}}</pre></td>
+                <td><pre class="m-0">{{@$contentData["estimated_daily_protein_grams"]["P"]}}</pre></td>
+            </tr>
+            @endif
+            @if(@$contentData["estimated_daily_vegetable_servings"]["S"] || @$contentData["estimated_daily_vegetable_servings"]["P"])
+            <tr>
+                <td class="pl-1 align-middle bg-light">Est. Daily Vegetable Servings</td>
+                <td><pre class="m-0">{{@$contentData["estimated_daily_vegetable_servings"]["S"]}}</pre></td>
+                <td><pre class="m-0">{{@$contentData["estimated_daily_vegetable_servings"]["P"]}}</pre></td>
+            </tr>
+            @endif
+            @if(@$contentData["estimated_daily_hours_of_sleep"]["S"] || @$contentData["estimated_daily_hours_of_sleep"]["P"])
+            <tr>
+                <td class="pl-1 align-middle bg-light">Est. Daily Hours Of Sleep</td>
+                <td><pre class="m-0">{{@$contentData["estimated_daily_hours_of_sleep"]["S"]}}</pre></td>
+                <td><pre class="m-0">{{@$contentData["estimated_daily_hours_of_sleep"]["P"]}}</pre></td>
+            </tr>
+            @endif
+            </tbody>
+        </table>
+    @endif
 
-    <table class="table table-sm table-bordered mb-2">
-        <thead class="bg-light">
-        <tr>
-            <th class="border-bottom-0 text-secondary width-200px">Subject</th>
-            <th class="border-bottom-0 text-secondary">Current</th>
-            <th class="border-bottom-0 text-secondary w-50">Target</th>
-        </tr>
-        </thead>
-        <tbody>
-        <tr>
-            <td class="pl-1 align-middle bg-light">Est. Daily Calories</td>
-            <td><pre class="m-0">{{@$contentData["estimated_daily_calories"]["S"]}}</pre></td>
-            <td><pre class="m-0">{{@$contentData["estimated_daily_calories"]["P"]}}</pre></td>
-        </tr>
-        <tr>
-            <td class="pl-1 align-middle bg-light">Est. Daily Protein Grams</td>
-            <td><pre class="m-0">{{@$contentData["estimated_daily_protein_grams"]["S"]}}</pre></td>
-            <td><pre class="m-0">{{@$contentData["estimated_daily_protein_grams"]["P"]}}</pre></td>
-        </tr>
-        <tr>
-            <td class="pl-1 align-middle bg-light">Est. Daily Vegetable Servings</td>
-            <td><pre class="m-0">{{@$contentData["estimated_daily_vegetable_servings"]["S"]}}</pre></td>
-            <td><pre class="m-0">{{@$contentData["estimated_daily_vegetable_servings"]["P"]}}</pre></td>
-        </tr>
-        <tr>
-            <td class="pl-1 align-middle bg-light">Est. Daily Hours Of Sleep</td>
-            <td><pre class="m-0">{{@$contentData["estimated_daily_hours_of_sleep"]["S"]}}</pre></td>
-            <td><pre class="m-0">{{@$contentData["estimated_daily_hours_of_sleep"]["P"]}}</pre></td>
-        </tr>
-        </tbody>
-    </table>
+    @if(!$hasTypicalDayData && !$hasTypicalDayData)
+        -
+    @endif
 </div>