Class: Components::Databasium::Records::ShowTurboStream
- Inherits:
-
Base
- Object
- Base
- Components::Databasium::Records::ShowTurboStream
- Includes:
- Phlex::Rails::Helpers::TurboStream
- Defined in:
- app/components/databasium/records/show_turbo_stream.rb
Instance Method Summary collapse
-
#initialize(refresh:, filter:, table:, records:, model:, turbo_frame:, pagy:, feedback:, columns_names_types:, limit:) ⇒ ShowTurboStream
constructor
A new instance of ShowTurboStream.
- #view_template ⇒ Object
Constructor Details
#initialize(refresh:, filter:, table:, records:, model:, turbo_frame:, pagy:, feedback:, columns_names_types:, limit:) ⇒ ShowTurboStream
Returns a new instance of ShowTurboStream.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/components/databasium/records/show_turbo_stream.rb', line 4 def initialize( refresh:, filter:, table:, records:, model:, turbo_frame:, pagy:, feedback:, columns_names_types:, limit: ) @filter = filter @table = table @records = records @model = model @turbo_frame = turbo_frame @pagy = pagy @feedback = feedback @columns_names_types = columns_names_types @limit = limit @refresh = refresh end |
Instance Method Details
#view_template ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/components/databasium/records/show_turbo_stream.rb', line 28 def view_template foreign = @turbo_frame.start_with?("foreign_records_table_") target_frame = foreign ? @turbo_frame : "records_list" turbo_stream.replace( target_frame, Components::Databasium::Records::Table.new( records: @records, model: @model, turbo_frame: target_frame, pagy: @pagy, feedback: @feedback ) ) return if foreign turbo_stream.update( "header_actions", Components::Databasium::Records::HeaderActions.new(filter: nil, table: @table, limit: @limit) ) if @refresh turbo_stream.replace( "filter", Components::Databasium::Records::Filter.new( model: @model, turbo_frame: @turbo_frame, columns_names_types: @columns_names_types, hidden: true ) ) turbo_stream.replace( "addRecord", Components::Databasium::Forms::Model.new( columns_names_types: @columns_names_types, model: @model ) ) turbo_stream.replace( "records_utilities", Components::Databasium::Records::Utilities.new( model: @model, columns_names_types: @columns_names_types ) ) end end |