inertia_rails 3.12.1 → 3.13.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 +6 -0
- data/lib/generators/inertia/controller/templates/controller.rb.tt +1 -1
- data/lib/generators/inertia/install/frameworks.yml +16 -36
- data/lib/generators/inertia/install/install_generator.rb +51 -8
- data/lib/generators/inertia/install/js_package_manager.rb +6 -6
- data/lib/generators/inertia/install/templates/controller.rb +2 -4
- data/lib/generators/inertia/install/templates/inertia_controller.rb +5 -0
- data/lib/generators/inertia/install/templates/react/InertiaExample.jsx +2 -2
- data/lib/generators/inertia/install/templates/react/InertiaExample.tsx +2 -2
- 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 +1 -1
- data/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +1 -1
- 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 +1 -1
- data/lib/generators/inertia/install/templates/vue/InertiaExample.vue +1 -1
- 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 -6
- 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
- metadata +87 -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
|
@@ -1,122 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
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>
|
|
@@ -1,118 +0,0 @@
|
|
|
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>
|
|
@@ -1,123 +0,0 @@
|
|
|
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>
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
form.post('<%= js_resources_path %>')
|
|
11
|
-
}
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<svelte:head>
|
|
15
|
-
<title>New <%= human_name.downcase %></title>
|
|
16
|
-
</svelte:head>
|
|
17
|
-
|
|
18
|
-
<div class="mx-auto md:w-2/3 w-full px-8 pt-8">
|
|
19
|
-
<h1 class="font-bold text-4xl">New <%= human_name.downcase %></h1>
|
|
20
|
-
|
|
21
|
-
<Form
|
|
22
|
-
{<%= singular_table_name %>}
|
|
23
|
-
submitText="Create <%= human_name %>"
|
|
24
|
-
onSubmit={handleSubmit}
|
|
25
|
-
/>
|
|
26
|
-
|
|
27
|
-
<Link
|
|
28
|
-
href="<%= js_resources_path %>"
|
|
29
|
-
class="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>
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Link, type InertiaForm } from '@inertiajs/svelte'
|
|
3
|
-
import type { <%= inertia_model_type %>, <%= inertia_model_form_type %> } from './types'
|
|
4
|
-
import Form from './Form.svelte'
|
|
5
|
-
|
|
6
|
-
export let <%= singular_table_name %>: <%= inertia_model_type %>
|
|
7
|
-
|
|
8
|
-
const handleSubmit = (e: CustomEvent<{ form: InertiaForm<<%= inertia_model_form_type %>> }>) => {
|
|
9
|
-
const { form } = e.detail
|
|
10
|
-
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
|
11
|
-
<% if attributes.any?(&:attachments?) -%>
|
|
12
|
-
form.post(`<%= js_resource_path %>`, {
|
|
13
|
-
headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
|
|
14
|
-
})
|
|
15
|
-
<% else -%>
|
|
16
|
-
form.patch(`<%= js_resource_path %>`)
|
|
17
|
-
<% end -%>
|
|
18
|
-
}
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<svelte:head>
|
|
22
|
-
<title>Editing <%= human_name.downcase %></title>
|
|
23
|
-
</svelte:head>
|
|
24
|
-
|
|
25
|
-
<div class="mx-auto md:w-2/3 w-full px-8 pt-8">
|
|
26
|
-
<h1 class="font-bold text-4xl">Editing <%= human_name.downcase %></h1>
|
|
27
|
-
|
|
28
|
-
<Form
|
|
29
|
-
{<%= singular_table_name %>}
|
|
30
|
-
submitText="Update <%= human_name %>"
|
|
31
|
-
on:submit={handleSubmit}
|
|
32
|
-
/>
|
|
33
|
-
|
|
34
|
-
<Link
|
|
35
|
-
href={`<%= js_resource_path %>`}
|
|
36
|
-
class="mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
|
37
|
-
>
|
|
38
|
-
Show this <%= human_name.downcase %>
|
|
39
|
-
</Link>
|
|
40
|
-
<Link
|
|
41
|
-
href="<%= js_resources_path %>"
|
|
42
|
-
class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
|
|
43
|
-
>
|
|
44
|
-
Back to <%= human_name.pluralize.downcase %>
|
|
45
|
-
</Link>
|
|
46
|
-
</div>
|