yummy-guide-generic-administrate 0.8.2 → 0.8.3
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a6e8b69f0347b22f47b72cf96c4f99c0c398d58a8f118809735f7bafaee65e20
|
|
4
|
+
data.tar.gz: 37decc40a9672713935cd76fdea50ff20992e6e35298a8096c1ab7625209060b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b3d6976869de3d91b3affb029c77195053e541513f5f8ebbe4279543dfea132cf2536ec0880d555e2112ea63178ac61140eea4bf43fb3b365f58951e9335aae9
|
|
7
|
+
data.tar.gz: 81db24d807a65056e6b9ce35c5f5240d30c370b11def34fb2ae6664c7404e850458cd9a6119de8602faf259fcbfe0d42872da16373a0154cdc81c28b0c5da496
|
|
@@ -18,7 +18,9 @@ module YummyGuide
|
|
|
18
18
|
button_label: "Filter",
|
|
19
19
|
title: "Filter Options",
|
|
20
20
|
submit_label: "Filter",
|
|
21
|
-
close_label: "Close"
|
|
21
|
+
close_label: "Close",
|
|
22
|
+
modal_mount: :inline,
|
|
23
|
+
modal_content_for: :admin_filter_modals
|
|
22
24
|
)
|
|
23
25
|
dashboard ||= admin_filter_dashboard_from_page(page)
|
|
24
26
|
scope = form.to_s
|
|
@@ -47,28 +49,32 @@ module YummyGuide
|
|
|
47
49
|
form_scope: scope
|
|
48
50
|
)
|
|
49
51
|
|
|
52
|
+
form_markup = admin_filter_form(
|
|
53
|
+
fields: fields,
|
|
54
|
+
scope: scope,
|
|
55
|
+
path: path,
|
|
56
|
+
clear_path: clear_path,
|
|
57
|
+
method: method,
|
|
58
|
+
current_values: current_values,
|
|
59
|
+
hidden_fields: hidden_fields,
|
|
60
|
+
root_hidden_fields: root_hidden_fields,
|
|
61
|
+
locals: locals,
|
|
62
|
+
extra_actions: extra_actions,
|
|
63
|
+
title: title,
|
|
64
|
+
submit_label: submit_label,
|
|
65
|
+
close_label: close_label
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
if admin_filter_body_modal_mount?(modal_mount)
|
|
69
|
+
modal_id = admin_filter_next_modal_id
|
|
70
|
+
content_for(modal_content_for, admin_filter_modal_root(modal_id: modal_id, form_markup: form_markup))
|
|
71
|
+
|
|
72
|
+
return admin_filter_button_container(button_label: button_label, modal_id: modal_id)
|
|
73
|
+
end
|
|
74
|
+
|
|
50
75
|
safe_join([
|
|
51
76
|
content_tag(:div, "", class: "modal_overlay"),
|
|
52
|
-
|
|
53
|
-
safe_join([
|
|
54
|
-
link_to(button_label, "javascript:void(0)", class: "button"),
|
|
55
|
-
admin_filter_form(
|
|
56
|
-
fields: fields,
|
|
57
|
-
scope: scope,
|
|
58
|
-
path: path,
|
|
59
|
-
clear_path: clear_path,
|
|
60
|
-
method: method,
|
|
61
|
-
current_values: current_values,
|
|
62
|
-
hidden_fields: hidden_fields,
|
|
63
|
-
root_hidden_fields: root_hidden_fields,
|
|
64
|
-
locals: locals,
|
|
65
|
-
extra_actions: extra_actions,
|
|
66
|
-
title: title,
|
|
67
|
-
submit_label: submit_label,
|
|
68
|
-
close_label: close_label
|
|
69
|
-
)
|
|
70
|
-
])
|
|
71
|
-
end
|
|
77
|
+
admin_filter_button_container(button_label: button_label, form_markup: form_markup)
|
|
72
78
|
])
|
|
73
79
|
end
|
|
74
80
|
|
|
@@ -138,6 +144,37 @@ module YummyGuide
|
|
|
138
144
|
end
|
|
139
145
|
end
|
|
140
146
|
|
|
147
|
+
def admin_filter_button_container(button_label:, form_markup: nil, modal_id: nil)
|
|
148
|
+
data = { admin_filter_controls: true }
|
|
149
|
+
data[:admin_filter_modal_id] = modal_id if modal_id
|
|
150
|
+
|
|
151
|
+
content_tag(:div, id: "reserv-filter-options", data: data) do
|
|
152
|
+
safe_join([
|
|
153
|
+
link_to(button_label, "javascript:void(0)", class: "button"),
|
|
154
|
+
form_markup
|
|
155
|
+
].compact)
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def admin_filter_modal_root(modal_id:, form_markup:)
|
|
160
|
+
content_tag(:div, id: modal_id, class: "admin-filter-modal-root", data: { admin_filter_modal_root: true }) do
|
|
161
|
+
safe_join([
|
|
162
|
+
content_tag(:div, "", class: "modal_overlay"),
|
|
163
|
+
form_markup
|
|
164
|
+
])
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def admin_filter_body_modal_mount?(modal_mount)
|
|
169
|
+
modal_mount.to_s == "body"
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def admin_filter_next_modal_id
|
|
173
|
+
@admin_filter_controls_modal_index ||= 0
|
|
174
|
+
@admin_filter_controls_modal_index += 1
|
|
175
|
+
"admin-filter-modal-#{@admin_filter_controls_modal_index}"
|
|
176
|
+
end
|
|
177
|
+
|
|
141
178
|
def admin_filter_form_header(title:, close_label:)
|
|
142
179
|
content_tag(:div, class: "filter-form__header") do
|
|
143
180
|
safe_join([
|
|
@@ -7,6 +7,7 @@ RSpec.describe YummyGuide::Administrate::FilterControlsHelper do
|
|
|
7
7
|
subject(:helper_host) do
|
|
8
8
|
Class.new do
|
|
9
9
|
include ActionView::Context
|
|
10
|
+
include ActionView::Helpers::CaptureHelper
|
|
10
11
|
include ActionView::Helpers::FormHelper
|
|
11
12
|
include ActionView::Helpers::FormOptionsHelper
|
|
12
13
|
include ActionView::Helpers::FormTagHelper
|
|
@@ -14,6 +15,10 @@ RSpec.describe YummyGuide::Administrate::FilterControlsHelper do
|
|
|
14
15
|
include ActionView::Helpers::TagHelper
|
|
15
16
|
include ActionView::Helpers::UrlHelper
|
|
16
17
|
include YummyGuide::Administrate::FilterControlsHelper
|
|
18
|
+
|
|
19
|
+
def initialize
|
|
20
|
+
@view_flow = ActionView::OutputFlow.new
|
|
21
|
+
end
|
|
17
22
|
end.new
|
|
18
23
|
end
|
|
19
24
|
|
|
@@ -53,6 +58,34 @@ RSpec.describe YummyGuide::Administrate::FilterControlsHelper do
|
|
|
53
58
|
expect(document.at_css('select[name="search_options[status]"] option[selected]')["value"]).to eq("closed")
|
|
54
59
|
end
|
|
55
60
|
|
|
61
|
+
# body mount指定時はフォームをcontent_forへ逃がし、ヘッダー側には起動ボタンだけを残すことを確認する
|
|
62
|
+
it "renders body-mounted modal markup into content_for" do
|
|
63
|
+
dashboard = Class.new
|
|
64
|
+
dashboard.const_set(
|
|
65
|
+
:FILTER_ATTRIBUTES,
|
|
66
|
+
{
|
|
67
|
+
keyword: YummyGuide::Administrate::Filters::Text.with_options(label: "Keyword")
|
|
68
|
+
}.freeze
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
html = helper_host.admin_filter_controls(
|
|
72
|
+
dashboard: dashboard,
|
|
73
|
+
path: "/admin/resources",
|
|
74
|
+
search_options: { keyword: "tokyo" },
|
|
75
|
+
modal_mount: :body
|
|
76
|
+
)
|
|
77
|
+
controls = fragment(html)
|
|
78
|
+
modals = fragment(helper_host.content_for(:admin_filter_modals))
|
|
79
|
+
modal_id = controls.at_css("#reserv-filter-options")["data-admin-filter-modal-id"]
|
|
80
|
+
|
|
81
|
+
expect(controls.at_css("#reserv-filter-options > a.button").text).to eq("Filter")
|
|
82
|
+
expect(controls.at_css("#reserv-filter-options > form")).to be_nil
|
|
83
|
+
expect(modal_id).to eq("admin-filter-modal-1")
|
|
84
|
+
expect(modals.at_css("##{modal_id}.admin-filter-modal-root > .modal_overlay")).to be_present
|
|
85
|
+
expect(modals.at_css("##{modal_id} > form.filter-form")["action"]).to eq("/admin/resources")
|
|
86
|
+
expect(modals.at_css('input[name="search_options[keyword]"]')["value"]).to eq("tokyo")
|
|
87
|
+
end
|
|
88
|
+
|
|
56
89
|
# boolean radio group が未指定・true・falseを横並びで描画し、ラベルと選択状態を反映することを確認する
|
|
57
90
|
it "renders boolean radio group controls with custom labels" do
|
|
58
91
|
dashboard = Class.new
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yummy-guide-generic-administrate
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- akatsuki-kk
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: administrate
|