Class: QTimetrap::Entries::ListComponent

Inherits:
Object
  • Object
show all
Includes:
ListHostHelpers, ListStateHelpers, ListTaskEditorHelpers, RenderHelpers, TreeHelpers, QtUiHelpers
Defined in:
app/components/entries/list_component.rb

Overview

Renders expandable week/day/project nodes and leaf time entries.

Constant Summary collapse

HOST_HORIZONTAL_MARGINS =
28
WIDTH_PADDING =
24
TIME_FILTER_DEBOUNCE_MS =
220

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ListTaskEditorHelpers

#close_active_task_editor, #task_editor_widget?

Constructor Details

#initialize(parent:, callbacks: {}, task_suggestions_for_project: nil) ⇒ ListComponent

Returns a new instance of ListComponent.



20
21
22
23
24
25
26
27
28
29
30
# File 'app/components/entries/list_component.rb', line 20

def initialize(parent:, callbacks: {}, task_suggestions_for_project: nil)
  @parent = parent
  @on_entry_note_change = callbacks[:on_entry_note_change]
  @on_entry_task_change = callbacks[:on_entry_task_change]
  @task_suggestions_for_project = task_suggestions_for_project
  @on_entry_time_change = callbacks[:on_entry_time_change]
  @on_entry_archive = callbacks[:on_entry_archive]
  @on_time_range_change = callbacks[:on_time_range_change]
  initialize_state!
  build
end

Instance Attribute Details

#widgetObject (readonly)

Returns the value of attribute widget.



18
19
20
# File 'app/components/entries/list_component.rb', line 18

def widget
  @widget
end

Instance Method Details

#render(nodes) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/components/entries/list_component.rb', line 32

def render(nodes)
  return if rendering

  @rendering = true
  @current_nodes = Array(nodes)
  @branch_bindings = {}
  @leaf_labels = []
  @entry_rows = []
  with_widget_updates_suspended { render_contents }
ensure
  @rendering = false
end

#shutdownObject



61
62
63
64
65
# File 'app/components/entries/list_component.rb', line 61

def shutdown
  return unless time_filter_debounce

  time_filter_debounce.stop if time_filter_debounce.is_active
end

#update_time_range_inputs(from_at:, to_at:) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/components/entries/list_component.rb', line 45

def update_time_range_inputs(from_at:, to_at:)
  @syncing_time_filters = true
  set_time_filter_state(
    toggle: time_filter_from_toggle,
    input: time_filter_from_input,
    value: from_at
  )
  set_time_filter_state(
    toggle: time_filter_to_toggle,
    input: time_filter_to_input,
    value: to_at
  )
ensure
  @syncing_time_filters = false
end