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,44 +0,0 @@
|
|
|
1
|
-
import { createInertiaApp, type ResolvedComponent } from '@inertiajs/svelte'
|
|
2
|
-
|
|
3
|
-
createInertiaApp({
|
|
4
|
-
// Set default page title
|
|
5
|
-
// see https://inertia-rails.dev/guide/title-and-meta
|
|
6
|
-
//
|
|
7
|
-
// title: title => title ? `${title} - App` : 'App',
|
|
8
|
-
|
|
9
|
-
// Disable progress bar
|
|
10
|
-
//
|
|
11
|
-
// see https://inertia-rails.dev/guide/progress-indicators
|
|
12
|
-
// progress: false,
|
|
13
|
-
|
|
14
|
-
resolve: (name) => {
|
|
15
|
-
const pages = import.meta.glob<ResolvedComponent>('../pages/**/*.svelte', {
|
|
16
|
-
eager: true,
|
|
17
|
-
})
|
|
18
|
-
const page = pages[`../pages/${name}.svelte`]
|
|
19
|
-
if (!page) {
|
|
20
|
-
console.error(`Missing Inertia page component: '${name}.svelte'`)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// To use a default layout, import the Layout component
|
|
24
|
-
// and use the following line.
|
|
25
|
-
// see https://inertia-rails.dev/guide/pages#default-layouts
|
|
26
|
-
//
|
|
27
|
-
// return { default: page.default, layout: page.layout || Layout }
|
|
28
|
-
|
|
29
|
-
return page
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
setup({ el, App, props }) {
|
|
33
|
-
if (el) {
|
|
34
|
-
<%= "// @ts-expect-error 1.3.0 beta contains types mismatch\n" if inertia_resolved_version.release == Gem::Version.new('1.3.0') -%>
|
|
35
|
-
new App({ target: el, props })
|
|
36
|
-
} else {
|
|
37
|
-
console.error(
|
|
38
|
-
'Missing root element.\n\n' +
|
|
39
|
-
'If you see this error, it probably means you load Inertia.js on non-Inertia pages.\n' +
|
|
40
|
-
'Consider moving <%%= vite_javascript_tag "inertia" %> to the Inertia-specific layout instead.',
|
|
41
|
-
)
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
})
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@tsconfig/svelte/tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "ESNext",
|
|
5
|
-
"useDefineForClassFields": true,
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"resolveJsonModule": true,
|
|
8
|
-
/**
|
|
9
|
-
* Typecheck JS in `.svelte` and `.js` files by default.
|
|
10
|
-
* Disable checkJs if you'd like to use dynamic types in JS.
|
|
11
|
-
* Note that setting allowJs false does not prevent the use
|
|
12
|
-
* of JS in `.svelte` files.
|
|
13
|
-
*/
|
|
14
|
-
"allowJs": true,
|
|
15
|
-
"checkJs": true,
|
|
16
|
-
"isolatedModules": true,
|
|
17
|
-
"moduleDetection": "force",
|
|
18
|
-
},
|
|
19
|
-
"include": ["<%= js_destination_path %>/**/*.ts", "<%= js_destination_path %>/**/*.js", "<%= js_destination_path %>/**/*.svelte"],
|
|
20
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
21
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"composite": true,
|
|
4
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
5
|
-
"skipLibCheck": true,
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"moduleResolution": "bundler",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"noEmit": true,
|
|
10
|
-
},
|
|
11
|
-
"include": ["vite.config.ts"]
|
|
12
|
-
}
|
|
@@ -1,111 +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}>
|
|
23
|
-
<% attributes.each do |attribute| -%>
|
|
24
|
-
<% if attribute.password_digest? -%>
|
|
25
|
-
<div>
|
|
26
|
-
<label style={{ display: 'block' }} htmlFor="password">
|
|
27
|
-
Password
|
|
28
|
-
</label>
|
|
29
|
-
<input
|
|
30
|
-
type="password"
|
|
31
|
-
name="password"
|
|
32
|
-
id="password"
|
|
33
|
-
onChange={(e) => setData('password', e.target.value)}
|
|
34
|
-
/>
|
|
35
|
-
{errors.password && (
|
|
36
|
-
<div style={{ color: 'red' }}>{errors.password.join(', ')}</div>
|
|
37
|
-
)}
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
<div>
|
|
41
|
-
<label style={{ display: 'block' }} htmlFor="password_confirmation">
|
|
42
|
-
Password confirmation
|
|
43
|
-
</label>
|
|
44
|
-
<input
|
|
45
|
-
type="password"
|
|
46
|
-
name="password_confirmation"
|
|
47
|
-
id="password_confirmation"
|
|
48
|
-
onChange={(e) => setData('password_confirmation', e.target.value)}
|
|
49
|
-
/>
|
|
50
|
-
{errors.password_confirmation && (
|
|
51
|
-
<div style={{ color: 'red' }}>{errors.password_confirmation.join(', ')}</div>
|
|
52
|
-
)}
|
|
53
|
-
</div>
|
|
54
|
-
<% else -%>
|
|
55
|
-
<div>
|
|
56
|
-
<label style={{ display: 'block' }} htmlFor="<%= attribute.singular_name %>">
|
|
57
|
-
<%= attribute.human_name %>
|
|
58
|
-
</label>
|
|
59
|
-
<% if input_type(attribute) == "text_area" -%>
|
|
60
|
-
<textarea
|
|
61
|
-
name="<%= attribute.singular_name %>"
|
|
62
|
-
id="<%= attribute.singular_name %>"
|
|
63
|
-
value={data.<%= attribute.column_name %>}
|
|
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
|
-
onChange={(e) => setData('<%= attribute.column_name %>', e.target.files[0])}
|
|
72
|
-
/>
|
|
73
|
-
<% elsif attribute.attachments? -%>
|
|
74
|
-
<input
|
|
75
|
-
type="file"
|
|
76
|
-
multiple
|
|
77
|
-
name="<%= attribute.singular_name %>[]"
|
|
78
|
-
id="<%= attribute.singular_name %>"
|
|
79
|
-
onChange={(e) => setData('<%= attribute.column_name %>', Array.from(e.target.files))}
|
|
80
|
-
/>
|
|
81
|
-
<% elsif input_type(attribute) == "checkbox" -%>
|
|
82
|
-
<input
|
|
83
|
-
type="<%= input_type(attribute) %>"
|
|
84
|
-
name="<%= attribute.singular_name %>"
|
|
85
|
-
id="<%= attribute.singular_name %>"
|
|
86
|
-
checked={data.<%= attribute.column_name %>}
|
|
87
|
-
onChange={(e) => setData('<%= attribute.column_name %>', e.target.checked)}
|
|
88
|
-
/>
|
|
89
|
-
<% else -%>
|
|
90
|
-
<input
|
|
91
|
-
type="<%= input_type(attribute) %>"
|
|
92
|
-
name="<%= attribute.singular_name %>"
|
|
93
|
-
id="<%= attribute.singular_name %>"
|
|
94
|
-
value={data.<%= attribute.column_name %>}
|
|
95
|
-
onChange={(e) => setData('<%= attribute.column_name %>', e.target.value)}
|
|
96
|
-
/>
|
|
97
|
-
<% end -%>
|
|
98
|
-
{errors.<%= attribute.column_name %> && (
|
|
99
|
-
<div style={{ color: 'red' }}>{errors.<%= attribute.column_name %>.join(', ')}</div>
|
|
100
|
-
)}
|
|
101
|
-
</div>
|
|
102
|
-
<% end -%>
|
|
103
|
-
<% end -%>
|
|
104
|
-
<div>
|
|
105
|
-
<button type="submit" disabled={processing}>
|
|
106
|
-
{submitText}
|
|
107
|
-
</button>
|
|
108
|
-
</div>
|
|
109
|
-
</form>
|
|
110
|
-
)
|
|
111
|
-
}
|
|
@@ -1,130 +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}>
|
|
34
|
-
<% attributes.each do |attribute| -%>
|
|
35
|
-
<% if attribute.password_digest? -%>
|
|
36
|
-
<div>
|
|
37
|
-
<label style={{ display: 'block' }} htmlFor="password">
|
|
38
|
-
Password
|
|
39
|
-
</label>
|
|
40
|
-
<input
|
|
41
|
-
type="password"
|
|
42
|
-
name="password"
|
|
43
|
-
id="password"
|
|
44
|
-
onChange={(e) => setData('password', e.target.value)}
|
|
45
|
-
/>
|
|
46
|
-
{errors.password && (
|
|
47
|
-
<div style={{ color: 'red' }}>{errors.password}</div>
|
|
48
|
-
)}
|
|
49
|
-
</div>
|
|
50
|
-
|
|
51
|
-
<div>
|
|
52
|
-
<label style={{ display: 'block' }} htmlFor="password_confirmation">
|
|
53
|
-
Password confirmation
|
|
54
|
-
</label>
|
|
55
|
-
<input
|
|
56
|
-
type="password"
|
|
57
|
-
name="password_confirmation"
|
|
58
|
-
id="password_confirmation"
|
|
59
|
-
onChange={(e) => setData('password_confirmation', e.target.value)}
|
|
60
|
-
/>
|
|
61
|
-
{errors.password_confirmation && (
|
|
62
|
-
<div style={{ color: 'red' }}>{errors.password_confirmation}</div>
|
|
63
|
-
)}
|
|
64
|
-
</div>
|
|
65
|
-
<% else -%>
|
|
66
|
-
<div>
|
|
67
|
-
<label style={{ display: 'block' }} htmlFor="<%= attribute.singular_name %>">
|
|
68
|
-
<%= attribute.human_name %>
|
|
69
|
-
</label>
|
|
70
|
-
<% if input_type(attribute) == "text_area" -%>
|
|
71
|
-
<textarea
|
|
72
|
-
name="<%= attribute.singular_name %>"
|
|
73
|
-
id="<%= attribute.singular_name %>"
|
|
74
|
-
value={data.<%= attribute.column_name %>}
|
|
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
|
-
onChange={(e) => setData('<%= attribute.column_name %>', (e.target.files || [])[0])}
|
|
83
|
-
/>
|
|
84
|
-
<% elsif attribute.attachments? -%>
|
|
85
|
-
<input
|
|
86
|
-
type="file"
|
|
87
|
-
multiple
|
|
88
|
-
name="<%= attribute.singular_name %>[]"
|
|
89
|
-
id="<%= attribute.singular_name %>"
|
|
90
|
-
onChange={(e) => setData('<%= attribute.column_name %>', Array.from(e.target.files || []))}
|
|
91
|
-
/>
|
|
92
|
-
<% elsif input_type(attribute) == "checkbox" -%>
|
|
93
|
-
<input
|
|
94
|
-
type="<%= input_type(attribute) %>"
|
|
95
|
-
name="<%= attribute.singular_name %>"
|
|
96
|
-
id="<%= attribute.singular_name %>"
|
|
97
|
-
checked={data.<%= attribute.column_name %>}
|
|
98
|
-
onChange={(e) => setData('<%= attribute.column_name %>', e.target.checked)}
|
|
99
|
-
/>
|
|
100
|
-
<% elsif input_type(attribute) == "number" -%>
|
|
101
|
-
<input
|
|
102
|
-
type="<%= input_type(attribute) %>"
|
|
103
|
-
name="<%= attribute.singular_name %>"
|
|
104
|
-
id="<%= attribute.singular_name %>"
|
|
105
|
-
value={data.<%= attribute.column_name %>}
|
|
106
|
-
onChange={(e) => setData('<%= attribute.column_name %>', parseInt(e.target.value))}
|
|
107
|
-
/>
|
|
108
|
-
<% else -%>
|
|
109
|
-
<input
|
|
110
|
-
type="<%= input_type(attribute) %>"
|
|
111
|
-
name="<%= attribute.singular_name %>"
|
|
112
|
-
id="<%= attribute.singular_name %>"
|
|
113
|
-
value={data.<%= attribute.column_name %>}
|
|
114
|
-
onChange={(e) => setData('<%= attribute.column_name %>', e.target.value)}
|
|
115
|
-
/>
|
|
116
|
-
<% end -%>
|
|
117
|
-
{errors.<%= attribute.column_name %> && (
|
|
118
|
-
<div style={{ color: 'red' }}>{errors.<%= attribute.column_name %>}</div>
|
|
119
|
-
)}
|
|
120
|
-
</div>
|
|
121
|
-
<% end -%>
|
|
122
|
-
<% end -%>
|
|
123
|
-
<div>
|
|
124
|
-
<button type="submit" disabled={processing}>
|
|
125
|
-
{submitText}
|
|
126
|
-
</button>
|
|
127
|
-
</div>
|
|
128
|
-
</form>
|
|
129
|
-
)
|
|
130
|
-
}
|
|
@@ -1,37 +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
|
-
<h1>Editing <%= human_name.downcase %></h1>
|
|
25
|
-
|
|
26
|
-
<Form
|
|
27
|
-
{<%= singular_table_name %>}
|
|
28
|
-
submitText="Update <%= human_name %>"
|
|
29
|
-
onSubmit={handleSubmit}
|
|
30
|
-
/>
|
|
31
|
-
|
|
32
|
-
<br />
|
|
33
|
-
|
|
34
|
-
<div>
|
|
35
|
-
<Link href={`<%= js_resource_path %>`}>Show this <%= human_name.downcase %></Link> |
|
|
36
|
-
<Link href="<%= js_resources_path %>">Back to <%= human_name.pluralize.downcase %></Link>
|
|
37
|
-
</div>
|
|
@@ -1,97 +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 onsubmit={handleSubmit}>
|
|
24
|
-
<% attributes.each do |attribute| -%>
|
|
25
|
-
<% if attribute.password_digest? -%>
|
|
26
|
-
<div>
|
|
27
|
-
<label for="password">Password</label>
|
|
28
|
-
<input
|
|
29
|
-
type="password"
|
|
30
|
-
name="password"
|
|
31
|
-
id="password"
|
|
32
|
-
bind:value={$form.password}
|
|
33
|
-
/>
|
|
34
|
-
{#if $form.errors.password}
|
|
35
|
-
<div class="error">{$form.errors.password.join(', ')}</div>
|
|
36
|
-
{/if}
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<div>
|
|
40
|
-
<label for="password_confirmation">Password confirmation</label>
|
|
41
|
-
<input
|
|
42
|
-
type="password"
|
|
43
|
-
name="password_confirmation"
|
|
44
|
-
id="password_confirmation"
|
|
45
|
-
bind:value={$form.password_confirmation}
|
|
46
|
-
/>
|
|
47
|
-
{#if $form.errors.password_confirmation}
|
|
48
|
-
<div class="error">{$form.errors.password_confirmation.join(', ')}</div>
|
|
49
|
-
{/if}
|
|
50
|
-
</div>
|
|
51
|
-
<% else -%>
|
|
52
|
-
<div>
|
|
53
|
-
<label for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
|
54
|
-
<% if input_type(attribute) == "text_area" -%>
|
|
55
|
-
<textarea name="<%= attribute.singular_name %>" id="<%= attribute.singular_name %>" bind:value={$form.<%= attribute.column_name %>}></textarea>
|
|
56
|
-
<% elsif attribute.attachment? -%>
|
|
57
|
-
<input
|
|
58
|
-
type="file"
|
|
59
|
-
name="<%= attribute.singular_name %>"
|
|
60
|
-
id="<%= attribute.singular_name %>"
|
|
61
|
-
oninput={(e) => ($form.<%= attribute.column_name %> = e.target.files[0])}
|
|
62
|
-
/>
|
|
63
|
-
<% elsif attribute.attachments? -%>
|
|
64
|
-
<input
|
|
65
|
-
type="file"
|
|
66
|
-
multiple
|
|
67
|
-
name="<%= attribute.singular_name %>[]"
|
|
68
|
-
id="<%= attribute.singular_name %>"
|
|
69
|
-
oninput={(e) => ($form.<%= attribute.column_name %> = Array.from(e.target.files))}
|
|
70
|
-
/>
|
|
71
|
-
<% else -%>
|
|
72
|
-
<input
|
|
73
|
-
type="<%= input_type(attribute) %>"
|
|
74
|
-
name="<%= attribute.singular_name %>"
|
|
75
|
-
id="<%= attribute.singular_name %>"
|
|
76
|
-
<%= input_type(attribute) == "checkbox" ? "bind:checked" : "bind:value" %>={$form.<%= attribute.column_name %>}
|
|
77
|
-
/>
|
|
78
|
-
<% end -%>
|
|
79
|
-
{#if $form.errors.<%= attribute.column_name %>}
|
|
80
|
-
<div class="error">{$form.errors.<%= attribute.column_name %>.join(', ')}</div>
|
|
81
|
-
{/if}
|
|
82
|
-
</div>
|
|
83
|
-
<% end -%>
|
|
84
|
-
<% end -%>
|
|
85
|
-
<div>
|
|
86
|
-
<button type="submit" disabled={$form.processing}>{submitText}</button>
|
|
87
|
-
</div>
|
|
88
|
-
</form>
|
|
89
|
-
|
|
90
|
-
<style>
|
|
91
|
-
label {
|
|
92
|
-
display: block;
|
|
93
|
-
}
|
|
94
|
-
.error {
|
|
95
|
-
color: red;
|
|
96
|
-
}
|
|
97
|
-
</style>
|
|
@@ -1,102 +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 onsubmit={handleSubmit}>
|
|
29
|
-
<% attributes.each do |attribute| -%>
|
|
30
|
-
<% if attribute.password_digest? -%>
|
|
31
|
-
<div>
|
|
32
|
-
<label for="password">Password</label>
|
|
33
|
-
<input
|
|
34
|
-
type="password"
|
|
35
|
-
name="password"
|
|
36
|
-
id="password"
|
|
37
|
-
bind:value={$form.password}
|
|
38
|
-
/>
|
|
39
|
-
{#if $form.errors.password}
|
|
40
|
-
<div class="error">{$form.errors.password}</div>
|
|
41
|
-
{/if}
|
|
42
|
-
</div>
|
|
43
|
-
|
|
44
|
-
<div>
|
|
45
|
-
<label for="password_confirmation">Password confirmation</label>
|
|
46
|
-
<input
|
|
47
|
-
type="password"
|
|
48
|
-
name="password_confirmation"
|
|
49
|
-
id="password_confirmation"
|
|
50
|
-
bind:value={$form.password_confirmation}
|
|
51
|
-
/>
|
|
52
|
-
{#if $form.errors.password_confirmation}
|
|
53
|
-
<div class="error">{$form.errors.password_confirmation}</div>
|
|
54
|
-
{/if}
|
|
55
|
-
</div>
|
|
56
|
-
<% else -%>
|
|
57
|
-
<div>
|
|
58
|
-
<label for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
|
|
59
|
-
<% if input_type(attribute) == "text_area" -%>
|
|
60
|
-
<textarea name="<%= attribute.singular_name %>" id="<%= attribute.singular_name %>" bind:value={$form.<%= attribute.column_name %>}></textarea>
|
|
61
|
-
<% elsif attribute.attachment? -%>
|
|
62
|
-
<input
|
|
63
|
-
type="file"
|
|
64
|
-
name="<%= attribute.singular_name %>"
|
|
65
|
-
id="<%= attribute.singular_name %>"
|
|
66
|
-
oninput={(e) => ($form.<%= attribute.column_name %> = ((e.target as HTMLInputElement).files || [])[0])}
|
|
67
|
-
/>
|
|
68
|
-
<% elsif attribute.attachments? -%>
|
|
69
|
-
<input
|
|
70
|
-
type="file"
|
|
71
|
-
multiple
|
|
72
|
-
name="<%= attribute.singular_name %>[]"
|
|
73
|
-
id="<%= attribute.singular_name %>"
|
|
74
|
-
oninput={(e) => ($form.<%= attribute.column_name %> = Array.from((e.target as HTMLInputElement).files || []))}
|
|
75
|
-
/>
|
|
76
|
-
<% else -%>
|
|
77
|
-
<input
|
|
78
|
-
type="<%= input_type(attribute) %>"
|
|
79
|
-
name="<%= attribute.singular_name %>"
|
|
80
|
-
id="<%= attribute.singular_name %>"
|
|
81
|
-
<%= input_type(attribute) == "checkbox" ? "bind:checked" : "bind:value" %>={$form.<%= attribute.column_name %>}
|
|
82
|
-
/>
|
|
83
|
-
<% end -%>
|
|
84
|
-
{#if $form.errors.<%= attribute.column_name %>}
|
|
85
|
-
<div class="error">{$form.errors.<%= attribute.column_name %>}</div>
|
|
86
|
-
{/if}
|
|
87
|
-
</div>
|
|
88
|
-
<% end -%>
|
|
89
|
-
<% end -%>
|
|
90
|
-
<div>
|
|
91
|
-
<button type="submit" disabled={$form.processing}>{submitText}</button>
|
|
92
|
-
</div>
|
|
93
|
-
</form>
|
|
94
|
-
|
|
95
|
-
<style>
|
|
96
|
-
label {
|
|
97
|
-
display: block;
|
|
98
|
-
}
|
|
99
|
-
.error {
|
|
100
|
-
color: red;
|
|
101
|
-
}
|
|
102
|
-
</style>
|
|
@@ -1,30 +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
|
-
<h1>New <%= human_name.downcase %></h1>
|
|
19
|
-
|
|
20
|
-
<Form
|
|
21
|
-
{<%= singular_table_name %>}
|
|
22
|
-
submitText="Create <%= human_name %>"
|
|
23
|
-
onSubmit={handleSubmit}
|
|
24
|
-
/>
|
|
25
|
-
|
|
26
|
-
<br />
|
|
27
|
-
|
|
28
|
-
<div>
|
|
29
|
-
<Link href="<%= js_resources_path %>">Back to <%= human_name.pluralize.downcase %></Link>
|
|
30
|
-
</div>
|
|
@@ -1,38 +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
|
-
<h1>Editing <%= human_name.downcase %></h1>
|
|
26
|
-
|
|
27
|
-
<Form
|
|
28
|
-
{<%= singular_table_name %>}
|
|
29
|
-
submitText="Update <%= human_name %>"
|
|
30
|
-
on:submit={handleSubmit}
|
|
31
|
-
/>
|
|
32
|
-
|
|
33
|
-
<br />
|
|
34
|
-
|
|
35
|
-
<div>
|
|
36
|
-
<Link href={`<%= js_resource_path %>`}>Show this <%= human_name.downcase %></Link> |
|
|
37
|
-
<Link href="<%= js_resources_path %>">Back to <%= human_name.pluralize.downcase %></Link>
|
|
38
|
-
</div>
|