mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
Replace bulk invoice CableReady broadcast with ActionCable
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class BulkInvoiceJob < ApplicationJob
|
||||
include CableReady::Broadcaster
|
||||
delegate :render, to: ActionController::Base
|
||||
attr_reader :options
|
||||
|
||||
@@ -40,13 +39,14 @@ class BulkInvoiceJob < ApplicationJob
|
||||
def broadcast(filepath, channel)
|
||||
file_id = filepath.split("/").last.split(".").first
|
||||
|
||||
cable_ready[channel].
|
||||
inner_html(
|
||||
ActionCable.server.broadcast(
|
||||
channel,
|
||||
{
|
||||
selector: "#bulk_invoices_modal .modal-content",
|
||||
html: render(partial: "spree/admin/orders/bulk/invoice_link",
|
||||
locals: { invoice_url: "/admin/orders/invoices/#{file_id}" })
|
||||
).
|
||||
broadcast
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def ensure_directory_exists(filepath)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import consumer from './consumer'
|
||||
import CableReady from 'cable_ready'
|
||||
|
||||
consumer.subscriptions.create("SessionChannel", {
|
||||
received(data) {
|
||||
if (data.cableReady) CableReady.perform(data.operations)
|
||||
if (!data.selector) return;
|
||||
|
||||
document.querySelector(data.selector).innerHTML = data.html;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user