fixing the default date output for the date search field in the dashboard widget
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 27 Sep 2018 16:29:38 +0000 (12:29 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 27 Sep 2018 16:29:38 +0000 (12:29 -0400)
views/admin/newDashboard/components/dateSearch.html

index d61dc4e..fae42a9 100644 (file)
@@ -1,28 +1,38 @@
 <div class="row date-search-container">
     <div class="date-search-title">Search By Date</div>
-    <div class="s12 m12 l4 col glm-widget-search">
+    <div class="s12 xl4 col glm-widget-search">
         <input id="{$addon.slug}-fromDate" type="text" class="fromDate date-field" name="fromDate" placeholder="From Date">
     </div>
-    <div class="s12 m12 l4 col glm-widget-search">
+    <div class="s12 xl4 col glm-widget-search">
         <input id="{$addon.slug}-toDate" type="text" class="toDate date-field" name="toDate" placeholder="To Date">
     </div>
-    <div class="s12 m12 l4 col">
-        <span class="btn">Button</span>
+    <div class="s12 xl4 col glm-widget-search">
+        <button style="float: right;margin-top: 13px;"class="btn-small date-search-btn">Search</button>        
     </div>
 </div>
 <script>
     jQuery(function($){
+
+        var date = new Date();
+        var toDate = '', fromDate = '';
         $('.fromDate').datepicker({
-            format: 'mm/dd/yyyy',
-            onClose: function(){
-                
+            format          : 'mm/dd/yyyy',
+            setDefaultDate  : true,
+            defaultDate     : date,
+            autoClose       : true,
+            onClose         : function(){
+                fromDate = '&fromDate=' + $(this)[0].el.value;
             }
         });
         $('.toDate').datepicker({
-            format: 'mm/dd/yyyy',
+            format      : 'mm/dd/yyyy',
+            autoClose   : true,
             onClose: function(){
-                
+                toDate = '&toDate=' + $(this)[0].el.value;
             }
         });
+        $('.date-search-btn').on("click", function(){
+            window.location = '{$component.resultUrl}' +fromDate + toDate;
+        })
     });
 </script>
\ No newline at end of file