~singpolyma/sgx-jmp

977e286ba3179e7e85807726db4a9879d3dad0ac — Stephen Paul Weber 1 year, 9 months ago 24554b3
Allow prev action on TelSelections search results
1 files changed, 10 insertions(+), 8 deletions(-)

M lib/tel_selections.rb
M lib/tel_selections.rb => lib/tel_selections.rb +10 -8
@@ 49,14 49,16 @@ class TelSelections
		end

		def choose_from_list(tns)
			if tns.empty?
				choose_tel(error: "No numbers found, try another search.")
			else
				Command.reply { |reply|
					reply.allowed_actions = [:next]
					reply.command << FormTemplate.render("tn_list", tns: tns)
				}.then { |iq| iq.form.field("tel").value.to_s.strip }
			end
			raise "No numbers found, try another search." if tns.empty?

			Command.reply { |reply|
				reply.allowed_actions = [:next, :prev]
				reply.command << FormTemplate.render("tn_list", tns: tns)
			}.then { |iq|
				next choose_tel if iq.prev?

				iq.form.field("tel").value.to_s.strip
			}
		end

		class AvailableNumber