Class: Migrations::Form

Inherits:
Components::Base
  • Object
show all
Includes:
Phlex::Rails::Helpers::FormWith, Phlex::Rails::Helpers::TurboFrameTag
Defined in:
app/components/databasium/migrations/form.rb

Instance Method Summary collapse

Constructor Details

#initialize(tables:, content:) ⇒ Form

Returns a new instance of Form.



9
10
11
12
# File 'app/components/databasium/migrations/form.rb', line 9

def initialize(tables:, content:)
  @tables = tables
  @content = content
end

Instance Method Details

#view_templateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/components/databasium/migrations/form.rb', line 14

def view_template
  form_with(
    url: helpers.migrations_path,
    method: :post,
    id: "migration_form",
    data: {
      controller: "new-migration",
      turbo_frame: "_top"
    },
    class:
      "flex flex-col gap-4 min-w-fit w-1/3 bg-panel border-1 border-border rounded-xl p-4"
  ) do |form|
    render_migration_action(form)
    render_table_name(form)
    render_columns(form)
    render_validations(form)
    render_table_datalist
    form.submit "Generate Preview",
                class: "bg-blue-500 p-2 rounded-md w-fit",
                name: "add_migration"
  end
end