inertia_rails-contrib 0.2.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -1
  3. data/README.md +12 -133
  4. data/lib/inertia_rails_contrib/version.rb +1 -1
  5. metadata +5 -112
  6. data/lib/generators/inertia/controller/controller_generator.rb +0 -16
  7. data/lib/generators/inertia/controller/templates/controller.rb.tt +0 -10
  8. data/lib/generators/inertia/install/frameworks.yml +0 -73
  9. data/lib/generators/inertia/install/helpers.rb +0 -48
  10. data/lib/generators/inertia/install/install_generator.rb +0 -282
  11. data/lib/generators/inertia/install/templates/assets/inertia.svg +0 -1
  12. data/lib/generators/inertia/install/templates/assets/react.svg +0 -1
  13. data/lib/generators/inertia/install/templates/assets/svelte.svg +0 -1
  14. data/lib/generators/inertia/install/templates/assets/vite_ruby.svg +0 -1
  15. data/lib/generators/inertia/install/templates/assets/vue.svg +0 -1
  16. data/lib/generators/inertia/install/templates/controller.rb +0 -7
  17. data/lib/generators/inertia/install/templates/dev +0 -23
  18. data/lib/generators/inertia/install/templates/initializer.rb +0 -4
  19. data/lib/generators/inertia/install/templates/react/InertiaExample.jsx +0 -60
  20. data/lib/generators/inertia/install/templates/react/InertiaExample.module.css +0 -80
  21. data/lib/generators/inertia/install/templates/react/InertiaExample.tsx +0 -60
  22. data/lib/generators/inertia/install/templates/react/inertia.js +0 -34
  23. data/lib/generators/inertia/install/templates/react/inertia.ts +0 -36
  24. data/lib/generators/inertia/install/templates/react/tsconfig.app.json +0 -27
  25. data/lib/generators/inertia/install/templates/react/tsconfig.json +0 -11
  26. data/lib/generators/inertia/install/templates/react/tsconfig.node.json +0 -13
  27. data/lib/generators/inertia/install/templates/react/vite-env.d.ts +0 -1
  28. data/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte +0 -116
  29. data/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +0 -116
  30. data/lib/generators/inertia/install/templates/svelte/inertia.js +0 -29
  31. data/lib/generators/inertia/install/templates/svelte/inertia.ts +0 -32
  32. data/lib/generators/inertia/install/templates/svelte/svelte.config.js +0 -7
  33. data/lib/generators/inertia/install/templates/svelte/tsconfig.json +0 -21
  34. data/lib/generators/inertia/install/templates/svelte/tsconfig.node.json +0 -12
  35. data/lib/generators/inertia/install/templates/svelte/vite-env.d.ts +0 -2
  36. data/lib/generators/inertia/install/templates/tailwind/application.css +0 -13
  37. data/lib/generators/inertia/install/templates/tailwind/postcss.config.js +0 -6
  38. data/lib/generators/inertia/install/templates/tailwind/tailwind.config.js.tt +0 -18
  39. data/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue +0 -117
  40. data/lib/generators/inertia/install/templates/vue/InertiaExample.vue +0 -117
  41. data/lib/generators/inertia/install/templates/vue/inertia.js +0 -33
  42. data/lib/generators/inertia/install/templates/vue/inertia.ts +0 -33
  43. data/lib/generators/inertia/install/templates/vue/tsconfig.app.json +0 -24
  44. data/lib/generators/inertia/install/templates/vue/tsconfig.json +0 -11
  45. data/lib/generators/inertia/install/templates/vue/tsconfig.node.json +0 -22
  46. data/lib/generators/inertia/install/templates/vue/vite-env.d.ts +0 -1
  47. data/lib/generators/inertia/scaffold/scaffold_generator.rb +0 -16
  48. data/lib/generators/inertia/scaffold_controller/scaffold_controller_generator.rb +0 -56
  49. data/lib/generators/inertia/scaffold_controller/templates/controller.rb.tt +0 -100
  50. data/lib/generators/inertia_templates/controller/controller_generator.rb +0 -12
  51. data/lib/generators/inertia_templates/controller/templates/react/view.jsx.tt +0 -8
  52. data/lib/generators/inertia_templates/controller/templates/svelte/view.svelte.tt +0 -2
  53. data/lib/generators/inertia_templates/controller/templates/vue/view.vue.tt +0 -4
  54. data/lib/generators/inertia_templates/scaffold/scaffold_generator.rb +0 -12
  55. data/lib/generators/inertia_templates/scaffold/templates/react/Edit.jsx.tt +0 -35
  56. data/lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt +0 -111
  57. data/lib/generators/inertia_templates/scaffold/templates/react/Index.jsx.tt +0 -26
  58. data/lib/generators/inertia_templates/scaffold/templates/react/New.jsx.tt +0 -27
  59. data/lib/generators/inertia_templates/scaffold/templates/react/One.jsx.tt +0 -26
  60. data/lib/generators/inertia_templates/scaffold/templates/react/Show.jsx.tt +0 -39
  61. data/lib/generators/inertia_templates/scaffold/templates/svelte/Edit.svelte.tt +0 -37
  62. data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.svelte.tt +0 -96
  63. data/lib/generators/inertia_templates/scaffold/templates/svelte/Index.svelte.tt +0 -42
  64. data/lib/generators/inertia_templates/scaffold/templates/svelte/New.svelte.tt +0 -30
  65. data/lib/generators/inertia_templates/scaffold/templates/svelte/One.svelte.tt +0 -28
  66. data/lib/generators/inertia_templates/scaffold/templates/svelte/Show.svelte.tt +0 -46
  67. data/lib/generators/inertia_templates/scaffold/templates/vue/Edit.vue.tt +0 -36
  68. data/lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt +0 -94
  69. data/lib/generators/inertia_templates/scaffold/templates/vue/Index.vue.tt +0 -31
  70. data/lib/generators/inertia_templates/scaffold/templates/vue/New.vue.tt +0 -29
  71. data/lib/generators/inertia_templates/scaffold/templates/vue/One.vue.tt +0 -26
  72. data/lib/generators/inertia_templates/scaffold/templates/vue/Show.vue.tt +0 -44
  73. data/lib/generators/inertia_tw_templates/controller/controller_generator.rb +0 -12
  74. data/lib/generators/inertia_tw_templates/controller/templates/react/view.jsx.tt +0 -8
  75. data/lib/generators/inertia_tw_templates/controller/templates/svelte/view.svelte.tt +0 -2
  76. data/lib/generators/inertia_tw_templates/controller/templates/vue/view.vue.tt +0 -4
  77. data/lib/generators/inertia_tw_templates/scaffold/scaffold_generator.rb +0 -12
  78. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Edit.jsx.tt +0 -42
  79. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.jsx.tt +0 -122
  80. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Index.jsx.tt +0 -43
  81. data/lib/generators/inertia_tw_templates/scaffold/templates/react/New.jsx.tt +0 -30
  82. data/lib/generators/inertia_tw_templates/scaffold/templates/react/One.jsx.tt +0 -26
  83. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Show.jsx.tt +0 -54
  84. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Edit.svelte.tt +0 -45
  85. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.svelte.tt +0 -120
  86. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Index.svelte.tt +0 -49
  87. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/New.svelte.tt +0 -33
  88. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/One.svelte.tt +0 -28
  89. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Show.svelte.tt +0 -58
  90. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Edit.vue.tt +0 -44
  91. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Form.vue.tt +0 -127
  92. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Index.vue.tt +0 -43
  93. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/New.vue.tt +0 -32
  94. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/One.vue.tt +0 -26
  95. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Show.vue.tt +0 -56
  96. data/lib/inertia_rails_contrib/generators/controller_template_base.rb +0 -56
  97. data/lib/inertia_rails_contrib/generators/scaffold_template_base.rb +0 -35
  98. data/lib/inertia_rails_contrib/generators_helper.rb +0 -88
@@ -1,127 +0,0 @@
1
- <template>
2
- <form @submit.prevent="emit('onSubmit', form)" class="contents">
3
- <% attributes.each do |attribute| -%>
4
- <% if attribute.password_digest? -%>
5
- <div class="my-5">
6
- <label for="password">Password</label>
7
- <input
8
- type="password"
9
- name="password"
10
- id="password"
11
- v-model="form.password"
12
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
13
- />
14
- <div
15
- v-if="form.errors.password"
16
- class="text-red-500 px-3 py-2 font-medium"
17
- >
18
- {{ form.errors.password.join(', ') }}
19
- </div>
20
- </div>
21
-
22
- <div class="my-5">
23
- <label for="password_confirmation">Password Confirmation</label>
24
- <input
25
- type="password"
26
- name="password_confirmation"
27
- id="password_confirmation"
28
- v-model="form.password_confirmation"
29
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
30
- />
31
- <div
32
- v-if="form.errors.password_confirmation"
33
- class="text-red-500 px-3 py-2 font-medium"
34
- >
35
- {{ form.errors.password_confirmation.join(', ') }}
36
- </div>
37
- </div>
38
- <% else -%>
39
- <div class="my-5">
40
- <label for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
41
- <% if input_type(attribute) == "text_area" -%>
42
- <textarea
43
- name="<%= attribute.singular_name %>"
44
- id="<%= attribute.singular_name %>"
45
- v-model="form.<%= attribute.column_name %>"
46
- rows="4"
47
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
48
- />
49
- <% elsif attribute.attachment? -%>
50
- <input
51
- type="file"
52
- name="<%= attribute.singular_name %>"
53
- id="<%= attribute.singular_name %>"
54
- @input="form.<%= attribute.column_name %> = $event.target.files[0]"
55
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
56
- />
57
- <% elsif attribute.attachments? -%>
58
- <input
59
- type="file"
60
- multiple="multiple"
61
- name="<%= attribute.singular_name %>[]"
62
- id="<%= attribute.singular_name %>"
63
- @input="form.<%= attribute.column_name %> = Array.from($event.target.files)"
64
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
65
- />
66
- <% elsif attribute.field_type == :check_box -%>
67
- <input
68
- type="<%= input_type(attribute) %>"
69
- name="<%= attribute.singular_name %>"
70
- id="<%= attribute.singular_name %>"
71
- v-model="form.<%= attribute.column_name %>"
72
- class="block mt-2 h-5 w-5"
73
- />
74
- <% else -%>
75
- <input
76
- type="<%= input_type(attribute) %>"
77
- name="<%= attribute.singular_name %>"
78
- id="<%= attribute.singular_name %>"
79
- v-model="form.<%= attribute.column_name %>"
80
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
81
- />
82
- <% end -%>
83
- <div v-if="form.errors.<%= attribute.column_name %>" :class="$style.error">
84
- {{ form.errors.<%= attribute.column_name %>.join(', ') }}
85
- </div>
86
- </div>
87
- <% end -%>
88
-
89
- <% end -%>
90
- <div class="inline">
91
- <button
92
- type="submit"
93
- :disabled="form.processing"
94
- class="rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer"
95
- >
96
- {{ submitText }}
97
- </button>
98
- </div>
99
- </form>
100
- </template>
101
-
102
- <script setup>
103
- import { useForm } from '@inertiajs/vue3'
104
-
105
- const { <%= singular_table_name %>, submitText } = defineProps(['<%= singular_table_name %>', 'submitText'])
106
- const emit = defineEmits(['onSubmit'])
107
-
108
- const form = useForm({
109
- <% attributes.each do |attribute| -%>
110
- <% if attribute.password_digest? -%>
111
- password: '',
112
- password_confirmation: '',
113
- <% else -%>
114
- <%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %> || <%= default_value(attribute) %>,
115
- <% end -%>
116
- <% end -%>
117
- })
118
- </script>
119
-
120
- <style module>
121
- .label {
122
- display: block;
123
- }
124
- .error {
125
- color: red;
126
- }
127
- </style>
@@ -1,43 +0,0 @@
1
- <template>
2
- <Head title="<%= human_name.pluralize %>" />
3
-
4
- <div className="mx-auto md:w-2/3 w-full px-8 pt-8">
5
- <p
6
- v-if="flash.notice"
7
- class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block"
8
- >
9
- {{ flash.notice }}
10
- </p>
11
-
12
- <div class="flex justify-between items-center">
13
- <h1 class="font-bold text-4xl"><%= human_name.pluralize %></h1>
14
- <Link
15
- href="<%= js_new_resource_path %>"
16
- class="rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium"
17
- >
18
- New <%= human_name.downcase %>
19
- </Link>
20
- </div>
21
-
22
- <div class="min-w-full">
23
- <template v-for="<%= singular_table_name %> in <%= plural_table_name %>" :key="<%= singular_table_name %>.id">
24
- <<%= inertia_component_name %> :<%= singular_table_name %>="<%= singular_table_name %>" />
25
- <p>
26
- <Link
27
- :href="`<%= js_resource_path %>`"
28
- class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
29
- >
30
- Show this <%= human_name.downcase %>
31
- </Link>
32
- </p>
33
- </template>
34
- </div>
35
- </div>
36
- </template>
37
-
38
- <script setup>
39
- import { Link, Head } from '@inertiajs/vue3'
40
- import <%= inertia_component_name %> from './<%= inertia_component_name %>.vue'
41
-
42
- const { <%= plural_table_name %>, flash } = defineProps(['<%= plural_table_name %>', 'flash'])
43
- </script>
@@ -1,32 +0,0 @@
1
- <template>
2
- <Head title="New <%= human_name.downcase %>" />
3
-
4
- <div className="mx-auto md:w-2/3 w-full px-8 pt-8">
5
- <h1 class="font-bold text-4xl">New <%= human_name.downcase %></h1>
6
-
7
- <Form
8
- :<%= singular_table_name %>="<%= singular_table_name %>"
9
- submitText="Create <%= human_name.downcase %>"
10
- @onSubmit="handleSubmit"
11
- />
12
-
13
- <Link
14
- href="<%= js_resources_path %>"
15
- class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
16
- >
17
- Back to <%= human_name.pluralize.downcase %>
18
- </Link>
19
- </div>
20
- </template>
21
-
22
- <script setup>
23
- import { Link, Head } from '@inertiajs/vue3'
24
- import Form from './Form.vue'
25
-
26
- const { <%= singular_table_name %> } = defineProps(['<%= singular_table_name %>'])
27
-
28
- const handleSubmit = (form) => {
29
- form.transform((data) => ({ <%= singular_table_name %>: data }))
30
- form.post('<%= js_resources_path %>')
31
- }
32
- </script>
@@ -1,26 +0,0 @@
1
- <template>
2
- <div>
3
- <% attributes.reject(&:password_digest?).each do |attribute| -%>
4
- <p class="my-5">
5
- <strong class="block font-medium mb-1"><%= attribute.human_name %>:</strong>
6
- <% if attribute.attachment? -%>
7
- <a v-if="<%= singular_table_name %>.<%= attribute.column_name %>" :href="<%= singular_table_name %>.<%= attribute.column_name %>.url">
8
- {{ <%= singular_table_name %>.<%= attribute.column_name %>.filename }}
9
- </a>
10
- </p>
11
- <% elsif attribute.attachments? -%>
12
- </p>
13
- <div v-for="file in <%= singular_table_name %>.<%= attribute.column_name %>">
14
- <a :href="file.url">{{ file.filename }}</a>
15
- </div>
16
- <% else -%>
17
- {{ <%= singular_table_name %>.<%= attribute.column_name %> }}
18
- </p>
19
- <% end -%>
20
- <% end -%>
21
- </div>
22
- </template>
23
-
24
- <script setup>
25
- const { <%= singular_table_name %> } = defineProps(['<%= singular_table_name %>'])
26
- </script>
@@ -1,56 +0,0 @@
1
- <template>
2
- <Head :title="`<%= human_name %> #${<%= singular_table_name %>.id}`" />
3
-
4
- <div className="mx-auto md:w-2/3 w-full px-8 pt-8">
5
- <div class="mx-auto">
6
- <p
7
- v-if="flash.notice"
8
- class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block"
9
- >
10
- {{ flash.notice }}
11
- </p>
12
-
13
- <h1 class="font-bold text-4xl"><%= human_name %> #{{ <%= singular_table_name %>.id }}</h1>
14
-
15
- <<%= inertia_component_name %> :<%= singular_table_name %>="<%= singular_table_name %>" />
16
-
17
- <Link
18
- :href="`<%= js_edit_resource_path %>`"
19
- class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
20
- >
21
- Edit this <%= human_name.downcase %>
22
- </Link>
23
- <Link
24
- href="<%= js_resources_path %>"
25
- class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
26
- >
27
- Back to <%= human_name.pluralize.downcase %>
28
- </Link>
29
-
30
- <div class="inline-block ml-2">
31
- <Link
32
- :href="`<%= js_resource_path %>`"
33
- @click="onDestroy"
34
- as="button"
35
- method="delete"
36
- class="mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium"
37
- >
38
- Destroy this <%= human_name.downcase %>
39
- </Link>
40
- </div>
41
- </div>
42
- </div>
43
- </template>
44
-
45
- <script setup>
46
- import { Link, Head } from '@inertiajs/vue3'
47
- import <%= inertia_component_name %> from './<%= inertia_component_name %>.vue'
48
-
49
- const { <%= singular_table_name %>, flash } = defineProps(['<%= singular_table_name %>', 'flash'])
50
-
51
- const onDestroy = (e) => {
52
- if (!confirm('Are you sure you want to delete this <%= human_name.downcase %>?')) {
53
- e.preventDefault()
54
- }
55
- }
56
- </script>
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/generators/named_base"
4
- require "inertia_rails_contrib/generators_helper"
5
-
6
- module InertiaRailsContrib
7
- module Generators
8
- class ControllerTemplateBase < Rails::Generators::NamedBase
9
- include GeneratorsHelper
10
- class_option :frontend_framework, required: true, desc: "Frontend framework to generate the views for.",
11
- default: GeneratorsHelper.guess_the_default_framework
12
-
13
- argument :actions, type: :array, default: [], banner: "action action"
14
-
15
- def empty_views_dir
16
- empty_directory base_path
17
- end
18
-
19
- def copy_view_files
20
- actions.each do |action|
21
- @action = action
22
- @path = File.join(base_path, "#{action.camelize}.#{extension}")
23
- template "#{options.frontend_framework}/#{template_filename}.#{extension}", @path
24
- end
25
- end
26
-
27
- private
28
-
29
- def base_path
30
- File.join(pages_path, inertia_base_path)
31
- end
32
-
33
- def template_filename
34
- "view"
35
- end
36
-
37
- def pages_path
38
- "#{root_path}/pages"
39
- end
40
-
41
- def root_path
42
- (defined?(ViteRuby) ? ViteRuby.config.source_code_dir : "app/frontend")
43
- end
44
-
45
- def extension
46
- case options.frontend_framework
47
- when "react" then "jsx"
48
- when "vue" then "vue"
49
- when "svelte" then "svelte"
50
- else
51
- raise ArgumentError, "Unknown frontend framework: #{options.frontend_framework}"
52
- end
53
- end
54
- end
55
- end
56
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/generators/resource_helpers"
4
- require_relative "controller_template_base"
5
-
6
- module InertiaRailsContrib
7
- module Generators
8
- class ScaffoldTemplateBase < ControllerTemplateBase
9
- include Rails::Generators::ResourceHelpers
10
-
11
- remove_argument :actions
12
-
13
- argument :attributes, type: :array, default: [], banner: "field:type field:type"
14
-
15
- def copy_view_files
16
- available_views.each do |view|
17
- filename = "#{view}.#{extension}"
18
- template "#{options.frontend_framework}/#{filename}", File.join(base_path, filename)
19
- end
20
-
21
- template "#{options.frontend_framework}/#{partial_name}.#{extension}", File.join(base_path, "#{inertia_component_name}.#{extension}")
22
- end
23
-
24
- private
25
-
26
- def available_views
27
- %w[Index Edit Show New Form]
28
- end
29
-
30
- def partial_name
31
- "One"
32
- end
33
- end
34
- end
35
- end
@@ -1,88 +0,0 @@
1
- module InertiaRailsContrib
2
- module GeneratorsHelper
3
- def self.guess_the_default_framework
4
- case Rails.root.join("package.json").read
5
- when /@inertiajs\/react/
6
- "react"
7
- when /@inertiajs\/svelte/
8
- "svelte"
9
- when /@inertiajs\/vue3/
10
- "vue"
11
- else
12
- say_error "Could not determine the Inertia.js framework you are using."
13
- end
14
- end
15
-
16
- def self.guess_inertia_template
17
- if Rails.root.join("tailwind.config.js").exist? || Rails.root.join("tailwind.config.ts").exist?
18
- "inertia_tw_templates"
19
- else
20
- "inertia_templates"
21
- end
22
- end
23
-
24
- def inertia_base_path
25
- (class_path + [file_name]).map(&:camelize).join("/")
26
- end
27
-
28
- def inertia_component_name
29
- singular_name.camelize
30
- end
31
-
32
- def attributes_to_serialize
33
- [:id] + attributes.reject do |attribute|
34
- attribute.password_digest? ||
35
- attribute.attachment? ||
36
- attribute.attachments?
37
- end.map(&:column_name)
38
- end
39
-
40
- def js_resource_path
41
- "#{route_url}/${#{singular_table_name}.id}"
42
- end
43
-
44
- def js_edit_resource_path
45
- "#{route_url}/${#{singular_table_name}.id}/edit"
46
- end
47
-
48
- def js_new_resource_path
49
- "#{route_url}/new"
50
- end
51
-
52
- def js_resources_path
53
- route_url
54
- end
55
-
56
- def input_type(attribute)
57
- case attribute.type
58
- when :string
59
- "text"
60
- when :text, :rich_text
61
- "text_area"
62
- when :integer
63
- "number"
64
- when :float, :decimal
65
- "number"
66
- when :datetime, :timestamp, :time
67
- "datetime-local"
68
- when :date
69
- "date"
70
- when :boolean
71
- "checkbox"
72
- when :attachments, :attachment
73
- "file"
74
- else
75
- "text"
76
- end
77
- end
78
-
79
- def default_value(attribute)
80
- case attribute.type
81
- when :boolean
82
- "false"
83
- else
84
- "''"
85
- end
86
- end
87
- end
88
- end