sun-sword 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e41591cff3bcf32886a1c7669fe7b20885592bae80c86c356a15328b4e74e24c
|
4
|
+
data.tar.gz: 39413beceebc80ff6358eb27065f87920f1c3dff062112daf17f1fa19ce3bbb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4216e337a604db0e6ed6bf6afacdac6902282ef87330613f0e3160d5fe0c627eef44c7446c8369179b34c8dc740b245897376f3e71ce97af21d758d2b4b5302e
|
7
|
+
data.tar.gz: 24139caa5c427558d494c33c215b7e1933bc1d69f37629e05bbb9e3b962a46cdacf2616790f2e30be07cf3a09fe61043cda9576d2cdaa9c465dcdb00650e8d2f
|
@@ -68,15 +68,16 @@ module SunSword
|
|
68
68
|
timestamp: :datetime_select,
|
69
69
|
time: :time_select,
|
70
70
|
enum: :select,
|
71
|
-
file: :file_field
|
71
|
+
file: :file_field,
|
72
|
+
files: :file_fields
|
72
73
|
}
|
73
74
|
end
|
74
75
|
|
75
76
|
def generate_form_fields_html
|
76
77
|
form_fields_html = ''
|
77
78
|
@form_fields.each do |field|
|
78
|
-
field_name = field[:name]
|
79
|
-
field_type = field[:type]
|
79
|
+
field_name = field[:name].to_sym
|
80
|
+
field_type = field[:type].to_sym
|
80
81
|
form_helper = @mapping_fields[field_type] || :text_field
|
81
82
|
input_id = "#{@variable_subject}_#{field_name}"
|
82
83
|
label_input_id = case form_helper
|
@@ -84,7 +85,6 @@ module SunSword
|
|
84
85
|
when :time_select then "#{input_id}_4i" # Hour
|
85
86
|
else input_id
|
86
87
|
end
|
87
|
-
|
88
88
|
field_html = <<-HTML
|
89
89
|
|
90
90
|
<div class="sm:grid sm:grid-cols-3 sm:items-start sm:gap-4 sm:py-6">
|
@@ -120,6 +120,25 @@ module SunSword
|
|
120
120
|
field_html += <<-HTML
|
121
121
|
<%= form.#{form_helper} :#{field_name}, { discard_second: true, id_prefix: '#{input_id}' }, { class: "text-gray-700 shadow-sm focus:ring-2 focus:ring-gray-300 focus:border-gray-300 sm:text-sm" } %>
|
122
122
|
HTML
|
123
|
+
when :file_fields
|
124
|
+
field_html += <<-HTML
|
125
|
+
<div class="flex max-w-2xl justify-center rounded-lg border border-dashed border-gray-300 px-6 py-10">
|
126
|
+
<div class="text-center">
|
127
|
+
<!-- SVG Icon -->
|
128
|
+
<svg class="mx-auto size-12 text-gray-300" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" data-slot="icon">
|
129
|
+
<path fill-rule="evenodd" d="M1.5 6a2.25 2.25 0 0 1 2.25-2.25h16.5A2.25 2.25 0 0 1 22.5 6v12a2.25 2.25 0 0 1-2.25 2.25H3.75A2.25 2.25 0 0 1 1.5 18V6ZM3 16.06V18c0 .414.336.75.75.75h16.5A.75.75 0 0 0 21 18v-1.94l-2.69-2.689a1.5 1.5 0 0 0-2.12 0l-.88.879.97.97a.75.75 0 1 1-1.06 1.06l-5.16-5.159a1.5 1.5 0 0 0-2.12 0L3 16.061Zm10.125-7.81a1.125 1.125 0 1 1 2.25 0 1.125 1.125 0 0 1-2.25 0Z" clip-rule="evenodd" />
|
130
|
+
</svg>
|
131
|
+
<div class="mt-4 flex text-sm text-gray-600">
|
132
|
+
<label for="<%= '#{input_id}' %>" class="relative cursor-pointer rounded-md bg-white font-semibold text-gray-600 hover:text-gray-500">
|
133
|
+
<span>Upload a file</span>
|
134
|
+
<%= form.file_field :#{field_name}, id: '#{input_id}', class: "sr-only", multiple: true %>
|
135
|
+
</label>
|
136
|
+
<p class="pl-1">or drag and drop</p>
|
137
|
+
</div>
|
138
|
+
<p class="text-xs text-gray-600">PNG, JPG, GIF, DOC etc.</p>
|
139
|
+
</div>
|
140
|
+
</div>
|
141
|
+
HTML
|
123
142
|
when :file_field
|
124
143
|
field_html += <<-HTML
|
125
144
|
<div class="flex max-w-2xl justify-center rounded-lg border border-dashed border-gray-300 px-6 py-10">
|
@@ -216,7 +235,13 @@ module SunSword
|
|
216
235
|
|
217
236
|
def strong_params
|
218
237
|
results = ''
|
219
|
-
@controllers.form_fields.
|
238
|
+
@controllers.form_fields.each do |field|
|
239
|
+
if field.type.to_s.eql?('files')
|
240
|
+
results << "{ #{field.name}: [] }, "
|
241
|
+
else
|
242
|
+
results << ":#{field.name}, "
|
243
|
+
end
|
244
|
+
end
|
220
245
|
results[0..-2]
|
221
246
|
end
|
222
247
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Template for the controller (controllers/controller.rb.tt)
|
2
2
|
class <%= [@route_scope_class, @scope_class].reject { |c| c.empty? }.join("::") %>Controller < ApplicationController
|
3
|
-
before_action :set_<%= @variable_subject %>, only: %i[
|
3
|
+
before_action :set_<%= @variable_subject %>, only: %i[edit update]
|
4
4
|
layout :set_layouts
|
5
5
|
|
6
6
|
# GET /<%= [@route_scope_path, @scope_path].reject { |c| c.empty? }.join("/") %>
|
@@ -8,7 +8,7 @@ class <%= [@route_scope_class, @scope_class].reject { |c| c.empty? }.join("::")
|
|
8
8
|
use_case = Core::UseCases::<%= [@route_scope_class, @scope_class, build_usecase_filename('list')].reject { |c| c.empty? }.join("::") %>
|
9
9
|
contract = use_case.contract!(build_contract({}))
|
10
10
|
result = use_case.new(contract).result
|
11
|
-
@<%= @
|
11
|
+
@<%= @variable_subject %> = Dry::Matcher::ResultMatcher.call(result) do |matcher|
|
12
12
|
matcher.success { |response| response }
|
13
13
|
matcher.failure { |errors| errors }
|
14
14
|
end
|
@@ -17,6 +17,13 @@ class <%= [@route_scope_class, @scope_class].reject { |c| c.empty? }.join("::")
|
|
17
17
|
|
18
18
|
# GET /<%= [@route_scope_path, @scope_path, ":uuid"].reject { |c| c.empty? }.join("/") %>
|
19
19
|
def show
|
20
|
+
use_case = Core::UseCases::<%= [@route_scope_class, @scope_class, build_usecase_filename('fetch', '_by_id')].reject { |c| c.empty? }.join("::") %>
|
21
|
+
contract = use_case.contract!(build_contract({ id: params[:id] }))
|
22
|
+
result = use_case.new(contract).result
|
23
|
+
@<%= @scope_path %> = Dry::Matcher::ResultMatcher.call(result) do |matcher|
|
24
|
+
matcher.success { |response| response }
|
25
|
+
matcher.failure { |errors| errors }
|
26
|
+
end
|
20
27
|
end
|
21
28
|
|
22
29
|
# GET /<%= [@route_scope_path, @scope_path, "new"].reject { |c| c.empty? }.join("/") %>
|
data/lib/sun_sword/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sun-sword
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kotarominami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|