Class: Schemas::HeaderActions
- Inherits:
-
Components::Base
- Object
- Components::Base
- Schemas::HeaderActions
- Includes:
- Phlex::Rails::Helpers::FormWith, Phlex::Rails::Helpers::HiddenFieldTag, Phlex::Rails::Helpers::LinkTo
- Defined in:
- app/components/databasium/schemas/header_actions.rb
Instance Attribute Summary collapse
-
#layers ⇒ Object
readonly
Returns the value of attribute layers.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
-
#initialize(model:, layers:) ⇒ HeaderActions
constructor
A new instance of HeaderActions.
- #view_template ⇒ Object
Constructor Details
#initialize(model:, layers:) ⇒ HeaderActions
Returns a new instance of HeaderActions.
11 12 13 14 |
# File 'app/components/databasium/schemas/header_actions.rb', line 11 def initialize(model:, layers:) @model = model @layers = layers end |
Instance Attribute Details
#layers ⇒ Object (readonly)
Returns the value of attribute layers.
9 10 11 |
# File 'app/components/databasium/schemas/header_actions.rb', line 9 def layers @layers end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
9 10 11 |
# File 'app/components/databasium/schemas/header_actions.rb', line 9 def model @model end |
Instance Method Details
#view_template ⇒ Object
16 17 18 19 20 21 22 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/components/databasium/schemas/header_actions.rb', line 16 def view_template div(id: "header_actions", class: "flex max-w-full gap-2 overflow-x-auto") do unless model render Components::Databasium::Navigation::IconPanel.new( icons_with_text: [ { icon: "arrow-path-rounded-square", text: "Sync Schema", method: :put, path: databasium.sync_schema_schemas_path } ] ) end if model render Components::Databasium::Navigation::IconPanel.new( icons_with_text: [ { icon: "arrow-path-rounded-square", text: "Sync Schema", method: :put, path: databasium.sync_schema_schemas_path }, { icon: "table-cells", text: "Model Schema", method: :get, turbo_frame: "records", path: model_layers_path(model, 0), active: layers == 0 }, { icon: "share", text: "Model Associations", method: :get, turbo_frame: "records", path: model_layers_path(model, 1), active: layers == 1 }, { icon: "square-2-stack", text: "Nested associations", method: :get, turbo_frame: "records", path: model_layers_path(model, 2), active: layers == 2 }, { icon: "squares-2x2", text: "All associations", method: :get, turbo_frame: "records", path: model_layers_path(model, nil), active: layers == nil } ] ) end if model form_with( method: :get, url: model_layers_path(model, layers), class: "border-l border-border pl-2 inline-flex gap-2 items-center" ) do |form| hidden_field_tag :model, model form.number_field :layers, value: layers, class: "w-10 border-1 border-border rounded-xl p-1 text-center text-sm" form.submit "Search for associations", class: "text-sm bg-accent shadow-accent rounded-xl p-1.5 text-center" end end end end |