Skip to content

Commit

Permalink
Merge pull request #224 from camptocamp/condition
Browse files Browse the repository at this point in the history
Allow to customize condition for mobile display
  • Loading branch information
tonio authored Jul 8, 2020
2 parents 490821d + ffa994a commit d5038ea
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions c2cgeoform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'geolocationTooltip': _('Zoom to current location'),
'zoomInTipLabel': _('Zoom in'),
'zoomOutTipLabel': _('Zoom out'),
'mobile': None
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TestExcavationViews():
assert [situation.name] == list(label.stripped_strings)
assert str(situation.id) == input['value']
if situation in excavation.situations:
assert 'True' == input['checked']
assert 'checked' == input['checked']
assert resp.form.get('situations', index=i).checked
else:
assert 'checked' not in input
Expand Down
9 changes: 8 additions & 1 deletion c2cgeoform/static/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@ export function initMapWidget(oid, options) {
map.getView().fit(options.view.initialExtent)
}
if (!options.readonly) {
const interactions = addInteractions({ map, source, type, input, multi })
const interactions = addInteractions({
map,
source,
type,
input,
multi,
mobile: options.mobile,
})
addControls(
Object.assign(options, {
target,
Expand Down
9 changes: 5 additions & 4 deletions c2cgeoform/static/src/interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ export function addInteractions(options) {
store(options.source.getFeatures()[0]?.getGeometry())
)
// Mobile drawing
if (
window.matchMedia('(max-width: 767px)').matches &&
interactionOptions.type === 'Point'
) {
const condition =
options.mobile !== undefined
? options.mobile
: window.matchMedia('(max-width: 767px)').matches
if (condition && interactionOptions.type === 'Point') {
let map = options.map
draw.setActive(false)
modify.setActive(false)
Expand Down
1 change: 1 addition & 0 deletions c2cgeoform/static/src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
bottom: 0;
margin: auto;
z-index: 100;
max-width: 10em;
}
&:after {
transform: rotate(0deg);
Expand Down

0 comments on commit d5038ea

Please sign in to comment.