Bladeren bron

Allow shortcuts with newlines in them

Vijayakrishnan 4 jaren geleden
bovenliggende
commit
4bd3fd1a2a

+ 5 - 14
public/js/shortcut.js

@@ -42,16 +42,7 @@
         let pos = getCaretPos();
         if(pos) {
             index = -1;
-            let rawOptions = $(_input).closest('[data-shortcuts]').attr('data-shortcuts');
-            options = [];
-            rawOptions = rawOptions.split('^^^');
-            for (let i = 0; i < rawOptions.length; i++) {
-                let parts = rawOptions[i].split('|||');
-                options.push({
-                    name: parts[0],
-                    value: parts[1]
-                });
-            }
+            options = window.userShortcuts;
             menu.empty();
             for(let i = 0; i < options.length; i++) {
                 menu.append(
@@ -212,10 +203,10 @@
                 if(!this.checkValidity()) return false;
                 $.post('/api/proTextShortcut/create', $(this).serialize(), function(_data) {
                     if(_data && _data.success && input) {
-                        var options = [$(input).closest('[data-shortcuts]').attr('data-shortcuts')]
-                        options.push(label + '|||' + content);
-                        options = options.join('^^^');
-                        $(input).closest('[data-shortcuts]').attr('data-shortcuts', options);
+                        window.userShortcuts.push({
+                            name: label,
+                            value: content
+                        });
                         toastr.success('Shortcut saved');
                         hideMoeFormMask();
                         $('#create-shortcut-form').hide();

+ 11 - 9
resources/views/app/patient/note/dashboard.blade.php

@@ -198,15 +198,17 @@
                 <div class="mb-3">
                     <div>
                         <?php
-                        $shortcuts = $pro->shortcuts;
-                        $packed = [];
-                        foreach ($shortcuts as $shortcut) {
-                            // TEMP Solution - disallow newlines in shortcut expansions
-                            // $packed[] = $shortcut->shortcut . '|||' . $shortcut->text;
-                            $packed[] = $shortcut->shortcut . '|||' . preg_replace("/[\\r\\n]+/i", " ", $shortcut->text);
+                        $shortCutsObject = [];
+                        foreach ($pro->shortcuts as $shortcut) {
+                            $shortCutsObject[] = [
+                                "name" => $shortcut->shortcut,
+                                "value" => $shortcut->text
+                            ];
                         }
-                        $packed = implode("^^^", $packed);
-                        $shortcuts = $packed;
+                        ?>
+                        <script>window.userShortcuts = <?= json_encode($shortCutsObject); ?>;</script>
+                        <?php
+                        $shortcuts = "";
                         $latestSectionTS = 0;
                         ?>
                         @foreach($note->sections as $section)
@@ -379,7 +381,7 @@
 
                     $(this).wrap(
                         $('<div class="border-left border-right rte-holder"/>')
-                            .attr('data-shortcuts', '{{ $packed }}')
+                            .attr('data-shortcuts', '')
                     );
 
                     // give a unique id to this editor instance

+ 1 - 1
resources/views/app/practice-management/my-text-shortcuts.blade.php

@@ -45,7 +45,7 @@
                 @foreach($myTextShortcuts as $textShortcut)
                     <tr>
                         <td class="px-3">{{ $textShortcut->shortcut }}</td>
-                        <td>{{ $textShortcut->text }}</td>
+                        <td><pre class="mb-0">{{ $textShortcut->text }}</pre></td>
                         <td>
                             <div class="d-flex align-items-center">
                                 <div moe wide class="mr-3">

+ 2 - 2
storage/sections/fhx/form.blade.php

@@ -223,7 +223,7 @@ $formID = rand(0, 100000);
         <div class="row mb-2">
             <div class="col-md-12">
                 <textarea rte class="form-control form-control-sm" type="text"
-                          data-shortcuts="{{ $shortcuts }}" :name="'item_' + index + '_comments'" v-model="item.comments">
+                          data-shortcuts="" :name="'item_' + index + '_comments'" v-model="item.comments">
                 </textarea>
             </div>
         </div>
@@ -298,7 +298,7 @@ $formID = rand(0, 100000);
 
                         $(this).wrap(
                             $('<div class="border-left border-right rte-holder"/>')
-                                .attr('data-shortcuts', '{{ $packed }}')
+                                .attr('data-shortcuts', '')
                         );
 
                         // give a unique id to this editor instance

+ 2 - 2
storage/sections/hospitalizations/form.blade.php

@@ -69,7 +69,7 @@ $formID = rand(0, 100000);
             <div class="col-md-12">
                 <textarea rte class="form-control form-control-sm" type="text"
                           :name="'item_' + index + '_comments'"
-                          data-shortcuts="{{ $shortcuts }}"  v-model="item.comments">
+                          data-shortcuts=""  v-model="item.comments">
                 </textarea>
             </div>
         </div>
@@ -123,7 +123,7 @@ $formID = rand(0, 100000);
 
                         $(this).wrap(
                             $('<div class="border-left border-right rte-holder"/>')
-                                .attr('data-shortcuts', '{{ $packed }}')
+                                .attr('data-shortcuts', '')
                         );
 
                         // give a unique id to this editor instance

+ 2 - 2
storage/sections/implantable-devices/form.blade.php

@@ -53,7 +53,7 @@ $formID = rand(0, 100000);
             <div class="col-md-12">
                 <textarea rte class="form-control form-control-sm" type="text"
                           :name="'item_' + index + '_comments'"
-                          data-shortcuts="{{ $shortcuts }}"  v-model="item.comments">
+                          data-shortcuts=""  v-model="item.comments">
                 </textarea>
             </div>
         </div>
@@ -104,7 +104,7 @@ $formID = rand(0, 100000);
 
                         $(this).wrap(
                             $('<div class="border-left border-right rte-holder"/>')
-                                .attr('data-shortcuts', '{{ $packed }}')
+                                .attr('data-shortcuts', '')
                         );
 
                         // give a unique id to this editor instance

+ 1 - 1
storage/sections/pmhx/form.blade.php

@@ -256,7 +256,7 @@ $formID = rand(0, 100000);
         <div class="col-12">
             <textarea rte type="text" class="form-control form-control-sm p-2"
                       name="comments"
-                      data-shortcuts="{{ $shortcuts }}"
+                      data-shortcuts=""
                       placeholder="Value"><?= isset($contentData['comments']) ? $contentData['comments'] : '' ?></textarea>
         </div>
     </div>

+ 1 - 1
storage/sections/pshx/form.blade.php

@@ -140,7 +140,7 @@ $formID = rand(0, 100000);
         <div class="col-12">
             <textarea rte type="text" class="form-control form-control-sm p-2"
                       name="comments"
-                      data-shortcuts="{{ $shortcuts }}"
+                      data-shortcuts=""
                       placeholder="Value"><?= isset($contentData['comments']) ? $contentData['comments'] : '' ?></textarea>
         </div>
     </div>

+ 1 - 1
storage/sections/sochx/form.blade.php

@@ -82,7 +82,7 @@ $formID = rand(0, 100000);
         <div class="col-12">
             <textarea rte type="text" class="form-control form-control-sm p-2"
                       name="comments"
-                      data-shortcuts="{{ $shortcuts }}"
+                      data-shortcuts=""
                       placeholder="Value"><?= isset($contentData['comments']) ? $contentData['comments'] : '' ?></textarea>
         </div>
     </div>

+ 1 - 1
storage/sections/subjective/form.blade.php

@@ -20,7 +20,7 @@ $formID = rand(0, 100000);
     <div class="form-group mb-2">
         <textarea rte type="text" class="form-control form-control-sm p-2"
                   name="value"
-                  data-shortcuts="{{ $shortcuts }}"
+                  data-shortcuts=""
                   placeholder="Value"><?= $contentData['value'] ?></textarea>
     </div>
     <div class="form-group m-0 d-flex">