inertia_rails 3.4.0 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +17 -13
- data/lib/generators/inertia/controller/controller_generator.rb +18 -0
- data/lib/generators/inertia/controller/templates/controller.rb.tt +10 -0
- data/lib/generators/inertia/install/frameworks.yml +98 -0
- data/lib/generators/inertia/install/helpers.rb +51 -0
- data/lib/generators/inertia/install/install_generator.rb +291 -0
- data/lib/generators/inertia/install/js_package_manager.rb +50 -0
- data/lib/generators/inertia/install/templates/assets/inertia.svg +1 -0
- data/lib/generators/inertia/install/templates/assets/react.svg +1 -0
- data/lib/generators/inertia/install/templates/assets/svelte.svg +1 -0
- data/lib/generators/inertia/install/templates/assets/vite_ruby.svg +1 -0
- data/lib/generators/inertia/install/templates/assets/vue.svg +1 -0
- data/lib/generators/{inertia_rails/install → inertia/install/templates}/controller.rb +3 -1
- data/lib/generators/inertia/install/templates/dev +23 -0
- data/lib/generators/inertia/install/templates/initializer.rb +6 -0
- data/lib/generators/inertia/install/templates/react/InertiaExample.jsx +60 -0
- data/lib/generators/inertia/install/templates/react/InertiaExample.module.css +80 -0
- data/lib/generators/inertia/install/templates/react/InertiaExample.tsx +60 -0
- data/lib/generators/inertia/install/templates/react/inertia.js +45 -0
- data/lib/generators/inertia/install/templates/react/inertia.ts +51 -0
- data/lib/generators/inertia/install/templates/react/tsconfig.app.json +27 -0
- data/lib/generators/inertia/install/templates/react/tsconfig.json +11 -0
- data/lib/generators/inertia/install/templates/react/tsconfig.node.json +13 -0
- data/lib/generators/inertia/install/templates/react/vite-env.d.ts +1 -0
- data/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte +112 -0
- data/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +112 -0
- data/lib/generators/inertia/install/templates/svelte/inertia.js +44 -0
- data/lib/generators/inertia/install/templates/svelte/inertia.ts.tt +45 -0
- data/lib/generators/inertia/install/templates/svelte/svelte.config.js +7 -0
- data/lib/generators/inertia/install/templates/svelte/tsconfig.json +21 -0
- data/lib/generators/inertia/install/templates/svelte/tsconfig.node.json +12 -0
- data/lib/generators/inertia/install/templates/svelte/vite-env.d.ts +2 -0
- data/lib/generators/inertia/install/templates/svelte4/InertiaExample.svelte +116 -0
- data/lib/generators/inertia/install/templates/svelte4/InertiaExample.ts.svelte +116 -0
- data/lib/generators/inertia/install/templates/svelte4/inertia.js +43 -0
- data/lib/generators/inertia/install/templates/svelte4/inertia.ts.tt +44 -0
- data/lib/generators/inertia/install/templates/svelte4/svelte.config.js +7 -0
- data/lib/generators/inertia/install/templates/svelte4/tsconfig.json +21 -0
- data/lib/generators/inertia/install/templates/svelte4/tsconfig.node.json +12 -0
- data/lib/generators/inertia/install/templates/svelte4/vite-env.d.ts +2 -0
- data/lib/generators/inertia/install/templates/tailwind/application.css +13 -0
- data/lib/generators/inertia/install/templates/tailwind/postcss.config.js +6 -0
- data/lib/generators/inertia/install/templates/tailwind/tailwind.config.js.tt +18 -0
- data/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue +117 -0
- data/lib/generators/inertia/install/templates/vue/InertiaExample.vue +117 -0
- data/lib/generators/inertia/install/templates/vue/inertia.js +35 -0
- data/lib/generators/inertia/install/templates/vue/inertia.ts +35 -0
- data/lib/generators/inertia/install/templates/vue/tsconfig.app.json +24 -0
- data/lib/generators/inertia/install/templates/vue/tsconfig.json +11 -0
- data/lib/generators/inertia/install/templates/vue/tsconfig.node.json +22 -0
- data/lib/generators/inertia/install/templates/vue/vite-env.d.ts +1 -0
- data/lib/generators/inertia/scaffold/scaffold_generator.rb +16 -0
- data/lib/generators/inertia/scaffold_controller/scaffold_controller_generator.rb +60 -0
- data/lib/generators/inertia/scaffold_controller/templates/controller.rb.tt +100 -0
- data/lib/generators/inertia_templates/controller/controller_generator.rb +12 -0
- data/lib/generators/inertia_templates/controller/templates/react/view.jsx.tt +8 -0
- data/lib/generators/inertia_templates/controller/templates/react/view.tsx.tt +8 -0
- data/lib/generators/inertia_templates/controller/templates/svelte/view.svelte.tt +2 -0
- data/lib/generators/inertia_templates/controller/templates/svelte4/view.svelte.tt +2 -0
- data/lib/generators/inertia_templates/controller/templates/vue/view.vue.tt +4 -0
- data/lib/generators/inertia_templates/scaffold/scaffold_generator.rb +12 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Edit.jsx.tt +35 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Edit.tsx.tt +40 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt +111 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Form.tsx.tt +130 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Index.jsx.tt +26 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Index.tsx.tt +32 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/New.jsx.tt +27 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/New.tsx.tt +32 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/One.jsx.tt +26 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/One.tsx.tt +32 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Show.jsx.tt +32 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/Show.tsx.tt +38 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/types.ts.tt +19 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Edit.svelte.tt +36 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Edit.ts.svelte.tt +37 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.svelte.tt +97 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.ts.svelte.tt +102 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Index.svelte.tt +35 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Index.ts.svelte.tt +39 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/New.svelte.tt +29 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/New.ts.svelte.tt +30 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/One.svelte.tt +28 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/One.ts.svelte.tt +30 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Show.svelte.tt +35 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Show.ts.svelte.tt +39 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/types.ts.tt +19 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.svelte.tt +37 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.ts.svelte.tt +38 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.svelte.tt +96 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.ts.svelte.tt +106 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.svelte.tt +36 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.ts.svelte.tt +37 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/New.svelte.tt +30 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/New.ts.svelte.tt +31 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/One.svelte.tt +28 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/One.ts.svelte.tt +30 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.svelte.tt +39 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.ts.svelte.tt +40 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/types.ts.tt +19 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Edit.ts.vue.tt +37 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Edit.vue.tt +36 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Form.ts.vue.tt +101 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt +94 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Index.ts.vue.tt +35 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Index.vue.tt +31 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/New.ts.vue.tt +30 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/New.vue.tt +29 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/One.ts.vue.tt +28 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/One.vue.tt +26 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Show.ts.vue.tt +41 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/Show.vue.tt +37 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/types.ts.tt +19 -0
- data/lib/generators/inertia_tw_templates/controller/controller_generator.rb +12 -0
- data/lib/generators/inertia_tw_templates/controller/templates/react/view.jsx.tt +8 -0
- data/lib/generators/inertia_tw_templates/controller/templates/react/view.tsx.tt +8 -0
- data/lib/generators/inertia_tw_templates/controller/templates/svelte/view.svelte.tt +2 -0
- data/lib/generators/inertia_tw_templates/controller/templates/svelte4/view.svelte.tt +2 -0
- data/lib/generators/inertia_tw_templates/controller/templates/vue/view.vue.tt +4 -0
- data/lib/generators/inertia_tw_templates/scaffold/scaffold_generator.rb +12 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Edit.jsx.tt +42 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Edit.tsx.tt +47 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.jsx.tt +122 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.tsx.tt +142 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Index.jsx.tt +43 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Index.tsx.tt +49 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/New.jsx.tt +30 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/New.tsx.tt +35 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/One.jsx.tt +26 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/One.tsx.tt +32 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Show.jsx.tt +47 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Show.tsx.tt +53 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/types.ts.tt +19 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Edit.svelte.tt +44 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Edit.ts.svelte.tt +45 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.svelte.tt +118 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.ts.svelte.tt +123 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Index.svelte.tt +42 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Index.ts.svelte.tt +46 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/New.svelte.tt +32 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/New.ts.svelte.tt +33 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/One.svelte.tt +28 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/One.ts.svelte.tt +30 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Show.svelte.tt +50 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Show.ts.svelte.tt +54 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/types.ts.tt +19 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Edit.svelte.tt +45 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Edit.ts.svelte.tt +46 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.svelte.tt +120 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.ts.svelte.tt +130 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.svelte.tt +43 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.ts.svelte.tt +44 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/New.svelte.tt +33 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/New.ts.svelte.tt +34 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.svelte.tt +28 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.ts.svelte.tt +30 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.svelte.tt +51 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.ts.svelte.tt +52 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/types.ts.tt +19 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Edit.ts.vue.tt +45 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Edit.vue.tt +44 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Form.ts.vue.tt +134 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Form.vue.tt +127 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Index.ts.vue.tt +47 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Index.vue.tt +43 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/New.ts.vue.tt +33 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/New.vue.tt +32 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/One.ts.vue.tt +28 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/One.vue.tt +26 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Show.ts.vue.tt +53 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Show.vue.tt +49 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/types.ts.tt +19 -0
- data/lib/inertia_rails/always_prop.rb +6 -0
- data/lib/inertia_rails/base_prop.rb +14 -0
- data/lib/inertia_rails/configuration.rb +4 -1
- data/lib/inertia_rails/controller.rb +16 -4
- data/lib/inertia_rails/defer_prop.rb +21 -0
- data/lib/inertia_rails/generators/controller_template_base.rb +63 -0
- data/lib/inertia_rails/generators/helper.rb +139 -0
- data/lib/inertia_rails/generators/scaffold_template_base.rb +45 -0
- data/lib/inertia_rails/ignore_on_first_load_prop.rb +6 -0
- data/lib/inertia_rails/inertia_rails.rb +34 -12
- data/lib/inertia_rails/lazy_prop.rb +24 -0
- data/lib/inertia_rails/merge_prop.rb +14 -0
- data/lib/inertia_rails/middleware.rb +7 -2
- data/lib/inertia_rails/optional_prop.rb +6 -0
- data/lib/inertia_rails/renderer.rb +106 -20
- data/lib/inertia_rails/version.rb +1 -1
- data/lib/inertia_rails.rb +2 -0
- data/lib/patches/better_errors.rb +10 -8
- data/lib/patches/debug_exceptions/patch-5-0.rb +7 -3
- data/lib/patches/debug_exceptions/patch-5-1.rb +7 -3
- data/lib/patches/mapper.rb +9 -5
- data/lib/patches/request.rb +10 -6
- metadata +185 -13
- data/lib/generators/inertia_rails/install/react/InertiaExample.jsx +0 -9
- data/lib/generators/inertia_rails/install/react/inertia.jsx +0 -17
- data/lib/generators/inertia_rails/install/svelte/InertiaExample.svelte +0 -11
- data/lib/generators/inertia_rails/install/svelte/inertia.js +0 -14
- data/lib/generators/inertia_rails/install/vue/InertiaExample.vue +0 -11
- data/lib/generators/inertia_rails/install/vue/inertia.js +0 -20
- data/lib/generators/inertia_rails/install_generator.rb +0 -84
- data/lib/inertia_rails/lazy.rb +0 -28
@@ -0,0 +1,41 @@
|
|
1
|
+
<template>
|
2
|
+
<Head :title="`<%= human_name %> #${<%= singular_table_name %>.id}`" />
|
3
|
+
|
4
|
+
<p v-if="flash.notice" class="notice">{{ flash.notice }}</p>
|
5
|
+
|
6
|
+
<h1><%= human_name %> #{{ <%= singular_table_name %>.id }}</h1>
|
7
|
+
|
8
|
+
<<%= inertia_component_name %> :<%= singular_table_name %>="<%= singular_table_name %>" />
|
9
|
+
|
10
|
+
<div>
|
11
|
+
<Link :href="`<%= js_edit_resource_path %>`">Edit this <%= human_name.downcase %></Link> |
|
12
|
+
<Link href="<%= js_resources_path %>">Back to <%= human_name.pluralize.downcase %></Link>
|
13
|
+
|
14
|
+
<br />
|
15
|
+
|
16
|
+
<Link
|
17
|
+
:href="`<%= js_resource_path %>`"
|
18
|
+
as="button"
|
19
|
+
method="delete"
|
20
|
+
>
|
21
|
+
Destroy this <%= human_name.downcase %>
|
22
|
+
</Link>
|
23
|
+
</div>
|
24
|
+
</template>
|
25
|
+
|
26
|
+
<script setup lang="ts">
|
27
|
+
import { Head, Link } from '@inertiajs/vue3'
|
28
|
+
import <%= inertia_component_name %> from './<%= inertia_component_name %>.vue'
|
29
|
+
import { <%= inertia_model_type %> } from './types'
|
30
|
+
|
31
|
+
const { <%= singular_table_name %>, flash } = defineProps<{
|
32
|
+
<%= singular_table_name %>: <%= inertia_model_type %>
|
33
|
+
flash: { notice?: string }
|
34
|
+
}>()
|
35
|
+
</script>
|
36
|
+
|
37
|
+
<style scoped>
|
38
|
+
.notice {
|
39
|
+
color: green;
|
40
|
+
}
|
41
|
+
</style>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<template>
|
2
|
+
<Head :title="`<%= human_name %> #${<%= singular_table_name %>.id}`" />
|
3
|
+
|
4
|
+
<p v-if="flash.notice" class="notice">{{ flash.notice }}</p>
|
5
|
+
|
6
|
+
<h1><%= human_name %> #{{ <%= singular_table_name %>.id }}</h1>
|
7
|
+
|
8
|
+
<<%= inertia_component_name %> :<%= singular_table_name %>="<%= singular_table_name %>" />
|
9
|
+
|
10
|
+
<div>
|
11
|
+
<Link :href="`<%= js_edit_resource_path %>`">Edit this <%= human_name.downcase %></Link> |
|
12
|
+
<Link href="<%= js_resources_path %>">Back to <%= human_name.pluralize.downcase %></Link>
|
13
|
+
|
14
|
+
<br />
|
15
|
+
|
16
|
+
<Link
|
17
|
+
:href="`<%= js_resource_path %>`"
|
18
|
+
as="button"
|
19
|
+
method="delete"
|
20
|
+
>
|
21
|
+
Destroy this <%= human_name.downcase %>
|
22
|
+
</Link>
|
23
|
+
</div>
|
24
|
+
</template>
|
25
|
+
|
26
|
+
<script setup>
|
27
|
+
import { Head, Link } from '@inertiajs/vue3'
|
28
|
+
import <%= inertia_component_name %> from './<%= inertia_component_name %>.vue'
|
29
|
+
|
30
|
+
const { <%= singular_table_name %>, flash } = defineProps(['<%= singular_table_name %>', 'flash'])
|
31
|
+
</script>
|
32
|
+
|
33
|
+
<style scoped>
|
34
|
+
.notice {
|
35
|
+
color: green;
|
36
|
+
}
|
37
|
+
</style>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
export interface <%= inertia_model_type %> {
|
2
|
+
id: number
|
3
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
4
|
+
<%= attribute.column_name %>: <%= ts_type(attribute) %>
|
5
|
+
<% end -%>
|
6
|
+
}
|
7
|
+
|
8
|
+
export type <%= inertia_model_form_type %> = Omit<<%= inertia_model_type %>, <%= omit_input_attributes.map { |a| "'#{a}'" }.join(' | ') %>><% if custom_form_attributes.any? -%> & {
|
9
|
+
<% custom_form_attributes.map do |attribute| -%>
|
10
|
+
<% if attribute.password_digest? -%>
|
11
|
+
password: string
|
12
|
+
password_confirmation: string
|
13
|
+
<% elsif attribute.attachment? -%>
|
14
|
+
<%= attribute.column_name %>?: File
|
15
|
+
<% elsif attribute.attachments? -%>
|
16
|
+
<%= attribute.column_name %>?: File[]
|
17
|
+
<% end -%>
|
18
|
+
<% end -%>
|
19
|
+
}<% end %>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'inertia_rails/generators/controller_template_base'
|
4
|
+
|
5
|
+
module InertiaTwTemplates
|
6
|
+
module Generators
|
7
|
+
class ControllerGenerator < InertiaRails::Generators::ControllerTemplateBase
|
8
|
+
hide!
|
9
|
+
source_root File.expand_path('./templates', __dir__)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'inertia_rails/generators/scaffold_template_base'
|
4
|
+
|
5
|
+
module InertiaTwTemplates
|
6
|
+
module Generators
|
7
|
+
class ScaffoldGenerator < InertiaRails::Generators::ScaffoldTemplateBase
|
8
|
+
hide!
|
9
|
+
source_root File.expand_path('./templates', __dir__)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { Head, Link } from '@inertiajs/react'
|
2
|
+
import Form from './Form'
|
3
|
+
|
4
|
+
export default function Edit({ <%= singular_table_name %> }) {
|
5
|
+
return (
|
6
|
+
<>
|
7
|
+
<Head title="Editing <%= human_name.downcase %>" />
|
8
|
+
|
9
|
+
<div className="mx-auto md:w-2/3 w-full px-8 pt-8">
|
10
|
+
<h1 className="font-bold text-4xl">Editing <%= human_name.downcase %></h1>
|
11
|
+
|
12
|
+
<Form
|
13
|
+
<%= singular_table_name %>={<%= singular_table_name %>}
|
14
|
+
onSubmit={(form) => {
|
15
|
+
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
16
|
+
<% if attributes.any?(&:attachments?) -%>
|
17
|
+
form.post(`<%= js_resource_path %>`, {
|
18
|
+
headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
|
19
|
+
})
|
20
|
+
<% else -%>
|
21
|
+
form.patch(`<%= js_resource_path %>`)
|
22
|
+
<% end -%>
|
23
|
+
}}
|
24
|
+
submitText="Update <%= human_name %>"
|
25
|
+
/>
|
26
|
+
|
27
|
+
<Link
|
28
|
+
href={`<%= js_resource_path %>`}
|
29
|
+
className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
30
|
+
>
|
31
|
+
Show this <%= human_name.downcase %>
|
32
|
+
</Link>
|
33
|
+
<Link
|
34
|
+
href="<%= js_resources_path %>"
|
35
|
+
className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
36
|
+
>
|
37
|
+
Back to <%= human_name.pluralize.downcase %>
|
38
|
+
</Link>
|
39
|
+
</div>
|
40
|
+
</>
|
41
|
+
)
|
42
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { Head, Link } from '@inertiajs/react'
|
2
|
+
import Form from './Form'
|
3
|
+
import { <%= inertia_model_type %> } from './types'
|
4
|
+
|
5
|
+
interface EditProps {
|
6
|
+
<%= singular_table_name %>: <%= inertia_model_type %>
|
7
|
+
}
|
8
|
+
|
9
|
+
export default function Edit({ <%= singular_table_name %> }: EditProps) {
|
10
|
+
return (
|
11
|
+
<>
|
12
|
+
<Head title="Editing <%= human_name.downcase %>" />
|
13
|
+
|
14
|
+
<div className="mx-auto md:w-2/3 w-full px-8 pt-8">
|
15
|
+
<h1 className="font-bold text-4xl">Editing <%= human_name.downcase %></h1>
|
16
|
+
|
17
|
+
<Form
|
18
|
+
<%= singular_table_name %>={<%= singular_table_name %>}
|
19
|
+
onSubmit={(form) => {
|
20
|
+
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
21
|
+
<% if attributes.any?(&:attachments?) -%>
|
22
|
+
form.post(`<%= js_resource_path %>`, {
|
23
|
+
headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
|
24
|
+
})
|
25
|
+
<% else -%>
|
26
|
+
form.patch(`<%= js_resource_path %>`)
|
27
|
+
<% end -%>
|
28
|
+
}}
|
29
|
+
submitText="Update <%= human_name %>"
|
30
|
+
/>
|
31
|
+
|
32
|
+
<Link
|
33
|
+
href={`<%= js_resource_path %>`}
|
34
|
+
className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
35
|
+
>
|
36
|
+
Show this <%= human_name.downcase %>
|
37
|
+
</Link>
|
38
|
+
<Link
|
39
|
+
href="<%= js_resources_path %>"
|
40
|
+
className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
41
|
+
>
|
42
|
+
Back to <%= human_name.pluralize.downcase %>
|
43
|
+
</Link>
|
44
|
+
</div>
|
45
|
+
</>
|
46
|
+
)
|
47
|
+
}
|
@@ -0,0 +1,122 @@
|
|
1
|
+
import { useForm } from '@inertiajs/react'
|
2
|
+
|
3
|
+
export default function Form({ <%= singular_table_name %>, onSubmit, submitText }) {
|
4
|
+
const form = useForm({
|
5
|
+
<% attributes.each do |attribute| -%>
|
6
|
+
<% if attribute.password_digest? -%>
|
7
|
+
password: '',
|
8
|
+
password_confirmation: '',
|
9
|
+
<% else -%>
|
10
|
+
<%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %> || <%= default_value(attribute) %>,
|
11
|
+
<% end -%>
|
12
|
+
<% end -%>
|
13
|
+
})
|
14
|
+
const { data, setData, errors, processing } = form
|
15
|
+
|
16
|
+
const handleSubmit = (e) => {
|
17
|
+
e.preventDefault()
|
18
|
+
onSubmit(form)
|
19
|
+
}
|
20
|
+
|
21
|
+
return (
|
22
|
+
<form onSubmit={handleSubmit} className="contents">
|
23
|
+
<% attributes.each do |attribute| -%>
|
24
|
+
<div className="my-5">
|
25
|
+
<% if attribute.password_digest? -%>
|
26
|
+
<label htmlFor="password">Password</label>
|
27
|
+
<input
|
28
|
+
type="password"
|
29
|
+
name="password"
|
30
|
+
id="password"
|
31
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
32
|
+
onChange={(e) => setData('password', e.target.value)}
|
33
|
+
/>
|
34
|
+
{errors.password && (
|
35
|
+
<div className="text-red-500 px-3 py-2 font-medium">
|
36
|
+
{errors.password.join(', ')}
|
37
|
+
</div>
|
38
|
+
)}
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div className="my-5">
|
42
|
+
<label htmlFor="password_confirmation">Password confirmation</label>
|
43
|
+
<input
|
44
|
+
type="password"
|
45
|
+
name="password_confirmation"
|
46
|
+
id="password_confirmation"
|
47
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
48
|
+
onChange={(e) => setData('password_confirmation', e.target.value)}
|
49
|
+
/>
|
50
|
+
{errors.password_confirmation && (
|
51
|
+
<div className="text-red-500 px-3 py-2 font-medium">
|
52
|
+
{errors.password_confirmation.join(', ')}
|
53
|
+
</div>
|
54
|
+
)}
|
55
|
+
<% else -%>
|
56
|
+
<label htmlFor="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
57
|
+
<% if input_type(attribute) == "text_area" -%>
|
58
|
+
<textarea
|
59
|
+
name="<%= attribute.singular_name %>"
|
60
|
+
id="<%= attribute.singular_name %>"
|
61
|
+
value={data.<%= attribute.column_name %>}
|
62
|
+
rows="4"
|
63
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
64
|
+
onChange={(e) => setData('<%= attribute.column_name %>', e.target.value)}
|
65
|
+
/>
|
66
|
+
<% elsif attribute.attachment? -%>
|
67
|
+
<input
|
68
|
+
type="file"
|
69
|
+
name="<%= attribute.singular_name %>"
|
70
|
+
id="<%= attribute.singular_name %>"
|
71
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
72
|
+
onChange={(e) => setData('<%= attribute.column_name %>', e.target.files[0])}
|
73
|
+
/>
|
74
|
+
<% elsif attribute.attachments? -%>
|
75
|
+
<input
|
76
|
+
type="file"
|
77
|
+
multiple
|
78
|
+
name="<%= attribute.singular_name %>[]"
|
79
|
+
id="<%= attribute.singular_name %>"
|
80
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
81
|
+
onChange={(e) => setData('<%= attribute.column_name %>', Array.from(e.target.files))}
|
82
|
+
/>
|
83
|
+
<% elsif input_type(attribute) == "checkbox" -%>
|
84
|
+
<input
|
85
|
+
type="<%= input_type(attribute) %>"
|
86
|
+
name="<%= attribute.singular_name %>"
|
87
|
+
id="<%= attribute.singular_name %>"
|
88
|
+
checked={!!data.<%= attribute.column_name %>}
|
89
|
+
className="block mt-2 h-5 w-5"
|
90
|
+
onChange={(e) => setData('<%= attribute.column_name %>', e.target.checked)}
|
91
|
+
/>
|
92
|
+
<% else -%>
|
93
|
+
<input
|
94
|
+
type="<%= input_type(attribute) %>"
|
95
|
+
name="<%= attribute.singular_name %>"
|
96
|
+
id="<%= attribute.singular_name %>"
|
97
|
+
value={data.<%= attribute.column_name %>}
|
98
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
99
|
+
onChange={(e) => setData('<%= attribute.column_name %>', e.target.value)}
|
100
|
+
/>
|
101
|
+
<% end -%>
|
102
|
+
{errors.<%= attribute.column_name %> && (
|
103
|
+
<div className="text-red-500 px-3 py-2 font-medium">
|
104
|
+
{errors.<%= attribute.column_name %>.join(', ')}
|
105
|
+
</div>
|
106
|
+
)}
|
107
|
+
<% end -%>
|
108
|
+
</div>
|
109
|
+
|
110
|
+
<% end -%>
|
111
|
+
<div className="inline">
|
112
|
+
<button
|
113
|
+
type="submit"
|
114
|
+
disabled={processing}
|
115
|
+
className="rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer"
|
116
|
+
>
|
117
|
+
{submitText}
|
118
|
+
</button>
|
119
|
+
</div>
|
120
|
+
</form>
|
121
|
+
)
|
122
|
+
}
|
@@ -0,0 +1,142 @@
|
|
1
|
+
import { useForm <%= ', InertiaFormProps ' if inertia_js_version.release == Gem::Version.new('1.3.0') %>} from '@inertiajs/react'
|
2
|
+
import { FormEvent } from 'react'
|
3
|
+
import { <%= inertia_model_form_type %>, <%= inertia_model_type %> } from './types'
|
4
|
+
<% if inertia_js_version.release != Gem::Version.new('1.3.0') %>
|
5
|
+
// Temporary fix for InertiaFormProps not being exported from @inertiajs/react
|
6
|
+
type InertiaFormProps<TForm extends Record<string, any>> = ReturnType<typeof useForm<TForm>>
|
7
|
+
<% end %>
|
8
|
+
interface FormProps {
|
9
|
+
<%= singular_table_name %>: <%= inertia_model_type %>
|
10
|
+
onSubmit: (form: InertiaFormProps<<%= inertia_model_form_type %>>) => void
|
11
|
+
submitText: string
|
12
|
+
}
|
13
|
+
|
14
|
+
export default function Form({ <%= singular_table_name %>, onSubmit, submitText }: FormProps) {
|
15
|
+
const form = useForm<<%= inertia_model_form_type %>>({
|
16
|
+
<% attributes.reject { |a| a.attachment? || a.attachments? }.each do |attribute| -%>
|
17
|
+
<% if attribute.password_digest? -%>
|
18
|
+
password: '',
|
19
|
+
password_confirmation: '',
|
20
|
+
<% else -%>
|
21
|
+
<%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %>,
|
22
|
+
<% end -%>
|
23
|
+
<% end -%>
|
24
|
+
})
|
25
|
+
const { data, setData, errors, processing } = form
|
26
|
+
|
27
|
+
const handleSubmit = (e: FormEvent<HTMLFormElement>) => {
|
28
|
+
e.preventDefault()
|
29
|
+
onSubmit(form)
|
30
|
+
}
|
31
|
+
|
32
|
+
return (
|
33
|
+
<form onSubmit={handleSubmit} className="contents">
|
34
|
+
<% attributes.each do |attribute| -%>
|
35
|
+
<div className="my-5">
|
36
|
+
<% if attribute.password_digest? -%>
|
37
|
+
<label htmlFor="password">Password</label>
|
38
|
+
<input
|
39
|
+
type="password"
|
40
|
+
name="password"
|
41
|
+
id="password"
|
42
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
43
|
+
onChange={(e) => setData('password', e.target.value)}
|
44
|
+
/>
|
45
|
+
{errors.password && (
|
46
|
+
<div className="text-red-500 px-3 py-2 font-medium">
|
47
|
+
{errors.password}
|
48
|
+
</div>
|
49
|
+
)}
|
50
|
+
</div>
|
51
|
+
|
52
|
+
<div className="my-5">
|
53
|
+
<label htmlFor="password_confirmation">Password confirmation</label>
|
54
|
+
<input
|
55
|
+
type="password"
|
56
|
+
name="password_confirmation"
|
57
|
+
id="password_confirmation"
|
58
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
59
|
+
onChange={(e) => setData('password_confirmation', e.target.value)}
|
60
|
+
/>
|
61
|
+
{errors.password_confirmation && (
|
62
|
+
<div className="text-red-500 px-3 py-2 font-medium">
|
63
|
+
{errors.password_confirmation}
|
64
|
+
</div>
|
65
|
+
)}
|
66
|
+
<% else -%>
|
67
|
+
<label htmlFor="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
68
|
+
<% if input_type(attribute) == "text_area" -%>
|
69
|
+
<textarea
|
70
|
+
name="<%= attribute.singular_name %>"
|
71
|
+
id="<%= attribute.singular_name %>"
|
72
|
+
value={data.<%= attribute.column_name %>}
|
73
|
+
rows={4}
|
74
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
75
|
+
onChange={(e) => setData('<%= attribute.column_name %>', e.target.value)}
|
76
|
+
/>
|
77
|
+
<% elsif attribute.attachment? -%>
|
78
|
+
<input
|
79
|
+
type="file"
|
80
|
+
name="<%= attribute.singular_name %>"
|
81
|
+
id="<%= attribute.singular_name %>"
|
82
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
83
|
+
onChange={(e) => setData('<%= attribute.column_name %>', (e.target.files || [])[0])}
|
84
|
+
/>
|
85
|
+
<% elsif attribute.attachments? -%>
|
86
|
+
<input
|
87
|
+
type="file"
|
88
|
+
multiple
|
89
|
+
name="<%= attribute.singular_name %>[]"
|
90
|
+
id="<%= attribute.singular_name %>"
|
91
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
92
|
+
onChange={(e) => setData('<%= attribute.column_name %>', Array.from(e.target.files || []))}
|
93
|
+
/>
|
94
|
+
<% elsif input_type(attribute) == "checkbox" -%>
|
95
|
+
<input
|
96
|
+
type="<%= input_type(attribute) %>"
|
97
|
+
name="<%= attribute.singular_name %>"
|
98
|
+
id="<%= attribute.singular_name %>"
|
99
|
+
checked={!!data.<%= attribute.column_name %>}
|
100
|
+
className="block mt-2 h-5 w-5"
|
101
|
+
onChange={(e) => setData('<%= attribute.column_name %>', e.target.checked)}
|
102
|
+
/>
|
103
|
+
<% elsif input_type(attribute) == "number" -%>
|
104
|
+
<input
|
105
|
+
type="<%= input_type(attribute) %>"
|
106
|
+
name="<%= attribute.singular_name %>"
|
107
|
+
id="<%= attribute.singular_name %>"
|
108
|
+
value={data.<%= attribute.column_name %>}
|
109
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
110
|
+
onChange={(e) => setData('<%= attribute.column_name %>', parseInt(e.target.value))}
|
111
|
+
/>
|
112
|
+
<% else -%>
|
113
|
+
<input
|
114
|
+
type="<%= input_type(attribute) %>"
|
115
|
+
name="<%= attribute.singular_name %>"
|
116
|
+
id="<%= attribute.singular_name %>"
|
117
|
+
value={data.<%= attribute.column_name %>}
|
118
|
+
className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
119
|
+
onChange={(e) => setData('<%= attribute.column_name %>', e.target.value)}
|
120
|
+
/>
|
121
|
+
<% end -%>
|
122
|
+
{errors.<%= attribute.column_name %> && (
|
123
|
+
<div className="text-red-500 px-3 py-2 font-medium">
|
124
|
+
{errors.<%= attribute.column_name %>}
|
125
|
+
</div>
|
126
|
+
)}
|
127
|
+
<% end -%>
|
128
|
+
</div>
|
129
|
+
|
130
|
+
<% end -%>
|
131
|
+
<div className="inline">
|
132
|
+
<button
|
133
|
+
type="submit"
|
134
|
+
disabled={processing}
|
135
|
+
className="rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer"
|
136
|
+
>
|
137
|
+
{submitText}
|
138
|
+
</button>
|
139
|
+
</div>
|
140
|
+
</form>
|
141
|
+
)
|
142
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { Head, Link } from '@inertiajs/react'
|
2
|
+
import { Fragment } from 'react'
|
3
|
+
import <%= inertia_component_name %> from './<%= inertia_component_name %>'
|
4
|
+
|
5
|
+
export default function Index({ <%= plural_table_name %>, flash }) {
|
6
|
+
return (
|
7
|
+
<>
|
8
|
+
<Head title="<%= human_name.pluralize %>" />
|
9
|
+
<div className="mx-auto md:w-2/3 w-full px-8 pt-8">
|
10
|
+
{flash.notice && (
|
11
|
+
<p className="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
|
12
|
+
{flash.notice}
|
13
|
+
</p>
|
14
|
+
)}
|
15
|
+
<div className="flex justify-between items-center">
|
16
|
+
<h1 className="font-bold text-4xl"><%= human_name.pluralize %></h1>
|
17
|
+
<Link
|
18
|
+
href="<%= js_new_resource_path %>"
|
19
|
+
className="rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium"
|
20
|
+
>
|
21
|
+
New <%= human_name.downcase %>
|
22
|
+
</Link>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<div className="min-w-full">
|
26
|
+
{<%= plural_table_name %>.map((<%= singular_table_name %>) => (
|
27
|
+
<Fragment key={<%= singular_table_name %>.id}>
|
28
|
+
<<%= inertia_component_name %> <%= singular_table_name %>={<%= singular_table_name %>} />
|
29
|
+
<p>
|
30
|
+
<Link
|
31
|
+
href={`<%= js_resource_path %>`}
|
32
|
+
className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
33
|
+
>
|
34
|
+
Show this <%= human_name.downcase %>
|
35
|
+
</Link>
|
36
|
+
</p>
|
37
|
+
</Fragment>
|
38
|
+
))}
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
</>
|
42
|
+
)
|
43
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { Head, Link } from '@inertiajs/react'
|
2
|
+
import { Fragment } from 'react'
|
3
|
+
import <%= inertia_component_name %> from './<%= inertia_component_name %>'
|
4
|
+
import { <%= inertia_model_type %> } from './types'
|
5
|
+
|
6
|
+
interface IndexProps {
|
7
|
+
<%= plural_table_name %>: <%= inertia_model_type %>[]
|
8
|
+
flash: { notice?: string }
|
9
|
+
}
|
10
|
+
|
11
|
+
export default function Index({ <%= plural_table_name %>, flash }: IndexProps) {
|
12
|
+
return (
|
13
|
+
<>
|
14
|
+
<Head title="<%= human_name.pluralize %>" />
|
15
|
+
<div className="mx-auto md:w-2/3 w-full px-8 pt-8">
|
16
|
+
{flash.notice && (
|
17
|
+
<p className="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
|
18
|
+
{flash.notice}
|
19
|
+
</p>
|
20
|
+
)}
|
21
|
+
<div className="flex justify-between items-center">
|
22
|
+
<h1 className="font-bold text-4xl"><%= human_name.pluralize %></h1>
|
23
|
+
<Link
|
24
|
+
href="<%= js_new_resource_path %>"
|
25
|
+
className="rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium"
|
26
|
+
>
|
27
|
+
New <%= human_name.downcase %>
|
28
|
+
</Link>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div className="min-w-full">
|
32
|
+
{<%= plural_table_name %>.map((<%= singular_table_name %>) => (
|
33
|
+
<Fragment key={<%= singular_table_name %>.id}>
|
34
|
+
<<%= inertia_component_name %> <%= singular_table_name %>={<%= singular_table_name %>} />
|
35
|
+
<p>
|
36
|
+
<Link
|
37
|
+
href={`<%= js_resource_path %>`}
|
38
|
+
className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
39
|
+
>
|
40
|
+
Show this <%= human_name.downcase %>
|
41
|
+
</Link>
|
42
|
+
</p>
|
43
|
+
</Fragment>
|
44
|
+
))}
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</>
|
48
|
+
)
|
49
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { Head, Link } from '@inertiajs/react'
|
2
|
+
import Form from './Form'
|
3
|
+
|
4
|
+
export default function New({ <%= singular_table_name %> }) {
|
5
|
+
return (
|
6
|
+
<>
|
7
|
+
<Head title="New <%= human_name.downcase %>" />
|
8
|
+
|
9
|
+
<div className="mx-auto md:w-2/3 w-full px-8 pt-8">
|
10
|
+
<h1 className="font-bold text-4xl">New <%= human_name.downcase %></h1>
|
11
|
+
|
12
|
+
<Form
|
13
|
+
<%= singular_table_name %>={<%= singular_table_name %>}
|
14
|
+
onSubmit={(form) => {
|
15
|
+
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
16
|
+
form.post('<%= js_resources_path %>')
|
17
|
+
}}
|
18
|
+
submitText="Create <%= human_name %>"
|
19
|
+
/>
|
20
|
+
|
21
|
+
<Link
|
22
|
+
href="<%= js_resources_path %>"
|
23
|
+
className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
24
|
+
>
|
25
|
+
Back to <%= human_name.pluralize.downcase %>
|
26
|
+
</Link>
|
27
|
+
</div>
|
28
|
+
</>
|
29
|
+
)
|
30
|
+
}
|