Sha256: 00cd2890d68a3621461adecfd4be1c8bab18752531239618a2c9f1fbb7be4f04

Contents?: true

Size: 860 Bytes

Versions: 1

Compression:

Stored size: 860 Bytes

Contents

module PgAssociable
  module Helpers
    MAX_RESULTS = 8

    def pg_respond_abrir_modal
      content = FormModalComponent.new(@clase_modelo.new.decorate)
                                  .render_in(view_context)
      modal = AsociableModalComponent.new(modal_id: params[:id]).with_content(content)
      render turbo_stream: turbo_stream.append_all('body', modal)
    end

    def pg_respond_buscar
      partial = 'pg_associable/resultados_inline'
      resultados_prefix = 'resultados-inline'
      query = params[:query]
      timeout_id = params[:timeout_id]
      @collection = policy_scope(@clase_modelo).kept.query(query).limit(MAX_RESULTS)
      render turbo_stream:
        turbo_stream.update("#{resultados_prefix}-#{params[:id]}",
                            partial:, locals: { collection: @collection, query:, timeout_id: })
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pg_rails-7.3.0 pg_associable/app/helpers/pg_associable/helpers.rb