haya_select_helpers 0.0.20 → 0.0.21
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 +4 -4
- data/lib/haya_select.rb +41 -1
- data/lib/haya_select_helpers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f3a49ed55099b6d8c40a7cc79dd858ec70a5b62c52256f8651194eafff7ef777
|
|
4
|
+
data.tar.gz: a32bfb12dc808215d3bbdcd09ee998ce9b84bdc13a1b351a15b2d73e9d4f837c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3265b3febd190d12e916542f458cc536405b17a4375ddae0df083126caaf1077b4777db974be50a66181868d86541ed89b2409ab884c6677610972d47ca28c46
|
|
7
|
+
data.tar.gz: 5e05c8c17dbb2840368de065731e6a164c2693c55d2daf1d92a0acd82147473ba974c3cd255f252f8f721087ac8fe0ef232d6e0748ff1e5b31bf55f6b90f6b59
|
data/lib/haya_select.rb
CHANGED
|
@@ -89,10 +89,12 @@ class HayaSelect
|
|
|
89
89
|
retry
|
|
90
90
|
end
|
|
91
91
|
|
|
92
|
-
def select(label = nil, value: nil)
|
|
92
|
+
def select(label = nil, value: nil, allow_if_selected: false)
|
|
93
93
|
attempts = 0
|
|
94
94
|
|
|
95
95
|
begin
|
|
96
|
+
guard_already_selected(label, value, allow_if_selected) if attempts.zero?
|
|
97
|
+
|
|
96
98
|
previous_value = value
|
|
97
99
|
open
|
|
98
100
|
selected_value = select_option_value(label:, value:)
|
|
@@ -108,6 +110,44 @@ class HayaSelect
|
|
|
108
110
|
end
|
|
109
111
|
end
|
|
110
112
|
|
|
113
|
+
def guard_already_selected(label, value, allow_if_selected)
|
|
114
|
+
current_value = value_no_wait
|
|
115
|
+
|
|
116
|
+
if !value.nil? && current_value == value
|
|
117
|
+
return if allow_if_selected
|
|
118
|
+
|
|
119
|
+
raise "The '#{label || value}'-option is already selected"
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
if value.nil? && !label.nil? && label_no_wait == label
|
|
123
|
+
return if allow_if_selected
|
|
124
|
+
|
|
125
|
+
raise "The '#{label}'-option is already selected"
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def value_no_wait
|
|
130
|
+
hidden_input = scope.page.first(
|
|
131
|
+
"#{base_selector} [data-class='current-selected'] input[type='hidden']",
|
|
132
|
+
visible: false,
|
|
133
|
+
wait: 0
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
hidden_input ? hidden_input[:value] : nil
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def label_no_wait
|
|
140
|
+
current_option = scope.page.first(
|
|
141
|
+
"#{base_selector} [data-class='current-selected'] [data-class='current-option']",
|
|
142
|
+
wait: 0
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
return nil unless current_option
|
|
146
|
+
|
|
147
|
+
option_text = current_option.first("[data-testid='option-presentation-text']", minimum: 0)
|
|
148
|
+
option_text ? option_text.text : current_option.text
|
|
149
|
+
end
|
|
150
|
+
|
|
111
151
|
def deselect(label: nil, value: nil)
|
|
112
152
|
raise "No 'label' or 'value' given" if label.nil? && value.nil?
|
|
113
153
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: haya_select_helpers
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.21
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kaspernj
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|