Prechádzať zdrojové kódy

Ability to set specific fields to autofocus in moe forms

Vijayakrishnan Krishnan 4 rokov pred
rodič
commit
39f11ad691

+ 10 - 4
public/js/mc.js

@@ -266,15 +266,21 @@ function fastLoad(_href, _history = true, _useCache = true, _replaceState = fals
     }
 }
 
-function initPrimaryForm() {
-    var primaryForm = $('.primary-form:visible');
+function initPrimaryForm(_form = false) {
+    var primaryForm = _form ? _form : $('.primary-form:visible');
     if (primaryForm.length) {
-        var rte = primaryForm.first().find('[contenteditable="true"]').first();
+        primaryForm = primaryForm.first();
+        var rte = primaryForm.find('[contenteditable="true"]').first();
         if(rte.length) {
             rte.focus().select();
         }
         else {
-            primaryForm.first().find('input, textarea, select').first().focus().select();
+            if(primaryForm.find('[autofocus]:visible').length) {
+                primaryForm.find('[autofocus]:visible').first().focus().select();
+            }
+            else {
+                primaryForm.find('input:not([type="hidden"]):visible, textarea:visible, select:visible').first().focus().select();
+            }
         }
     }
 }

+ 2 - 2
public/js/yemi.js

@@ -303,8 +303,8 @@ jQuery(document).ready(function () {
                             $(realForm)[0].reset();
                             showMoeFormMask();
                             setTimeout(function() {
-                                $(realForm).find('input:not([type="hidden"]), textarea, select').first().select().focus();
-                            }, 0);
+                                initPrimaryForm($(realForm));
+                            }, 100);
                         }
                     }
                 }

+ 2 - 2
resources/views/app/patient/care-month/dashboard.blade.php

@@ -244,7 +244,7 @@
                                                 $d = date('d');
                                             }
                                             ?>
-                                            <input type="date" min="{{ date($y . '-' . $m . '-01') }}" max="{{ date($y . '-' . $m . '-' . $d) }}" class="form-control form-control-sm" name="effectiveDate"
+                                            <input autofocus type="date" min="{{ date($y . '-' . $m . '-01') }}" max="{{ date($y . '-' . $m . '-' . $d) }}" class="form-control form-control-sm" name="effectiveDate"
                                                    value="" placeholder="Effective Date">
                                         </div>
                                         <div class="mb-2">
@@ -396,7 +396,7 @@
                                         $d = date('d');
                                     }
                                     ?>
-                                    <input type="date" min="{{ date($y . '-' . $m . '-01') }}" max="{{ date($y . '-' . $m . '-' . $d) }}" class="form-control form-control-sm" name="effectiveDate"
+                                    <input autofocus type="date" min="{{ date($y . '-' . $m . '-01') }}" max="{{ date($y . '-' . $m . '-' . $d) }}" class="form-control form-control-sm" name="effectiveDate"
                                            value="" placeholder="Effective Date">
                                 </div>
                                 <div class="mb-2">