inertia_rails-contrib 0.2.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -1
  3. data/README.md +12 -133
  4. data/lib/inertia_rails_contrib/version.rb +1 -1
  5. metadata +5 -112
  6. data/lib/generators/inertia/controller/controller_generator.rb +0 -16
  7. data/lib/generators/inertia/controller/templates/controller.rb.tt +0 -10
  8. data/lib/generators/inertia/install/frameworks.yml +0 -73
  9. data/lib/generators/inertia/install/helpers.rb +0 -48
  10. data/lib/generators/inertia/install/install_generator.rb +0 -282
  11. data/lib/generators/inertia/install/templates/assets/inertia.svg +0 -1
  12. data/lib/generators/inertia/install/templates/assets/react.svg +0 -1
  13. data/lib/generators/inertia/install/templates/assets/svelte.svg +0 -1
  14. data/lib/generators/inertia/install/templates/assets/vite_ruby.svg +0 -1
  15. data/lib/generators/inertia/install/templates/assets/vue.svg +0 -1
  16. data/lib/generators/inertia/install/templates/controller.rb +0 -7
  17. data/lib/generators/inertia/install/templates/dev +0 -23
  18. data/lib/generators/inertia/install/templates/initializer.rb +0 -4
  19. data/lib/generators/inertia/install/templates/react/InertiaExample.jsx +0 -60
  20. data/lib/generators/inertia/install/templates/react/InertiaExample.module.css +0 -80
  21. data/lib/generators/inertia/install/templates/react/InertiaExample.tsx +0 -60
  22. data/lib/generators/inertia/install/templates/react/inertia.js +0 -34
  23. data/lib/generators/inertia/install/templates/react/inertia.ts +0 -36
  24. data/lib/generators/inertia/install/templates/react/tsconfig.app.json +0 -27
  25. data/lib/generators/inertia/install/templates/react/tsconfig.json +0 -11
  26. data/lib/generators/inertia/install/templates/react/tsconfig.node.json +0 -13
  27. data/lib/generators/inertia/install/templates/react/vite-env.d.ts +0 -1
  28. data/lib/generators/inertia/install/templates/svelte/InertiaExample.svelte +0 -116
  29. data/lib/generators/inertia/install/templates/svelte/InertiaExample.ts.svelte +0 -116
  30. data/lib/generators/inertia/install/templates/svelte/inertia.js +0 -29
  31. data/lib/generators/inertia/install/templates/svelte/inertia.ts +0 -32
  32. data/lib/generators/inertia/install/templates/svelte/svelte.config.js +0 -7
  33. data/lib/generators/inertia/install/templates/svelte/tsconfig.json +0 -21
  34. data/lib/generators/inertia/install/templates/svelte/tsconfig.node.json +0 -12
  35. data/lib/generators/inertia/install/templates/svelte/vite-env.d.ts +0 -2
  36. data/lib/generators/inertia/install/templates/tailwind/application.css +0 -13
  37. data/lib/generators/inertia/install/templates/tailwind/postcss.config.js +0 -6
  38. data/lib/generators/inertia/install/templates/tailwind/tailwind.config.js.tt +0 -18
  39. data/lib/generators/inertia/install/templates/vue/InertiaExample.ts.vue +0 -117
  40. data/lib/generators/inertia/install/templates/vue/InertiaExample.vue +0 -117
  41. data/lib/generators/inertia/install/templates/vue/inertia.js +0 -33
  42. data/lib/generators/inertia/install/templates/vue/inertia.ts +0 -33
  43. data/lib/generators/inertia/install/templates/vue/tsconfig.app.json +0 -24
  44. data/lib/generators/inertia/install/templates/vue/tsconfig.json +0 -11
  45. data/lib/generators/inertia/install/templates/vue/tsconfig.node.json +0 -22
  46. data/lib/generators/inertia/install/templates/vue/vite-env.d.ts +0 -1
  47. data/lib/generators/inertia/scaffold/scaffold_generator.rb +0 -16
  48. data/lib/generators/inertia/scaffold_controller/scaffold_controller_generator.rb +0 -56
  49. data/lib/generators/inertia/scaffold_controller/templates/controller.rb.tt +0 -100
  50. data/lib/generators/inertia_templates/controller/controller_generator.rb +0 -12
  51. data/lib/generators/inertia_templates/controller/templates/react/view.jsx.tt +0 -8
  52. data/lib/generators/inertia_templates/controller/templates/svelte/view.svelte.tt +0 -2
  53. data/lib/generators/inertia_templates/controller/templates/vue/view.vue.tt +0 -4
  54. data/lib/generators/inertia_templates/scaffold/scaffold_generator.rb +0 -12
  55. data/lib/generators/inertia_templates/scaffold/templates/react/Edit.jsx.tt +0 -35
  56. data/lib/generators/inertia_templates/scaffold/templates/react/Form.jsx.tt +0 -111
  57. data/lib/generators/inertia_templates/scaffold/templates/react/Index.jsx.tt +0 -26
  58. data/lib/generators/inertia_templates/scaffold/templates/react/New.jsx.tt +0 -27
  59. data/lib/generators/inertia_templates/scaffold/templates/react/One.jsx.tt +0 -26
  60. data/lib/generators/inertia_templates/scaffold/templates/react/Show.jsx.tt +0 -39
  61. data/lib/generators/inertia_templates/scaffold/templates/svelte/Edit.svelte.tt +0 -37
  62. data/lib/generators/inertia_templates/scaffold/templates/svelte/Form.svelte.tt +0 -96
  63. data/lib/generators/inertia_templates/scaffold/templates/svelte/Index.svelte.tt +0 -42
  64. data/lib/generators/inertia_templates/scaffold/templates/svelte/New.svelte.tt +0 -30
  65. data/lib/generators/inertia_templates/scaffold/templates/svelte/One.svelte.tt +0 -28
  66. data/lib/generators/inertia_templates/scaffold/templates/svelte/Show.svelte.tt +0 -46
  67. data/lib/generators/inertia_templates/scaffold/templates/vue/Edit.vue.tt +0 -36
  68. data/lib/generators/inertia_templates/scaffold/templates/vue/Form.vue.tt +0 -94
  69. data/lib/generators/inertia_templates/scaffold/templates/vue/Index.vue.tt +0 -31
  70. data/lib/generators/inertia_templates/scaffold/templates/vue/New.vue.tt +0 -29
  71. data/lib/generators/inertia_templates/scaffold/templates/vue/One.vue.tt +0 -26
  72. data/lib/generators/inertia_templates/scaffold/templates/vue/Show.vue.tt +0 -44
  73. data/lib/generators/inertia_tw_templates/controller/controller_generator.rb +0 -12
  74. data/lib/generators/inertia_tw_templates/controller/templates/react/view.jsx.tt +0 -8
  75. data/lib/generators/inertia_tw_templates/controller/templates/svelte/view.svelte.tt +0 -2
  76. data/lib/generators/inertia_tw_templates/controller/templates/vue/view.vue.tt +0 -4
  77. data/lib/generators/inertia_tw_templates/scaffold/scaffold_generator.rb +0 -12
  78. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Edit.jsx.tt +0 -42
  79. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Form.jsx.tt +0 -122
  80. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Index.jsx.tt +0 -43
  81. data/lib/generators/inertia_tw_templates/scaffold/templates/react/New.jsx.tt +0 -30
  82. data/lib/generators/inertia_tw_templates/scaffold/templates/react/One.jsx.tt +0 -26
  83. data/lib/generators/inertia_tw_templates/scaffold/templates/react/Show.jsx.tt +0 -54
  84. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Edit.svelte.tt +0 -45
  85. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Form.svelte.tt +0 -120
  86. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Index.svelte.tt +0 -49
  87. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/New.svelte.tt +0 -33
  88. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/One.svelte.tt +0 -28
  89. data/lib/generators/inertia_tw_templates/scaffold/templates/svelte/Show.svelte.tt +0 -58
  90. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Edit.vue.tt +0 -44
  91. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Form.vue.tt +0 -127
  92. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Index.vue.tt +0 -43
  93. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/New.vue.tt +0 -32
  94. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/One.vue.tt +0 -26
  95. data/lib/generators/inertia_tw_templates/scaffold/templates/vue/Show.vue.tt +0 -56
  96. data/lib/inertia_rails_contrib/generators/controller_template_base.rb +0 -56
  97. data/lib/inertia_rails_contrib/generators/scaffold_template_base.rb +0 -35
  98. data/lib/inertia_rails_contrib/generators_helper.rb +0 -88
@@ -1,122 +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} className="contents">
23
- <% attributes.each do |attribute| -%>
24
- <div className="my-5">
25
- <% if attribute.password_digest? -%>
26
- <label htmlFor="password">Password</label>
27
- <input
28
- type="password"
29
- name="password"
30
- id="password"
31
- className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
32
- onChange={(e) => setData('password', e.target.value)}
33
- />
34
- {errors.password && (
35
- <div className="text-red-500 px-3 py-2 font-medium">
36
- {errors.password.join(', ')}
37
- </div>
38
- )}
39
- </div>
40
-
41
- <div className="my-5">
42
- <label htmlFor="password_confirmation">Password Confirmation</label>
43
- <input
44
- type="password"
45
- name="password_confirmation"
46
- id="password_confirmation"
47
- className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
48
- onChange={(e) => setData('password_confirmation', e.target.value)}
49
- />
50
- {errors.password_confirmation && (
51
- <div className="text-red-500 px-3 py-2 font-medium">
52
- {errors.password_confirmation.join(', ')}
53
- </div>
54
- )}
55
- <% else -%>
56
- <label htmlFor="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
57
- <% if input_type(attribute) == "text_area" -%>
58
- <textarea
59
- name="<%= attribute.singular_name %>"
60
- id="<%= attribute.singular_name %>"
61
- value={data.<%= attribute.column_name %>}
62
- rows="4"
63
- className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
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
- className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
72
- onChange={(e) => setData('<%= attribute.column_name %>', e.target.files[0])}
73
- />
74
- <% elsif attribute.attachments? -%>
75
- <input
76
- type="file"
77
- multiple="multiple"
78
- name="<%= attribute.singular_name %>[]"
79
- id="<%= attribute.singular_name %>"
80
- className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
81
- onChange={(e) => setData('<%= attribute.column_name %>', Array.from(e.target.files))}
82
- />
83
- <% elsif attribute.field_type == :check_box -%>
84
- <input
85
- type="<%= input_type(attribute) %>"
86
- name="<%= attribute.singular_name %>"
87
- id="<%= attribute.singular_name %>"
88
- checked={!!data.<%= attribute.column_name %>}
89
- className="block mt-2 h-5 w-5"
90
- onChange={(e) => setData('<%= attribute.column_name %>', e.target.checked)}
91
- />
92
- <% else -%>
93
- <input
94
- type="<%= input_type(attribute) %>"
95
- name="<%= attribute.singular_name %>"
96
- id="<%= attribute.singular_name %>"
97
- value={data.<%= attribute.column_name %>}
98
- className="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
99
- onChange={(e) => setData('<%= attribute.column_name %>', e.target.value)}
100
- />
101
- <% end -%>
102
- {errors.<%= attribute.column_name %> && (
103
- <div className="text-red-500 px-3 py-2 font-medium">
104
- {errors.<%= attribute.column_name %>.join(', ')}
105
- </div>
106
- )}
107
- <% end -%>
108
- </div>
109
-
110
- <% end -%>
111
- <div className="inline">
112
- <button
113
- type="submit"
114
- disabled={processing}
115
- className="rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer"
116
- >
117
- {submitText}
118
- </button>
119
- </div>
120
- </form>
121
- )
122
- }
@@ -1,43 +0,0 @@
1
- import { Link, Head } from '@inertiajs/react'
2
- import { Fragment } from 'react'
3
- import <%= inertia_component_name %> from './<%= inertia_component_name %>'
4
-
5
- export default function Index({ <%= plural_table_name %>, flash }) {
6
- return (
7
- <>
8
- <Head title="<%= human_name.pluralize %>" />
9
- <div className="mx-auto md:w-2/3 w-full px-8 pt-8">
10
- {flash.notice && (
11
- <p className="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
12
- {flash.notice}
13
- </p>
14
- )}
15
- <div className="flex justify-between items-center">
16
- <h1 className="font-bold text-4xl"><%= human_name.pluralize %></h1>
17
- <Link
18
- href="<%= js_new_resource_path %>"
19
- className="rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium"
20
- >
21
- New <%= human_name.downcase %>
22
- </Link>
23
- </div>
24
-
25
- <div className="min-w-full">
26
- {<%= plural_table_name %>.map((<%= singular_table_name %>) => (
27
- <Fragment key={<%= singular_table_name %>.id}>
28
- <<%= inertia_component_name %> <%= singular_table_name %>={<%= singular_table_name %>} />
29
- <p>
30
- <Link
31
- href={`<%= js_resource_path %>`}
32
- className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
33
- >
34
- Show this <%= human_name.downcase %>
35
- </Link>
36
- </p>
37
- </Fragment>
38
- ))}
39
- </div>
40
- </div>
41
- </>
42
- )
43
- }
@@ -1,30 +0,0 @@
1
- import { Link, Head } from '@inertiajs/react'
2
- import Form from './Form'
3
-
4
- export default function New({ <%= singular_table_name %> }) {
5
- return (
6
- <>
7
- <Head title="New <%= human_name.downcase %>" />
8
-
9
- <div className="mx-auto md:w-2/3 w-full px-8 pt-8">
10
- <h1 className="font-bold text-4xl">New <%= human_name.downcase %></h1>
11
-
12
- <Form
13
- <%= singular_table_name %>={<%= singular_table_name %>}
14
- onSubmit={(form) => {
15
- form.transform((data) => ({ <%= singular_table_name %>: data }))
16
- form.post('<%= js_resources_path %>')
17
- }}
18
- submitText="Create <%= human_name.downcase %>"
19
- />
20
-
21
- <Link
22
- href="<%= js_resources_path %>"
23
- className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
24
- >
25
- Back to <%= human_name.pluralize.downcase %>
26
- </Link>
27
- </div>
28
- </>
29
- )
30
- }
@@ -1,26 +0,0 @@
1
- export default function <%= inertia_component_name %>({ <%= singular_table_name %> }) {
2
- return (
3
- <div>
4
- <% attributes.reject(&:password_digest?).each do |attribute| -%>
5
- <p className="my-5">
6
- <strong className="block font-medium mb-1"><%= attribute.human_name %>:</strong>
7
- <% if attribute.attachment? -%>
8
- {<%= singular_table_name %>.<%= attribute.column_name %> && (
9
- <a href={<%= singular_table_name %>.<%= attribute.column_name %>.url}>{<%= singular_table_name %>.<%= attribute.column_name %>.filename}</a>
10
- )}
11
- </p>
12
- <% elsif attribute.attachments? -%>
13
- </p>
14
- {<%= singular_table_name %>.<%= attribute.column_name %>.map((file, i) => (
15
- <div key={i}>
16
- <a href={file.url}>{file.filename}</a>
17
- </div>
18
- ))}
19
- <% else -%>
20
- {<%= singular_table_name %>.<%= attribute.column_name %>?.toString()}
21
- </p>
22
- <% end -%>
23
- <% end -%>
24
- </div>
25
- )
26
- }
@@ -1,54 +0,0 @@
1
- import { Link, Head } from '@inertiajs/react'
2
- import <%= inertia_component_name %> from './<%= inertia_component_name %>'
3
-
4
- export default function Show({ <%= singular_table_name %>, flash }) {
5
- const onDestroy = (e) => {
6
- if (!confirm('Are you sure you want to delete this <%= human_name.downcase %>?')) {
7
- e.preventDefault()
8
- }
9
- }
10
-
11
- return (
12
- <>
13
- <Head title={`<%= human_name %> #${<%= singular_table_name %>.id}`} />
14
-
15
- <div className="mx-auto md:w-2/3 w-full px-8 pt-8">
16
- <div className="mx-auto">
17
- {flash.notice && (
18
- <p className="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
19
- {flash.notice}
20
- </p>
21
- )}
22
-
23
- <h1 className="font-bold text-4xl"><%= human_name %> #{<%= singular_table_name %>.id}</h1>
24
-
25
- <<%= inertia_component_name %> <%= singular_table_name %>={<%= singular_table_name %>} />
26
-
27
- <Link
28
- href={`<%= js_edit_resource_path %>`}
29
- className="mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
30
- >
31
- Edit this <%= human_name.downcase %>
32
- </Link>
33
- <Link
34
- href="<%= js_resources_path %>"
35
- className="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
36
- >
37
- Back to <%= human_name.pluralize.downcase %>
38
- </Link>
39
- <div className="inline-block ml-2">
40
- <Link
41
- href={`<%= js_resource_path %>`}
42
- onClick={onDestroy}
43
- as="button"
44
- method="delete"
45
- className="mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium"
46
- >
47
- Destroy this <%= human_name.downcase %>
48
- </Link>
49
- </div>
50
- </div>
51
- </div>
52
- </>
53
- )
54
- }
@@ -1,45 +0,0 @@
1
- <script>
2
- import { Link } from '@inertiajs/svelte'
3
- import Form from './Form.svelte'
4
-
5
- export let <%= singular_table_name %>
6
-
7
- const handleSubmit = (e) => {
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
- }
18
- </script>
19
-
20
- <svelte:head>
21
- <title>Editing <%= human_name.downcase %></title>
22
- </svelte:head>
23
-
24
- <div class="mx-auto md:w-2/3 w-full px-8 pt-8">
25
- <h1 class="font-bold text-4xl">Editing <%= human_name.downcase %></h1>
26
-
27
- <Form
28
- {<%= singular_table_name %>}
29
- submitText="Update <%= human_name.downcase %>"
30
- on:submit={handleSubmit}
31
- />
32
-
33
- <Link
34
- href={`<%= js_resource_path %>`}
35
- class="mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
36
- >
37
- Show this <%= human_name.downcase %>
38
- </Link>
39
- <Link
40
- href="<%= js_resources_path %>"
41
- class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
42
- >
43
- Back to <%= human_name.pluralize.downcase %>
44
- </Link>
45
- </div>
@@ -1,120 +0,0 @@
1
- <script>
2
- import { useForm } from '@inertiajs/svelte'
3
- import { createEventDispatcher } from 'svelte'
4
-
5
- const dispatch = createEventDispatcher()
6
-
7
- export let <%= singular_table_name %>
8
- export let submitText
9
-
10
- const form = useForm({
11
- <% attributes.each do |attribute| -%>
12
- <% if attribute.password_digest? -%>
13
- password: '',
14
- password_confirmation: '',
15
- <% else -%>
16
- <%= attribute.column_name %>: <%= singular_table_name %>.<%= attribute.column_name %> || <%= default_value(attribute) %>,
17
- <% end -%>
18
- <% end -%>
19
- })
20
- </script>
21
-
22
- <form
23
- class="contents"
24
- on:submit|preventDefault={dispatch('submit', { form: $form })}
25
- >
26
- <% attributes.each do |attribute| -%>
27
- <div class="my-5">
28
- <% if attribute.password_digest? -%>
29
- <label for="password">Password</label>
30
- <input
31
- type="password"
32
- name="password"
33
- id="password"
34
- bind:value={$form.password}
35
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
36
- />
37
- {#if $form.errors.password}
38
- <div class="text-red-500 px-3 py-2 font-medium">
39
- {$form.errors.password.join(', ')}
40
- </div>
41
- {/if}
42
- </div>
43
-
44
- <div class="my-5">
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
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
52
- />
53
- {#if $form.errors.password_confirmation}
54
- <div class="text-red-500 px-3 py-2 font-medium">
55
- {$form.errors.password_confirmation.join(', ')}
56
- </div>
57
- {/if}
58
- <% else -%>
59
- <label for="<%= attribute.singular_name %>"><%= attribute.human_name %></label>
60
- <% if input_type(attribute) == "text_area" -%>
61
- <textarea
62
- name="<%= attribute.singular_name %>"
63
- id="<%= attribute.singular_name %>"
64
- bind:value={$form.<%= attribute.column_name %>}
65
- rows="4"
66
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
67
- />
68
- <% elsif attribute.attachment? -%>
69
- <input
70
- type="file"
71
- name="<%= attribute.singular_name %>"
72
- id="<%= attribute.singular_name %>"
73
- on:input={(e) => ($form.<%= attribute.column_name %> = e.target.files[0])}
74
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
75
- />
76
- <% elsif attribute.attachments? -%>
77
- <input
78
- type="file"
79
- multiple="multiple"
80
- name="<%= attribute.singular_name %>[]"
81
- id="<%= attribute.singular_name %>"
82
- on:input={(e) => ($form.<%= attribute.column_name %> = Array.from(e.target.files))}
83
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
84
- />
85
- <% elsif attribute.field_type == :check_box -%>
86
- <input
87
- type="<%= input_type(attribute) %>"
88
- name="<%= attribute.singular_name %>"
89
- id="<%= attribute.singular_name %>"
90
- bind:checked={$form.<%= attribute.column_name %>}
91
- class="block mt-2 h-5 w-5"
92
- />
93
- <% else -%>
94
- <input
95
- type="<%= input_type(attribute) %>"
96
- name="<%= attribute.singular_name %>"
97
- id="<%= attribute.singular_name %>"
98
- bind:value={$form.<%= attribute.column_name %>}
99
- class="block shadow rounded-md border border-gray-400 outline-none px-3 py-2 mt-2 w-full"
100
- />
101
- <% end -%>
102
- {#if $form.errors.<%= attribute.column_name %>}
103
- <div class="text-red-500 px-3 py-2 font-medium">
104
- {$form.errors.<%= attribute.column_name %>.join(', ')}
105
- </div>
106
- {/if}
107
- <% end -%>
108
- </div>
109
-
110
- <% end -%>
111
- <div class="inline">
112
- <button
113
- type="submit"
114
- disabled={$form.processing}
115
- class="rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer"
116
- >
117
- {submitText}
118
- </button>
119
- </div>
120
- </form>
@@ -1,49 +0,0 @@
1
- <script>
2
- import { Link } from '@inertiajs/svelte'
3
- import <%= inertia_component_name %> from './<%= inertia_component_name %>.svelte'
4
-
5
- export let <%= plural_table_name %>
6
- export let flash
7
-
8
- const onDestroy = (e) => {
9
- if (!confirm('Are you sure you want to delete this <%= human_name.downcase %>?')) {
10
- e.preventDefault()
11
- }
12
- }
13
- </script>
14
-
15
- <svelte:head>
16
- <title><%= human_name.pluralize %></title>
17
- </svelte:head>
18
-
19
- <div class="mx-auto md:w-2/3 w-full px-8 pt-8">
20
- {#if flash.notice}
21
- <p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
22
- {flash.notice}
23
- </p>
24
- {/if}
25
-
26
- <div class="flex justify-between items-center">
27
- <h1 class="font-bold text-4xl"><%= human_name.pluralize %></h1>
28
- <Link
29
- href="<%= js_new_resource_path %>"
30
- class="rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium"
31
- >
32
- New <%= human_name.downcase %>
33
- </Link>
34
- </div>
35
-
36
- <div class="min-w-full">
37
- {#each <%= plural_table_name %> as <%= singular_table_name %> (<%= singular_table_name %>.id)}
38
- <<%= inertia_component_name %> {<%= singular_table_name %>} />
39
- <p>
40
- <Link
41
- href={`<%= js_resource_path %>`}
42
- class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
43
- >
44
- Show this <%= human_name.downcase %>
45
- </Link>
46
- </p>
47
- {/each}
48
- </div>
49
- </div>
@@ -1,33 +0,0 @@
1
- <script>
2
- import { Link } from '@inertiajs/svelte'
3
- import Form from './Form.svelte'
4
-
5
- export let <%= singular_table_name %>
6
-
7
- const handleSubmit = (e) => {
8
- const { form } = e.detail
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
- <div class="mx-auto md:w-2/3 w-full px-8 pt-8">
19
- <h1 class="font-bold text-4xl">New <%= human_name.downcase %></h1>
20
-
21
- <Form
22
- {<%= singular_table_name %>}
23
- submitText="Create <%= human_name.downcase %>"
24
- on:submit={handleSubmit}
25
- />
26
-
27
- <Link
28
- href="<%= js_resources_path %>"
29
- class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
30
- >
31
- Back to <%= human_name.pluralize.downcase %>
32
- </Link>
33
- </div>
@@ -1,28 +0,0 @@
1
- <script>
2
- export let <%= singular_table_name %>
3
- </script>
4
-
5
- <div>
6
- <% attributes.reject(&:password_digest?).each do |attribute| -%>
7
- <p class="my-5">
8
- <strong class="block font-medium mb-1"><%= attribute.human_name %>:</strong>
9
- <% if attribute.attachment? -%>
10
- {#if <%= singular_table_name %>.<%= attribute.column_name %>}
11
- <a href={<%= singular_table_name %>.<%= attribute.column_name %>.url}>
12
- {<%= singular_table_name %>.<%= attribute.column_name %>.filename}
13
- </a>
14
- {/if}
15
- </p>
16
- <% elsif attribute.attachments? -%>
17
- </p>
18
- {#each <%= singular_table_name %>.<%= attribute.column_name %> as { url, filename }}
19
- <div>
20
- <a href={url}>{filename}</a>
21
- </div>
22
- {/each}
23
- <% else -%>
24
- {<%= singular_table_name %>.<%= attribute.column_name %>}
25
- </p>
26
- <% end -%>
27
- <% end -%>
28
- </div>
@@ -1,58 +0,0 @@
1
- <script>
2
- import { inertia, Link } from '@inertiajs/svelte'
3
- import <%= inertia_component_name %> from './<%= inertia_component_name %>.svelte'
4
-
5
- export let <%= singular_table_name %>
6
- export let flash
7
-
8
- const onDestroy = (e) => {
9
- if (!confirm('Are you sure you want to delete this <%= human_name.downcase %>?')) {
10
- e.preventDefault()
11
- }
12
- }
13
- </script>
14
-
15
- <svelte:head>
16
- <title><%= human_name %> #{<%= singular_table_name %>.id}</title>
17
- </svelte:head>
18
-
19
- <div class="mx-auto md:w-2/3 w-full px-8 pt-8">
20
- <div class="mx-auto">
21
- {#if flash.notice}
22
- <p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block">
23
- {flash.notice}
24
- </p>
25
- {/if}
26
-
27
- <h1 class="font-bold text-4xl"><%= human_name %> #{<%= singular_table_name %>.id}</h1>
28
-
29
- <<%= inertia_component_name %> {<%= singular_table_name %>} />
30
-
31
- <Link
32
- href={`<%= js_edit_resource_path %>`}
33
- class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
34
- >
35
- Edit this <%= human_name.downcase %>
36
- </Link>
37
- <Link
38
- href="<%= js_resources_path %>"
39
- class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
40
- >
41
- Back to <%= human_name.pluralize.downcase %>
42
- </Link>
43
- <div class="inline-block ml-2">
44
- <button
45
- use:inertia={{ href: `<%= js_resource_path %>`, method: 'delete' }}
46
- on:click={onDestroy}
47
- type="button"
48
- class="mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium"
49
- >
50
- Destroy this <%= human_name.downcase %>
51
- </button>
52
- </div>
53
- </div>
54
- </div>
55
-
56
-
57
-
58
-
@@ -1,44 +0,0 @@
1
- <template>
2
- <Head title="Editing <%= human_name.downcase %>" />
3
-
4
- <div className="mx-auto md:w-2/3 w-full px-8 pt-8">
5
- <h1 class="font-bold text-4xl">Editing <%= human_name.downcase %></h1>
6
-
7
- <Form
8
- :<%= singular_table_name %>="<%= singular_table_name %>"
9
- submitText="Update <%= human_name.downcase %>"
10
- @onSubmit="handleSubmit"
11
- />
12
-
13
- <Link
14
- :href="`<%= js_resource_path %>`"
15
- class="mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
16
- >
17
- Show this <%= human_name.downcase %>
18
- </Link>
19
- <Link
20
- href="<%= js_resources_path %>"
21
- class="ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium"
22
- >
23
- Back to <%= human_name.pluralize.downcase %>
24
- </Link>
25
- </div>
26
- </template>
27
-
28
- <script setup>
29
- import { Link, Head } from '@inertiajs/vue3'
30
- import Form from './Form.vue'
31
-
32
- const { <%= singular_table_name %> } = defineProps(['<%= singular_table_name %>'])
33
-
34
- const handleSubmit = (form) => {
35
- form.transform((data) => ({ <%= singular_table_name %>: data }))
36
- <% if attributes.any?(&:attachments?) -%>
37
- form.post(`<%= js_resource_path %>`, {
38
- headers: { 'X-HTTP-METHOD-OVERRIDE': 'put' },
39
- })
40
- <% else -%>
41
- form.patch(`<%= js_resource_path %>`)
42
- <% end -%>
43
- }
44
- </script>