inertia_rails 3.14.0 → 3.16.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 +13 -0
- data/app/views/inertia.html.erb +1 -1
- data/lib/generators/inertia/install/helpers.rb +9 -0
- data/lib/generators/inertia/install/install_generator.rb +11 -26
- data/lib/generators/inertia/install/templates/inertia_controller.rb +3 -1
- data/lib/generators/inertia/install/templates/initializer.rb +1 -0
- data/lib/generators/inertia/install/templates/react/InertiaExample.tsx +1 -1
- data/lib/generators/inertia/install/templates/react/inertia.jsx +1 -0
- data/lib/generators/inertia/install/templates/react/inertia.tsx +1 -0
- data/lib/generators/inertia/install/templates/react/types/globals.d.ts +2 -1
- data/lib/generators/inertia/install/templates/react/types/index.ts +2 -4
- data/lib/generators/inertia/install/templates/svelte/inertia.ts +1 -0
- data/lib/generators/inertia/install/templates/svelte/types/globals.d.ts +2 -1
- data/lib/generators/inertia/install/templates/svelte/types/index.ts +2 -4
- data/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue +1 -1
- data/lib/generators/inertia/install/templates/vue/inertia.ts +1 -0
- data/lib/generators/inertia/install/templates/vue/types/globals.d.ts +2 -1
- data/lib/generators/inertia/install/templates/vue/types/index.ts +2 -4
- data/lib/generators/inertia/scaffold_controller/templates/controller.rb.tt +0 -4
- data/lib/generators/inertia_templates/scaffold/templates/react/index.jsx.tt +4 -2
- data/lib/generators/inertia_templates/scaffold/templates/react/index.tsx.tt +4 -3
- data/lib/generators/inertia_templates/scaffold/templates/react/show.jsx.tt +4 -2
- data/lib/generators/inertia_templates/scaffold/templates/react/show.tsx.tt +4 -3
- data/lib/generators/inertia_templates/scaffold/templates/svelte/index.svelte.tt +4 -4
- data/lib/generators/inertia_templates/scaffold/templates/svelte/index.ts.svelte.tt +4 -5
- data/lib/generators/inertia_templates/scaffold/templates/svelte/show.svelte.tt +4 -4
- data/lib/generators/inertia_templates/scaffold/templates/svelte/show.ts.svelte.tt +4 -5
- data/lib/generators/inertia_templates/scaffold/templates/vue/index.ts.vue.tt +3 -3
- data/lib/generators/inertia_templates/scaffold/templates/vue/index.vue.tt +3 -2
- data/lib/generators/inertia_templates/scaffold/templates/vue/show.ts.vue.tt +3 -3
- data/lib/generators/inertia_templates/scaffold/templates/vue/show.vue.tt +3 -2
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/edit.jsx.tt +4 -4
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/edit.tsx.tt +4 -4
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/index.jsx.tt +4 -2
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/index.tsx.tt +4 -3
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/show.jsx.tt +4 -2
- data/lib/generators/inertia_tw_templates/scaffold/templates/react/show.tsx.tt +4 -3
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/index.svelte.tt +4 -4
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/index.ts.svelte.tt +4 -5
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/show.svelte.tt +4 -4
- data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/show.ts.svelte.tt +4 -5
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/index.ts.vue.tt +3 -3
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/index.vue.tt +3 -2
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/show.ts.vue.tt +3 -3
- data/lib/generators/inertia_tw_templates/scaffold/templates/vue/show.vue.tt +3 -2
- data/lib/inertia_rails/base_prop.rb +1 -1
- data/lib/inertia_rails/configuration.rb +10 -0
- data/lib/inertia_rails/controller.rb +12 -1
- data/lib/inertia_rails/defer_prop.rb +1 -0
- data/lib/inertia_rails/engine.rb +6 -0
- data/lib/inertia_rails/flash_extension.rb +63 -0
- data/lib/inertia_rails/generators/helper.rb +0 -8
- data/lib/inertia_rails/helper.rb +14 -0
- data/lib/inertia_rails/inertia_rails.rb +10 -4
- data/lib/inertia_rails/merge_prop.rb +1 -0
- data/lib/inertia_rails/middleware.rb +1 -1
- data/lib/inertia_rails/once_prop.rb +12 -0
- data/lib/inertia_rails/optional_prop.rb +1 -0
- data/lib/inertia_rails/prop_onceable.rb +39 -0
- data/lib/inertia_rails/renderer.rb +55 -13
- data/lib/inertia_rails/version.rb +1 -1
- data/lib/patches/debug_exceptions.rb +8 -4
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dde0b293a9be9f560b828392e23a40cfb5ecb72f6c912e48660660640c211c9a
|
|
4
|
+
data.tar.gz: f72cce31fc538e2985f0be5c938c603ecfaeb03d0b6bafc682d32049c05f514f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b4b064f174ceb0122be41945f045234d7caba21327bc750b9dd9bae49f5c14b17839a707e463b34f9ccaf0646f93f55b71d76fd22b1d31a11a6e12c324ed9afe
|
|
7
|
+
data.tar.gz: b38aa3f36e089e46a1f4d827ef32f9e1e12234e5490490cdc179cf90200bb2c6a7b7cbc66492d83df2a7d990b955ccf5e641f8718808a0391c1342ffa5256e1d
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [3.16.0] - 2025-12-30
|
|
8
|
+
|
|
9
|
+
* Fix optional once props (@skryukov)
|
|
10
|
+
* Support for new Flash API in Inertia.js page object (@skryukov)
|
|
11
|
+
* Generator improvements (@skryukov)
|
|
12
|
+
* Fix debug exceptions patch for Rails 8.2 (@crobbo)
|
|
13
|
+
|
|
14
|
+
## [3.15.0] - 2025-12-11
|
|
15
|
+
|
|
16
|
+
* Support for rendering initial page data in a script tag (@skryukov)
|
|
17
|
+
* Once props support (@skryukov)
|
|
18
|
+
* Fix file references in TypeScript templates (@bigmasonwang)
|
|
19
|
+
|
|
7
20
|
## [3.14.0] - 2025-11-27
|
|
8
21
|
|
|
9
22
|
Lots of quality of life improvements!
|
data/app/views/inertia.html.erb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
<%= inertia_root(page: page) %>
|
|
@@ -31,6 +31,15 @@ module Inertia
|
|
|
31
31
|
File.join(destination_root, *relative_path)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
+
def update_package_json
|
|
35
|
+
package_json_path = file_path('package.json')
|
|
36
|
+
package_json = JSON.parse(File.read(package_json_path))
|
|
37
|
+
|
|
38
|
+
yield package_json
|
|
39
|
+
|
|
40
|
+
File.write(package_json_path, "#{JSON.pretty_generate(package_json)}\n")
|
|
41
|
+
end
|
|
42
|
+
|
|
34
43
|
# Interactivity Helpers
|
|
35
44
|
def ask(*)
|
|
36
45
|
unless options[:interactive]
|
|
@@ -49,11 +49,6 @@ module Inertia
|
|
|
49
49
|
def install
|
|
50
50
|
say "Installing Inertia's Rails adapter"
|
|
51
51
|
|
|
52
|
-
if inertia_resolved_version.version == '0'
|
|
53
|
-
say_error "Could not find the Inertia.js package version #{options[:inertia_version]}.", :red
|
|
54
|
-
exit(false)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
52
|
install_vite unless ruby_vite_installed?
|
|
58
53
|
|
|
59
54
|
install_typescript if typescript?
|
|
@@ -137,14 +132,6 @@ module Inertia
|
|
|
137
132
|
|
|
138
133
|
def install_typescript
|
|
139
134
|
say 'Adding TypeScript support'
|
|
140
|
-
if svelte? && inertia_resolved_version.release < Gem::Version.new('1.3.0')
|
|
141
|
-
say 'WARNING: @inertiajs/svelte < 1.3.0 does not support TypeScript ' \
|
|
142
|
-
"(resolved version: #{inertia_resolved_version}).",
|
|
143
|
-
:yellow
|
|
144
|
-
say 'Skipping TypeScript support for @inertiajs/svelte', :yellow
|
|
145
|
-
@typescript = false
|
|
146
|
-
return
|
|
147
|
-
end
|
|
148
135
|
|
|
149
136
|
add_dependencies(*FRAMEWORKS[framework]['packages_ts'])
|
|
150
137
|
|
|
@@ -165,12 +152,16 @@ module Inertia
|
|
|
165
152
|
end
|
|
166
153
|
|
|
167
154
|
say 'Adding TypeScript check scripts to package.json'
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
155
|
+
update_package_json do |package_json|
|
|
156
|
+
package_json['scripts'] ||= {}
|
|
157
|
+
package_json['scripts']['check'] =
|
|
158
|
+
if svelte?
|
|
159
|
+
'svelte-check --tsconfig ./tsconfig.json && tsc -p tsconfig.node.json'
|
|
160
|
+
elsif react?
|
|
161
|
+
'tsc -p tsconfig.app.json && tsc -p tsconfig.node.json'
|
|
162
|
+
elsif vue?
|
|
163
|
+
'vue-tsc -p tsconfig.app.json && tsc -p tsconfig.node.json'
|
|
164
|
+
end
|
|
174
165
|
end
|
|
175
166
|
end
|
|
176
167
|
|
|
@@ -225,6 +216,7 @@ module Inertia
|
|
|
225
216
|
end
|
|
226
217
|
if (capture = run('bundle exec vite install', capture: !verbose?))
|
|
227
218
|
rename_application_js_to_ts if typescript?
|
|
219
|
+
run('bundle binstub vite_ruby', capture: !verbose?) if File.exist?(file_path('bin/vite'))
|
|
228
220
|
say 'Vite Rails successfully installed', :green
|
|
229
221
|
else
|
|
230
222
|
say capture
|
|
@@ -325,13 +317,6 @@ module Inertia
|
|
|
325
317
|
"#{tag} #{filename}"
|
|
326
318
|
end
|
|
327
319
|
|
|
328
|
-
def inertia_resolved_version
|
|
329
|
-
package = "@inertiajs/core@#{options[:inertia_version]}"
|
|
330
|
-
@inertia_resolved_version ||= Gem::Version.new(
|
|
331
|
-
`npm show #{package} version --json | tail -n2 | head -n1 | tr -d '", '`.strip
|
|
332
|
-
)
|
|
333
|
-
end
|
|
334
|
-
|
|
335
320
|
def verbose?
|
|
336
321
|
options[:verbose]
|
|
337
322
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class InertiaController < ApplicationController
|
|
4
|
-
|
|
4
|
+
# Share data with all Inertia responses
|
|
5
|
+
# see https://inertia-rails.dev/guide/shared-data
|
|
6
|
+
# inertia_share user: -> { Current.user&.as_json(only: [:id, :name, :email]) }
|
|
5
7
|
end
|
|
@@ -34,7 +34,7 @@ export default function InertiaExample(
|
|
|
34
34
|
<div className={cs.footer}>
|
|
35
35
|
<div className={cs.card}>
|
|
36
36
|
<p>
|
|
37
|
-
Edit <code><%= js_destination_path %>/pages/inertia_example/index.
|
|
37
|
+
Edit <code><%= js_destination_path %>/pages/inertia_example/index.tsx</code> and save to test <abbr title="Hot Module Replacement">HMR</abbr>.
|
|
38
38
|
</p>
|
|
39
39
|
</div>
|
|
40
40
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { SharedProps } from '@/types'
|
|
1
|
+
import type { FlashData, SharedProps } from '@/types'
|
|
2
2
|
|
|
3
3
|
declare module '@inertiajs/core' {
|
|
4
4
|
export interface InertiaConfig {
|
|
5
5
|
sharedPageProps: SharedProps
|
|
6
|
+
flashDataType: FlashData
|
|
6
7
|
errorValueType: string[]
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { SharedProps } from '@/types'
|
|
1
|
+
import type { FlashData, SharedProps } from '@/types'
|
|
2
2
|
|
|
3
3
|
declare module '@inertiajs/core' {
|
|
4
4
|
export interface InertiaConfig {
|
|
5
5
|
sharedPageProps: SharedProps
|
|
6
|
+
flashDataType: FlashData
|
|
6
7
|
errorValueType: string[]
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<div class="footer">
|
|
18
18
|
<div class="card">
|
|
19
19
|
<p>
|
|
20
|
-
Edit <code><%= js_destination_path %>/pages/inertia_example/index.
|
|
20
|
+
Edit <code><%= js_destination_path %>/pages/inertia_example/index.vue</code> and save to test <abbr title="Hot Module Replacement">HMR</abbr>.
|
|
21
21
|
</p>
|
|
22
22
|
</div>
|
|
23
23
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { SharedProps } from '@/types'
|
|
1
|
+
import type { FlashData, SharedProps } from '@/types'
|
|
2
2
|
|
|
3
3
|
declare module '@inertiajs/core' {
|
|
4
4
|
export interface InertiaConfig {
|
|
5
5
|
sharedPageProps: SharedProps
|
|
6
|
+
flashDataType: FlashData
|
|
6
7
|
errorValueType: string[]
|
|
7
8
|
}
|
|
8
9
|
}
|
|
@@ -5,10 +5,6 @@ class <%= controller_class_name %>Controller < <%= parent_controller %>
|
|
|
5
5
|
<% if regular_class_path.any? -%>
|
|
6
6
|
wrap_parameters :<%= singular_table_name %>
|
|
7
7
|
|
|
8
|
-
<% end -%>
|
|
9
|
-
<% if parent_controller != 'InertiaController' -%>
|
|
10
|
-
inertia_share flash: -> { flash.to_hash }
|
|
11
|
-
|
|
12
8
|
<% end -%>
|
|
13
9
|
# GET <%= route_url %>
|
|
14
10
|
def index
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Head, Link } from '@inertiajs/react'
|
|
1
|
+
import { Head, Link, usePage } from '@inertiajs/react'
|
|
2
2
|
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
|
|
4
|
-
export default function Index({ <%= plural_table_name
|
|
4
|
+
export default function Index({ <%= plural_table_name %> }) {
|
|
5
|
+
const { flash } = usePage()
|
|
6
|
+
|
|
5
7
|
return (
|
|
6
8
|
<>
|
|
7
9
|
<Head title="<%= human_name.pluralize %>" />
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Head, Link } from '@inertiajs/react'
|
|
1
|
+
import { Head, Link, usePage } from '@inertiajs/react'
|
|
2
2
|
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
import { <%= inertia_model_type %> } from './types'
|
|
4
4
|
|
|
5
5
|
interface IndexProps {
|
|
6
6
|
<%= plural_table_name %>: <%= inertia_model_type %>[]
|
|
7
|
-
flash: { notice?: string }
|
|
8
7
|
}
|
|
9
8
|
|
|
10
|
-
export default function Index({ <%= plural_table_name
|
|
9
|
+
export default function Index({ <%= plural_table_name %> }: IndexProps) {
|
|
10
|
+
const { flash } = usePage()
|
|
11
|
+
|
|
11
12
|
return (
|
|
12
13
|
<>
|
|
13
14
|
<Head title="<%= human_name.pluralize %>" />
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Head, Link } from '@inertiajs/react'
|
|
1
|
+
import { Head, Link, usePage } from '@inertiajs/react'
|
|
2
2
|
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
|
|
4
|
-
export default function Show({ <%= singular_table_name
|
|
4
|
+
export default function Show({ <%= singular_table_name %> }) {
|
|
5
|
+
const { flash } = usePage()
|
|
6
|
+
|
|
5
7
|
return (
|
|
6
8
|
<>
|
|
7
9
|
<Head title={`<%= human_name %> #${<%= singular_table_name %>.id}`} />
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Head, Link } from '@inertiajs/react'
|
|
1
|
+
import { Head, Link, usePage } from '@inertiajs/react'
|
|
2
2
|
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
import { <%= inertia_model_type %> } from './types'
|
|
4
4
|
|
|
5
5
|
interface ShowProps {
|
|
6
6
|
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
7
|
-
flash: { notice?: string }
|
|
8
7
|
}
|
|
9
8
|
|
|
10
|
-
export default function Show({ <%= singular_table_name
|
|
9
|
+
export default function Show({ <%= singular_table_name %> }: ShowProps) {
|
|
10
|
+
const { flash } = usePage()
|
|
11
|
+
|
|
11
12
|
return (
|
|
12
13
|
<>
|
|
13
14
|
<Head title={`<%= human_name %> #${<%= singular_table_name %>.id}`} />
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { Link } from '@inertiajs/svelte'
|
|
2
|
+
import { Link, page } from '@inertiajs/svelte'
|
|
3
3
|
import <%= inertia_component_name %> from './<%= singular_name %>.svelte'
|
|
4
4
|
|
|
5
|
-
let { <%= plural_table_name
|
|
5
|
+
let { <%= plural_table_name %> } = $props()
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<svelte:head>
|
|
9
9
|
<title><%= human_name.pluralize %></title>
|
|
10
10
|
</svelte:head>
|
|
11
11
|
|
|
12
|
-
{#if flash.notice}
|
|
13
|
-
<p class="notice">{flash.notice}</p>
|
|
12
|
+
{#if $page.flash.notice}
|
|
13
|
+
<p class="notice">{$page.flash.notice}</p>
|
|
14
14
|
{/if}
|
|
15
15
|
|
|
16
16
|
<h1><%= human_name.pluralize %></h1>
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { Link } from '@inertiajs/svelte'
|
|
2
|
+
import { Link, page } from '@inertiajs/svelte'
|
|
3
3
|
import <%= inertia_component_name %> from './<%= singular_name %>.svelte'
|
|
4
4
|
import type { <%= inertia_model_type %> } from './types'
|
|
5
5
|
|
|
6
|
-
let { <%= plural_table_name
|
|
6
|
+
let { <%= plural_table_name %> } = $props<{
|
|
7
7
|
<%= plural_table_name %>: <%= inertia_model_type %>[]
|
|
8
|
-
flash: { notice?: string }
|
|
9
8
|
}>()
|
|
10
9
|
</script>
|
|
11
10
|
|
|
@@ -13,8 +12,8 @@
|
|
|
13
12
|
<title><%= human_name.pluralize %></title>
|
|
14
13
|
</svelte:head>
|
|
15
14
|
|
|
16
|
-
{#if flash.notice}
|
|
17
|
-
<p class="notice">{flash.notice}</p>
|
|
15
|
+
{#if $page.flash.notice}
|
|
16
|
+
<p class="notice">{$page.flash.notice}</p>
|
|
18
17
|
{/if}
|
|
19
18
|
|
|
20
19
|
<h1><%= human_name.pluralize %></h1>
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { Link } from '@inertiajs/svelte'
|
|
2
|
+
import { Link, page } from '@inertiajs/svelte'
|
|
3
3
|
import <%= inertia_component_name %> from './<%= singular_name %>.svelte'
|
|
4
4
|
|
|
5
|
-
let { <%= singular_table_name
|
|
5
|
+
let { <%= singular_table_name %> } = $props()
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<svelte:head>
|
|
9
9
|
<title><%= human_name %> #{<%= singular_table_name %>.id}</title>
|
|
10
10
|
</svelte:head>
|
|
11
11
|
|
|
12
|
-
{#if flash.notice}
|
|
13
|
-
<p class="notice">{flash.notice}</p>
|
|
12
|
+
{#if $page.flash.notice}
|
|
13
|
+
<p class="notice">{$page.flash.notice}</p>
|
|
14
14
|
{/if}
|
|
15
15
|
|
|
16
16
|
<h1><%= human_name %> #{<%= singular_table_name %>.id}</h1>
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { Link } from '@inertiajs/svelte'
|
|
2
|
+
import { Link, page } from '@inertiajs/svelte'
|
|
3
3
|
import <%= inertia_component_name %> from './<%= singular_name %>.svelte'
|
|
4
4
|
import type { <%= inertia_model_type %> } from './types'
|
|
5
5
|
|
|
6
|
-
let { <%= singular_table_name
|
|
6
|
+
let { <%= singular_table_name %> } = $props<{
|
|
7
7
|
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
8
|
-
flash: { notice?: string }
|
|
9
8
|
}>()
|
|
10
9
|
</script>
|
|
11
10
|
|
|
@@ -13,8 +12,8 @@
|
|
|
13
12
|
<title><%= human_name %> #{<%= singular_table_name %>.id}</title>
|
|
14
13
|
</svelte:head>
|
|
15
14
|
|
|
16
|
-
{#if flash.notice}
|
|
17
|
-
<p class="notice">{flash.notice}</p>
|
|
15
|
+
{#if $page.flash.notice}
|
|
16
|
+
<p class="notice">{$page.flash.notice}</p>
|
|
18
17
|
{/if}
|
|
19
18
|
|
|
20
19
|
<h1><%= human_name %> #{<%= singular_table_name %>.id}</h1>
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
</template>
|
|
19
19
|
|
|
20
20
|
<script setup lang="ts">
|
|
21
|
-
import { Head, Link } from '@inertiajs/vue3'
|
|
21
|
+
import { Head, Link, usePage } from '@inertiajs/vue3'
|
|
22
22
|
import <%= inertia_component_name %> from './<%= singular_name %>.vue'
|
|
23
23
|
import { <%= inertia_model_type %> } from './types'
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
defineProps<{
|
|
26
26
|
<%= plural_table_name %>: <%= inertia_model_type %>[]
|
|
27
|
-
flash: { notice?: string }
|
|
28
27
|
}>()
|
|
28
|
+
const { flash } = usePage()
|
|
29
29
|
</script>
|
|
30
30
|
|
|
31
31
|
<style scoped>
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
</template>
|
|
19
19
|
|
|
20
20
|
<script setup>
|
|
21
|
-
import { Head, Link } from '@inertiajs/vue3'
|
|
21
|
+
import { Head, Link, usePage } from '@inertiajs/vue3'
|
|
22
22
|
import <%= inertia_component_name %> from './<%= singular_name %>.vue'
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
defineProps(['<%= plural_table_name %>'])
|
|
25
|
+
const { flash } = usePage()
|
|
25
26
|
</script>
|
|
26
27
|
|
|
27
28
|
<style scoped>
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
26
|
<script setup lang="ts">
|
|
27
|
-
import { Head, Link } from '@inertiajs/vue3'
|
|
27
|
+
import { Head, Link, usePage } from '@inertiajs/vue3'
|
|
28
28
|
import <%= inertia_component_name %> from './<%= singular_name %>.vue'
|
|
29
29
|
import { <%= inertia_model_type %> } from './types'
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
defineProps<{
|
|
32
32
|
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
33
|
-
flash: { notice?: string }
|
|
34
33
|
}>()
|
|
34
|
+
const { flash } = usePage()
|
|
35
35
|
</script>
|
|
36
36
|
|
|
37
37
|
<style scoped>
|
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
26
|
<script setup>
|
|
27
|
-
import { Head, Link } from '@inertiajs/vue3'
|
|
27
|
+
import { Head, Link, usePage } from '@inertiajs/vue3'
|
|
28
28
|
import <%= inertia_component_name %> from './<%= singular_name %>.vue'
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
defineProps(['<%= singular_table_name %>'])
|
|
31
|
+
const { flash } = usePage()
|
|
31
32
|
</script>
|
|
32
33
|
|
|
33
34
|
<style scoped>
|
|
@@ -11,12 +11,12 @@ export default function Edit({ <%= singular_table_name %> }) {
|
|
|
11
11
|
|
|
12
12
|
<Form
|
|
13
13
|
<%= singular_table_name %>={<%= singular_table_name %>}
|
|
14
|
-
|
|
14
|
+
action={`<%= js_resource_path %>`}
|
|
15
15
|
<% if attributes.any?(&:attachments?) -%>
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
method="post"
|
|
17
|
+
headers={{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }}
|
|
18
18
|
<% else -%>
|
|
19
|
-
|
|
19
|
+
method="patch"
|
|
20
20
|
<% end -%>
|
|
21
21
|
submitText="Update <%= human_name %>"
|
|
22
22
|
/>
|
|
@@ -16,12 +16,12 @@ export default function Edit({ <%= singular_table_name %> }: EditProps) {
|
|
|
16
16
|
|
|
17
17
|
<Form
|
|
18
18
|
<%= singular_table_name %>={<%= singular_table_name %>}
|
|
19
|
-
|
|
19
|
+
action={`<%= js_resource_path %>`}
|
|
20
20
|
<% if attributes.any?(&:attachments?) -%>
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
method="post"
|
|
22
|
+
headers={{ 'X-HTTP-METHOD-OVERRIDE': 'patch' }}
|
|
23
23
|
<% else -%>
|
|
24
|
-
|
|
24
|
+
method="patch"
|
|
25
25
|
<% end -%>
|
|
26
26
|
submitText="Update <%= human_name %>"
|
|
27
27
|
/>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Head, Link } from '@inertiajs/react'
|
|
1
|
+
import { Head, Link, usePage } from '@inertiajs/react'
|
|
2
2
|
import { Fragment } from 'react'
|
|
3
3
|
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
4
4
|
|
|
5
|
-
export default function Index({ <%= plural_table_name
|
|
5
|
+
export default function Index({ <%= plural_table_name %> }) {
|
|
6
|
+
const { flash } = usePage()
|
|
7
|
+
|
|
6
8
|
return (
|
|
7
9
|
<>
|
|
8
10
|
<Head title="<%= human_name.pluralize %>" />
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { Head, Link } from '@inertiajs/react'
|
|
1
|
+
import { Head, Link, usePage } from '@inertiajs/react'
|
|
2
2
|
import { Fragment } from 'react'
|
|
3
3
|
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
4
4
|
import { <%= inertia_model_type %> } from './types'
|
|
5
5
|
|
|
6
6
|
interface IndexProps {
|
|
7
7
|
<%= plural_table_name %>: <%= inertia_model_type %>[]
|
|
8
|
-
flash: { notice?: string }
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
export default function Index({ <%= plural_table_name
|
|
10
|
+
export default function Index({ <%= plural_table_name %> }: IndexProps) {
|
|
11
|
+
const { flash } = usePage()
|
|
12
|
+
|
|
12
13
|
return (
|
|
13
14
|
<>
|
|
14
15
|
<Head title="<%= human_name.pluralize %>" />
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Head, Link } from '@inertiajs/react'
|
|
1
|
+
import { Head, Link, usePage } from '@inertiajs/react'
|
|
2
2
|
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
|
|
4
|
-
export default function Show({ <%= singular_table_name
|
|
4
|
+
export default function Show({ <%= singular_table_name %> }) {
|
|
5
|
+
const { flash } = usePage()
|
|
6
|
+
|
|
5
7
|
return (
|
|
6
8
|
<>
|
|
7
9
|
<Head title={`<%= human_name %> #${<%= singular_table_name %>.id}`} />
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { Head, Link } from '@inertiajs/react'
|
|
1
|
+
import { Head, Link, usePage } from '@inertiajs/react'
|
|
2
2
|
import <%= inertia_component_name %> from './<%= singular_name %>'
|
|
3
3
|
import { <%= inertia_model_type %> } from './types'
|
|
4
4
|
|
|
5
5
|
interface ShowProps {
|
|
6
6
|
<%= singular_table_name %>: <%= inertia_model_type %>
|
|
7
|
-
flash: { notice?: string }
|
|
8
7
|
}
|
|
9
8
|
|
|
10
|
-
export default function Show({ <%= singular_table_name
|
|
9
|
+
export default function Show({ <%= singular_table_name %> }: ShowProps) {
|
|
10
|
+
const { flash } = usePage()
|
|
11
|
+
|
|
11
12
|
return (
|
|
12
13
|
<>
|
|
13
14
|
<Head title={`<%= human_name %> #${<%= singular_table_name %>.id}`} />
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { Link } from '@inertiajs/svelte'
|
|
2
|
+
import { Link, page } from '@inertiajs/svelte'
|
|
3
3
|
import <%= inertia_component_name %> from './<%= singular_name %>.svelte'
|
|
4
4
|
|
|
5
|
-
let { <%= plural_table_name
|
|
5
|
+
let { <%= plural_table_name %> } = $props()
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<svelte:head>
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
</svelte:head>
|
|
11
11
|
|
|
12
12
|
<div class="mx-auto md:w-2/3 w-full px-8 pt-8">
|
|
13
|
-
{#if flash.notice}
|
|
13
|
+
{#if $page.flash.notice}
|
|
14
14
|
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
|
|
15
|
-
{flash.notice}
|
|
15
|
+
{$page.flash.notice}
|
|
16
16
|
</p>
|
|
17
17
|
{/if}
|
|
18
18
|
|