inertia_rails 3.3.0 → 3.5.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 +21 -0
- data/README.md +6 -7
- 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/action_filter.rb +27 -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 +1 -1
- data/lib/inertia_rails/controller.rb +70 -15
- 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/inertia_rails.rb +18 -12
- data/lib/inertia_rails/lazy_prop.rb +20 -0
- data/lib/inertia_rails/renderer.rb +71 -17
- data/lib/inertia_rails/version.rb +1 -1
- 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 +192 -126
- data/.github/workflows/push.yml +0 -33
- data/.gitignore +0 -25
- data/.rspec +0 -3
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -7
- data/Rakefile +0 -6
- data/bin/console +0 -13
- data/bin/setup +0 -8
- data/inertia_rails.gemspec +0 -37
- 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,35 @@
|
|
1
|
+
import { Head, Link } from '@inertiajs/react'
|
2
|
+
import Form from './Form'
|
3
|
+
import { <%= inertia_model_type %> } from './types'
|
4
|
+
|
5
|
+
interface NewProps {
|
6
|
+
<%= singular_table_name %>: <%= inertia_model_type %>
|
7
|
+
}
|
8
|
+
|
9
|
+
export default function New({ <%= singular_table_name %> }: NewProps) {
|
10
|
+
return (
|
11
|
+
<>
|
12
|
+
<Head title="New <%= 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">New <%= 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
|
+
form.post('<%= js_resources_path %>')
|
22
|
+
}}
|
23
|
+
submitText="Create <%= human_name %>"
|
24
|
+
/>
|
25
|
+
|
26
|
+
<Link
|
27
|
+
href="<%= js_resources_path %>"
|
28
|
+
className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
29
|
+
>
|
30
|
+
Back to <%= human_name.pluralize.downcase %>
|
31
|
+
</Link>
|
32
|
+
</div>
|
33
|
+
</>
|
34
|
+
)
|
35
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
export default function <%= inertia_component_name %>({ <%= singular_table_name %> }) {
|
2
|
+
return (
|
3
|
+
<div>
|
4
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
5
|
+
<p className="my-5">
|
6
|
+
<strong className="block font-medium mb-1"><%= attribute.human_name %>:</strong>
|
7
|
+
<% if attribute.attachment? -%>
|
8
|
+
{<%= singular_table_name %>.<%= attribute.column_name %> && (
|
9
|
+
<a href={<%= singular_table_name %>.<%= attribute.column_name %>.url}>{<%= singular_table_name %>.<%= attribute.column_name %>.filename}</a>
|
10
|
+
)}
|
11
|
+
</p>
|
12
|
+
<% elsif attribute.attachments? -%>
|
13
|
+
</p>
|
14
|
+
{<%= singular_table_name %>.<%= attribute.column_name %>.map((file, i) => (
|
15
|
+
<div key={i}>
|
16
|
+
<a href={file.url}>{file.filename}</a>
|
17
|
+
</div>
|
18
|
+
))}
|
19
|
+
<% else -%>
|
20
|
+
{<%= singular_table_name %>.<%= attribute.column_name %>?.toString()}
|
21
|
+
</p>
|
22
|
+
<% end -%>
|
23
|
+
<% end -%>
|
24
|
+
</div>
|
25
|
+
)
|
26
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { <%= inertia_model_type %> } from './types'
|
2
|
+
|
3
|
+
interface <%= inertia_component_name %>Props {
|
4
|
+
<%= singular_table_name %>: <%= inertia_model_type %>
|
5
|
+
}
|
6
|
+
|
7
|
+
export default function <%= inertia_component_name %>({ <%= singular_table_name %> }: <%= inertia_component_name %>Props) {
|
8
|
+
return (
|
9
|
+
<div>
|
10
|
+
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
11
|
+
<p className="my-5">
|
12
|
+
<strong className="block font-medium mb-1"><%= attribute.human_name %>:</strong>
|
13
|
+
<% if attribute.attachment? -%>
|
14
|
+
{<%= singular_table_name %>.<%= attribute.column_name %> && (
|
15
|
+
<a href={<%= singular_table_name %>.<%= attribute.column_name %>.url}>{<%= singular_table_name %>.<%= attribute.column_name %>.filename}</a>
|
16
|
+
)}
|
17
|
+
</p>
|
18
|
+
<% elsif attribute.attachments? -%>
|
19
|
+
</p>
|
20
|
+
{<%= singular_table_name %>.<%= attribute.column_name %>.map((file, i) => (
|
21
|
+
<div key={i}>
|
22
|
+
<a href={file.url}>{file.filename}</a>
|
23
|
+
</div>
|
24
|
+
))}
|
25
|
+
<% else -%>
|
26
|
+
{<%= singular_table_name %>.<%= attribute.column_name %>?.toString()}
|
27
|
+
</p>
|
28
|
+
<% end -%>
|
29
|
+
<% end -%>
|
30
|
+
</div>
|
31
|
+
)
|
32
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { Head, Link } from '@inertiajs/react'
|
2
|
+
import <%= inertia_component_name %> from './<%= inertia_component_name %>'
|
3
|
+
|
4
|
+
export default function Show({ <%= singular_table_name %>, flash }) {
|
5
|
+
return (
|
6
|
+
<>
|
7
|
+
<Head title={`<%= human_name %> #${<%= singular_table_name %>.id}`} />
|
8
|
+
|
9
|
+
<div className="mx-auto md:w-2/3 w-full px-8 pt-8">
|
10
|
+
<div className="mx-auto">
|
11
|
+
{flash.notice && (
|
12
|
+
<p className="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
|
13
|
+
{flash.notice}
|
14
|
+
</p>
|
15
|
+
)}
|
16
|
+
|
17
|
+
<h1 className="font-bold text-4xl"><%= human_name %> #{<%= singular_table_name %>.id}</h1>
|
18
|
+
|
19
|
+
<<%= inertia_component_name %> <%= singular_table_name %>={<%= singular_table_name %>} />
|
20
|
+
|
21
|
+
<Link
|
22
|
+
href={`<%= js_edit_resource_path %>`}
|
23
|
+
className="mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
24
|
+
>
|
25
|
+
Edit this <%= human_name.downcase %>
|
26
|
+
</Link>
|
27
|
+
<Link
|
28
|
+
href="<%= js_resources_path %>"
|
29
|
+
className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
30
|
+
>
|
31
|
+
Back to <%= human_name.pluralize.downcase %>
|
32
|
+
</Link>
|
33
|
+
<div className="inline-block ml-2">
|
34
|
+
<Link
|
35
|
+
href={`<%= js_resource_path %>`}
|
36
|
+
as="button"
|
37
|
+
method="delete"
|
38
|
+
className="mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium"
|
39
|
+
>
|
40
|
+
Destroy this <%= human_name.downcase %>
|
41
|
+
</Link>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
</>
|
46
|
+
)
|
47
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { Head, Link } from '@inertiajs/react'
|
2
|
+
import <%= inertia_component_name %> from './<%= inertia_component_name %>'
|
3
|
+
import { <%= inertia_model_type %> } from './types'
|
4
|
+
|
5
|
+
interface ShowProps {
|
6
|
+
<%= singular_table_name %>: <%= inertia_model_type %>
|
7
|
+
flash: { notice?: string }
|
8
|
+
}
|
9
|
+
|
10
|
+
export default function Show({ <%= singular_table_name %>, flash }: ShowProps) {
|
11
|
+
return (
|
12
|
+
<>
|
13
|
+
<Head title={`<%= human_name %> #${<%= singular_table_name %>.id}`} />
|
14
|
+
|
15
|
+
<div className="mx-auto md:w-2/3 w-full px-8 pt-8">
|
16
|
+
<div className="mx-auto">
|
17
|
+
{flash.notice && (
|
18
|
+
<p className="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
|
19
|
+
{flash.notice}
|
20
|
+
</p>
|
21
|
+
)}
|
22
|
+
|
23
|
+
<h1 className="font-bold text-4xl"><%= human_name %> #{<%= singular_table_name %>.id}</h1>
|
24
|
+
|
25
|
+
<<%= inertia_component_name %> <%= singular_table_name %>={<%= singular_table_name %>} />
|
26
|
+
|
27
|
+
<Link
|
28
|
+
href={`<%= js_edit_resource_path %>`}
|
29
|
+
className="mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
30
|
+
>
|
31
|
+
Edit 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 className="inline-block ml-2">
|
40
|
+
<Link
|
41
|
+
href={`<%= js_resource_path %>`}
|
42
|
+
as="button"
|
43
|
+
method="delete"
|
44
|
+
className="mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium"
|
45
|
+
>
|
46
|
+
Destroy this <%= human_name.downcase %>
|
47
|
+
</Link>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
</div>
|
51
|
+
</>
|
52
|
+
)
|
53
|
+
}
|
@@ -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,44 @@
|
|
1
|
+
<script>
|
2
|
+
import { Link } from '@inertiajs/svelte'
|
3
|
+
import Form from './Form.svelte'
|
4
|
+
|
5
|
+
let { <%= singular_table_name %> } = $props()
|
6
|
+
|
7
|
+
const handleSubmit = ({ form }) => {
|
8
|
+
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
9
|
+
<% if attributes.any?(&:attachments?) -%>
|
10
|
+
form.post(`<%= js_resource_path %>`, {
|
11
|
+
headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
|
12
|
+
})
|
13
|
+
<% else -%>
|
14
|
+
form.patch(`<%= js_resource_path %>`)
|
15
|
+
<% end -%>
|
16
|
+
}
|
17
|
+
</script>
|
18
|
+
|
19
|
+
<svelte:head>
|
20
|
+
<title>Editing <%= human_name.downcase %></title>
|
21
|
+
</svelte:head>
|
22
|
+
|
23
|
+
<div class="mx-auto md:w-2/3 w-full px-8 pt-8">
|
24
|
+
<h1 class="font-bold text-4xl">Editing <%= human_name.downcase %></h1>
|
25
|
+
|
26
|
+
<Form
|
27
|
+
{<%= singular_table_name %>}
|
28
|
+
submitText="Update <%= human_name %>"
|
29
|
+
onSubmit={handleSubmit}
|
30
|
+
/>
|
31
|
+
|
32
|
+
<Link
|
33
|
+
href={`<%= js_resource_path %>`}
|
34
|
+
class="mt-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
|
+
class="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>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import { Link, type InertiaFormProps } from '@inertiajs/svelte'
|
3
|
+
import type { <%= inertia_model_type %>, <%= inertia_model_form_type %> } from './types'
|
4
|
+
import Form from './Form.svelte'
|
5
|
+
|
6
|
+
let { <%= singular_table_name %> } = $props<{ <%= singular_table_name %>: <%= inertia_model_type %> }>()
|
7
|
+
|
8
|
+
const handleSubmit = ({ form }: { form: InertiaFormProps<<%= inertia_model_form_type %>> }) => {
|
9
|
+
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
10
|
+
<% if attributes.any?(&:attachments?) -%>
|
11
|
+
form.post(`<%= js_resource_path %>`, {
|
12
|
+
headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
|
13
|
+
})
|
14
|
+
<% else -%>
|
15
|
+
form.patch(`<%= js_resource_path %>`)
|
16
|
+
<% end -%>
|
17
|
+
}
|
18
|
+
</script>
|
19
|
+
|
20
|
+
<svelte:head>
|
21
|
+
<title>Editing <%= human_name.downcase %></title>
|
22
|
+
</svelte:head>
|
23
|
+
|
24
|
+
<div class="mx-auto md:w-2/3 w-full px-8 pt-8">
|
25
|
+
<h1 class="font-bold text-4xl">Editing <%= human_name.downcase %></h1>
|
26
|
+
|
27
|
+
<Form
|
28
|
+
{<%= singular_table_name %>}
|
29
|
+
submitText="Update <%= human_name %>"
|
30
|
+
onSubmit={handleSubmit}
|
31
|
+
/>
|
32
|
+
|
33
|
+
<Link
|
34
|
+
href={`<%= js_resource_path %>`}
|
35
|
+
class="mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
36
|
+
>
|
37
|
+
Show this <%= human_name.downcase %>
|
38
|
+
</Link>
|
39
|
+
<Link
|
40
|
+
href="<%= js_resources_path %>"
|
41
|
+
class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
42
|
+
>
|
43
|
+
Back to <%= human_name.pluralize.downcase %>
|
44
|
+
</Link>
|
45
|
+
</div>
|
@@ -0,0 +1,118 @@
|
|
1
|
+
<script>
|
2
|
+
import { useForm } from '@inertiajs/svelte'
|
3
|
+
|
4
|
+
let { <%= singular_table_name %>, submitText, onSubmit } = $props()
|
5
|
+
|
6
|
+
const form = useForm({
|
7
|
+
<% attributes.each do |attribute| -%>
|
8
|
+
<% if attribute.password_digest? -%>
|
9
|
+
password: '',
|
10
|
+
password_confirmation: '',
|
11
|
+
<% else -%>
|
12
|
+
<%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %> || <%= default_value(attribute) %>,
|
13
|
+
<% end -%>
|
14
|
+
<% end -%>
|
15
|
+
})
|
16
|
+
|
17
|
+
const handleSubmit = (e) => {
|
18
|
+
e.preventDefault()
|
19
|
+
onSubmit({ form: $form })
|
20
|
+
}
|
21
|
+
</script>
|
22
|
+
|
23
|
+
<form class="contents" onsubmit={handleSubmit}>
|
24
|
+
<% attributes.each do |attribute| -%>
|
25
|
+
<div class="my-5">
|
26
|
+
<% if attribute.password_digest? -%>
|
27
|
+
<label for="password">Password</label>
|
28
|
+
<input
|
29
|
+
type="password"
|
30
|
+
name="password"
|
31
|
+
id="password"
|
32
|
+
bind:value={$form.password}
|
33
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
34
|
+
/>
|
35
|
+
{#if $form.errors.password}
|
36
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
37
|
+
{$form.errors.password.join(', ')}
|
38
|
+
</div>
|
39
|
+
{/if}
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<div class="my-5">
|
43
|
+
<label for="password_confirmation">Password confirmation</label>
|
44
|
+
<input
|
45
|
+
type="password"
|
46
|
+
name="password_confirmation"
|
47
|
+
id="password_confirmation"
|
48
|
+
bind:value={$form.password_confirmation}
|
49
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
50
|
+
/>
|
51
|
+
{#if $form.errors.password_confirmation}
|
52
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
53
|
+
{$form.errors.password_confirmation.join(', ')}
|
54
|
+
</div>
|
55
|
+
{/if}
|
56
|
+
<% else -%>
|
57
|
+
<label for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
58
|
+
<% if input_type(attribute) == "text_area" -%>
|
59
|
+
<textarea
|
60
|
+
name="<%= attribute.singular_name %>"
|
61
|
+
id="<%= attribute.singular_name %>"
|
62
|
+
bind:value={$form.<%= attribute.column_name %>}
|
63
|
+
rows="4"
|
64
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
65
|
+
></textarea>
|
66
|
+
<% elsif attribute.attachment? -%>
|
67
|
+
<input
|
68
|
+
type="file"
|
69
|
+
name="<%= attribute.singular_name %>"
|
70
|
+
id="<%= attribute.singular_name %>"
|
71
|
+
oninput={(e) => ($form.<%= attribute.column_name %> = e.target.files[0])}
|
72
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
73
|
+
/>
|
74
|
+
<% elsif attribute.attachments? -%>
|
75
|
+
<input
|
76
|
+
type="file"
|
77
|
+
multiple
|
78
|
+
name="<%= attribute.singular_name %>[]"
|
79
|
+
id="<%= attribute.singular_name %>"
|
80
|
+
oninput={(e) => ($form.<%= attribute.column_name %> = Array.from(e.target.files))}
|
81
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
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
|
+
bind:checked={$form.<%= attribute.column_name %>}
|
89
|
+
class="block mt-2 h-5 w-5"
|
90
|
+
/>
|
91
|
+
<% else -%>
|
92
|
+
<input
|
93
|
+
type="<%= input_type(attribute) %>"
|
94
|
+
name="<%= attribute.singular_name %>"
|
95
|
+
id="<%= attribute.singular_name %>"
|
96
|
+
bind:value={$form.<%= attribute.column_name %>}
|
97
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
98
|
+
/>
|
99
|
+
<% end -%>
|
100
|
+
{#if $form.errors.<%= attribute.column_name %>}
|
101
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
102
|
+
{$form.errors.<%= attribute.column_name %>.join(', ')}
|
103
|
+
</div>
|
104
|
+
{/if}
|
105
|
+
<% end -%>
|
106
|
+
</div>
|
107
|
+
|
108
|
+
<% end -%>
|
109
|
+
<div class="inline">
|
110
|
+
<button
|
111
|
+
type="submit"
|
112
|
+
disabled={$form.processing}
|
113
|
+
class="rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer"
|
114
|
+
>
|
115
|
+
{submitText}
|
116
|
+
</button>
|
117
|
+
</div>
|
118
|
+
</form>
|
@@ -0,0 +1,123 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import { useForm, type InertiaFormProps } from '@inertiajs/svelte'
|
3
|
+
import type { <%= inertia_model_type %>, <%= inertia_model_form_type %> } from './types'
|
4
|
+
|
5
|
+
let { <%= singular_table_name %>, submitText, onSubmit } = $props<{
|
6
|
+
<%= singular_table_name %>: <%= inertia_model_type %>
|
7
|
+
onSubmit: (props: { form: InertiaFormProps<<%= inertia_model_form_type %>> }) => void
|
8
|
+
submitText: string
|
9
|
+
}>()
|
10
|
+
|
11
|
+
const form = useForm<<%= inertia_model_form_type %>>({
|
12
|
+
<% attributes.reject { |a| a.attachment? || a.attachments? }.each do |attribute| -%>
|
13
|
+
<% if attribute.password_digest? -%>
|
14
|
+
password: '',
|
15
|
+
password_confirmation: '',
|
16
|
+
<% else -%>
|
17
|
+
<%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %> || <%= default_value(attribute) %>,
|
18
|
+
<% end -%>
|
19
|
+
<% end -%>
|
20
|
+
})
|
21
|
+
|
22
|
+
const handleSubmit = (e: SubmitEvent) => {
|
23
|
+
e.preventDefault()
|
24
|
+
onSubmit({ form: $form })
|
25
|
+
}
|
26
|
+
</script>
|
27
|
+
|
28
|
+
<form class="contents" onsubmit={handleSubmit}>
|
29
|
+
<% attributes.each do |attribute| -%>
|
30
|
+
<div class="my-5">
|
31
|
+
<% if attribute.password_digest? -%>
|
32
|
+
<label for="password">Password</label>
|
33
|
+
<input
|
34
|
+
type="password"
|
35
|
+
name="password"
|
36
|
+
id="password"
|
37
|
+
bind:value={$form.password}
|
38
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
39
|
+
/>
|
40
|
+
{#if $form.errors.password}
|
41
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
42
|
+
{$form.errors.password}
|
43
|
+
</div>
|
44
|
+
{/if}
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div class="my-5">
|
48
|
+
<label for="password_confirmation">Password confirmation</label>
|
49
|
+
<input
|
50
|
+
type="password"
|
51
|
+
name="password_confirmation"
|
52
|
+
id="password_confirmation"
|
53
|
+
bind:value={$form.password_confirmation}
|
54
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
55
|
+
/>
|
56
|
+
{#if $form.errors.password_confirmation}
|
57
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
58
|
+
{$form.errors.password_confirmation}
|
59
|
+
</div>
|
60
|
+
{/if}
|
61
|
+
<% else -%>
|
62
|
+
<label for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
63
|
+
<% if input_type(attribute) == "text_area" -%>
|
64
|
+
<textarea
|
65
|
+
name="<%= attribute.singular_name %>"
|
66
|
+
id="<%= attribute.singular_name %>"
|
67
|
+
bind:value={$form.<%= attribute.column_name %>}
|
68
|
+
rows="4"
|
69
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
70
|
+
></textarea>
|
71
|
+
<% elsif attribute.attachment? -%>
|
72
|
+
<input
|
73
|
+
type="file"
|
74
|
+
name="<%= attribute.singular_name %>"
|
75
|
+
id="<%= attribute.singular_name %>"
|
76
|
+
oninput={(e) => ($form.<%= attribute.column_name %> = ((e.target as HTMLInputElement).files || [])[0])}
|
77
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
78
|
+
/>
|
79
|
+
<% elsif attribute.attachments? -%>
|
80
|
+
<input
|
81
|
+
type="file"
|
82
|
+
multiple
|
83
|
+
name="<%= attribute.singular_name %>[]"
|
84
|
+
id="<%= attribute.singular_name %>"
|
85
|
+
oninput={(e) => ($form.<%= attribute.column_name %> = Array.from((e.target as HTMLInputElement).files || []))}
|
86
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
87
|
+
/>
|
88
|
+
<% elsif input_type(attribute) == "checkbox" -%>
|
89
|
+
<input
|
90
|
+
type="<%= input_type(attribute) %>"
|
91
|
+
name="<%= attribute.singular_name %>"
|
92
|
+
id="<%= attribute.singular_name %>"
|
93
|
+
bind:checked={$form.<%= attribute.column_name %>}
|
94
|
+
class="block mt-2 h-5 w-5"
|
95
|
+
/>
|
96
|
+
<% else -%>
|
97
|
+
<input
|
98
|
+
type="<%= input_type(attribute) %>"
|
99
|
+
name="<%= attribute.singular_name %>"
|
100
|
+
id="<%= attribute.singular_name %>"
|
101
|
+
bind:value={$form.<%= attribute.column_name %>}
|
102
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
103
|
+
/>
|
104
|
+
<% end -%>
|
105
|
+
{#if $form.errors.<%= attribute.column_name %>}
|
106
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
107
|
+
{$form.errors.<%= attribute.column_name %>}
|
108
|
+
</div>
|
109
|
+
{/if}
|
110
|
+
<% end -%>
|
111
|
+
</div>
|
112
|
+
|
113
|
+
<% end -%>
|
114
|
+
<div class="inline">
|
115
|
+
<button
|
116
|
+
type="submit"
|
117
|
+
disabled={$form.processing}
|
118
|
+
class="rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer"
|
119
|
+
>
|
120
|
+
{submitText}
|
121
|
+
</button>
|
122
|
+
</div>
|
123
|
+
</form>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<script>
|
2
|
+
import { Link } from '@inertiajs/svelte'
|
3
|
+
import <%= inertia_component_name %> from './<%= inertia_component_name %>.svelte'
|
4
|
+
|
5
|
+
let { <%= plural_table_name %>, flash } = $props()
|
6
|
+
</script>
|
7
|
+
|
8
|
+
<svelte:head>
|
9
|
+
<title><%= human_name.pluralize %></title>
|
10
|
+
</svelte:head>
|
11
|
+
|
12
|
+
<div class="mx-auto md:w-2/3 w-full px-8 pt-8">
|
13
|
+
{#if flash.notice}
|
14
|
+
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
|
15
|
+
{flash.notice}
|
16
|
+
</p>
|
17
|
+
{/if}
|
18
|
+
|
19
|
+
<div class="flex justify-between items-center">
|
20
|
+
<h1 class="font-bold text-4xl"><%= human_name.pluralize %></h1>
|
21
|
+
<Link
|
22
|
+
href="<%= js_new_resource_path %>"
|
23
|
+
class="rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium"
|
24
|
+
>
|
25
|
+
New <%= human_name.downcase %>
|
26
|
+
</Link>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div class="min-w-full">
|
30
|
+
{#each <%= plural_table_name %> as <%= singular_table_name %> (<%= singular_table_name %>.id)}
|
31
|
+
<<%= inertia_component_name %> {<%= singular_table_name %>} />
|
32
|
+
<p>
|
33
|
+
<Link
|
34
|
+
href={`<%= js_resource_path %>`}
|
35
|
+
class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
36
|
+
>
|
37
|
+
Show this <%= human_name.downcase %>
|
38
|
+
</Link>
|
39
|
+
</p>
|
40
|
+
{/each}
|
41
|
+
</div>
|
42
|
+
</div>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import { Link } from '@inertiajs/svelte'
|
3
|
+
import <%= inertia_component_name %> from './<%= inertia_component_name %>.svelte'
|
4
|
+
import type { <%= inertia_model_type %> } from './types'
|
5
|
+
|
6
|
+
let { <%= plural_table_name %>, flash } = $props<{
|
7
|
+
<%= plural_table_name %>: <%= inertia_model_type %>[]
|
8
|
+
flash: { notice?: string }
|
9
|
+
}>()
|
10
|
+
</script>
|
11
|
+
|
12
|
+
<svelte:head>
|
13
|
+
<title><%= human_name.pluralize %></title>
|
14
|
+
</svelte:head>
|
15
|
+
|
16
|
+
<div class="mx-auto md:w-2/3 w-full px-8 pt-8">
|
17
|
+
{#if flash.notice}
|
18
|
+
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
|
19
|
+
{flash.notice}
|
20
|
+
</p>
|
21
|
+
{/if}
|
22
|
+
|
23
|
+
<div class="flex justify-between items-center">
|
24
|
+
<h1 class="font-bold text-4xl"><%= human_name.pluralize %></h1>
|
25
|
+
<Link
|
26
|
+
href="<%= js_new_resource_path %>"
|
27
|
+
class="rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium"
|
28
|
+
>
|
29
|
+
New <%= human_name.downcase %>
|
30
|
+
</Link>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div class="min-w-full">
|
34
|
+
{#each <%= plural_table_name %> as <%= singular_table_name %> (<%= singular_table_name %>.id)}
|
35
|
+
<<%= inertia_component_name %> {<%= singular_table_name %>} />
|
36
|
+
<p>
|
37
|
+
<Link
|
38
|
+
href={`<%= js_resource_path %>`}
|
39
|
+
class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
40
|
+
>
|
41
|
+
Show this <%= human_name.downcase %>
|
42
|
+
</Link>
|
43
|
+
</p>
|
44
|
+
{/each}
|
45
|
+
</div>
|
46
|
+
</div>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<script>
|
2
|
+
import { Link } from '@inertiajs/svelte'
|
3
|
+
import Form from './Form.svelte'
|
4
|
+
|
5
|
+
let { <%= singular_table_name %> } = $props()
|
6
|
+
|
7
|
+
const handleSubmit = ({ form }) => {
|
8
|
+
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
9
|
+
form.post('<%= js_resources_path %>')
|
10
|
+
}
|
11
|
+
</script>
|
12
|
+
|
13
|
+
<svelte:head>
|
14
|
+
<title>New <%= human_name.downcase %></title>
|
15
|
+
</svelte:head>
|
16
|
+
|
17
|
+
<div class="mx-auto md:w-2/3 w-full px-8 pt-8">
|
18
|
+
<h1 class="font-bold text-4xl">New <%= human_name.downcase %></h1>
|
19
|
+
|
20
|
+
<Form
|
21
|
+
{<%= singular_table_name %>}
|
22
|
+
submitText="Create <%= human_name %>"
|
23
|
+
onSubmit={handleSubmit}
|
24
|
+
/>
|
25
|
+
|
26
|
+
<Link
|
27
|
+
href="<%= js_resources_path %>"
|
28
|
+
class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
29
|
+
>
|
30
|
+
Back to <%= human_name.pluralize.downcase %>
|
31
|
+
</Link>
|
32
|
+
</div>
|