yummy-guide-generic-administrate 0.8.17 → 0.8.18
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: b53bff1d61f85a0cf761db5b1268073c026170320b44cd8b02f1f8ebdcf42938
|
|
4
|
+
data.tar.gz: e1e7da598410b265d230ba48a204e604539c9e33e4318027ba0f03152e7083f9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 973806241c05cb384995d1ce293af242adda092846ff9c0d94790bed8c4e04f82e7d418dbce3b1fa29843ab56d6e3c022c72d695da8f7fe3aff95806c7615f7c
|
|
7
|
+
data.tar.gz: b02c11686425c3ca4c120e7d286a076595ec3074f640252918d8278b5bbaa4d6dd58167482c23afe400dcc54617c905103c988cbf23876ebd3f08b56d4f5e2e7
|
|
@@ -79,12 +79,21 @@
|
|
|
79
79
|
|
|
80
80
|
function clearFormFields(formEl) {
|
|
81
81
|
formEl.querySelectorAll("input, select, textarea").forEach(function(fieldEl) {
|
|
82
|
-
if (fieldEl.disabled || fieldEl.type === "
|
|
82
|
+
if (fieldEl.disabled || fieldEl.type === "submit") {
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
// フォーム全体のhidden(hidden_fields / root_hidden_fields等)は保持し、フィルター行内のhiddenのみクリアする
|
|
87
|
+
if (fieldEl.type === "hidden") {
|
|
88
|
+
if (!fieldEl.closest(".filter_table")) return;
|
|
89
|
+
|
|
87
90
|
fieldEl.value = "";
|
|
91
|
+
fieldEl.setAttribute("value", "");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (fieldEl.tagName === "SELECT") {
|
|
96
|
+
resetSelectControl(fieldEl);
|
|
88
97
|
return;
|
|
89
98
|
}
|
|
90
99
|
|
|
@@ -123,15 +132,18 @@
|
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
function clearSelectControls(rowEl) {
|
|
126
|
-
rowEl.querySelectorAll("select").forEach(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
rowEl.querySelectorAll("select").forEach(resetSelectControl);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 空の選択肢がないselect(例: ["All months", "all"]始まり)でも未選択表示にならないよう、"all"を優先して選択する
|
|
139
|
+
function resetSelectControl(selectEl) {
|
|
140
|
+
if (selectEl.querySelector('option[value=""]')) {
|
|
141
|
+
selectEl.value = "";
|
|
142
|
+
} else if (selectEl.querySelector('option[value="all"]')) {
|
|
143
|
+
selectEl.value = "all";
|
|
144
|
+
} else {
|
|
145
|
+
selectEl.selectedIndex = -1;
|
|
146
|
+
}
|
|
135
147
|
}
|
|
136
148
|
|
|
137
149
|
function clearDatetimeFilters(rowEl) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.describe "filter form assets" do
|
|
4
|
+
let(:javascript_source) do
|
|
5
|
+
File.read(File.expand_path("../../../app/assets/javascripts/yummy_guide_administrate/filter_form.js", __dir__))
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
let(:clear_form_fields_source) do
|
|
9
|
+
javascript_source[/function clearFormFields\(formEl\) \{.*?\n \}\n/m]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# フォーム全体のClearでフィルター行内のhidden値(Location等)もクリアし、フォーム全体のhiddenは保持することを静的に確認する
|
|
13
|
+
it "clears hidden fields inside filter rows only" do
|
|
14
|
+
expect(clear_form_fields_source).not_to be_nil
|
|
15
|
+
expect(clear_form_fields_source).not_to include('fieldEl.type === "hidden" || fieldEl.type === "submit"')
|
|
16
|
+
expect(clear_form_fields_source).to include('if (!fieldEl.closest(".filter_table")) return;')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# フォーム全体のClearでも行単位のClearと同じく、空の選択肢がないselectは"all"を選択することを静的に確認する
|
|
20
|
+
it "resets selects the same way as the per-row clear" do
|
|
21
|
+
expect(clear_form_fields_source).to include("resetSelectControl(fieldEl);")
|
|
22
|
+
expect(javascript_source).to include('rowEl.querySelectorAll("select").forEach(resetSelectControl);')
|
|
23
|
+
expect(javascript_source).to include('selectEl.value = "all";')
|
|
24
|
+
end
|
|
25
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.18
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- akatsuki-kk
|
|
@@ -158,6 +158,7 @@ files:
|
|
|
158
158
|
- spec/yummy_guide/administrate/fields/version_item_field_spec.rb
|
|
159
159
|
- spec/yummy_guide/administrate/fields/version_whodunnit_field_spec.rb
|
|
160
160
|
- spec/yummy_guide/administrate/filter_controls_helper_spec.rb
|
|
161
|
+
- spec/yummy_guide/administrate/filter_form_asset_spec.rb
|
|
161
162
|
- spec/yummy_guide/administrate/filter_form_helper_spec.rb
|
|
162
163
|
- spec/yummy_guide/administrate/filters_spec.rb
|
|
163
164
|
- spec/yummy_guide/administrate/number_input_helper_spec.rb
|