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

Move note sections up/down

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

+ 33 - 1
resources/views/app/patient/note/dashboard.blade.php

@@ -240,11 +240,17 @@
                                     ?> @include('sections/' . $sectionInternalName . '/actions') <?php
                                 }
                                 ?>
-                                <a href="#" class="d-none text-danger if-edit ml-auto remove-section-trigger"
+                                <a href="#" class="d-none text-danger if-edit ml-auto remove-section-trigger mr-1"
                                    data-uid="{{$section->uid}}"
                                    title="Remove {{$section->sectionTemplate->title}}">
                                     Remove {{$section->sectionTemplate->title}}
                                 </a>
+                                <a href="#" class="d-none if-edit ml-2 move-up-trigger" data-uid="{{$section->uid}}" title="Move Up">
+                                    <i class="fa fa-arrow-up"></i>
+                                </a>
+                                <a href="#" class="d-none if-edit ml-2 move-down-trigger" data-uid="{{$section->uid}}" title="Move Down">
+                                    <i class="fa fa-arrow-down"></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>
@@ -630,6 +636,32 @@
                     scrollToLatest();
                 }
 
+                function __moveSection(_uid, _direction) {
+                    $.post('/api/section/move' + _direction, {
+                        uid: _uid
+                    }, function(_data) {
+                        if(_data && _data.success) {
+                            fastReload();
+                        }
+                        else {
+                            if(_data) {
+                                toastr.error(_data.message);
+                            }
+                            else {
+                                toastr.error('Unknown error while moving section');
+                            }
+                        }
+                    }, 'json')
+                }
+
+                $('.move-up-trigger').click(function() {
+                    __moveSection($(this).attr('data-uid'), 'Up');
+                });
+
+                $('.move-down-trigger').click(function() {
+                    __moveSection($(this).attr('data-uid'), 'Down');
+                });
+
             }
 
             // scroll to latest created section