Class: Avo::KeyboardShortcutsComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/avo/keyboard_shortcuts_component.rb

Constant Summary

Constants included from Concerns::FindAssociationField

Concerns::FindAssociationField::ASSOCIATIONS

Instance Method Summary collapse

Methods inherited from BaseComponent

#component_name, #hotkey_badge

Methods included from ApplicationHelper

#a_button, #a_link, #body_classes, #button_classes, #chart_color, #container_classes, #d, #decode_filter_params, #e, #editor_file_path, #editor_url, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #rtl?, #text_direction, #ui, #wrap_in_modal

Methods included from ResourcesHelper

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #record_path, #record_title, #resource_for_record, #resource_grid, #resource_show_path, #resource_table

Methods included from Concerns::FindAssociationField

#find_association_field

Instance Method Details

#render_shortcut_keys(shortcut) ⇒ Object



44
45
46
47
48
49
50
# File 'app/components/avo/keyboard_shortcuts_component.rb', line 44

def render_shortcut_keys(shortcut)
  if shortcut[:any_of].present?
    render_shortcut_alternatives(shortcut[:any_of])
  else
    render_chord(shortcut[:keys])
  end
end

#sectionsObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/components/avo/keyboard_shortcuts_component.rb', line 4

def sections
  @sections ||= [
    build_section(
      "Navigation",
      [
        shortcut(action: "Show keyboard shortcuts", keys: ["?"]),
        shortcut(action: "Focus resource search", keys: {mac: ["Cmd", "K"], other: ["Ctrl", "K"]}),
        shortcut(action: "Toggle sidebar", keys: {mac: ["Cmd", "\\"], other: ["Ctrl", "\\"]}),
        shortcut(action: "Close modal", keys: ["Esc"]),
        shortcut(
          action: "Navigate options in the modal",
          any_of: [[""], [""]],
          keys_aria_label: "Up arrow or down arrow"
        ),
        shortcut(action: "Go back", keys: ["B"])
      ]
    ),
    build_section(
      "Edit view",
      [
        shortcut(action: "Submit form", keys: {mac: ["Cmd", ""], other: ["Ctrl", ""]}),
        shortcut(action: "Unfocus field", keys: ["Esc"])
      ]
    ),
    build_section(
      "Show view",
      [
        shortcut(action: "Delete record", keys: ["D"]),
        shortcut(action: "Edit record", keys: ["E"])
      ]
    ),
    build_section(
      "Index view",
      [
        shortcut(action: "Create new record", keys: ["C"])
      ]
    )
  ]
end