Module: SolidQueueTui::Views::Confirmable
- Included in:
- FailedView, JobDetailView, QueuesView, RecurringTasksView, ScheduledView
- Defined in:
- lib/solid_queue_tui/views/concerns/confirmable.rb
Instance Method Summary collapse
- #confirm_bindings ⇒ Object
- #confirm_mode? ⇒ Boolean
- #handle_confirm_input(event) ⇒ Object
- #init_confirm ⇒ Object
- #render_confirm_popup(frame, area) ⇒ Object
Instance Method Details
#confirm_bindings ⇒ Object
12 13 14 |
# File 'lib/solid_queue_tui/views/concerns/confirmable.rb', line 12 def confirm_bindings [{ key: "y", action: "Confirm" }, { key: "n/Esc", action: "Cancel" }] end |
#confirm_mode? ⇒ Boolean
10 |
# File 'lib/solid_queue_tui/views/concerns/confirmable.rb', line 10 def confirm_mode? = !!@confirm_action |
#handle_confirm_input(event) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/solid_queue_tui/views/concerns/confirmable.rb', line 16 def handle_confirm_input(event) case event in { type: :key, code: "y" } action = @confirm_action @confirm_action = nil execute_confirm_action(action) in { type: :key, code: "n" } | { type: :key, code: "esc" } @confirm_action = nil nil else nil end end |
#init_confirm ⇒ Object
6 7 8 |
# File 'lib/solid_queue_tui/views/concerns/confirmable.rb', line 6 def init_confirm @confirm_action = nil end |
#render_confirm_popup(frame, area) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/solid_queue_tui/views/concerns/confirmable.rb', line 30 def render_confirm_popup(frame, area) popup_area = area.centered( @tui.constraint_percentage(50), @tui.constraint_length(5) ) frame.(@tui.clear(), popup_area) frame.( @tui.paragraph( text: " #{confirm_message}", style: @tui.style(fg: :yellow, modifiers: [:bold]), block: @tui.block( title: " Confirm ", title_style: @tui.style(fg: :red, modifiers: [:bold]), borders: [:all], border_type: :rounded, border_style: @tui.style(fg: :red) ) ), popup_area ) end |