Jelajahi Sumber

Remove section button (top-right), click anywhere to edit mode

Vijayakrishnan Krishnan 4 tahun lalu
induk
melakukan
04b8d42b80

+ 4 - 0
public/css/style.css

@@ -277,6 +277,10 @@ body>nav.navbar {
 .note-section:not(.edit) div.if-not-edit {
     padding-left: 1rem;
 }
+.note-section:not(.edit):hover {
+    background: #f6f9fc;
+    cursor: pointer;
+}
 .note-section.edit .if-edit {
     display: block !important;
 }

+ 32 - 0
resources/views/app/patient/note/dashboard.blade.php

@@ -245,6 +245,11 @@
                                 </a>
                                 <?php $sectionInternalName = $section->sectionTemplate->internal_name; ?>
                                 @include('app/patient/note/_templates-index')
+                                <a href="#" class="d-none text-danger if-edit ml-auto remove-section-trigger"
+                                   data-uid="{{$section->uid}}"
+                                   title="Remove {{$section->sectionTemplate->title}}">
+                                    <i class="fa fa-times-circle"></i>
+                                </a>
                             </div>
                             <div class="d-none if-not-edit  inset-comment">{!! !empty($section->summary_html) ? $section->summary_html : '-' !!}</div>
                             <div class="d-none if-edit">@include('sections/'.$section->sectionTemplate->internal_name.'/form')</div>
@@ -563,6 +568,33 @@
                         return loadTemplateSet($(this));
                     });
 
+                $('.remove-section-trigger').click(function() {
+                    $.post('/api/section/deactivate', {
+                        uid: $(this).attr('data-uid'),
+                        memo: 'Deactivated from note',
+                    }, function(_data) {
+                        if(_data) {
+                            if(_data.success) {
+                                fastReload();
+                            }
+                            else {
+                                toastr.error(_data.message);
+                            }
+                        }
+                        else {
+                            toastr.error('Unable to remove section!');
+                        }
+                    }, 'json');
+                    return false;
+                });
+
+                $(document)
+                    .off('mousedown.enable-edit', '.note-section:not(.edit)')
+                    .on('mousedown.enable-edit', '.note-section:not(.edit)', function() {
+                        $(this).find('.edit-trigger').first().click();
+                        return false;
+                    });
+
             }
 
             function loadTemplateSet(_chooser) {