Browse Source

Merge branch 'develop'

feature/symfony6.1
Guillaume Bourgeois 2 years ago
parent
commit
68f2a5ee70
4 changed files with 33 additions and 21 deletions
  1. +11
    -10
      Component/CitiesComponent.php
  2. +1
    -1
      Definition/Field/AbstractFieldDefinition.php
  3. +9
    -0
      Resources/assets/functions/tools.js
  4. +12
    -10
      Resources/assets/functions/widgets.js

+ 11
- 10
Component/CitiesComponent.php View File



public function callAddressApi($query) public function callAddressApi($query)
{ {
if(is_null($query)) {
$query = '';
}
$resultsToReturn = [];

if(!is_null($query)) {
$provider = $this->getGeocoderProvider() ;
$query = GeocodeQuery::create($query)->withData('type', 'housenumber');
$results = $provider->geocodeQuery($query);


$provider = $this->getGeocoderProvider() ;
$query = GeocodeQuery::create($query)->withData('type', 'housenumber');
$results = $provider->geocodeQuery($query);
$resultsToReturn = array();
foreach($results as $result) {
if ($result->getStreetNumber() && strlen($result->getStreetNumber()) > 0) {
$resultsToReturn[] = $result;
foreach($results as $result) {
if ($result->getStreetNumber() && strlen($result->getStreetNumber()) > 0) {
$resultsToReturn[] = $result;
}
} }
} }

return $resultsToReturn; return $resultsToReturn;
} }



+ 1
- 1
Definition/Field/AbstractFieldDefinition.php View File

$fieldArray = []; $fieldArray = [];
foreach($configureFieldArray as $fieldName) { foreach($configureFieldArray as $fieldName) {
if(isset($allFieldArray[$fieldName])) { if(isset($allFieldArray[$fieldName])) {
$fieldArray[] = $allFieldArray[$fieldName];
$fieldArray[$fieldName] = $allFieldArray[$fieldName];
} }
else { else {
throw new \ErrorException('Le field "'.$fieldName.'" n\'est pas défini dans configureFields()'); throw new \ErrorException('Le field "'.$fieldName.'" n\'est pas défini dans configureFields()');

+ 9
- 0
Resources/assets/functions/tools.js View File

else return null; else return null;
} }


static formatNumberWithoutRounding(number, toFixed) {
if (number){
let factor = Math.pow(10, toFixed);
return Math.floor(number * factor) / factor
}else{
return null
}
}

static formatNumberWithoutFixed(number) { static formatNumberWithoutFixed(number) {
if (typeof number == 'string') number = number.replace(',', '.'); if (typeof number == 'string') number = number.replace(',', '.');
if (number) return Number(number); if (number) return Number(number);

+ 12
- 10
Resources/assets/functions/widgets.js View File

static setAutoCompleteField() { static setAutoCompleteField() {
var autocompleteFields = $('[data-lc-autocomplete-url]'); var autocompleteFields = $('[data-lc-autocomplete-url]');
autocompleteFields.each(function () { autocompleteFields.each(function () {
var $this = $(this),
url = $this.data('lc-autocomplete-url');

$this.autoComplete({
//bootstrapVersion: 4,
//noResultsText: 'Aucun résultat n\'a été trouvé.',
resolverSettings: {
url: url
}
});
if(!$(this).hasClass('autocomplete-disabled')) {
var $this = $(this),
url = $this.data('lc-autocomplete-url');

$this.autoComplete({
//bootstrapVersion: 4,
//noResultsText: 'Aucun résultat n\'a été trouvé.',
resolverSettings: {
url: url
}
});
}
}); });
} }



Loading…
Cancel
Save