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
data/lib/generators/inertia_tw_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>
|
|
@@ -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
|
<Link
|
|
@@ -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>
|
|
@@ -27,7 +17,13 @@
|
|
|
27
17
|
<Form
|
|
28
18
|
{<%= singular_table_name %>}
|
|
29
19
|
submitText="Update <%= human_name %>"
|
|
30
|
-
|
|
20
|
+
action={`<%= js_resource_path %>`}
|
|
21
|
+
<% if attributes.any?(&:attachments?) -%>
|
|
22
|
+
method="post"
|
|
23
|
+
headers={{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }}
|
|
24
|
+
<% else -%>
|
|
25
|
+
method="patch"
|
|
26
|
+
<% end -%>
|
|
31
27
|
/>
|
|
32
28
|
|
|
33
29
|
<Link
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { Form } from '@inertiajs/svelte'
|
|
3
|
+
|
|
4
|
+
let { <%= singular_table_name %>, submitText, ...restProps } = $props()
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<Form
|
|
8
|
+
class="contents"
|
|
9
|
+
transform={(data) => ({ <%= singular_table_name %>: data })}
|
|
10
|
+
{...restProps}
|
|
11
|
+
>
|
|
12
|
+
{#snippet children({
|
|
13
|
+
errors,
|
|
14
|
+
processing,
|
|
15
|
+
})}
|
|
16
|
+
<% attributes.each do |attribute| -%>
|
|
17
|
+
<% if attribute.password_digest? -%>
|
|
18
|
+
<div class="my-5">
|
|
19
|
+
<label for="password">Password</label>
|
|
20
|
+
<input
|
|
21
|
+
type="password"
|
|
22
|
+
name="password"
|
|
23
|
+
id="password"
|
|
24
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
25
|
+
/>
|
|
26
|
+
{#if errors.password}
|
|
27
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
|
28
|
+
{errors.password.join(', ')}
|
|
29
|
+
</div>
|
|
30
|
+
{/if}
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div class="my-5">
|
|
34
|
+
<label for="password_confirmation">Password confirmation</label>
|
|
35
|
+
<input
|
|
36
|
+
type="password"
|
|
37
|
+
name="password_confirmation"
|
|
38
|
+
id="password_confirmation"
|
|
39
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
40
|
+
/>
|
|
41
|
+
{#if errors.password_confirmation}
|
|
42
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
|
43
|
+
{errors.password_confirmation.join(', ')}
|
|
44
|
+
</div>
|
|
45
|
+
{/if}
|
|
46
|
+
</div>
|
|
47
|
+
<% else -%>
|
|
48
|
+
<div class="my-5">
|
|
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
|
+
rows="4"
|
|
56
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
57
|
+
></textarea>
|
|
58
|
+
<% elsif attribute.attachment? -%>
|
|
59
|
+
<input
|
|
60
|
+
type="file"
|
|
61
|
+
name="<%= attribute.singular_name %>"
|
|
62
|
+
id="<%= attribute.singular_name %>"
|
|
63
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
64
|
+
/>
|
|
65
|
+
<% elsif attribute.attachments? -%>
|
|
66
|
+
<input
|
|
67
|
+
type="file"
|
|
68
|
+
multiple
|
|
69
|
+
name="<%= attribute.singular_name %>[]"
|
|
70
|
+
id="<%= attribute.singular_name %>"
|
|
71
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
72
|
+
/>
|
|
73
|
+
<% elsif input_type(attribute) == "checkbox" -%>
|
|
74
|
+
<input
|
|
75
|
+
type="<%= input_type(attribute) %>"
|
|
76
|
+
name="<%= attribute.singular_name %>"
|
|
77
|
+
id="<%= attribute.singular_name %>"
|
|
78
|
+
defaultChecked={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
79
|
+
class="block mt-2 h-5 w-5"
|
|
80
|
+
/>
|
|
81
|
+
<% else -%>
|
|
82
|
+
<input
|
|
83
|
+
type="<%= input_type(attribute) %>"
|
|
84
|
+
name="<%= attribute.singular_name %>"
|
|
85
|
+
id="<%= attribute.singular_name %>"
|
|
86
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %> ?? ''}
|
|
87
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
88
|
+
/>
|
|
89
|
+
<% end -%>
|
|
90
|
+
{#if errors.<%= attribute.column_name %>}
|
|
91
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
|
92
|
+
{errors.<%= attribute.column_name %>.join(', ')}
|
|
93
|
+
</div>
|
|
94
|
+
{/if}
|
|
95
|
+
</div>
|
|
96
|
+
<% end -%>
|
|
97
|
+
|
|
98
|
+
<% end -%>
|
|
99
|
+
<div class="inline">
|
|
100
|
+
<button
|
|
101
|
+
type="submit"
|
|
102
|
+
disabled={processing}
|
|
103
|
+
class="rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer"
|
|
104
|
+
>
|
|
105
|
+
{submitText}
|
|
106
|
+
</button>
|
|
107
|
+
</div>
|
|
108
|
+
{/snippet}
|
|
109
|
+
</Form>
|
|
@@ -0,0 +1,115 @@
|
|
|
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 class="my-5">
|
|
25
|
+
<label for="password">Password</label>
|
|
26
|
+
<input
|
|
27
|
+
type="password"
|
|
28
|
+
name="password"
|
|
29
|
+
id="password"
|
|
30
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
31
|
+
/>
|
|
32
|
+
{#if errors.password}
|
|
33
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
|
34
|
+
{errors.password.join(', ')}
|
|
35
|
+
</div>
|
|
36
|
+
{/if}
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div class="my-5">
|
|
40
|
+
<label for="password_confirmation">Password confirmation</label>
|
|
41
|
+
<input
|
|
42
|
+
type="password"
|
|
43
|
+
name="password_confirmation"
|
|
44
|
+
id="password_confirmation"
|
|
45
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
46
|
+
/>
|
|
47
|
+
{#if errors.password_confirmation}
|
|
48
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
|
49
|
+
{errors.password_confirmation.join(', ')}
|
|
50
|
+
</div>
|
|
51
|
+
{/if}
|
|
52
|
+
</div>
|
|
53
|
+
<% else -%>
|
|
54
|
+
<div class="my-5">
|
|
55
|
+
<label for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
|
56
|
+
<% if input_type(attribute) == "text_area" -%>
|
|
57
|
+
<textarea
|
|
58
|
+
name="<%= attribute.singular_name %>"
|
|
59
|
+
id="<%= attribute.singular_name %>"
|
|
60
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %> ?? ''}
|
|
61
|
+
rows="4"
|
|
62
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
63
|
+
></textarea>
|
|
64
|
+
<% elsif attribute.attachment? -%>
|
|
65
|
+
<input
|
|
66
|
+
type="file"
|
|
67
|
+
name="<%= attribute.singular_name %>"
|
|
68
|
+
id="<%= attribute.singular_name %>"
|
|
69
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
70
|
+
/>
|
|
71
|
+
<% elsif attribute.attachments? -%>
|
|
72
|
+
<input
|
|
73
|
+
type="file"
|
|
74
|
+
multiple
|
|
75
|
+
name="<%= attribute.singular_name %>[]"
|
|
76
|
+
id="<%= attribute.singular_name %>"
|
|
77
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
78
|
+
/>
|
|
79
|
+
<% elsif input_type(attribute) == "checkbox" -%>
|
|
80
|
+
<input
|
|
81
|
+
type="<%= input_type(attribute) %>"
|
|
82
|
+
name="<%= attribute.singular_name %>"
|
|
83
|
+
id="<%= attribute.singular_name %>"
|
|
84
|
+
defaultChecked={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
85
|
+
class="block mt-2 h-5 w-5"
|
|
86
|
+
/>
|
|
87
|
+
<% else -%>
|
|
88
|
+
<input
|
|
89
|
+
type="<%= input_type(attribute) %>"
|
|
90
|
+
name="<%= attribute.singular_name %>"
|
|
91
|
+
id="<%= attribute.singular_name %>"
|
|
92
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %> ?? ''}
|
|
93
|
+
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
94
|
+
/>
|
|
95
|
+
<% end -%>
|
|
96
|
+
{#if errors.<%= attribute.column_name %>}
|
|
97
|
+
<div class="text-red-500 px-3 py-2 font-medium">
|
|
98
|
+
{errors.<%= attribute.column_name %>.join(', ')}
|
|
99
|
+
</div>
|
|
100
|
+
{/if}
|
|
101
|
+
</div>
|
|
102
|
+
<% end -%>
|
|
103
|
+
|
|
104
|
+
<% end -%>
|
|
105
|
+
<div class="inline">
|
|
106
|
+
<button
|
|
107
|
+
type="submit"
|
|
108
|
+
disabled={processing}
|
|
109
|
+
class="rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer"
|
|
110
|
+
>
|
|
111
|
+
{submitText}
|
|
112
|
+
</button>
|
|
113
|
+
</div>
|
|
114
|
+
{/snippet}
|
|
115
|
+
</Form>
|
|
@@ -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_tw_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>
|
|
@@ -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
|
<Link
|
|
@@ -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>
|
|
@@ -21,7 +17,8 @@
|
|
|
21
17
|
<Form
|
|
22
18
|
{<%= singular_table_name %>}
|
|
23
19
|
submitText="Create <%= human_name %>"
|
|
24
|
-
|
|
20
|
+
action="<%= js_resources_path %>"
|
|
21
|
+
method="post"
|
|
25
22
|
/>
|
|
26
23
|
|
|
27
24
|
<Link
|
data/lib/generators/inertia_tw_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_tw_templates/scaffold/templates/vue/{Edit.ts.vue.tt → edit.ts.vue.tt}
RENAMED
|
@@ -7,7 +7,13 @@
|
|
|
7
7
|
<Form
|
|
8
8
|
:<%= singular_table_name %>="<%= singular_table_name %>"
|
|
9
9
|
submitText="Update <%= human_name %>"
|
|
10
|
-
|
|
10
|
+
:action="`<%= js_resource_path %>`"
|
|
11
|
+
<% if attributes.any?(&:attachments?) -%>
|
|
12
|
+
method="post"
|
|
13
|
+
:headers="{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }"
|
|
14
|
+
<% else -%>
|
|
15
|
+
method="patch"
|
|
16
|
+
<% end -%>
|
|
11
17
|
/>
|
|
12
18
|
|
|
13
19
|
<Link
|
|
@@ -26,20 +32,9 @@
|
|
|
26
32
|
</template>
|
|
27
33
|
|
|
28
34
|
<script setup lang="ts">
|
|
29
|
-
import { Head,
|
|
30
|
-
import Form from './
|
|
31
|
-
import { <%=
|
|
35
|
+
import { Head, Link } from '@inertiajs/vue3'
|
|
36
|
+
import Form from './form.vue'
|
|
37
|
+
import type { <%= inertia_model_type %> } from './types'
|
|
32
38
|
|
|
33
39
|
const { <%= singular_table_name %> } = defineProps<{ <%= singular_table_name %>: <%= inertia_model_type %> }>()
|
|
34
|
-
|
|
35
|
-
const handleSubmit = (form: InertiaForm<<%= inertia_model_form_type %>>) => {
|
|
36
|
-
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
|
37
|
-
<% if attributes.any?(&:attachments?) -%>
|
|
38
|
-
form.post(`<%= js_resource_path %>`, {
|
|
39
|
-
headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
|
|
40
|
-
})
|
|
41
|
-
<% else -%>
|
|
42
|
-
form.patch(`<%= js_resource_path %>`)
|
|
43
|
-
<% end -%>
|
|
44
|
-
}
|
|
45
40
|
</script>
|
|
@@ -7,7 +7,13 @@
|
|
|
7
7
|
<Form
|
|
8
8
|
:<%= singular_table_name %>="<%= singular_table_name %>"
|
|
9
9
|
submitText="Update <%= human_name %>"
|
|
10
|
-
|
|
10
|
+
:action="`<%= js_resource_path %>`"
|
|
11
|
+
<% if attributes.any?(&:attachments?) -%>
|
|
12
|
+
method="post"
|
|
13
|
+
:headers="{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }"
|
|
14
|
+
<% else -%>
|
|
15
|
+
method="patch"
|
|
16
|
+
<% end -%>
|
|
11
17
|
/>
|
|
12
18
|
|
|
13
19
|
<Link
|
|
@@ -27,18 +33,7 @@
|
|
|
27
33
|
|
|
28
34
|
<script setup>
|
|
29
35
|
import { Head, Link } from '@inertiajs/vue3'
|
|
30
|
-
import Form from './
|
|
36
|
+
import Form from './form.vue'
|
|
31
37
|
|
|
32
38
|
const { <%= singular_table_name %> } = defineProps(['<%= singular_table_name %>'])
|
|
33
|
-
|
|
34
|
-
const handleSubmit = (form) => {
|
|
35
|
-
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
|
36
|
-
<% if attributes.any?(&:attachments?) -%>
|
|
37
|
-
form.post(`<%= js_resource_path %>`, {
|
|
38
|
-
headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
|
|
39
|
-
})
|
|
40
|
-
<% else -%>
|
|
41
|
-
form.patch(`<%= js_resource_path %>`)
|
|
42
|
-
<% end -%>
|
|
43
|
-
}
|
|
44
39
|
</script>
|
data/lib/generators/inertia_tw_templates/scaffold/templates/vue/{Form.ts.vue.tt → form.ts.vue.tt}
RENAMED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<Form
|
|
3
|
+
class="contents"
|
|
4
|
+
:transform="data => ({ <%= singular_table_name %>: data })"
|
|
5
|
+
v-slot="{ processing, errors }"
|
|
6
|
+
v-bind="$attrs"
|
|
7
|
+
>
|
|
3
8
|
<% attributes.each do |attribute| -%>
|
|
4
9
|
<% if attribute.password_digest? -%>
|
|
5
10
|
<div class="my-5">
|
|
@@ -8,14 +13,13 @@
|
|
|
8
13
|
type="password"
|
|
9
14
|
name="password"
|
|
10
15
|
id="password"
|
|
11
|
-
v-model="form.password"
|
|
12
16
|
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
13
17
|
/>
|
|
14
18
|
<div
|
|
15
|
-
v-if="
|
|
19
|
+
v-if="errors.password"
|
|
16
20
|
class="text-red-500 px-3 py-2 font-medium"
|
|
17
21
|
>
|
|
18
|
-
{{
|
|
22
|
+
{{ errors.password.join(', ') }}
|
|
19
23
|
</div>
|
|
20
24
|
</div>
|
|
21
25
|
|
|
@@ -25,14 +29,13 @@
|
|
|
25
29
|
type="password"
|
|
26
30
|
name="password_confirmation"
|
|
27
31
|
id="password_confirmation"
|
|
28
|
-
v-model="form.password_confirmation"
|
|
29
32
|
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
30
33
|
/>
|
|
31
34
|
<div
|
|
32
|
-
v-if="
|
|
35
|
+
v-if="errors.password_confirmation"
|
|
33
36
|
class="text-red-500 px-3 py-2 font-medium"
|
|
34
37
|
>
|
|
35
|
-
{{
|
|
38
|
+
{{ errors.password_confirmation.join(', ') }}
|
|
36
39
|
</div>
|
|
37
40
|
</div>
|
|
38
41
|
<% else -%>
|
|
@@ -42,7 +45,7 @@
|
|
|
42
45
|
<textarea
|
|
43
46
|
name="<%= attribute.singular_name %>"
|
|
44
47
|
id="<%= attribute.singular_name %>"
|
|
45
|
-
|
|
48
|
+
:value="<%= singular_table_name %>.<%= attribute.column_name %>"
|
|
46
49
|
rows="4"
|
|
47
50
|
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
48
51
|
/>
|
|
@@ -51,7 +54,6 @@
|
|
|
51
54
|
type="file"
|
|
52
55
|
name="<%= attribute.singular_name %>"
|
|
53
56
|
id="<%= attribute.singular_name %>"
|
|
54
|
-
@input="form.<%= attribute.column_name %> = (($event.target as HTMLInputElement).files || [])[0]"
|
|
55
57
|
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
56
58
|
/>
|
|
57
59
|
<% elsif attribute.attachments? -%>
|
|
@@ -60,7 +62,6 @@
|
|
|
60
62
|
multiple
|
|
61
63
|
name="<%= attribute.singular_name %>[]"
|
|
62
64
|
id="<%= attribute.singular_name %>"
|
|
63
|
-
@input="form.<%= attribute.column_name %> = Array.from(($event.target as HTMLInputElement).files || [])"
|
|
64
65
|
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
65
66
|
/>
|
|
66
67
|
<% elsif input_type(attribute) == "checkbox" -%>
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
type="<%= input_type(attribute) %>"
|
|
69
70
|
name="<%= attribute.singular_name %>"
|
|
70
71
|
id="<%= attribute.singular_name %>"
|
|
71
|
-
|
|
72
|
+
:checked="<%= singular_table_name %>.<%= attribute.column_name %>"
|
|
72
73
|
class="block mt-2 h-5 w-5"
|
|
73
74
|
/>
|
|
74
75
|
<% else -%>
|
|
@@ -76,12 +77,12 @@
|
|
|
76
77
|
type="<%= input_type(attribute) %>"
|
|
77
78
|
name="<%= attribute.singular_name %>"
|
|
78
79
|
id="<%= attribute.singular_name %>"
|
|
79
|
-
|
|
80
|
+
:value="<%= singular_table_name %>.<%= attribute.column_name %>"
|
|
80
81
|
class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
|
|
81
82
|
/>
|
|
82
83
|
<% end -%>
|
|
83
|
-
<div v-if="
|
|
84
|
-
{{
|
|
84
|
+
<div v-if="errors.<%= attribute.column_name %>" class="text-red-500 px-3 py-2 font-medium">
|
|
85
|
+
{{ errors.<%= attribute.column_name %>.join(', ') }}
|
|
85
86
|
</div>
|
|
86
87
|
</div>
|
|
87
88
|
<% end -%>
|
|
@@ -90,45 +91,21 @@
|
|
|
90
91
|
<div class="inline">
|
|
91
92
|
<button
|
|
92
93
|
type="submit"
|
|
93
|
-
:disabled="
|
|
94
|
+
:disabled="processing"
|
|
94
95
|
class="rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer"
|
|
95
96
|
>
|
|
96
97
|
{{ submitText }}
|
|
97
98
|
</button>
|
|
98
99
|
</div>
|
|
99
|
-
</
|
|
100
|
+
</Form>
|
|
100
101
|
</template>
|
|
101
102
|
|
|
102
103
|
<script setup lang="ts">
|
|
103
|
-
import {
|
|
104
|
-
import { <%=
|
|
104
|
+
import { Form } from '@inertiajs/vue3'
|
|
105
|
+
import { <%= inertia_model_type %> } from './types'
|
|
105
106
|
|
|
106
107
|
const { <%= singular_table_name %>, submitText } = defineProps<{
|
|
107
108
|
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
108
109
|
submitText: string
|
|
109
110
|
}>()
|
|
110
|
-
|
|
111
|
-
const emit = defineEmits<{
|
|
112
|
-
onSubmit: [form: InertiaForm<<%= inertia_model_form_type %>>]
|
|
113
|
-
}>()
|
|
114
|
-
|
|
115
|
-
const form = useForm<<%= inertia_model_form_type %>>({
|
|
116
|
-
<% attributes.reject { |a| a.attachment? || a.attachments? }.each do |attribute| -%>
|
|
117
|
-
<% if attribute.password_digest? -%>
|
|
118
|
-
password: '',
|
|
119
|
-
password_confirmation: '',
|
|
120
|
-
<% else -%>
|
|
121
|
-
<%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %>,
|
|
122
|
-
<% end -%>
|
|
123
|
-
<% end -%>
|
|
124
|
-
})
|
|
125
111
|
</script>
|
|
126
|
-
|
|
127
|
-
<style module>
|
|
128
|
-
.label {
|
|
129
|
-
display: block;
|
|
130
|
-
}
|
|
131
|
-
.error {
|
|
132
|
-
color: red;
|
|
133
|
-
}
|
|
134
|
-
</style>
|