Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
social_geolocation-3452526
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
social_geolocation-3452526
Commits
4b01024a
Commit
4b01024a
authored
1 year ago
by
Volodymyr Baldych
Committed by
Taras Kruts
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3394300
: Fix location filter on admin/people page
parent
d0d1c264
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
social_geolocation.libraries.yml
+1
-1
1 addition, 1 deletion
social_geolocation.libraries.yml
social_geolocation.module
+28
-22
28 additions, 22 deletions
social_geolocation.module
with
29 additions
and
23 deletions
social_geolocation.libraries.yml
+
1
−
1
View file @
4b01024a
social_geolocation.location
:
js
:
assets/js/social_geolocation_autocomplete.js
:
{}
assets/js/social_geolocation_autocomplete.js
:
{}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
social_geolocation.module
+
28
−
22
View file @
4b01024a
...
...
@@ -56,8 +56,11 @@ function social_geolocation_form_views_exposed_form_alter(&$form, FormStateInter
social_geolocation_attach_views_location_filter
(
$form
,
'fieldset'
);
// Clean up profile geolocation field filters added by default.
$form
[
'field_profile_geolocation_proximity'
][
'#type'
]
=
'hidden'
;
// Hide fields that shouldn't be shown.
hide
(
$form
[
'field_profile_geolocation_proximity_center'
]);
hide
(
$form
[
'field_profile_geolocation_proximity'
]);
// Clean up profile geolocation filter fields added by default.
unset
(
$form
[
'center'
]);
// It's possible that location_details wasn't created because there is no
...
...
@@ -65,11 +68,7 @@ function social_geolocation_form_views_exposed_form_alter(&$form, FormStateInter
// we don't tweak the fieldset.
if
(
isset
(
$form
[
'location_details'
]))
{
$form
[
'location_details'
][
'geolocation_geocoder_address'
][
'#size'
]
=
30
;
unset
(
$form
[
'location_details'
][
'proximity'
][
'#description'
],
$form
[
'location_details'
][
'geolocation_geocoder_address'
][
'#description'
]
);
unset
(
$form
[
'location_details'
][
'geolocation_geocoder_address'
][
'#description'
]);
}
}
...
...
@@ -89,22 +88,25 @@ function social_geolocation_attach_views_location_filter(array &$form, string $c
return
;
}
$range_min
=
10
;
$range_max
=
1000
;
$unit_of_measurement
=
\Drupal
::
config
(
'social_geolocation.settings'
)
->
get
(
'unit_of_measurement'
);
$form
[
'#validate'
][]
=
'_social_geolocation_form_views_exposed_form_validate'
;
// Set up a container for our location filtering fields.
$form
[
'location_details'
]
=
[
'#title'
=>
t
(
'Location
r
ange'
),
'#title'
=>
t
(
'Location
& R
ange'
),
'#type'
=>
$container_type
,
'#weight'
=>
50
,
];
$form
[
'location_details'
][
'proximity'
]
=
[
'#type'
=>
'number'
,
'#title'
=>
t
(
'
Distance (@unitOfMeasurement)'
,
[
'@unitOfMeasurement'
=>
$unit_of_measurement
]
),
'#description'
=>
t
(
'Recommended range from 10 to 1000.'
),
'#min'
=>
0
,
'#max'
=>
10000
,
'#title'
=>
t
(
'
Range'
),
'#description'
=>
t
(
"From
{
$range_min
}
to
{
$range_max
}
{
$unit_of_measurement
}
"
),
'#min'
=>
$range_min
,
'#max'
=>
$range_max
,
'#weight'
=>
10
,
];
...
...
@@ -144,20 +146,24 @@ function _social_geolocation_form_views_exposed_form_validate(&$form, FormStateI
$address_geocoded
=
_social_geolocation_geocode_address
(
$address
);
if
(
!
empty
(
$address_geocoded
))
{
// Set values for proximity.
// Default is 20.
// Set values for field_profile_geolocation_proximity. Default is 20.
$proximity
=
$form_state
->
getValue
(
'proximity'
);
if
(
!
empty
(
$form_state
->
getValue
(
'proximity'
)))
{
$form_state
->
setValue
(
[
'field_profile_geolocation_proximity'
]
,
$proximity
);
$form_state
->
setValue
(
'field_profile_geolocation_proximity'
,
$proximity
);
}
$form_state
->
setValue
(
[
'lat'
],
$address_geocoded
[
'lat'
]
);
$form_state
->
setValue
([
'field_profile_geolocation_proximity_center'
,
'coordinates'
,
'lat'
,
],
$address_geocoded
[
'lat'
]);
$form_state
->
setValue
(
[
'lng'
],
$address_geocoded
[
'lng'
]
);
$form_state
->
setValue
([
'field_profile_geolocation_proximity_center'
,
'coordinates'
,
'lng'
,
],
$address_geocoded
[
'lng'
]);
}
else
{
$element
=
[
'geolocation_geocoder_address'
];
...
...
@@ -420,4 +426,4 @@ function _social_geolocation_reformat_address_for_api(AddressInterface $address)
}
return
[];
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment