mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Handle enterprise edit response with turbo_stream
This commit is contained in:
@@ -7,7 +7,6 @@ require 'open_food_network/order_cycle_permissions'
|
||||
module Admin
|
||||
class EnterprisesController < Admin::ResourceController
|
||||
include GeocodeEnterpriseAddress
|
||||
include CablecarResponses
|
||||
include Pagy::Backend
|
||||
|
||||
# These need to run before #load_resource so that @object is initialised with sanitised values
|
||||
@@ -51,8 +50,10 @@ module Admin
|
||||
|
||||
@enterprise.is_primary_producer = params[:is_primary_producer]
|
||||
@enterprise.sells = params[:enterprise_sells]
|
||||
render cable_ready: cable_car.morph("#side_menu", partial("admin/shared/side_menu"))
|
||||
.morph("#permalink", partial("admin/enterprises/form/permalink"))
|
||||
respond_to do |format|
|
||||
format.html { head :ok }
|
||||
format.turbo_stream { render :edit }
|
||||
end
|
||||
end
|
||||
|
||||
def welcome
|
||||
|
||||
4
app/views/admin/enterprises/edit.turbo_stream.haml
Normal file
4
app/views/admin/enterprises/edit.turbo_stream.haml
Normal file
@@ -0,0 +1,4 @@
|
||||
= turbo_stream.replace 'side_menu' do
|
||||
= render partial: 'admin/shared/side_menu'
|
||||
= turbo_stream.replace 'permalink' do
|
||||
= render partial: 'admin/enterprises/form/permalink'
|
||||
@@ -22,13 +22,13 @@ export default class extends Controller {
|
||||
`?stimulus=true&enterprise_sells=${this.enterpriseSellsValue}&is_primary_producer=${this.primaryProducerValue}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: { "Content-type": "application/json; charset=UTF-8" },
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Accept': 'text/vnd.turbo-stream.html'
|
||||
}
|
||||
}
|
||||
)
|
||||
.then((data) => data.json())
|
||||
.then((operation) => {
|
||||
CableReady.perform(operation);
|
||||
this.spinnerTarget.classList.add("hidden");
|
||||
});
|
||||
}
|
||||
.then(response => response.text())
|
||||
.then(html => Turbo.renderStreamMessage(html))
|
||||
.then(() => this.spinnerTarget.classList.add("hidden"))}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user