Bug 14794: Display JS tooltip whenever dateofbirth is being searched
authorNick Clemens <nick@bywatersolutions.com>
Fri, 7 Jun 2019 14:53:16 +0000 (14:53 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 13 Jun 2019 11:04:32 +0000 (12:04 +0100)
This updates the code that adds a tooltip for the correct date format
to display after the initial search

To test:
1 - Do a patron search, choosing date of birth as the search field
2 - Note on choosing that field you get a tooltip defining the format
3 - Do a search
4 - Note tooltip is gone, but date fo birth is still selected as the field to search
5 - Apply patch, reload
6 - Note tooltip shows after initial search and until field is changed

Signed-off-by: Maryse Simard <maryse.simard@inlibro.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

koha-tmpl/intranet-tmpl/prog/js/members-menu.js

index 235467d..ad39b99 100644 (file)
@@ -15,22 +15,10 @@ $(document).ready(function(){
     } else {
         $("#filteraction_off").toggle();
     }
+
+    searchfield_date_tooltip();
     $("#searchfieldstype").change(function() {
-        var MSG_DATE_FORMAT = "";
-        if ( $(this).val() == 'dateofbirth' ) {
-            if( dateformat == 'us' ){
-                MSG_DATE_FORMAT = MSG_DATE_FORMAT_US;
-            } else if( dateformat == 'iso' ){
-                MSG_DATE_FORMAT = MSG_DATE_FORMAT_ISO;
-            } else if( dateformat == 'metric' ){
-                MSG_DATE_FORMAT = MSG_DATE_FORMAT_METRIC;
-            } else if( dateformat == 'dmydot' ){
-                MSG_DATE_FORMAT = MSG_DATE_FORMAT_DMYDOT;
-            }
-            $('#searchmember').attr("title", MSG_DATE_FORMAT).tooltip('show');
-        } else {
-            $('#searchmember').tooltip('destroy');
-        }
+        searchfield_date_tooltip();
     });
 
     if( CAN_user_borrowers_edit_borrowers ){
@@ -104,6 +92,24 @@ $(document).ready(function(){
     });
 });
 
+function searchfield_date_tooltip() {
+    var MSG_DATE_FORMAT = "";
+    if ( $("#searchfieldstype").val() == 'dateofbirth' ) {
+        if( dateformat == 'us' ){
+            MSG_DATE_FORMAT = MSG_DATE_FORMAT_US;
+        } else if( dateformat == 'iso' ){
+            MSG_DATE_FORMAT = MSG_DATE_FORMAT_ISO;
+        } else if( dateformat == 'metric' ){
+            MSG_DATE_FORMAT = MSG_DATE_FORMAT_METRIC;
+        } else if( dateformat == 'dmydot' ){
+            MSG_DATE_FORMAT = MSG_DATE_FORMAT_DMYDOT;
+        }
+        $('#searchmember').attr("title", MSG_DATE_FORMAT).tooltip('show');
+    } else {
+        $('#searchmember').tooltip('destroy');
+    }
+}
+
 function confirm_updatechild() {
     var is_confirmed = window.confirm( MSG_CONFIRM_UPDATE_CHILD );
     if (is_confirmed) {