Class: TurboCrud::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/turbo_crud.rb

Overview

Config stays small to stay sane. 🧘‍♂️

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



23
24
25
26
27
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 'lib/turbo_crud.rb', line 23

def initialize
  # Where modal content gets swapped in.
  @modal_frame_id = "turbo_modal"

  # Where drawer content gets swapped in.
  @drawer_frame_id = "turbo_drawer"

  # Where flash/toast content gets swapped in.
  @flash_frame_id = "turbo_flash"

  # When creating, where does the new row go? :prepend or :append
  @default_insert = :prepend

  # Which container should forms target by default?
  # :modal or :drawer
  @default_container = :modal

  # Which partial should be used to render a row when replacing/inserting?
  # :auto => try <collection>/row, then <collection>/<element>
  # Or set a string like "posts/post" or "shared/post_row".
  @row_partial = :auto

  # Per-model overrides:
  # {
  #   "Blog" => { row_partial: "blogs/blog", container: :drawer, insert: :append }
  # }
  @model_defaults = {}

  # How flash UI is rendered:
  # - nil / :default => built-in partial
  # - :app / :rails_default => render app partial "shared/flash"
  # - :off / :none => disable flash rendering in Turbo stream updates
  # - "path/to/partial" => custom partial
  # - Proc => called with (view_context, messages:)
  @flash_renderer = :default

  # Map incoming flash keys to UI levels.
  @flash_levels = {
    notice: :notice,
    alert: :alert,
    success: :success,
    error: :error,
    warning: :warning
  }

  # Optional auto-dismiss delay used by Stimulus controller (ms). nil disables auto-hide.
  @flash_auto_hide_ms = 4500

  # Flash placement:
  # :top_right (default), :top_center, :inline
  @flash_position = :top_right
end

Instance Attribute Details

#default_containerObject

Returns the value of attribute default_container.



19
20
21
# File 'lib/turbo_crud.rb', line 19

def default_container
  @default_container
end

#default_insertObject

Returns the value of attribute default_insert.



19
20
21
# File 'lib/turbo_crud.rb', line 19

def default_insert
  @default_insert
end

#drawer_frame_idObject

Returns the value of attribute drawer_frame_id.



19
20
21
# File 'lib/turbo_crud.rb', line 19

def drawer_frame_id
  @drawer_frame_id
end

#flash_auto_hide_msObject

Returns the value of attribute flash_auto_hide_ms.



19
20
21
# File 'lib/turbo_crud.rb', line 19

def flash_auto_hide_ms
  @flash_auto_hide_ms
end

#flash_frame_idObject

Returns the value of attribute flash_frame_id.



19
20
21
# File 'lib/turbo_crud.rb', line 19

def flash_frame_id
  @flash_frame_id
end

#flash_levelsObject

Returns the value of attribute flash_levels.



19
20
21
# File 'lib/turbo_crud.rb', line 19

def flash_levels
  @flash_levels
end

#flash_positionObject

Returns the value of attribute flash_position.



19
20
21
# File 'lib/turbo_crud.rb', line 19

def flash_position
  @flash_position
end

#flash_rendererObject

Returns the value of attribute flash_renderer.



19
20
21
# File 'lib/turbo_crud.rb', line 19

def flash_renderer
  @flash_renderer
end

Returns the value of attribute modal_frame_id.



19
20
21
# File 'lib/turbo_crud.rb', line 19

def modal_frame_id
  @modal_frame_id
end

#model_defaultsObject

Returns the value of attribute model_defaults.



19
20
21
# File 'lib/turbo_crud.rb', line 19

def model_defaults
  @model_defaults
end

#row_partialObject

Returns the value of attribute row_partial.



19
20
21
# File 'lib/turbo_crud.rb', line 19

def row_partial
  @row_partial
end