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

Notes table content truncation #1

Vijayakrishnan Krishnan 4 жил өмнө
parent
commit
b696958e87

+ 37 - 12
resources/views/app/patient/notes.blade.php

@@ -86,18 +86,22 @@
                     {!! $note->hcpPro && $note->is_signed_by_hcp ? '<b class="text-success">Yes</b>' : 'No' !!}
                 </td>
                 <td class="px-2 note-summary">
-                    <?php
-                    $textContent = strip_tags($note->free_text_html);
-                    if(strlen($textContent) > 200) {
-                        $textContent = substr($textContent, 0, 200) . '…';
-                    }
-                    ?>
-                    {!! $textContent !!}
-                    @foreach($note->sections as $section)
-                    <div p-2>
-                        {!! $section->summary_html !!}
+                    <div class="note-section-content-html-outer">
+                        <?php
+                        $textContent = strip_tags($note->free_text_html);
+                        if(strlen($textContent) > 200) {
+                            $textContent = substr($textContent, 0, 200) . '…';
+                        }
+                        ?>
+                        {!! $textContent !!}
+                        @foreach($note->sections as $section)
+                            @if(!!$section->summary_html)
+                                <div p-2 class="note-section-content-html">
+                                    {!! $section->summary_html !!}
+                                </div>
+                            @endif
+                        @endforeach
                     </div>
-                    @endforeach
                 </td>
                 <td class="px-2">
                     <div class="position-relative c-pointer text-center stag-tooltip">
@@ -122,6 +126,27 @@
     <script>
         (function() {
             function initNotesList() {
+
+                // truncate content
+                $('.note-section-content-html').each(function() {
+                    if($.trim($(this).text()) === '') $(this).remove();
+                    $(this).find('p, div').each(function() {
+                        if($.trim($(this).text()) === '') $(this).remove();
+                    });
+                });
+                $('.note-section-content-html-outer').each(function() {
+                    let pCount = 0;
+                    $(this).find('p').each(function() {
+                        pCount++;
+                        if(pCount > 3) {
+                            $(this).hide();
+                        }
+                    });
+                    if(pCount > 3) {
+                        $('<p/>').text('…').appendTo(this);
+                    }
+                });
+
                 $('.trigger-clone')
                     .off('click.clone')
                     .on('click.clone', function() {
@@ -141,7 +166,7 @@
                                 toastr.error('Unable to clone the note!');
                             }
                         }, 'json');
-                    })
+                    });
             }
             addMCInitializer('notes-list', initNotesList);
         })();