refactor(turbo): champ carte use turbo
This commit is contained in:
parent
1500a1cf28
commit
1c2bd5543f
5 changed files with 10 additions and 14 deletions
|
@ -38,7 +38,7 @@ export function useFeatureCollection(
|
||||||
features: callback(features)
|
features: callback(features)
|
||||||
}));
|
}));
|
||||||
httpRequest(url)
|
httpRequest(url)
|
||||||
.js()
|
.turbo()
|
||||||
.catch(() => null);
|
.catch(() => null);
|
||||||
},
|
},
|
||||||
[url, setFeatureCollection]
|
[url, setFeatureCollection]
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<%= render_flash(timeout: 5000, fixed: true) %>
|
|
||||||
|
|
||||||
<%= render_to_element("##{@champ.input_group_id} .geo-areas",
|
|
||||||
partial: 'shared/champs/carte/geo_areas',
|
|
||||||
locals: { champ: @champ, editing: true }) %>
|
|
||||||
|
|
||||||
<% if @focus %>
|
|
||||||
<%= fire_event('map:feature:focus', { bbox: @champ.bounding_box }.to_json) %>
|
|
||||||
<% end %>
|
|
4
app/views/champs/carte/index.turbo_stream.haml
Normal file
4
app/views/champs/carte/index.turbo_stream.haml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
= turbo_stream.update dom_id(@champ, :geo_areas), partial: 'shared/champs/carte/geo_areas', locals: { champ: @champ, editing: true }
|
||||||
|
|
||||||
|
- if @focus
|
||||||
|
= turbo_stream.dispatch 'map:feature:focus', bbox: @champ.bounding_box
|
|
@ -1,4 +1,4 @@
|
||||||
= react_component("MapEditor", featureCollection: champ.to_feature_collection, url: champs_carte_features_path(champ), options: champ.render_options)
|
= react_component("MapEditor", featureCollection: champ.to_feature_collection, url: champs_carte_features_path(champ), options: champ.render_options)
|
||||||
|
|
||||||
.geo-areas
|
.geo-areas{ id: dom_id(champ, :geo_areas) }
|
||||||
= render partial: 'shared/champs/carte/geo_areas', locals: { champ: champ, editing: true }
|
= render partial: 'shared/champs/carte/geo_areas', locals: { champ: champ, editing: true }
|
||||||
|
|
|
@ -117,7 +117,7 @@ describe Champs::CarteController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
before do
|
before do
|
||||||
get :index, params: params, format: :js, xhr: true
|
get :index, params: params, format: :turbo_stream
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'without focus' do
|
context 'without focus' do
|
||||||
|
@ -126,7 +126,7 @@ describe Champs::CarteController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the list' do
|
it 'updates the list' do
|
||||||
expect(response.body).not_to include("DS.fire('map:feature:focus'")
|
expect(response.body).not_to include("map:feature:focus")
|
||||||
expect(response.status).to eq 200
|
expect(response.status).to eq 200
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -140,7 +140,8 @@ describe Champs::CarteController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'updates the list and focuses the map' do
|
it 'updates the list and focuses the map' do
|
||||||
expect(response.body).to include("DS.fire('map:feature:focus'")
|
expect(response.body).to include(ActionView::RecordIdentifier.dom_id(champ, :geo_areas))
|
||||||
|
expect(response.body).to include("map:feature:focus")
|
||||||
expect(response.status).to eq 200
|
expect(response.status).to eq 200
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue