Sfoglia il codice sorgente

Ticket #4575 - Events: Enhancements. Point 5.

AntonLV 2 anni fa
parent
commit
fe51b03d94

+ 6 - 0
inc/classes/BxDolLocationFieldNominatim.php

@@ -94,6 +94,8 @@ class BxDolLocationFieldNominatim extends BxDolLocationField
             $sRet = $oForm->getTemplate()->parseHtmlByName('location_field_plain_auto.html', $aVars);
         }
         else {
+            $bMinimized = isset($aInput['minimized']) && $aInput['minimized'];
+
             $aFields = array(
                 'lat' => array('type' => 'hidden'),
                 'lng' => array('type' => 'hidden'),
@@ -104,6 +106,8 @@ class BxDolLocationFieldNominatim extends BxDolLocationField
                 'zip' => array('type' => 'text', 'ph' => _t('_sys_location_ph_zip')),
                 'country' => array('type' => 'select'),
             );
+            if($bMinimized)
+                unset($aFields['street_number'], $aFields['street'], $aFields['zip']);
 
             $sInputs = '';
             foreach ($aFields as $sKey => $a) {
@@ -130,10 +134,12 @@ class BxDolLocationFieldNominatim extends BxDolLocationField
             }
             $sRet = $oForm->getTemplate()->parseHtmlByName('location_field_plain.html', array(
                 'name' => $aInput['name'],
+                'minimized' => $bMinimized ? 'minimized' : '',
                 'nominatim_server' => $this->getNominatimServer(),
                 'nominatim_email' => $this->getNominatimEmail(),
                 'inputs' => $sInputs,
                 'normalize_names' => getParam('sys_location_normalize_names') ? 1 : 0,
+                
             ));
         }
         return $sRet;

+ 20 - 7
modules/boonex/artificer/data/template/system/css/forms.css

@@ -245,10 +245,14 @@ import url(../../../../../../../template/css/forms.css);
 .bx-form-element .bx-form-value select {
     display: inline-block;
 }
-.bx-form-element .bx-form-input-location-country,
-.bx-form-element .bx-form-input-location-zip,
-.bx-form-element .bx-form-input-location-state,
-.bx-form-element .bx-form-input-location-city {
+.bx-form-element .bx-form-value .minimized input,
+.bx-form-element .bx-form-value .minimized select {
+    display: block;
+}
+.bx-form-element .bx-form-input-location-cont:not(.minimized) .bx-form-input-location-country,
+.bx-form-element .bx-form-input-location-cont:not(.minimized) .bx-form-input-location-zip,
+.bx-form-element .bx-form-input-location-cont:not(.minimized) .bx-form-input-location-state,
+.bx-form-element .bx-form-input-location-cont:not(.minimized) .bx-form-input-location-city {
     width:49%;
 }
 .bx-form-element .bx-form-input-location-street {
@@ -263,9 +267,9 @@ import url(../../../../../../../template/css/forms.css);
 .bx-form-element .bx-form-input-location-city {
     margin-bottom: 0.25rem;
 }
-.bx-form-element .bx-form-input-location-street,
-.bx-form-element .bx-form-input-location-state,
-.bx-form-element .bx-form-input-location-country {
+.bx-form-element .bx-form-input-location-cont:not(.minimized) .bx-form-input-location-street,
+.bx-form-element .bx-form-input-location-cont:not(.minimized) .bx-form-input-location-state,
+.bx-form-element .bx-form-input-location-cont:not(.minimized) .bx-form-input-location-country {
     margin-left: 0.25rem;
 }
 
@@ -274,12 +278,21 @@ import url(../../../../../../../template/css/forms.css);
     width:98%;
     line-height:normal;
 }
+.bx-form-element .bx-form-input-location-cont.minimized .bx-form-input-location-status-cont {
+    display: flex;
+    flex-direction: column;
+    width: auto;
+}
 .bx-form-element .bx-form-input-location-status {
     float:left;
 }
 .bx-form-element .bx-form-input-location-copyright {
     float:right;
 }
+.bx-form-element .bx-form-input-location-cont.minimized .bx-form-input-location-copyright {
+    float: none;
+    margin-top: 0.25rem;
+}
 
 .bx-form-element .bx-form-input-location-auto-cont {
     display:table;

+ 2 - 1
modules/boonex/events/classes/BxEventsModule.php

@@ -29,7 +29,8 @@ class BxEventsModule extends BxBaseModGroupsModule implements iBxDolCalendarServ
         ]);
 
         $this->_aBrowsingFiltersKeys = array_merge($this->_aBrowsingFiltersKeys, [
-            'by_city', 'by_date', 'date_start', 'date_end', 'timezone'
+            'by_location_country', 'by_location_state', 'by_location_city',
+            'by_date', 'date_start', 'date_end', 'timezone'
         ]);
     }
 

+ 7 - 3
modules/boonex/events/classes/BxEventsSearchResult.php

@@ -83,9 +83,13 @@ class BxEventsSearchResult extends BxBaseModGroupsSearchResult
         $oJoinedProfile = null;
         $bProcessConditionsForPrivateContent = true;
 
-        if(isset($this->_aParams['by_city'])) {
-            $this->setMetaType('location_city');
-            $this->setCustomSearchCondition(['keyword' => $this->_aParams['by_city']]);
+        if(isset($this->_aParams['by_location_country'], $this->_aParams['by_location_state'], $this->_aParams['by_location_city'])) {
+            $this->setMetaType('location_country_city');
+            $this->setCustomSearchCondition([
+                'keyword' => $this->_aParams['by_location_country'],
+                'state' => $this->_aParams['by_location_state'],
+                'city' => $this->_aParams['by_location_city']
+            ]);
         }
 
         $iDateStart = $iDateEnd = 0;

+ 11 - 5
modules/boonex/events/classes/BxEventsTemplate.php

@@ -100,10 +100,12 @@ class BxEventsTemplate extends BxBaseModGroupsTemplate
                 'view_mode' => 0,
             ],
             'inputs' => [
-                'by_city' => [
-                    'name' => 'by_city',
-                    'type' => 'text',
-                    'caption' => _t('_bx_events_form_filters_input_by_city'),
+                'by_location' => [
+                    'name' => 'by_location',
+                    'type' => 'location',
+                    'caption' => _t('_bx_events_form_filters_input_by_location'),
+                    'manual_input' => true,
+                    'minimized' => true
                 ],
                 'by_date' => [
                     'name' => 'by_date',
@@ -166,7 +168,11 @@ class BxEventsTemplate extends BxBaseModGroupsTemplate
         if($this->_bIsApi)
             return $oForm->getCodeAPI();
 
-        return $this->addJs(['moment-timezone-with-data-1970-2030.min.js'], true) . $oForm->getCode(true);
+        $sIncludes = '';
+        $sIncludes .= $this->addCss(['filters.css'], true);
+        $sIncludes .= $this->addJs(['moment-timezone-with-data-1970-2030.min.js'], true);
+
+        return $sIncludes . $oForm->getCode(true);
     }
 }
 

+ 1 - 1
modules/boonex/events/install/langs/en.xml

@@ -152,7 +152,7 @@
     <string name="_bx_events_form_price_input_sys_do_cancel"><![CDATA[Cancel]]></string>
     <string name="_bx_events_form_price_input_do_cancel"><![CDATA[Cancel]]></string>
 
-    <string name="_bx_events_form_filters_input_by_city"><![CDATA[By city]]></string>
+    <string name="_bx_events_form_filters_input_by_location"><![CDATA[By location]]></string>
     <string name="_bx_events_form_filters_input_by_date"><![CDATA[By date]]></string>
     <string name="_bx_events_form_filters_input_by_date_all"><![CDATA[Any date]]></string>
     <string name="_bx_events_form_filters_input_by_date_today"><![CDATA[Today]]></string>

+ 3 - 1
modules/boonex/events/js/main.js

@@ -42,7 +42,9 @@ BxEventsMain.prototype.applyBrowsingFilter = function(oElement, oRequestParams)
     if(oRequestParams == undefined)
         oRequestParams = {};
 
-    oRequestParams.by_city = oFilters.find("input[name='by_city']").val();
+    oRequestParams.by_location_country = oFilters.find("[name='by_location_country']").val();
+    oRequestParams.by_location_state = oFilters.find("input[name='by_location_state']").val();
+    oRequestParams.by_location_city = oFilters.find("input[name='by_location_city']").val();
 
     oRequestParams.by_date = oFilters.find("input[name='by_date']:checked").val();
     if(oRequestParams.by_date == 'date_range') {

+ 8 - 0
modules/boonex/events/template/css/filters.css

@@ -0,0 +1,8 @@
+.bx-base-general-browsing-filters {
+    max-width: 20rem;
+}
+
+/*-- Location field: Google --*/
+.pac-container {
+    z-index: 10001;
+}

+ 1 - 1
modules/boonex/russian/data/langs/bx_events/ru.xml

@@ -128,7 +128,7 @@
     <string name="_bx_events_form_session_input_sys_do_cancel"><![CDATA[Отмена]]></string>
     <string name="_bx_events_form_session_input_do_cancel"><![CDATA[Отмена]]></string>
 
-    <string name="_bx_events_form_filters_input_by_city"><![CDATA[По городу]]></string>
+    <string name="_bx_events_form_filters_input_by_location"><![CDATA[По местоположению]]></string>
     <string name="_bx_events_form_filters_input_by_date"><![CDATA[По дате]]></string>
     <string name="_bx_events_form_filters_input_by_date_all"><![CDATA[Любая дата]]></string>
     <string name="_bx_events_form_filters_input_by_date_today"><![CDATA[Сегодня]]></string>

+ 13 - 4
template/css/forms.css

@@ -627,10 +627,10 @@
 
 /* Location field */
 
-.bx-form-input-location-country,
-.bx-form-input-location-zip,
-.bx-form-input-location-state,
-.bx-form-input-location-city {
+.bx-form-input-location-cont:not(.minimized) .bx-form-input-location-country,
+.bx-form-input-location-cont:not(.minimized) .bx-form-input-location-zip,
+.bx-form-input-location-cont:not(.minimized) .bx-form-input-location-state,
+.bx-form-input-location-cont:not(.minimized) .bx-form-input-location-city {
     width:49%;
 }
 
@@ -654,12 +654,21 @@
     width:98%;
     line-height:normal;
 }
+.bx-form-input-location-cont.minimized .bx-form-input-location-status-cont {
+    display: flex;
+    flex-direction: column;
+    width: auto;
+}
 .bx-form-input-location-status {
     float:left;
 }
 .bx-form-input-location-copyright {
     float:right;
 }
+.bx-form-input-location-cont.minimized .bx-form-input-location-copyright {
+    float: none;
+    margin-top: 0.25rem;
+}
 
 .bx-form-input-location-auto-cont {
     display:table;

+ 4 - 4
template/location_field_plain.html

@@ -1,5 +1,5 @@
 
-<div class="bx-form-input-location-__name__ bx-form-input-location-cont bx-clearfix">
+<div class="bx-form-input-location-__name__ __minimized__ bx-form-input-location-cont bx-clearfix">
     __inputs__
     <div class="bx-form-input-location-status-cont bx-def-font-small bx-def-font-grayed bx-def-margin-thd-top bx-clearfix">
         <div class="bx-form-input-location-status ok"><i class="sys-icon sys-colored col-green1-dark check-circle"></i> <bx_text:_sys_location_status_ok /></div>
@@ -41,10 +41,10 @@
 
         sRet = '&country=' + encodeURIComponent(sCountry);
 
-        if (sZip.length && sMode !== 'no_street_no_zip')
+        if (sZip !== undefined && sZip.length && sMode !== 'no_street_no_zip')
             sRet += '&postalcode=' + encodeURIComponent(sZip);
 
-        if ('zip_only' == sMode)
+        if (sZip !== undefined && 'zip_only' == sMode)
             return sZip.length ? sRet : '';
 
         if (sState.length)
@@ -53,7 +53,7 @@
         if (sCity.length)
             sRet += ('county_as_city' == sMode ? '&county=' : '&city=') + encodeURIComponent(sCity);
         
-        if (sStreet.length && sMode !== 'no_street_no_zip')
+        if (sStreet !== undefined && sStreet.length && sMode !== 'no_street_no_zip')
             sRet += '&street=' + (sNum.length ? encodeURIComponent(sNum) + ' ' : '') + encodeURIComponent(sStreet);
 
         return sRet;