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,96 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { useForm } from '@inertiajs/svelte'
|
|
3
|
-
import { createEventDispatcher } from 'svelte'
|
|
4
|
-
|
|
5
|
-
const dispatch = createEventDispatcher()
|
|
6
|
-
|
|
7
|
-
export let <%= singular_table_name %>
|
|
8
|
-
export let submitText
|
|
9
|
-
|
|
10
|
-
const form = useForm({
|
|
11
|
-
<% attributes.each do |attribute| -%>
|
|
12
|
-
<% if attribute.password_digest? -%>
|
|
13
|
-
password: '',
|
|
14
|
-
password_confirmation: '',
|
|
15
|
-
<% else -%>
|
|
16
|
-
<%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %> || <%= default_value(attribute) %>,
|
|
17
|
-
<% end -%>
|
|
18
|
-
<% end -%>
|
|
19
|
-
})
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
<form on:submit|preventDefault={dispatch('submit', { form: $form })}>
|
|
23
|
-
<% attributes.each do |attribute| -%>
|
|
24
|
-
<% if attribute.password_digest? -%>
|
|
25
|
-
<div>
|
|
26
|
-
<label for="password">Password</label>
|
|
27
|
-
<input
|
|
28
|
-
type="password"
|
|
29
|
-
name="password"
|
|
30
|
-
id="password"
|
|
31
|
-
bind:value={$form.password}
|
|
32
|
-
/>
|
|
33
|
-
{#if $form.errors.password}
|
|
34
|
-
<div class="error">{$form.errors.password.join(', ')}</div>
|
|
35
|
-
{/if}
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
<div>
|
|
39
|
-
<label for="password_confirmation">Password confirmation</label>
|
|
40
|
-
<input
|
|
41
|
-
type="password"
|
|
42
|
-
name="password_confirmation"
|
|
43
|
-
id="password_confirmation"
|
|
44
|
-
bind:value={$form.password_confirmation}
|
|
45
|
-
/>
|
|
46
|
-
{#if $form.errors.password_confirmation}
|
|
47
|
-
<div class="error">{$form.errors.password_confirmation.join(', ')}</div>
|
|
48
|
-
{/if}
|
|
49
|
-
</div>
|
|
50
|
-
<% else -%>
|
|
51
|
-
<div>
|
|
52
|
-
<label for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
|
53
|
-
<% if input_type(attribute) == "text_area" -%>
|
|
54
|
-
<textarea name="<%= attribute.singular_name %>" id="<%= attribute.singular_name %>" bind:value={$form.<%= attribute.column_name %>}></textarea>
|
|
55
|
-
<% elsif attribute.attachment? -%>
|
|
56
|
-
<input
|
|
57
|
-
type="file"
|
|
58
|
-
name="<%= attribute.singular_name %>"
|
|
59
|
-
id="<%= attribute.singular_name %>"
|
|
60
|
-
on:input={(e) => ($form.<%= attribute.column_name %> = e.target.files[0])}
|
|
61
|
-
/>
|
|
62
|
-
<% elsif attribute.attachments? -%>
|
|
63
|
-
<input
|
|
64
|
-
type="file"
|
|
65
|
-
multiple
|
|
66
|
-
name="<%= attribute.singular_name %>[]"
|
|
67
|
-
id="<%= attribute.singular_name %>"
|
|
68
|
-
on:input={(e) => ($form.<%= attribute.column_name %> = Array.from(e.target.files))}
|
|
69
|
-
/>
|
|
70
|
-
<% else -%>
|
|
71
|
-
<input
|
|
72
|
-
type="<%= input_type(attribute) %>"
|
|
73
|
-
name="<%= attribute.singular_name %>"
|
|
74
|
-
id="<%= attribute.singular_name %>"
|
|
75
|
-
<%= input_type(attribute) == "checkbox" ? "bind:checked" : "bind:value" %>={$form.<%= attribute.column_name %>}
|
|
76
|
-
/>
|
|
77
|
-
<% end -%>
|
|
78
|
-
{#if $form.errors.<%= attribute.column_name %>}
|
|
79
|
-
<div class="error">{$form.errors.<%= attribute.column_name %>.join(', ')}</div>
|
|
80
|
-
{/if}
|
|
81
|
-
</div>
|
|
82
|
-
<% end -%>
|
|
83
|
-
<% end -%>
|
|
84
|
-
<div>
|
|
85
|
-
<button type="submit" disabled={$form.processing}>{submitText}</button>
|
|
86
|
-
</div>
|
|
87
|
-
</form>
|
|
88
|
-
|
|
89
|
-
<style>
|
|
90
|
-
label {
|
|
91
|
-
display: block;
|
|
92
|
-
}
|
|
93
|
-
.error {
|
|
94
|
-
color: red;
|
|
95
|
-
}
|
|
96
|
-
</style>
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { useForm, type InertiaForm } from '@inertiajs/svelte'
|
|
3
|
-
import { createEventDispatcher } from 'svelte'
|
|
4
|
-
import type { <%= inertia_model_type %>, <%= inertia_model_form_type %> } from './types'
|
|
5
|
-
|
|
6
|
-
const dispatch = createEventDispatcher<{
|
|
7
|
-
submit: { form: InertiaForm<<%= inertia_model_form_type %>> }
|
|
8
|
-
}>()
|
|
9
|
-
|
|
10
|
-
export let <%= singular_table_name %>: <%= inertia_model_type %>
|
|
11
|
-
export let submitText: string
|
|
12
|
-
|
|
13
|
-
<% if attributes.any? { |a| a.attachment? || a.attachments? } -%>
|
|
14
|
-
const filesFromEvent = (e: Event) => {
|
|
15
|
-
const target = e.target as HTMLInputElement
|
|
16
|
-
return Array.from(target.files || [])
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
<% end -%>
|
|
20
|
-
const form = useForm<<%= inertia_model_form_type %>>({
|
|
21
|
-
<% attributes.reject { |a| a.attachment? || a.attachments? }.each do |attribute| -%>
|
|
22
|
-
<% if attribute.password_digest? -%>
|
|
23
|
-
password: '',
|
|
24
|
-
password_confirmation: '',
|
|
25
|
-
<% else -%>
|
|
26
|
-
<%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %>,
|
|
27
|
-
<% end -%>
|
|
28
|
-
<% end -%>
|
|
29
|
-
})
|
|
30
|
-
</script>
|
|
31
|
-
|
|
32
|
-
<form on:submit|preventDefault={() => dispatch('submit', { form: $form })}>
|
|
33
|
-
<% attributes.each do |attribute| -%>
|
|
34
|
-
<% if attribute.password_digest? -%>
|
|
35
|
-
<div>
|
|
36
|
-
<label for="password">Password</label>
|
|
37
|
-
<input
|
|
38
|
-
type="password"
|
|
39
|
-
name="password"
|
|
40
|
-
id="password"
|
|
41
|
-
bind:value={$form.password}
|
|
42
|
-
/>
|
|
43
|
-
{#if $form.errors.password}
|
|
44
|
-
<div class="error">{$form.errors.password}</div>
|
|
45
|
-
{/if}
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
<div>
|
|
49
|
-
<label for="password_confirmation">Password confirmation</label>
|
|
50
|
-
<input
|
|
51
|
-
type="password"
|
|
52
|
-
name="password_confirmation"
|
|
53
|
-
id="password_confirmation"
|
|
54
|
-
bind:value={$form.password_confirmation}
|
|
55
|
-
/>
|
|
56
|
-
{#if $form.errors.password_confirmation}
|
|
57
|
-
<div class="error">{$form.errors.password_confirmation}</div>
|
|
58
|
-
{/if}
|
|
59
|
-
</div>
|
|
60
|
-
<% else -%>
|
|
61
|
-
<div>
|
|
62
|
-
<label for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
|
63
|
-
<% if input_type(attribute) == "text_area" -%>
|
|
64
|
-
<textarea name="<%= attribute.singular_name %>" id="<%= attribute.singular_name %>" bind:value={$form.<%= attribute.column_name %>}></textarea>
|
|
65
|
-
<% elsif attribute.attachment? -%>
|
|
66
|
-
<input
|
|
67
|
-
type="file"
|
|
68
|
-
name="<%= attribute.singular_name %>"
|
|
69
|
-
id="<%= attribute.singular_name %>"
|
|
70
|
-
on:input={(e) => ($form.<%= attribute.column_name %> = filesFromEvent(e)[0])}
|
|
71
|
-
/>
|
|
72
|
-
<% elsif attribute.attachments? -%>
|
|
73
|
-
<input
|
|
74
|
-
type="file"
|
|
75
|
-
multiple
|
|
76
|
-
name="<%= attribute.singular_name %>[]"
|
|
77
|
-
id="<%= attribute.singular_name %>"
|
|
78
|
-
on:input={(e) => ($form.<%= attribute.column_name %> = filesFromEvent(e))}
|
|
79
|
-
/>
|
|
80
|
-
<% else -%>
|
|
81
|
-
<input
|
|
82
|
-
type="<%= input_type(attribute) %>"
|
|
83
|
-
name="<%= attribute.singular_name %>"
|
|
84
|
-
id="<%= attribute.singular_name %>"
|
|
85
|
-
<%= input_type(attribute) == "checkbox" ? "bind:checked" : "bind:value" %>={$form.<%= attribute.column_name %>}
|
|
86
|
-
/>
|
|
87
|
-
<% end -%>
|
|
88
|
-
{#if $form.errors.<%= attribute.column_name %>}
|
|
89
|
-
<div class="error">{$form.errors.<%= attribute.column_name %>}</div>
|
|
90
|
-
{/if}
|
|
91
|
-
</div>
|
|
92
|
-
<% end -%>
|
|
93
|
-
<% end -%>
|
|
94
|
-
<div>
|
|
95
|
-
<button type="submit" disabled={$form.processing}>{submitText}</button>
|
|
96
|
-
</div>
|
|
97
|
-
</form>
|
|
98
|
-
|
|
99
|
-
<style>
|
|
100
|
-
label {
|
|
101
|
-
display: block;
|
|
102
|
-
}
|
|
103
|
-
.error {
|
|
104
|
-
color: red;
|
|
105
|
-
}
|
|
106
|
-
</style>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import <%= inertia_component_name %> from './<%= inertia_component_name %>.svelte'
|
|
4
|
-
|
|
5
|
-
export let <%= plural_table_name %>
|
|
6
|
-
export let flash
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<svelte:head>
|
|
10
|
-
<title><%= human_name.pluralize %></title>
|
|
11
|
-
</svelte:head>
|
|
12
|
-
|
|
13
|
-
{#if flash.notice}
|
|
14
|
-
<p class="notice">{flash.notice}</p>
|
|
15
|
-
{/if}
|
|
16
|
-
|
|
17
|
-
<h1><%= human_name.pluralize %></h1>
|
|
18
|
-
|
|
19
|
-
<div>
|
|
20
|
-
{#each <%= plural_table_name %> as <%= singular_table_name %> (<%= singular_table_name %>.id)}
|
|
21
|
-
<div>
|
|
22
|
-
<<%= inertia_component_name %> {<%= singular_table_name %>} />
|
|
23
|
-
<p>
|
|
24
|
-
<Link href={`<%= js_resource_path %>`}>Show this <%= human_name.downcase %></Link>
|
|
25
|
-
</p>
|
|
26
|
-
</div>
|
|
27
|
-
{/each}
|
|
28
|
-
</div>
|
|
29
|
-
|
|
30
|
-
<Link href="<%= js_new_resource_path %>">New <%= human_name.downcase %></Link>
|
|
31
|
-
|
|
32
|
-
<style>
|
|
33
|
-
.notice {
|
|
34
|
-
color: green;
|
|
35
|
-
}
|
|
36
|
-
</style>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import <%= inertia_component_name %> from './<%= inertia_component_name %>.svelte'
|
|
4
|
-
import type { <%= inertia_model_type %> } from './types'
|
|
5
|
-
|
|
6
|
-
export let <%= plural_table_name %>: <%= inertia_model_type %>[]
|
|
7
|
-
export let flash: { notice?: string }
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<svelte:head>
|
|
11
|
-
<title><%= human_name.pluralize %></title>
|
|
12
|
-
</svelte:head>
|
|
13
|
-
|
|
14
|
-
{#if flash.notice}
|
|
15
|
-
<p class="notice">{flash.notice}</p>
|
|
16
|
-
{/if}
|
|
17
|
-
|
|
18
|
-
<h1><%= human_name.pluralize %></h1>
|
|
19
|
-
|
|
20
|
-
<div>
|
|
21
|
-
{#each <%= plural_table_name %> as <%= singular_table_name %> (<%= singular_table_name %>.id)}
|
|
22
|
-
<div>
|
|
23
|
-
<<%= inertia_component_name %> {<%= singular_table_name %>} />
|
|
24
|
-
<p>
|
|
25
|
-
<Link href={`<%= js_resource_path %>`}>Show this <%= human_name.downcase %></Link>
|
|
26
|
-
</p>
|
|
27
|
-
</div>
|
|
28
|
-
{/each}
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
<Link href="<%= js_new_resource_path %>">New <%= human_name.downcase %></Link>
|
|
32
|
-
|
|
33
|
-
<style>
|
|
34
|
-
.notice {
|
|
35
|
-
color: green;
|
|
36
|
-
}
|
|
37
|
-
</style>
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Link, type InertiaForm } from '@inertiajs/svelte'
|
|
3
|
-
import Form from './Form.svelte'
|
|
4
|
-
import type { <%= inertia_model_type %>, <%= inertia_model_form_type %> } from './types'
|
|
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
|
-
form.post('<%= js_resources_path %>')
|
|
12
|
-
}
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<svelte:head>
|
|
16
|
-
<title>New <%= human_name.downcase %></title>
|
|
17
|
-
</svelte:head>
|
|
18
|
-
|
|
19
|
-
<h1>New <%= human_name.downcase %></h1>
|
|
20
|
-
|
|
21
|
-
<Form
|
|
22
|
-
{<%= singular_table_name %>}
|
|
23
|
-
submitText="Create <%= human_name %>"
|
|
24
|
-
on:submit={handleSubmit}
|
|
25
|
-
/>
|
|
26
|
-
|
|
27
|
-
<br />
|
|
28
|
-
|
|
29
|
-
<div>
|
|
30
|
-
<Link href="<%= js_resources_path %>">Back to <%= human_name.pluralize.downcase %></Link>
|
|
31
|
-
</div>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
export let <%= singular_table_name %>
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<div>
|
|
6
|
-
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
|
7
|
-
<p>
|
|
8
|
-
<strong><%= attribute.human_name %>:</strong>
|
|
9
|
-
<% if attribute.attachment? -%>
|
|
10
|
-
{#if <%= singular_table_name %>.<%= attribute.column_name %>}
|
|
11
|
-
<a href={<%= singular_table_name %>.<%= attribute.column_name %>.url}>
|
|
12
|
-
{<%= singular_table_name %>.<%= attribute.column_name %>.filename}
|
|
13
|
-
</a>
|
|
14
|
-
{/if}
|
|
15
|
-
</p>
|
|
16
|
-
<% elsif attribute.attachments? -%>
|
|
17
|
-
</p>
|
|
18
|
-
{#each <%= singular_table_name %>.<%= attribute.column_name %> as { url, filename }}
|
|
19
|
-
<div>
|
|
20
|
-
<a href={url}>{filename}</a>
|
|
21
|
-
</div>
|
|
22
|
-
{/each}
|
|
23
|
-
<% else -%>
|
|
24
|
-
{<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
25
|
-
</p>
|
|
26
|
-
<% end -%>
|
|
27
|
-
<% end -%>
|
|
28
|
-
</div>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { <%= inertia_model_type %> } from './types'
|
|
3
|
-
|
|
4
|
-
export let <%= singular_table_name %>: <%= inertia_model_type %>
|
|
5
|
-
</script>
|
|
6
|
-
|
|
7
|
-
<div>
|
|
8
|
-
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
|
9
|
-
<p>
|
|
10
|
-
<strong><%= attribute.human_name %>:</strong>
|
|
11
|
-
<% if attribute.attachment? -%>
|
|
12
|
-
{#if <%= singular_table_name %>.<%= attribute.column_name %>}
|
|
13
|
-
<a href={<%= singular_table_name %>.<%= attribute.column_name %>.url}>
|
|
14
|
-
{<%= singular_table_name %>.<%= attribute.column_name %>.filename}
|
|
15
|
-
</a>
|
|
16
|
-
{/if}
|
|
17
|
-
</p>
|
|
18
|
-
<% elsif attribute.attachments? -%>
|
|
19
|
-
</p>
|
|
20
|
-
{#each <%= singular_table_name %>.<%= attribute.column_name %> as { url, filename }}
|
|
21
|
-
<div>
|
|
22
|
-
<a href={url}>{filename}</a>
|
|
23
|
-
</div>
|
|
24
|
-
{/each}
|
|
25
|
-
<% else -%>
|
|
26
|
-
{<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
27
|
-
</p>
|
|
28
|
-
<% end -%>
|
|
29
|
-
<% end -%>
|
|
30
|
-
</div>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { inertia, Link } from '@inertiajs/svelte'
|
|
3
|
-
import <%= inertia_component_name %> from './<%= inertia_component_name %>.svelte'
|
|
4
|
-
|
|
5
|
-
export let <%= singular_table_name %>
|
|
6
|
-
export let flash
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<svelte:head>
|
|
10
|
-
<title><%= human_name %> #{<%= singular_table_name %>.id}</title>
|
|
11
|
-
</svelte:head>
|
|
12
|
-
|
|
13
|
-
{#if flash.notice}
|
|
14
|
-
<p class="notice">{flash.notice}</p>
|
|
15
|
-
{/if}
|
|
16
|
-
|
|
17
|
-
<h1><%= human_name %> #{<%= singular_table_name %>.id}</h1>
|
|
18
|
-
|
|
19
|
-
<<%= inertia_component_name %> {<%= singular_table_name %>} />
|
|
20
|
-
|
|
21
|
-
<div>
|
|
22
|
-
<Link href={`<%= js_edit_resource_path %>`}>Edit this <%= human_name.downcase %></Link> |
|
|
23
|
-
<Link href="<%= js_resources_path %>">Back to <%= human_name.pluralize.downcase %></Link>
|
|
24
|
-
|
|
25
|
-
<br />
|
|
26
|
-
|
|
27
|
-
<button
|
|
28
|
-
use:inertia={{ href: `<%= js_resource_path %>`, method: 'delete' }}
|
|
29
|
-
type="button"
|
|
30
|
-
>
|
|
31
|
-
Destroy this <%= human_name.downcase %>
|
|
32
|
-
</button>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<style>
|
|
36
|
-
.notice {
|
|
37
|
-
color: green;
|
|
38
|
-
}
|
|
39
|
-
</style>
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { inertia, Link } from '@inertiajs/svelte'
|
|
3
|
-
import <%= inertia_component_name %> from './<%= inertia_component_name %>.svelte'
|
|
4
|
-
import type { <%= inertia_model_type %> } from './types'
|
|
5
|
-
|
|
6
|
-
export let <%= singular_table_name %>: <%= inertia_model_type %>
|
|
7
|
-
export let flash: { notice?: string }
|
|
8
|
-
</script>
|
|
9
|
-
|
|
10
|
-
<svelte:head>
|
|
11
|
-
<title><%= human_name %> #{<%= singular_table_name %>.id}</title>
|
|
12
|
-
</svelte:head>
|
|
13
|
-
|
|
14
|
-
{#if flash.notice}
|
|
15
|
-
<p class="notice">{flash.notice}</p>
|
|
16
|
-
{/if}
|
|
17
|
-
|
|
18
|
-
<h1><%= human_name %> #{<%= singular_table_name %>.id}</h1>
|
|
19
|
-
|
|
20
|
-
<<%= inertia_component_name %> {<%= singular_table_name %>} />
|
|
21
|
-
|
|
22
|
-
<div>
|
|
23
|
-
<Link href={`<%= js_edit_resource_path %>`}>Edit this <%= human_name.downcase %></Link> |
|
|
24
|
-
<Link href="<%= js_resources_path %>">Back to <%= human_name.pluralize.downcase %></Link>
|
|
25
|
-
|
|
26
|
-
<br />
|
|
27
|
-
|
|
28
|
-
<button
|
|
29
|
-
use:inertia={{ href: `<%= js_resource_path %>`, method: 'delete' }}
|
|
30
|
-
type="button"
|
|
31
|
-
>
|
|
32
|
-
Destroy this <%= human_name.downcase %>
|
|
33
|
-
</button>
|
|
34
|
-
</div>
|
|
35
|
-
|
|
36
|
-
<style>
|
|
37
|
-
.notice {
|
|
38
|
-
color: green;
|
|
39
|
-
}
|
|
40
|
-
</style>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface <%= inertia_model_type %> {
|
|
2
|
-
id: number
|
|
3
|
-
<% attributes.reject(&:password_digest?).each do |attribute| -%>
|
|
4
|
-
<%= attribute.column_name %>: <%= ts_type(attribute) %>
|
|
5
|
-
<% end -%>
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type <%= inertia_model_form_type %> = Omit<<%= inertia_model_type %>, <%= omit_input_attributes.map { |a| "'#{a}'" }.join(' | ') %>><% if custom_form_attributes.any? -%> & {
|
|
9
|
-
<% custom_form_attributes.map do |attribute| -%>
|
|
10
|
-
<% if attribute.password_digest? -%>
|
|
11
|
-
password: string
|
|
12
|
-
password_confirmation: string
|
|
13
|
-
<% elsif attribute.attachment? -%>
|
|
14
|
-
<%= attribute.column_name %>?: File
|
|
15
|
-
<% elsif attribute.attachments? -%>
|
|
16
|
-
<%= attribute.column_name %>?: File[]
|
|
17
|
-
<% end -%>
|
|
18
|
-
<% end -%>
|
|
19
|
-
}<% end %>
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<form @submit.prevent="emit('onSubmit', form)">
|
|
3
|
-
<% attributes.each do |attribute| -%>
|
|
4
|
-
<% if attribute.password_digest? -%>
|
|
5
|
-
<div>
|
|
6
|
-
<label class="label" for="password">Password</label>
|
|
7
|
-
<input
|
|
8
|
-
type="password"
|
|
9
|
-
name="password"
|
|
10
|
-
id="password"
|
|
11
|
-
v-model="form.password"
|
|
12
|
-
/>
|
|
13
|
-
<div v-if="form.errors.password" class="error">
|
|
14
|
-
{{ form.errors.password }}
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<div>
|
|
19
|
-
<label class="label" for="password_confirmation">
|
|
20
|
-
Password confirmation
|
|
21
|
-
</label>
|
|
22
|
-
<input
|
|
23
|
-
type="password"
|
|
24
|
-
name="password_confirmation"
|
|
25
|
-
id="password_confirmation"
|
|
26
|
-
v-model="form.password_confirmation"
|
|
27
|
-
/>
|
|
28
|
-
<div v-if="form.errors.password_confirmation" class="error">
|
|
29
|
-
{{ form.errors.password_confirmation }}
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
<% else -%>
|
|
33
|
-
<div>
|
|
34
|
-
<label class="label" for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
|
35
|
-
<% if input_type(attribute) == "text_area" -%>
|
|
36
|
-
<textarea name="<%= attribute.singular_name %>" id="<%= attribute.singular_name %>" v-model="form.<%= attribute.column_name %>" />
|
|
37
|
-
<% elsif attribute.attachment? -%>
|
|
38
|
-
<input
|
|
39
|
-
type="file"
|
|
40
|
-
name="<%= attribute.singular_name %>"
|
|
41
|
-
id="<%= attribute.singular_name %>"
|
|
42
|
-
@input="form.<%= attribute.column_name %> = (($event.target as HTMLInputElement).files || [])[0]"
|
|
43
|
-
/>
|
|
44
|
-
<% elsif attribute.attachments? -%>
|
|
45
|
-
<input
|
|
46
|
-
type="file"
|
|
47
|
-
multiple
|
|
48
|
-
name="<%= attribute.singular_name %>[]"
|
|
49
|
-
id="<%= attribute.singular_name %>"
|
|
50
|
-
@input="form.<%= attribute.column_name %> = Array.from(($event.target as HTMLInputElement).files || [])"
|
|
51
|
-
/>
|
|
52
|
-
<% else -%>
|
|
53
|
-
<input type="<%= input_type(attribute) %>" name="<%= attribute.singular_name %>" id="<%= attribute.singular_name %>" v-model="form.<%= attribute.column_name %>" />
|
|
54
|
-
<% end -%>
|
|
55
|
-
<div v-if="form.errors.<%= attribute.column_name %>" class="error">
|
|
56
|
-
{{ form.errors.<%= attribute.column_name %> }}
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
|
-
<% end -%>
|
|
60
|
-
<% end -%>
|
|
61
|
-
<div>
|
|
62
|
-
<button type="submit" :disabled="form.processing">
|
|
63
|
-
{{ submitText }}
|
|
64
|
-
</button>
|
|
65
|
-
</div>
|
|
66
|
-
</form>
|
|
67
|
-
</template>
|
|
68
|
-
|
|
69
|
-
<script setup lang="ts">
|
|
70
|
-
import { InertiaForm, useForm } from '@inertiajs/vue3'
|
|
71
|
-
import { <%= inertia_model_form_type %>, <%= inertia_model_type %> } from './types'
|
|
72
|
-
|
|
73
|
-
const { <%= singular_table_name %>, submitText } = defineProps<{
|
|
74
|
-
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
75
|
-
submitText: string
|
|
76
|
-
}>()
|
|
77
|
-
|
|
78
|
-
const emit = defineEmits<{
|
|
79
|
-
onSubmit: [form: InertiaForm<<%= inertia_model_form_type %>>]
|
|
80
|
-
}>()
|
|
81
|
-
|
|
82
|
-
const form = useForm<<%= inertia_model_form_type %>>({
|
|
83
|
-
<% attributes.reject { |a| a.attachment? || a.attachments? }.each do |attribute| -%>
|
|
84
|
-
<% if attribute.password_digest? -%>
|
|
85
|
-
password: '',
|
|
86
|
-
password_confirmation: '',
|
|
87
|
-
<% else -%>
|
|
88
|
-
<%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %>,
|
|
89
|
-
<% end -%>
|
|
90
|
-
<% end -%>
|
|
91
|
-
})
|
|
92
|
-
</script>
|
|
93
|
-
|
|
94
|
-
<style scoped>
|
|
95
|
-
.label {
|
|
96
|
-
display: block;
|
|
97
|
-
}
|
|
98
|
-
.error {
|
|
99
|
-
color: red;
|
|
100
|
-
}
|
|
101
|
-
</style>
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<form @submit.prevent="emit('onSubmit', form)">
|
|
3
|
-
<% attributes.each do |attribute| -%>
|
|
4
|
-
<% if attribute.password_digest? -%>
|
|
5
|
-
<div>
|
|
6
|
-
<label class="label" for="password">Password</label>
|
|
7
|
-
<input
|
|
8
|
-
type="password"
|
|
9
|
-
name="password"
|
|
10
|
-
id="password"
|
|
11
|
-
v-model="form.password"
|
|
12
|
-
/>
|
|
13
|
-
<div v-if="form.errors.password" class="error">
|
|
14
|
-
{{ form.errors.password.join(', ') }}
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<div>
|
|
19
|
-
<label class="label" for="password_confirmation">
|
|
20
|
-
Password confirmation
|
|
21
|
-
</label>
|
|
22
|
-
<input
|
|
23
|
-
type="password"
|
|
24
|
-
name="password_confirmation"
|
|
25
|
-
id="password_confirmation"
|
|
26
|
-
v-model="form.password_confirmation"
|
|
27
|
-
/>
|
|
28
|
-
<div v-if="form.errors.password_confirmation" class="error">
|
|
29
|
-
{{ form.errors.password_confirmation.join(', ') }}
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
<% else -%>
|
|
33
|
-
<div>
|
|
34
|
-
<label class="label" for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
|
35
|
-
<% if input_type(attribute) == "text_area" -%>
|
|
36
|
-
<textarea name="<%= attribute.singular_name %>" id="<%= attribute.singular_name %>" v-model="form.<%= attribute.column_name %>" />
|
|
37
|
-
<% elsif attribute.attachment? -%>
|
|
38
|
-
<input
|
|
39
|
-
type="file"
|
|
40
|
-
name="<%= attribute.singular_name %>"
|
|
41
|
-
id="<%= attribute.singular_name %>"
|
|
42
|
-
@input="form.<%= attribute.column_name %> = $event.target.files[0]"
|
|
43
|
-
/>
|
|
44
|
-
<% elsif attribute.attachments? -%>
|
|
45
|
-
<input
|
|
46
|
-
type="file"
|
|
47
|
-
multiple
|
|
48
|
-
name="<%= attribute.singular_name %>[]"
|
|
49
|
-
id="<%= attribute.singular_name %>"
|
|
50
|
-
@input="form.<%= attribute.column_name %> = Array.from($event.target.files)"
|
|
51
|
-
/>
|
|
52
|
-
<% else -%>
|
|
53
|
-
<input type="<%= input_type(attribute) %>" name="<%= attribute.singular_name %>" id="<%= attribute.singular_name %>" v-model="form.<%= attribute.column_name %>" />
|
|
54
|
-
<% end -%>
|
|
55
|
-
<div v-if="form.errors.<%= attribute.column_name %>" class="error">
|
|
56
|
-
{{ form.errors.<%= attribute.column_name %>.join(', ') }}
|
|
57
|
-
</div>
|
|
58
|
-
</div>
|
|
59
|
-
<% end -%>
|
|
60
|
-
<% end -%>
|
|
61
|
-
<div>
|
|
62
|
-
<button type="submit" :disabled="form.processing">
|
|
63
|
-
{{ submitText }}
|
|
64
|
-
</button>
|
|
65
|
-
</div>
|
|
66
|
-
</form>
|
|
67
|
-
</template>
|
|
68
|
-
|
|
69
|
-
<script setup>
|
|
70
|
-
import { useForm } from '@inertiajs/vue3'
|
|
71
|
-
|
|
72
|
-
const { <%= singular_table_name %>, submitText } = defineProps(['<%= singular_table_name %>', 'submitText'])
|
|
73
|
-
const emit = defineEmits(['onSubmit'])
|
|
74
|
-
|
|
75
|
-
const form = useForm({
|
|
76
|
-
<% attributes.each do |attribute| -%>
|
|
77
|
-
<% if attribute.password_digest? -%>
|
|
78
|
-
password: '',
|
|
79
|
-
password_confirmation: '',
|
|
80
|
-
<% else -%>
|
|
81
|
-
<%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %> || <%= default_value(attribute) %>,
|
|
82
|
-
<% end -%>
|
|
83
|
-
<% end -%>
|
|
84
|
-
})
|
|
85
|
-
</script>
|
|
86
|
-
|
|
87
|
-
<style scoped>
|
|
88
|
-
.label {
|
|
89
|
-
display: block;
|
|
90
|
-
}
|
|
91
|
-
.error {
|
|
92
|
-
color: red;
|
|
93
|
-
}
|
|
94
|
-
</style>
|