inertia_rails-contrib 0.3.0 → 0.4.0

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