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
|
@@ -16,15 +16,18 @@ createInertiaApp({
|
|
|
16
16
|
const pages = import.meta.glob('../pages/**/*.vue', {
|
|
17
17
|
eager: true,
|
|
18
18
|
})
|
|
19
|
-
|
|
19
|
+
const page = pages[`../pages/${name}.vue`]
|
|
20
|
+
if (!page) {
|
|
21
|
+
console.error(`Missing Inertia page component: '${name}.vue'`)
|
|
22
|
+
}
|
|
20
23
|
|
|
21
24
|
// To use a default layout, import the Layout component
|
|
22
25
|
// and use the following lines.
|
|
23
26
|
// see https://inertia-rails.dev/guide/pages#default-layouts
|
|
24
27
|
//
|
|
25
|
-
// const page = pages[`../pages/${name}.vue`]
|
|
26
28
|
// page.default.layout = page.default.layout || Layout
|
|
27
|
-
|
|
29
|
+
|
|
30
|
+
return page
|
|
28
31
|
},
|
|
29
32
|
|
|
30
33
|
setup({ el, App, props, plugin }) {
|
|
@@ -32,4 +35,28 @@ createInertiaApp({
|
|
|
32
35
|
.use(plugin)
|
|
33
36
|
.mount(el)
|
|
34
37
|
},
|
|
38
|
+
|
|
39
|
+
defaults: {
|
|
40
|
+
future: {
|
|
41
|
+
useDataInertiaHeadAttribute: true,
|
|
42
|
+
useDialogForErrorModal: true,
|
|
43
|
+
preserveEqualProps: true,
|
|
44
|
+
},
|
|
45
|
+
visitOptions: () => {
|
|
46
|
+
return { queryStringArrayFormat: "brackets" }
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
}).catch((error) => {
|
|
50
|
+
// This ensures this entrypoint is only loaded on Inertia pages
|
|
51
|
+
// by checking for the presence of the root element (#app by default).
|
|
52
|
+
// Feel free to remove this `catch` if you don't need it.
|
|
53
|
+
if (document.getElementById("app")) {
|
|
54
|
+
throw error
|
|
55
|
+
} else {
|
|
56
|
+
console.error(
|
|
57
|
+
"Missing root element.\n\n" +
|
|
58
|
+
"If you see this error, it probably means you loaded Inertia.js on non-Inertia pages.\n" +
|
|
59
|
+
'Consider moving <%= vite_javascript_tag "inertia" %> to the Inertia-specific layout instead.',
|
|
60
|
+
)
|
|
61
|
+
}
|
|
35
62
|
})
|
|
@@ -16,15 +16,18 @@ createInertiaApp({
|
|
|
16
16
|
const pages = import.meta.glob<DefineComponent>('../pages/**/*.vue', {
|
|
17
17
|
eager: true,
|
|
18
18
|
})
|
|
19
|
-
|
|
19
|
+
const page = pages[`../pages/${name}.vue`]
|
|
20
|
+
if (!page) {
|
|
21
|
+
console.error(`Missing Inertia page component: '${name}.vue'`)
|
|
22
|
+
}
|
|
20
23
|
|
|
21
24
|
// To use a default layout, import the Layout component
|
|
22
25
|
// and use the following lines.
|
|
23
26
|
// see https://inertia-rails.dev/guide/pages#default-layouts
|
|
24
27
|
//
|
|
25
|
-
// const page = pages[`../pages/${name}.vue`]
|
|
26
28
|
// page.default.layout = page.default.layout || Layout
|
|
27
|
-
|
|
29
|
+
|
|
30
|
+
return page
|
|
28
31
|
},
|
|
29
32
|
|
|
30
33
|
setup({ el, App, props, plugin }) {
|
|
@@ -32,4 +35,29 @@ createInertiaApp({
|
|
|
32
35
|
.use(plugin)
|
|
33
36
|
.mount(el)
|
|
34
37
|
},
|
|
38
|
+
|
|
39
|
+
defaults: {
|
|
40
|
+
future: {
|
|
41
|
+
useDataInertiaHeadAttribute: true,
|
|
42
|
+
useDialogForErrorModal: true,
|
|
43
|
+
preserveEqualProps: true,
|
|
44
|
+
},
|
|
45
|
+
visitOptions: () => {
|
|
46
|
+
return { queryStringArrayFormat: "brackets" }
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
}).catch((error) => {
|
|
50
|
+
// This ensures this entrypoint is only loaded on Inertia pages
|
|
51
|
+
// by checking for the presence of the root element (#app by default).
|
|
52
|
+
// Feel free to remove this `catch` if you don't need it.
|
|
53
|
+
if (document.getElementById("app")) {
|
|
54
|
+
throw error
|
|
55
|
+
} else {
|
|
56
|
+
console.error(
|
|
57
|
+
"Missing root element.\n\n" +
|
|
58
|
+
"If you see this error, it probably means you loaded Inertia.js on non-Inertia pages.\n" +
|
|
59
|
+
'Consider moving <%= vite_javascript_tag "inertia" %> to the Inertia-specific layout instead.',
|
|
60
|
+
)
|
|
61
|
+
}
|
|
35
62
|
})
|
|
63
|
+
|
|
@@ -18,7 +18,15 @@
|
|
|
18
18
|
"strict": true,
|
|
19
19
|
"noUnusedLocals": true,
|
|
20
20
|
"noUnusedParameters": true,
|
|
21
|
-
"noFallthroughCasesInSwitch": true
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
|
|
23
|
+
/* Aliases */
|
|
24
|
+
"baseUrl": ".",
|
|
25
|
+
"paths": {
|
|
26
|
+
"@/*": ["<%= js_destination_path %>/*"],
|
|
27
|
+
"~/*": ["<%= js_destination_path %>/*"]
|
|
28
|
+
}
|
|
22
29
|
},
|
|
30
|
+
|
|
23
31
|
"include": ["<%= js_destination_path %>/**/*.ts", "<%= js_destination_path %>/**/*.tsx", "<%= js_destination_path %>/**/*.vue"]
|
|
24
32
|
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
<% module_namespacing do -%>
|
|
2
|
-
class <%= controller_class_name %>Controller <
|
|
2
|
+
class <%= controller_class_name %>Controller < <%= parent_controller %>
|
|
3
3
|
before_action :set_<%= singular_table_name %>, only: %i[ show edit update destroy ]
|
|
4
4
|
|
|
5
5
|
<% if regular_class_path.any? -%>
|
|
6
6
|
wrap_parameters :<%= singular_table_name %>
|
|
7
7
|
|
|
8
8
|
<% end -%>
|
|
9
|
+
<% if parent_controller != 'InertiaController' -%>
|
|
9
10
|
inertia_share flash: -> { flash.to_hash }
|
|
10
11
|
|
|
12
|
+
<% end -%>
|
|
11
13
|
# GET <%= route_url %>
|
|
12
14
|
def index
|
|
13
15
|
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
|
14
|
-
render inertia:
|
|
16
|
+
render inertia: {
|
|
15
17
|
<%= plural_table_name %>: @<%= plural_table_name %>.map do |<%= singular_table_name %>|
|
|
16
18
|
<%= "serialize_#{singular_table_name}" %>(<%= singular_table_name %>)
|
|
17
19
|
end
|
|
@@ -20,7 +22,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
|
20
22
|
|
|
21
23
|
# GET <%= route_url %>/1
|
|
22
24
|
def show
|
|
23
|
-
render inertia:
|
|
25
|
+
render inertia: {
|
|
24
26
|
<%= singular_table_name %>: <%= "serialize_#{singular_table_name}" %>(@<%= singular_table_name %>)
|
|
25
27
|
}
|
|
26
28
|
end
|
|
@@ -28,14 +30,14 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
|
28
30
|
# GET <%= route_url %>/new
|
|
29
31
|
def new
|
|
30
32
|
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
|
31
|
-
render inertia:
|
|
33
|
+
render inertia: {
|
|
32
34
|
<%= singular_table_name %>: <%= "serialize_#{singular_table_name}" %>(@<%= singular_table_name %>)
|
|
33
35
|
}
|
|
34
36
|
end
|
|
35
37
|
|
|
36
38
|
# GET <%= route_url %>/1/edit
|
|
37
39
|
def edit
|
|
38
|
-
render inertia:
|
|
40
|
+
render inertia: {
|
|
39
41
|
<%= singular_table_name %>: <%= "serialize_#{singular_table_name}" %>(@<%= singular_table_name %>)
|
|
40
42
|
}
|
|
41
43
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
import Form from './
|
|
2
|
+
import Form from './form'
|
|
3
3
|
|
|
4
4
|
export default function Edit({ <%= singular_table_name %> }) {
|
|
5
5
|
return (
|
|
@@ -10,16 +10,13 @@ export default function Edit({ <%= singular_table_name %> }) {
|
|
|
10
10
|
|
|
11
11
|
<Form
|
|
12
12
|
<%= singular_table_name %>={<%= singular_table_name %>}
|
|
13
|
-
|
|
14
|
-
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
|
13
|
+
action={`<%= js_resource_path %>`}
|
|
15
14
|
<% if attributes.any?(&:attachments?) -%>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
15
|
+
method="post"
|
|
16
|
+
headers={{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }}
|
|
19
17
|
<% else -%>
|
|
20
|
-
|
|
18
|
+
method="patch"
|
|
21
19
|
<% end -%>
|
|
22
|
-
}}
|
|
23
20
|
submitText="Update <%= human_name %>"
|
|
24
21
|
/>
|
|
25
22
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
|
|
3
|
+
import Form from './form'
|
|
4
|
+
import type { <%= inertia_model_type %> } from './types'
|
|
4
5
|
|
|
5
6
|
interface EditProps {
|
|
6
7
|
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
@@ -15,16 +16,13 @@ export default function Edit({ <%= singular_table_name %> }: EditProps) {
|
|
|
15
16
|
|
|
16
17
|
<Form
|
|
17
18
|
<%= singular_table_name %>={<%= singular_table_name %>}
|
|
18
|
-
|
|
19
|
-
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
|
19
|
+
action={`<%= js_resource_path %>`}
|
|
20
20
|
<% if attributes.any?(&:attachments?) -%>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
21
|
+
method="post"
|
|
22
|
+
headers={{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }}
|
|
24
23
|
<% else -%>
|
|
25
|
-
|
|
24
|
+
method="patch"
|
|
26
25
|
<% end -%>
|
|
27
|
-
}}
|
|
28
26
|
submitText="Update <%= human_name %>"
|
|
29
27
|
/>
|
|
30
28
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Form as InertiaForm } from '@inertiajs/react'
|
|
2
|
+
|
|
3
|
+
export default function Form({ <%= singular_table_name %>, submitText, ...formProps }) {
|
|
4
|
+
return (
|
|
5
|
+
<InertiaForm
|
|
6
|
+
transform={data => ({ <%= singular_table_name %>: data })}
|
|
7
|
+
{...formProps}
|
|
8
|
+
>
|
|
9
|
+
{({ errors, processing }) => (
|
|
10
|
+
<>
|
|
11
|
+
<% attributes.each do |attribute| -%>
|
|
12
|
+
<% if attribute.password_digest? -%>
|
|
13
|
+
<div>
|
|
14
|
+
<label style={{ display: 'block' }} htmlFor="password">
|
|
15
|
+
Password
|
|
16
|
+
</label>
|
|
17
|
+
<input
|
|
18
|
+
type="password"
|
|
19
|
+
name="password"
|
|
20
|
+
id="password"
|
|
21
|
+
/>
|
|
22
|
+
{errors.password && (
|
|
23
|
+
<div style={{ color: 'red' }}>{errors.password.join(', ')}</div>
|
|
24
|
+
)}
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<div>
|
|
28
|
+
<label style={{ display: 'block' }} htmlFor="password_confirmation">
|
|
29
|
+
Password confirmation
|
|
30
|
+
</label>
|
|
31
|
+
<input
|
|
32
|
+
type="password"
|
|
33
|
+
name="password_confirmation"
|
|
34
|
+
id="password_confirmation"
|
|
35
|
+
/>
|
|
36
|
+
{errors.password_confirmation && (
|
|
37
|
+
<div style={{ color: 'red' }}>{errors.password_confirmation.join(', ')}</div>
|
|
38
|
+
)}
|
|
39
|
+
</div>
|
|
40
|
+
<% else -%>
|
|
41
|
+
<div>
|
|
42
|
+
<label style={{ display: 'block' }} htmlFor="<%= attribute.singular_name %>">
|
|
43
|
+
<%= attribute.human_name %>
|
|
44
|
+
</label>
|
|
45
|
+
<% if input_type(attribute) == "text_area" -%>
|
|
46
|
+
<textarea
|
|
47
|
+
name="<%= attribute.singular_name %>"
|
|
48
|
+
id="<%= attribute.singular_name %>"
|
|
49
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
50
|
+
/>
|
|
51
|
+
<% elsif attribute.attachment? -%>
|
|
52
|
+
<input
|
|
53
|
+
type="file"
|
|
54
|
+
name="<%= attribute.singular_name %>"
|
|
55
|
+
id="<%= attribute.singular_name %>"
|
|
56
|
+
/>
|
|
57
|
+
<% elsif attribute.attachments? -%>
|
|
58
|
+
<input
|
|
59
|
+
type="file"
|
|
60
|
+
multiple
|
|
61
|
+
name="<%= attribute.singular_name %>[]"
|
|
62
|
+
id="<%= attribute.singular_name %>"
|
|
63
|
+
/>
|
|
64
|
+
<% elsif input_type(attribute) == "checkbox" -%>
|
|
65
|
+
<input
|
|
66
|
+
type="<%= input_type(attribute) %>"
|
|
67
|
+
name="<%= attribute.singular_name %>"
|
|
68
|
+
id="<%= attribute.singular_name %>"
|
|
69
|
+
defaultChecked={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
70
|
+
/>
|
|
71
|
+
<% else -%>
|
|
72
|
+
<input
|
|
73
|
+
type="<%= input_type(attribute) %>"
|
|
74
|
+
name="<%= attribute.singular_name %>"
|
|
75
|
+
id="<%= attribute.singular_name %>"
|
|
76
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
77
|
+
/>
|
|
78
|
+
<% end -%>
|
|
79
|
+
{errors.<%= attribute.column_name %> && (
|
|
80
|
+
<div style={{ color: 'red' }}>{errors.<%= attribute.column_name %>.join(', ')}</div>
|
|
81
|
+
)}
|
|
82
|
+
</div>
|
|
83
|
+
<% end -%>
|
|
84
|
+
<% end -%>
|
|
85
|
+
<div>
|
|
86
|
+
<button type="submit" disabled={processing}>
|
|
87
|
+
{submitText}
|
|
88
|
+
</button>
|
|
89
|
+
</div>
|
|
90
|
+
</>
|
|
91
|
+
)}
|
|
92
|
+
</InertiaForm>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Form as InertiaForm } from '@inertiajs/react'
|
|
2
|
+
import { type ComponentProps } from 'react'
|
|
3
|
+
|
|
4
|
+
import type { <%= inertia_model_type %> } from './types'
|
|
5
|
+
|
|
6
|
+
type FormProps = Omit<ComponentProps<typeof InertiaForm>, 'children'> & {
|
|
7
|
+
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
8
|
+
submitText: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default function Form({ <%= singular_table_name %>, submitText, ...formProps }: FormProps) {
|
|
12
|
+
return (
|
|
13
|
+
<InertiaForm
|
|
14
|
+
transform={data => ({ <%= singular_table_name %>: data })}
|
|
15
|
+
{...formProps}
|
|
16
|
+
>
|
|
17
|
+
{({ errors, processing }) => (
|
|
18
|
+
<>
|
|
19
|
+
<% attributes.each do |attribute| -%>
|
|
20
|
+
<% if attribute.password_digest? -%>
|
|
21
|
+
<div>
|
|
22
|
+
<label style={{ display: 'block' }} htmlFor="password">
|
|
23
|
+
Password
|
|
24
|
+
</label>
|
|
25
|
+
<input
|
|
26
|
+
type="password"
|
|
27
|
+
name="password"
|
|
28
|
+
id="password"
|
|
29
|
+
/>
|
|
30
|
+
{errors.password && (
|
|
31
|
+
<div style={{ color: 'red' }}>{errors.password}</div>
|
|
32
|
+
)}
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<div>
|
|
36
|
+
<label style={{ display: 'block' }} htmlFor="password_confirmation">
|
|
37
|
+
Password confirmation
|
|
38
|
+
</label>
|
|
39
|
+
<input
|
|
40
|
+
type="password"
|
|
41
|
+
name="password_confirmation"
|
|
42
|
+
id="password_confirmation"
|
|
43
|
+
/>
|
|
44
|
+
{errors.password_confirmation && (
|
|
45
|
+
<div style={{ color: 'red' }}>{errors.password_confirmation}</div>
|
|
46
|
+
)}
|
|
47
|
+
</div>
|
|
48
|
+
<% else -%>
|
|
49
|
+
<div>
|
|
50
|
+
<label style={{ display: 'block' }} htmlFor="<%= attribute.singular_name %>">
|
|
51
|
+
<%= attribute.human_name %>
|
|
52
|
+
</label>
|
|
53
|
+
<% if input_type(attribute) == "text_area" -%>
|
|
54
|
+
<textarea
|
|
55
|
+
name="<%= attribute.singular_name %>"
|
|
56
|
+
id="<%= attribute.singular_name %>"
|
|
57
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
58
|
+
/>
|
|
59
|
+
<% elsif attribute.attachment? -%>
|
|
60
|
+
<input
|
|
61
|
+
type="file"
|
|
62
|
+
name="<%= attribute.singular_name %>"
|
|
63
|
+
id="<%= attribute.singular_name %>"
|
|
64
|
+
/>
|
|
65
|
+
<% elsif attribute.attachments? -%>
|
|
66
|
+
<input
|
|
67
|
+
type="file"
|
|
68
|
+
multiple
|
|
69
|
+
name="<%= attribute.singular_name %>[]"
|
|
70
|
+
id="<%= attribute.singular_name %>"
|
|
71
|
+
/>
|
|
72
|
+
<% elsif input_type(attribute) == "checkbox" -%>
|
|
73
|
+
<input
|
|
74
|
+
type="<%= input_type(attribute) %>"
|
|
75
|
+
name="<%= attribute.singular_name %>"
|
|
76
|
+
id="<%= attribute.singular_name %>"
|
|
77
|
+
defaultChecked={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
78
|
+
/>
|
|
79
|
+
<% elsif input_type(attribute) == "number" -%>
|
|
80
|
+
<input
|
|
81
|
+
type="<%= input_type(attribute) %>"
|
|
82
|
+
name="<%= attribute.singular_name %>"
|
|
83
|
+
id="<%= attribute.singular_name %>"
|
|
84
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
85
|
+
/>
|
|
86
|
+
<% else -%>
|
|
87
|
+
<input
|
|
88
|
+
type="<%= input_type(attribute) %>"
|
|
89
|
+
name="<%= attribute.singular_name %>"
|
|
90
|
+
id="<%= attribute.singular_name %>"
|
|
91
|
+
defaultValue={<%= singular_table_name %>.<%= attribute.column_name %>}
|
|
92
|
+
/>
|
|
93
|
+
<% end -%>
|
|
94
|
+
{errors.<%= attribute.column_name %> && (
|
|
95
|
+
<div style={{ color: 'red' }}>{errors.<%= attribute.column_name %>}</div>
|
|
96
|
+
)}
|
|
97
|
+
</div>
|
|
98
|
+
<% end -%>
|
|
99
|
+
<% end -%>
|
|
100
|
+
<div>
|
|
101
|
+
<button type="submit" disabled={processing}>
|
|
102
|
+
{submitText}
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
</>
|
|
106
|
+
)}
|
|
107
|
+
</InertiaForm>
|
|
108
|
+
)
|
|
109
|
+
}
|
data/lib/generators/inertia_templates/scaffold/templates/react/{Index.jsx.tt → index.jsx.tt}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
import <%= inertia_component_name %> from './<%=
|
|
2
|
+
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
|
|
4
4
|
export default function Index({ <%= plural_table_name %>, flash }) {
|
|
5
5
|
return (
|
data/lib/generators/inertia_templates/scaffold/templates/react/{Index.tsx.tt → index.tsx.tt}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
import <%= inertia_component_name %> from './<%=
|
|
2
|
+
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
import { <%= inertia_model_type %> } from './types'
|
|
4
4
|
|
|
5
5
|
interface IndexProps {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
import Form from './
|
|
2
|
+
import Form from './form'
|
|
3
3
|
|
|
4
4
|
export default function New({ <%= singular_table_name %> }) {
|
|
5
5
|
return (
|
|
@@ -10,10 +10,8 @@ export default function New({ <%= singular_table_name %> }) {
|
|
|
10
10
|
|
|
11
11
|
<Form
|
|
12
12
|
<%= singular_table_name %>={<%= singular_table_name %>}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
form.post('<%= js_resources_path %>')
|
|
16
|
-
}}
|
|
13
|
+
action="<%= js_resources_path %>"
|
|
14
|
+
method="post"
|
|
17
15
|
submitText="Create <%= human_name %>"
|
|
18
16
|
/>
|
|
19
17
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
|
|
3
|
-
import
|
|
2
|
+
|
|
3
|
+
import Form from './form'
|
|
4
|
+
import type { <%= inertia_model_type %> } from './types'
|
|
4
5
|
|
|
5
6
|
interface NewProps {
|
|
6
7
|
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
@@ -15,10 +16,8 @@ export default function New({ <%= singular_table_name %> }: NewProps) {
|
|
|
15
16
|
|
|
16
17
|
<Form
|
|
17
18
|
<%= singular_table_name %>={<%= singular_table_name %>}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
form.post('<%= js_resources_path %>')
|
|
21
|
-
}}
|
|
19
|
+
action="<%= js_resources_path %>"
|
|
20
|
+
method="post"
|
|
22
21
|
submitText="Create <%= human_name %>"
|
|
23
22
|
/>
|
|
24
23
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
import <%= inertia_component_name %> from './<%=
|
|
2
|
+
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
|
|
4
4
|
export default function Show({ <%= singular_table_name %>, flash }) {
|
|
5
5
|
return (
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Head, Link } from '@inertiajs/react'
|
|
2
|
-
import <%= inertia_component_name %> from './<%=
|
|
2
|
+
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
import { <%= inertia_model_type %> } from './types'
|
|
4
4
|
|
|
5
5
|
interface ShowProps {
|
data/lib/generators/inertia_templates/scaffold/templates/svelte/{Edit.svelte.tt → edit.svelte.tt}
RENAMED
|
@@ -1,19 +1,9 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import Form from './Form.svelte'
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
import Form from './form.svelte'
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
|
9
|
-
<% if attributes.any?(&:attachments?) -%>
|
|
10
|
-
form.post(`<%= js_resource_path %>`, {
|
|
11
|
-
headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
|
|
12
|
-
})
|
|
13
|
-
<% else -%>
|
|
14
|
-
form.patch(`<%= js_resource_path %>`)
|
|
15
|
-
<% end -%>
|
|
16
|
-
}
|
|
6
|
+
let { <%= singular_table_name %> } = $props()
|
|
17
7
|
</script>
|
|
18
8
|
|
|
19
9
|
<svelte:head>
|
|
@@ -25,7 +15,13 @@
|
|
|
25
15
|
<Form
|
|
26
16
|
{<%= singular_table_name %>}
|
|
27
17
|
submitText="Update <%= human_name %>"
|
|
28
|
-
|
|
18
|
+
action={`<%= js_resource_path %>`}
|
|
19
|
+
<% if attributes.any?(&:attachments?) -%>
|
|
20
|
+
method="post"
|
|
21
|
+
headers={{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }}
|
|
22
|
+
<% else -%>
|
|
23
|
+
method="patch"
|
|
24
|
+
<% end -%>
|
|
29
25
|
/>
|
|
30
26
|
|
|
31
27
|
<br />
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { Link } from '@inertiajs/svelte'
|
|
3
|
-
import Form from './Form.svelte'
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
import type { <%= inertia_model_type %> } from './types'
|
|
5
|
+
import Form from './form.svelte'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const { form } = e.detail
|
|
9
|
-
form.transform((data) => ({ <%= singular_table_name %>: data }))
|
|
10
|
-
<% if attributes.any?(&:attachments?) -%>
|
|
11
|
-
form.post(`<%= js_resource_path %>`, {
|
|
12
|
-
headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
|
|
13
|
-
})
|
|
14
|
-
<% else -%>
|
|
15
|
-
form.patch(`<%= js_resource_path %>`)
|
|
16
|
-
<% end -%>
|
|
17
|
-
}
|
|
7
|
+
let { <%= singular_table_name %> } = $props<{ <%= singular_table_name %>: <%= inertia_model_type %> }>()
|
|
18
8
|
</script>
|
|
19
9
|
|
|
20
10
|
<svelte:head>
|
|
@@ -26,7 +16,13 @@
|
|
|
26
16
|
<Form
|
|
27
17
|
{<%= singular_table_name %>}
|
|
28
18
|
submitText="Update <%= human_name %>"
|
|
29
|
-
|
|
19
|
+
action={`<%= js_resource_path %>`}
|
|
20
|
+
<% if attributes.any?(&:attachments?) -%>
|
|
21
|
+
method="post"
|
|
22
|
+
headers={{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }}
|
|
23
|
+
<% else -%>
|
|
24
|
+
method="patch"
|
|
25
|
+
<% end -%>
|
|
30
26
|
/>
|
|
31
27
|
|
|
32
28
|
<br />
|