inertia_rails 3.12.1 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/lib/generators/inertia/controller/templates/controller.rb.tt +1 -1
- data/lib/generators/inertia/install/frameworks.yml +10 -45
- data/lib/generators/inertia/install/install_generator.rb +102 -14
- data/lib/generators/inertia/install/js_package_manager.rb +6 -6
- data/lib/generators/inertia/install/templates/assets/rails.svg +9 -0
- data/lib/generators/inertia/install/templates/controller.rb +6 -3
- data/lib/generators/inertia/install/templates/inertia_controller.rb +5 -0
- data/lib/generators/inertia/install/templates/react/InertiaExample.jsx +43 -47
- data/lib/generators/inertia/install/templates/react/InertiaExample.module.css +63 -41
- data/lib/generators/inertia/install/templates/react/InertiaExample.tsx +46 -47
- data/lib/generators/inertia/install/templates/react/inertia.jsx +65 -0
- data/lib/generators/inertia/install/templates/react/inertia.tsx +65 -0
- data/lib/generators/inertia/install/templates/react/tsconfig.app.json +7 -0
- data/lib/generators/inertia/install/templates/react/types/globals.d.ts +8 -0
- data/lib/generators/inertia/install/templates/react/types/index.ts +8 -0
- data/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte +103 -69
- data/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +104 -69
- data/lib/generators/inertia/install/templates/svelte/inertia.js +14 -3
- data/lib/generators/inertia/install/templates/svelte/{inertia.ts.tt → inertia.ts} +12 -2
- data/lib/generators/inertia/install/templates/svelte/tsconfig.json +8 -0
- data/lib/generators/inertia/install/templates/svelte/types/globals.d.ts +8 -0
- data/lib/generators/inertia/install/templates/svelte/types/index.ts +8 -0
- data/lib/generators/inertia/install/templates/tailwind/application.css +3 -3
- data/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue +107 -70
- data/lib/generators/inertia/install/templates/vue/InertiaExample.vue +129 -92
- data/lib/generators/inertia/install/templates/vue/inertia.js +30 -3
- data/lib/generators/inertia/install/templates/vue/inertia.ts +31 -3
- data/lib/generators/inertia/install/templates/vue/tsconfig.app.json +9 -1
- data/lib/generators/inertia/install/templates/vue/types/globals.d.ts +8 -0
- data/lib/generators/inertia/install/templates/vue/types/index.ts +8 -0
- data/lib/generators/inertia/scaffold_controller/scaffold_controller_generator.rb +4 -0
- data/lib/generators/inertia/scaffold_controller/templates/controller.rb.tt +7 -5
- data/lib/generators/inertia_templates/scaffold/templates/react/{Edit.jsx.tt → edit.jsx.tt} +5 -8
- data/lib/generators/inertia_templates/scaffold/templates/react/{Edit.tsx.tt → edit.tsx.tt} +7 -9
- data/lib/generators/inertia_templates/scaffold/templates/react/form.jsx.tt +94 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/form.tsx.tt +109 -0
- data/lib/generators/inertia_templates/scaffold/templates/react/{Index.jsx.tt → index.jsx.tt} +1 -1
- data/lib/generators/inertia_templates/scaffold/templates/react/{Index.tsx.tt → index.tsx.tt} +1 -1
- data/lib/generators/inertia_templates/scaffold/templates/react/{New.jsx.tt → new.jsx.tt} +3 -5
- data/lib/generators/inertia_templates/scaffold/templates/react/{New.tsx.tt → new.tsx.tt} +5 -6
- data/lib/generators/inertia_templates/scaffold/templates/react/{Show.jsx.tt → show.jsx.tt} +1 -1
- data/lib/generators/inertia_templates/scaffold/templates/react/{Show.tsx.tt → show.tsx.tt} +1 -1
- data/lib/generators/inertia_templates/scaffold/templates/svelte/{Edit.svelte.tt → edit.svelte.tt} +9 -13
- data/lib/generators/inertia_templates/scaffold/templates/{svelte4/Edit.svelte.tt → svelte/edit.ts.svelte.tt} +11 -15
- data/lib/generators/inertia_templates/scaffold/templates/svelte/form.svelte.tt +96 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/form.ts.svelte.tt +103 -0
- data/lib/generators/inertia_templates/scaffold/templates/svelte/{Index.svelte.tt → index.svelte.tt} +1 -1
- data/lib/generators/inertia_templates/scaffold/templates/svelte/{Index.ts.svelte.tt → index.ts.svelte.tt} +1 -1
- data/lib/generators/inertia_templates/scaffold/templates/svelte/{New.svelte.tt → new.svelte.tt} +4 -7
- data/lib/generators/inertia_templates/scaffold/templates/{svelte4/New.svelte.tt → svelte/new.ts.svelte.tt} +6 -9
- data/lib/generators/inertia_templates/scaffold/templates/svelte/{Show.svelte.tt → show.svelte.tt} +1 -1
- data/lib/generators/inertia_templates/scaffold/templates/svelte/{Show.ts.svelte.tt → show.ts.svelte.tt} +1 -1
- data/lib/generators/inertia_templates/scaffold/templates/vue/{Edit.ts.vue.tt → edit.ts.vue.tt} +11 -15
- data/lib/generators/inertia_templates/scaffold/templates/vue/{Edit.vue.tt → edit.vue.tt} +9 -13
- data/lib/generators/inertia_templates/scaffold/templates/vue/form.ts.vue.tt +102 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/form.vue.tt +98 -0
- data/lib/generators/inertia_templates/scaffold/templates/vue/{Index.ts.vue.tt → index.ts.vue.tt} +1 -1
- data/lib/generators/inertia_templates/scaffold/templates/vue/{Index.vue.tt → index.vue.tt} +1 -1
- data/lib/generators/inertia_templates/scaffold/templates/vue/{New.ts.vue.tt → new.ts.vue.tt} +6 -9
- data/lib/generators/inertia_templates/scaffold/templates/vue/{New.vue.tt → new.vue.tt} +4 -7
- data/lib/generators/inertia_templates/scaffold/templates/vue/{Show.ts.vue.tt → show.ts.vue.tt} +1 -1
- data/lib/generators/inertia_templates/scaffold/templates/vue/{Show.vue.tt → show.vue.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Edit.jsx.tt → edit.jsx.tt} +5 -8
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Edit.tsx.tt → edit.tsx.tt} +6 -9
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/form.jsx.tt +106 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/form.tsx.tt +122 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Index.jsx.tt → index.jsx.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Index.tsx.tt → index.tsx.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/{New.jsx.tt → new.jsx.tt} +3 -5
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/{New.tsx.tt → new.tsx.tt} +4 -6
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Show.jsx.tt → show.jsx.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/{Show.tsx.tt → show.tsx.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Edit.svelte.tt → edit.svelte.tt} +9 -13
- data/lib/generators/inertia_tw_templates/scaffold/templates/{svelte4/Edit.svelte.tt → svelte/edit.ts.svelte.tt} +11 -15
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/form.svelte.tt +109 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/form.ts.svelte.tt +115 -0
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Index.svelte.tt → index.svelte.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Index.ts.svelte.tt → index.ts.svelte.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{New.svelte.tt → new.svelte.tt} +4 -7
- data/lib/generators/inertia_tw_templates/scaffold/templates/{svelte4/New.svelte.tt → svelte/new.ts.svelte.tt} +6 -9
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Show.svelte.tt → show.svelte.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{Show.ts.svelte.tt → show.ts.svelte.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Edit.ts.vue.tt → edit.ts.vue.tt} +10 -15
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Edit.vue.tt → edit.vue.tt} +8 -13
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Form.ts.vue.tt → form.ts.vue.tt} +19 -42
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Form.vue.tt → form.vue.tt} +18 -38
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Index.ts.vue.tt → index.ts.vue.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Index.vue.tt → index.vue.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{New.ts.vue.tt → new.ts.vue.tt} +6 -9
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{New.vue.tt → new.vue.tt} +4 -7
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Show.ts.vue.tt → show.ts.vue.tt} +1 -1
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Show.vue.tt → show.vue.tt} +1 -1
- data/lib/inertia_rails/generators/controller_template_base.rb +1 -1
- data/lib/inertia_rails/generators/helper.rb +2 -3
- data/lib/inertia_rails/generators/scaffold_template_base.rb +3 -3
- data/lib/inertia_rails/version.rb +1 -1
- data/lib/inertia_rails.rb +1 -0
- metadata +88 -116
- data/lib/generators/inertia/install/templates/react/inertia.js +0 -45
- data/lib/generators/inertia/install/templates/react/inertia.ts +0 -51
- data/lib/generators/inertia/install/templates/svelte4/InertiaExample.svelte +0 -116
- data/lib/generators/inertia/install/templates/svelte4/InertiaExample.ts.svelte +0 -116
- data/lib/generators/inertia/install/templates/svelte4/inertia.js +0 -43
- data/lib/generators/inertia/install/templates/svelte4/inertia.ts.tt +0 -44
- data/lib/generators/inertia/install/templates/svelte4/svelte.config.js +0 -7
- data/lib/generators/inertia/install/templates/svelte4/tsconfig.json +0 -21
- data/lib/generators/inertia/install/templates/svelte4/tsconfig.node.json +0 -12
- data/lib/generators/inertia/install/templates/svelte4/vite-env.d.ts +0 -2
- data/lib/generators/inertia_templates/controller/templates/svelte4/view.svelte.tt +0 -2
- data/lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt +0 -111
- data/lib/generators/inertia_templates/scaffold/templates/react/Form.tsx.tt +0 -130
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Edit.ts.svelte.tt +0 -37
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.svelte.tt +0 -97
- data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.ts.svelte.tt +0 -102
- data/lib/generators/inertia_templates/scaffold/templates/svelte/New.ts.svelte.tt +0 -30
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Edit.ts.svelte.tt +0 -38
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.svelte.tt +0 -96
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Form.ts.svelte.tt +0 -106
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.svelte.tt +0 -36
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Index.ts.svelte.tt +0 -37
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/New.ts.svelte.tt +0 -31
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/One.svelte.tt +0 -28
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/One.ts.svelte.tt +0 -30
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.svelte.tt +0 -39
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/Show.ts.svelte.tt +0 -40
- data/lib/generators/inertia_templates/scaffold/templates/svelte4/types.ts.tt +0 -19
- data/lib/generators/inertia_templates/scaffold/templates/vue/Form.ts.vue.tt +0 -101
- data/lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt +0 -94
- data/lib/generators/inertia_tw_templates/controller/templates/svelte4/view.svelte.tt +0 -2
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.jsx.tt +0 -122
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.tsx.tt +0 -142
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Edit.ts.svelte.tt +0 -45
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.svelte.tt +0 -118
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.ts.svelte.tt +0 -123
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/New.ts.svelte.tt +0 -33
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Edit.ts.svelte.tt +0 -46
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.svelte.tt +0 -120
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Form.ts.svelte.tt +0 -130
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.svelte.tt +0 -43
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Index.ts.svelte.tt +0 -44
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/New.ts.svelte.tt +0 -34
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.svelte.tt +0 -28
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/One.ts.svelte.tt +0 -30
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.svelte.tt +0 -51
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/Show.ts.svelte.tt +0 -52
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte4/types.ts.tt +0 -19
- /data/lib/generators/inertia/install/templates/react/{vite-env.d.ts → types/vite-env.d.ts} +0 -0
- /data/lib/generators/inertia/install/templates/svelte/{vite-env.d.ts → types/vite-env.d.ts} +0 -0
- /data/lib/generators/inertia/install/templates/vue/{vite-env.d.ts → types/vite-env.d.ts} +0 -0
- /data/lib/generators/inertia_templates/scaffold/templates/react/{One.jsx.tt → one.jsx.tt} +0 -0
- /data/lib/generators/inertia_templates/scaffold/templates/react/{One.tsx.tt → one.tsx.tt} +0 -0
- /data/lib/generators/inertia_templates/scaffold/templates/svelte/{One.svelte.tt → one.svelte.tt} +0 -0
- /data/lib/generators/inertia_templates/scaffold/templates/svelte/{One.ts.svelte.tt → one.ts.svelte.tt} +0 -0
- /data/lib/generators/inertia_templates/scaffold/templates/vue/{One.ts.vue.tt → one.ts.vue.tt} +0 -0
- /data/lib/generators/inertia_templates/scaffold/templates/vue/{One.vue.tt → one.vue.tt} +0 -0
- /data/lib/generators/inertia_tw_templates/scaffold/templates/react/{One.jsx.tt → one.jsx.tt} +0 -0
- /data/lib/generators/inertia_tw_templates/scaffold/templates/react/{One.tsx.tt → one.tsx.tt} +0 -0
- /data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{One.svelte.tt → one.svelte.tt} +0 -0
- /data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/{One.ts.svelte.tt → one.ts.svelte.tt} +0 -0
- /data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{One.ts.vue.tt → one.ts.vue.tt} +0 -0
- /data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{One.vue.tt → one.vue.tt} +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Form as InertiaForm } from '@inertiajs/react'
|
|
2
|
+
import { type ComponentProps } from 'react'
|
|
3
|
+
|
|
4
|
+
import type { <%= inertia_model_type %> } from './types'
|
|
5
|
+
|
|
6
|
+
type FormProps = Omit<ComponentProps<typeof InertiaForm>, 'children'> & {
|
|
7
|
+
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
8
|
+
submitText: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function Form({ <%= singular_table_name %>, submitText, ...formProps }: FormProps) {
|
|
12
|
+
return (
|
|
13
|
+
<InertiaForm
|
|
14
|
+
transform={data => ({ <%= singular_table_name %>: data })}
|
|
15
|
+
{...formProps}
|
|
16
|
+
>
|
|
17
|
+
{({ errors, processing }) => (
|
|
18
|
+
<>
|
|
19
|
+
<% attributes.each do |attribute| -%>
|
|
20
|
+
<% if attribute.password_digest? -%>
|
|
21
|
+
<div>
|
|
22
|
+
<label style={{ display: 'block' }} htmlFor="password">
|
|
23
|
+
Password
|
|
24
|
+
</label>
|
|
25
|
+
<input
|
|
26
|
+
type="password"
|
|
27
|
+
name="password"
|
|
28
|
+
id="password"
|
|
29
|
+
/>
|
|
30
|
+
{errors.password && (
|
|
31
|
+
<div style={{ color: 'red' }}>{errors.password.join(', ')}</div>
|
|
32
|
+
)}
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div>
|
|
36
|
+
<label style={{ display: 'block' }} htmlFor="password_confirmation">
|
|
37
|
+
Password confirmation
|
|
38
|
+
</label>
|
|
39
|
+
<input
|
|
40
|
+
type="password"
|
|
41
|
+
name="password_confirmation"
|
|
42
|
+
id="password_confirmation"
|
|
43
|
+
/>
|
|
44
|
+
{errors.password_confirmation && (
|
|
45
|
+
<div style={{ color: 'red' }}>{errors.password_confirmation.join(', ')}</div>
|
|
46
|
+
)}
|
|
47
|
+
</div>
|
|
48
|
+
<% else -%>
|
|
49
|
+
<div>
|
|
50
|
+
<label style={{ display: 'block' }} htmlFor="<%= attribute.singular_name %>">
|
|
51
|
+
<%= attribute.human_name %>
|
|
52
|
+
</label>
|
|
53
|
+
<% if input_type(attribute) == "text_area" -%>
|
|
54
|
+
<textarea
|
|
55
|
+
name="<%= attribute.singular_name %>"
|
|
56
|
+
id="<%= attribute.singular_name %>"
|
|
57
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
58
|
+
/>
|
|
59
|
+
<% elsif attribute.attachment? -%>
|
|
60
|
+
<input
|
|
61
|
+
type="file"
|
|
62
|
+
name="<%= attribute.singular_name %>"
|
|
63
|
+
id="<%= attribute.singular_name %>"
|
|
64
|
+
/>
|
|
65
|
+
<% elsif attribute.attachments? -%>
|
|
66
|
+
<input
|
|
67
|
+
type="file"
|
|
68
|
+
multiple
|
|
69
|
+
name="<%= attribute.singular_name %>[]"
|
|
70
|
+
id="<%= attribute.singular_name %>"
|
|
71
|
+
/>
|
|
72
|
+
<% elsif input_type(attribute) == "checkbox" -%>
|
|
73
|
+
<input
|
|
74
|
+
type="<%= input_type(attribute) %>"
|
|
75
|
+
name="<%= attribute.singular_name %>"
|
|
76
|
+
id="<%= attribute.singular_name %>"
|
|
77
|
+
defaultChecked={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
78
|
+
/>
|
|
79
|
+
<% elsif input_type(attribute) == "number" -%>
|
|
80
|
+
<input
|
|
81
|
+
type="<%= input_type(attribute) %>"
|
|
82
|
+
name="<%= attribute.singular_name %>"
|
|
83
|
+
id="<%= attribute.singular_name %>"
|
|
84
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
85
|
+
/>
|
|
86
|
+
<% else -%>
|
|
87
|
+
<input
|
|
88
|
+
type="<%= input_type(attribute) %>"
|
|
89
|
+
name="<%= attribute.singular_name %>"
|
|
90
|
+
id="<%= attribute.singular_name %>"
|
|
91
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
92
|
+
/>
|
|
93
|
+
<% end -%>
|
|
94
|
+
{errors.<%= attribute.column_name %> && (
|
|
95
|
+
<div style={{ color: 'red' }}>{errors.<%= attribute.column_name %>.join(', ')}</div>
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
<% end -%>
|
|
99
|
+
<% end -%>
|
|
100
|
+
<div>
|
|
101
|
+
<button type="submit" disabled={processing}>
|
|
102
|
+
{submitText}
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
</>
|
|
106
|
+
)}
|
|
107
|
+
</InertiaForm>
|
|
108
|
+
)
|
|
109
|
+
}
|
data/lib/generators/inertia_templates/scaffold/templates/react/{Index.jsx.tt → index.jsx.tt}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
import <%= inertia_component_name %> from './<%=
|
|
2
|
+
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
|
|
4
4
|
export default function Index({ <%= plural_table_name %>, flash }) {
|
|
5
5
|
return (
|
data/lib/generators/inertia_templates/scaffold/templates/react/{Index.tsx.tt → index.tsx.tt}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
import <%= inertia_component_name %> from './<%=
|
|
2
|
+
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
import { <%= inertia_model_type %> } from './types'
|
|
4
4
|
|
|
5
5
|
interface IndexProps {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
import Form from './
|
|
2
|
+
import Form from './form'
|
|
3
3
|
|
|
4
4
|
export default function New({ <%= singular_table_name %> }) {
|
|
5
5
|
return (
|
|
@@ -10,10 +10,8 @@ export default function New({ <%= singular_table_name %> }) {
|
|
|
10
10
|
|
|
11
11
|
<Form
|
|
12
12
|
<%= singular_table_name %>={<%= singular_table_name %>}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
form.post('<%= js_resources_path %>')
|
|
16
|
-
}}
|
|
13
|
+
action="<%= js_resources_path %>"
|
|
14
|
+
method="post"
|
|
17
15
|
submitText="Create <%= human_name %>"
|
|
18
16
|
/>
|
|
19
17
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
|
|
3
|
+
import Form from './form'
|
|
4
|
+
import type { <%= inertia_model_type %> } from './types'
|
|
4
5
|
|
|
5
6
|
interface NewProps {
|
|
6
7
|
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
@@ -15,10 +16,8 @@ export default function New({ <%= singular_table_name %> }: NewProps) {
|
|
|
15
16
|
|
|
16
17
|
<Form
|
|
17
18
|
<%= singular_table_name %>={<%= singular_table_name %>}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
form.post('<%= js_resources_path %>')
|
|
21
|
-
}}
|
|
19
|
+
action="<%= js_resources_path %>"
|
|
20
|
+
method="post"
|
|
22
21
|
submitText="Create <%= human_name %>"
|
|
23
22
|
/>
|
|
24
23
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
import <%= inertia_component_name %> from './<%=
|
|
2
|
+
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
|
|
4
4
|
export default function Show({ <%= singular_table_name %>, flash }) {
|
|
5
5
|
return (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
import <%= inertia_component_name %> from './<%=
|
|
2
|
+
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
import { <%= inertia_model_type %> } from './types'
|
|
4
4
|
|
|
5
5
|
interface ShowProps {
|
data/lib/generators/inertia_templates/scaffold/templates/svelte/{Edit.svelte.tt → edit.svelte.tt}
RENAMED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import Form from './Form.svelte'
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
import Form from './form.svelte'
|
|
6
5
|
|
|
7
|
-
|
|
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
|
-
}
|
|
6
|
+
let { <%= singular_table_name %> } = $props()
|
|
17
7
|
</script>
|
|
18
8
|
|
|
19
9
|
<svelte:head>
|
|
@@ -25,7 +15,13 @@
|
|
|
25
15
|
<Form
|
|
26
16
|
{<%= singular_table_name %>}
|
|
27
17
|
submitText="Update <%= human_name %>"
|
|
28
|
-
|
|
18
|
+
action={`<%= js_resource_path %>`}
|
|
19
|
+
<% if attributes.any?(&:attachments?) -%>
|
|
20
|
+
method="post"
|
|
21
|
+
headers={{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }}
|
|
22
|
+
<% else -%>
|
|
23
|
+
method="patch"
|
|
24
|
+
<% end -%>
|
|
29
25
|
/>
|
|
30
26
|
|
|
31
27
|
<br />
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import Form from './Form.svelte'
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
import type { <%= inertia_model_type %> } from './types'
|
|
5
|
+
import Form from './form.svelte'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const { form } = e.detail
|
|
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
|
-
}
|
|
7
|
+
let { <%= singular_table_name %> } = $props<{ <%= singular_table_name %>: <%= inertia_model_type %> }>()
|
|
18
8
|
</script>
|
|
19
9
|
|
|
20
10
|
<svelte:head>
|
|
@@ -26,7 +16,13 @@
|
|
|
26
16
|
<Form
|
|
27
17
|
{<%= singular_table_name %>}
|
|
28
18
|
submitText="Update <%= human_name %>"
|
|
29
|
-
|
|
19
|
+
action={`<%= js_resource_path %>`}
|
|
20
|
+
<% if attributes.any?(&:attachments?) -%>
|
|
21
|
+
method="post"
|
|
22
|
+
headers={{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }}
|
|
23
|
+
<% else -%>
|
|
24
|
+
method="patch"
|
|
25
|
+
<% end -%>
|
|
30
26
|
/>
|
|
31
27
|
|
|
32
28
|
<br />
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Form } from '@inertiajs/svelte'
|
|
3
|
+
|
|
4
|
+
let { <%= singular_table_name %>, submitText, restProps } = $props()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<Form
|
|
8
|
+
transform={(data) => ({ <%= singular_table_name %>: data })}
|
|
9
|
+
{...restProps}
|
|
10
|
+
>
|
|
11
|
+
{#snippet children({
|
|
12
|
+
errors,
|
|
13
|
+
processing,
|
|
14
|
+
})}
|
|
15
|
+
<% attributes.each do |attribute| -%>
|
|
16
|
+
<% if attribute.password_digest? -%>
|
|
17
|
+
<div>
|
|
18
|
+
<label for="password">Password</label>
|
|
19
|
+
<input
|
|
20
|
+
type="password"
|
|
21
|
+
name="password"
|
|
22
|
+
id="password"
|
|
23
|
+
/>
|
|
24
|
+
{#if errors.password}
|
|
25
|
+
<div class="error">{errors.password.join(', ')}</div>
|
|
26
|
+
{/if}
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<div>
|
|
30
|
+
<label for="password_confirmation">Password confirmation</label>
|
|
31
|
+
<input
|
|
32
|
+
type="password"
|
|
33
|
+
name="password_confirmation"
|
|
34
|
+
id="password_confirmation"
|
|
35
|
+
/>
|
|
36
|
+
{#if errors.password_confirmation}
|
|
37
|
+
<div class="error">{errors.password_confirmation.join(', ')}</div>
|
|
38
|
+
{/if}
|
|
39
|
+
</div>
|
|
40
|
+
<% else -%>
|
|
41
|
+
<div>
|
|
42
|
+
<label for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
|
43
|
+
<% if input_type(attribute) == "text_area" -%>
|
|
44
|
+
<textarea
|
|
45
|
+
name="<%= attribute.singular_name %>"
|
|
46
|
+
id="<%= attribute.singular_name %>"
|
|
47
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %> ?? ''}
|
|
48
|
+
></textarea>
|
|
49
|
+
<% elsif attribute.attachment? -%>
|
|
50
|
+
<input
|
|
51
|
+
type="file"
|
|
52
|
+
name="<%= attribute.singular_name %>"
|
|
53
|
+
id="<%= attribute.singular_name %>"
|
|
54
|
+
/>
|
|
55
|
+
<% elsif attribute.attachments? -%>
|
|
56
|
+
<input
|
|
57
|
+
type="file"
|
|
58
|
+
multiple
|
|
59
|
+
name="<%= attribute.singular_name %>[]"
|
|
60
|
+
id="<%= attribute.singular_name %>"
|
|
61
|
+
/>
|
|
62
|
+
<% elsif input_type(attribute) == "checkbox" -%>
|
|
63
|
+
<input
|
|
64
|
+
type="<%= input_type(attribute) %>"
|
|
65
|
+
name="<%= attribute.singular_name %>"
|
|
66
|
+
id="<%= attribute.singular_name %>"
|
|
67
|
+
defaultChecked={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
68
|
+
/>
|
|
69
|
+
<% else -%>
|
|
70
|
+
<input
|
|
71
|
+
type="<%= input_type(attribute) %>"
|
|
72
|
+
name="<%= attribute.singular_name %>"
|
|
73
|
+
id="<%= attribute.singular_name %>"
|
|
74
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %> ?? ''}
|
|
75
|
+
/>
|
|
76
|
+
<% end -%>
|
|
77
|
+
{#if errors.<%= attribute.column_name %>}
|
|
78
|
+
<div class="error">{errors.<%= attribute.column_name %>.join(', ')}</div>
|
|
79
|
+
{/if}
|
|
80
|
+
</div>
|
|
81
|
+
<% end -%>
|
|
82
|
+
<% end -%>
|
|
83
|
+
<div>
|
|
84
|
+
<button type="submit" disabled={processing}>{submitText}</button>
|
|
85
|
+
</div>
|
|
86
|
+
{/snippet}
|
|
87
|
+
</Form>
|
|
88
|
+
|
|
89
|
+
<style>
|
|
90
|
+
label {
|
|
91
|
+
display: block;
|
|
92
|
+
}
|
|
93
|
+
.error {
|
|
94
|
+
color: red;
|
|
95
|
+
}
|
|
96
|
+
</style>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type FormComponentSlotProps } from "@inertiajs/core"
|
|
3
|
+
import { Form } from '@inertiajs/svelte'
|
|
4
|
+
import type { ComponentProps } from 'svelte'
|
|
5
|
+
|
|
6
|
+
import type { <%= inertia_model_type %> } from './types'
|
|
7
|
+
|
|
8
|
+
let { <%= singular_table_name %>, submitText, ...restProps } = $props<{
|
|
9
|
+
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
10
|
+
submitText: string
|
|
11
|
+
} & ComponentProps<Form>>()
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<Form
|
|
15
|
+
transform={(data) => ({ <%= singular_table_name %>: data })}
|
|
16
|
+
{...restProps}
|
|
17
|
+
>
|
|
18
|
+
{#snippet children({
|
|
19
|
+
errors,
|
|
20
|
+
processing,
|
|
21
|
+
}: FormComponentSlotProps)}
|
|
22
|
+
<% attributes.each do |attribute| -%>
|
|
23
|
+
<% if attribute.password_digest? -%>
|
|
24
|
+
<div>
|
|
25
|
+
<label for="password">Password</label>
|
|
26
|
+
<input
|
|
27
|
+
type="password"
|
|
28
|
+
name="password"
|
|
29
|
+
id="password"
|
|
30
|
+
/>
|
|
31
|
+
{#if errors.password}
|
|
32
|
+
<div class="error">{errors.password.join(', ')}</div>
|
|
33
|
+
{/if}
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<div>
|
|
37
|
+
<label for="password_confirmation">Password confirmation</label>
|
|
38
|
+
<input
|
|
39
|
+
type="password"
|
|
40
|
+
name="password_confirmation"
|
|
41
|
+
id="password_confirmation"
|
|
42
|
+
/>
|
|
43
|
+
{#if errors.password_confirmation}
|
|
44
|
+
<div class="error">{errors.password_confirmation.join(', ')}</div>
|
|
45
|
+
{/if}
|
|
46
|
+
</div>
|
|
47
|
+
<% else -%>
|
|
48
|
+
<div>
|
|
49
|
+
<label for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
|
50
|
+
<% if input_type(attribute) == "text_area" -%>
|
|
51
|
+
<textarea
|
|
52
|
+
name="<%= attribute.singular_name %>"
|
|
53
|
+
id="<%= attribute.singular_name %>"
|
|
54
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %> ?? ''}
|
|
55
|
+
></textarea>
|
|
56
|
+
<% elsif attribute.attachment? -%>
|
|
57
|
+
<input
|
|
58
|
+
type="file"
|
|
59
|
+
name="<%= attribute.singular_name %>"
|
|
60
|
+
id="<%= attribute.singular_name %>"
|
|
61
|
+
/>
|
|
62
|
+
<% elsif attribute.attachments? -%>
|
|
63
|
+
<input
|
|
64
|
+
type="file"
|
|
65
|
+
multiple
|
|
66
|
+
name="<%= attribute.singular_name %>[]"
|
|
67
|
+
id="<%= attribute.singular_name %>"
|
|
68
|
+
/>
|
|
69
|
+
<% elsif input_type(attribute) == "checkbox" -%>
|
|
70
|
+
<input
|
|
71
|
+
type="<%= input_type(attribute) %>"
|
|
72
|
+
name="<%= attribute.singular_name %>"
|
|
73
|
+
id="<%= attribute.singular_name %>"
|
|
74
|
+
defaultChecked={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
75
|
+
/>
|
|
76
|
+
<% else -%>
|
|
77
|
+
<input
|
|
78
|
+
type="<%= input_type(attribute) %>"
|
|
79
|
+
name="<%= attribute.singular_name %>"
|
|
80
|
+
id="<%= attribute.singular_name %>"
|
|
81
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %> ?? ''}
|
|
82
|
+
/>
|
|
83
|
+
<% end -%>
|
|
84
|
+
{#if errors.<%= attribute.column_name %>}
|
|
85
|
+
<div class="error">{errors.<%= attribute.column_name %>.join(', ')}</div>
|
|
86
|
+
{/if}
|
|
87
|
+
</div>
|
|
88
|
+
<% end -%>
|
|
89
|
+
<% end -%>
|
|
90
|
+
<div>
|
|
91
|
+
<button type="submit" disabled={processing}>{submitText}</button>
|
|
92
|
+
</div>
|
|
93
|
+
{/snippet}
|
|
94
|
+
</Form>
|
|
95
|
+
|
|
96
|
+
<style>
|
|
97
|
+
label {
|
|
98
|
+
display: block;
|
|
99
|
+
}
|
|
100
|
+
.error {
|
|
101
|
+
color: red;
|
|
102
|
+
}
|
|
103
|
+
</style>
|
data/lib/generators/inertia_templates/scaffold/templates/svelte/{Index.svelte.tt → index.svelte.tt}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import <%= inertia_component_name %> from './<%=
|
|
3
|
+
import <%= inertia_component_name %> from './<%= singular_name %>.svelte'
|
|
4
4
|
|
|
5
5
|
let { <%= plural_table_name %>, flash } = $props()
|
|
6
6
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import <%= inertia_component_name %> from './<%=
|
|
3
|
+
import <%= inertia_component_name %> from './<%= singular_name %>.svelte'
|
|
4
4
|
import type { <%= inertia_model_type %> } from './types'
|
|
5
5
|
|
|
6
6
|
let { <%= plural_table_name %>, flash } = $props<{
|
data/lib/generators/inertia_templates/scaffold/templates/svelte/{New.svelte.tt → new.svelte.tt}
RENAMED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import Form from './Form.svelte'
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
import Form from './form.svelte'
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
|
9
|
-
form.post('<%= js_resources_path %>')
|
|
10
|
-
}
|
|
6
|
+
let { <%= singular_table_name %> } = $props()
|
|
11
7
|
</script>
|
|
12
8
|
|
|
13
9
|
<svelte:head>
|
|
@@ -19,7 +15,8 @@
|
|
|
19
15
|
<Form
|
|
20
16
|
{<%= singular_table_name %>}
|
|
21
17
|
submitText="Create <%= human_name %>"
|
|
22
|
-
|
|
18
|
+
action="<%= js_resources_path %>"
|
|
19
|
+
method="post"
|
|
23
20
|
/>
|
|
24
21
|
|
|
25
22
|
<br />
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import Form from './Form.svelte'
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
import type { <%= inertia_model_type %> } from './types'
|
|
5
|
+
import Form from './form.svelte'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const { form } = e.detail
|
|
9
|
-
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
|
10
|
-
form.post('<%= js_resources_path %>')
|
|
11
|
-
}
|
|
7
|
+
let { <%= singular_table_name %> } = $props<{ <%= singular_table_name %>: <%= inertia_model_type %> }>()
|
|
12
8
|
</script>
|
|
13
9
|
|
|
14
10
|
<svelte:head>
|
|
@@ -20,7 +16,8 @@
|
|
|
20
16
|
<Form
|
|
21
17
|
{<%= singular_table_name %>}
|
|
22
18
|
submitText="Create <%= human_name %>"
|
|
23
|
-
|
|
19
|
+
action="<%= js_resources_path %>"
|
|
20
|
+
method="post"
|
|
24
21
|
/>
|
|
25
22
|
|
|
26
23
|
<br />
|
data/lib/generators/inertia_templates/scaffold/templates/svelte/{Show.svelte.tt → show.svelte.tt}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import <%= inertia_component_name %> from './<%=
|
|
3
|
+
import <%= inertia_component_name %> from './<%= singular_name %>.svelte'
|
|
4
4
|
|
|
5
5
|
let { <%= singular_table_name %>, flash } = $props()
|
|
6
6
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import <%= inertia_component_name %> from './<%=
|
|
3
|
+
import <%= inertia_component_name %> from './<%= singular_name %>.svelte'
|
|
4
4
|
import type { <%= inertia_model_type %> } from './types'
|
|
5
5
|
|
|
6
6
|
let { <%= singular_table_name %>, flash } = $props<{
|
data/lib/generators/inertia_templates/scaffold/templates/vue/{Edit.ts.vue.tt → edit.ts.vue.tt}
RENAMED
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
<Form
|
|
7
7
|
:<%= singular_table_name %>="<%= singular_table_name %>"
|
|
8
8
|
submitText="Update <%= human_name %>"
|
|
9
|
-
|
|
9
|
+
:action="`<%= js_resource_path %>`"
|
|
10
|
+
<% if attributes.any?(&:attachments?) -%>
|
|
11
|
+
method="post"
|
|
12
|
+
:headers="{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }"
|
|
13
|
+
<% else -%>
|
|
14
|
+
method="patch"
|
|
15
|
+
<% end -%>
|
|
10
16
|
/>
|
|
11
17
|
|
|
12
18
|
<br />
|
|
@@ -18,20 +24,10 @@
|
|
|
18
24
|
</template>
|
|
19
25
|
|
|
20
26
|
<script setup lang="ts">
|
|
21
|
-
import { Head,
|
|
22
|
-
import Form from './Form.vue'
|
|
23
|
-
import { <%= inertia_model_form_type %>, <%= inertia_model_type %> } from './types'
|
|
27
|
+
import { Head, Link } from '@inertiajs/vue3'
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
import Form from './form.vue'
|
|
30
|
+
import type { <%= inertia_model_type %> } from './types'
|
|
26
31
|
|
|
27
|
-
const
|
|
28
|
-
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
|
29
|
-
<% if attributes.any?(&:attachments?) -%>
|
|
30
|
-
form.post(`<%= js_resource_path %>`, {
|
|
31
|
-
headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
|
|
32
|
-
})
|
|
33
|
-
<% else -%>
|
|
34
|
-
form.patch(`<%= js_resource_path %>`)
|
|
35
|
-
<% end -%>
|
|
36
|
-
}
|
|
32
|
+
const { <%= singular_table_name %> } = defineProps<{ <%= singular_table_name %>: <%= inertia_model_type %> }>()
|
|
37
33
|
</script>
|
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
<Form
|
|
7
7
|
:<%= singular_table_name %>="<%= singular_table_name %>"
|
|
8
8
|
submitText="Update <%= human_name %>"
|
|
9
|
-
|
|
9
|
+
:action="`<%= js_resource_path %>`"
|
|
10
|
+
<% if attributes.any?(&:attachments?) -%>
|
|
11
|
+
method="post"
|
|
12
|
+
:headers="{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }"
|
|
13
|
+
<% else -%>
|
|
14
|
+
method="patch"
|
|
15
|
+
<% end -%>
|
|
10
16
|
/>
|
|
11
17
|
|
|
12
18
|
<br />
|
|
@@ -19,18 +25,8 @@
|
|
|
19
25
|
|
|
20
26
|
<script setup>
|
|
21
27
|
import { Head, Link } from '@inertiajs/vue3'
|
|
22
|
-
import Form from './Form.vue'
|
|
23
28
|
|
|
24
|
-
|
|
29
|
+
import Form from './form.vue'
|
|
25
30
|
|
|
26
|
-
const
|
|
27
|
-
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
|
28
|
-
<% if attributes.any?(&:attachments?) -%>
|
|
29
|
-
form.post(`<%= js_resource_path %>`, {
|
|
30
|
-
headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
|
|
31
|
-
})
|
|
32
|
-
<% else -%>
|
|
33
|
-
form.patch(`<%= js_resource_path %>`)
|
|
34
|
-
<% end -%>
|
|
35
|
-
}
|
|
31
|
+
const { <%= singular_table_name %> } = defineProps(['<%= singular_table_name %>'])
|
|
36
32
|
</script>
|