Sha256: b5e487ba9cf5eb78047963cde1bb5d1a774e271b18a4ab5a0d2b6666184cbc99
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
module TkInspectRails module SqlPanel class RootComponent < TkComponent::Base attr_accessor :sql_panel attr_accessor :expression attr_accessor :results def generate(parent_component, options = {}) parse_component(parent_component, options) do |p| p.vpaned(sticky: 'wens', x_flex: 1, y_flex: 1) do |f| f.vframe(sticky: 'wens', x_flex: 1) do |vf| vf.hframe(sticky: 'wen', padding: 8, x_flex: 1) do |hf| hf.label(text: "SQL Expression", sticky: 'w', x_flex: 1) hf.button(text: "Execute", sticky: 'e', on_click: :execute_sql) end @text = vf.text(value: @expression.to_s, width: 20, height: 5, scrollers: 'y', x_flex: 1, y_flex: 1, sticky: 'news') end f.insert_component(TkComponent::TableViewComponent, self, data_source: self, columns: @results&.first&.keys&.map { |k| { key: k, text: k } } || [], scrollers: 'xy', sticky: 'nsew', x_flex: 1, y_flex: 1) end end end def items_for_path(path) @results || [] end def execute_sql(e) @expression = @text.value @results = @sql_panel.execute_sql(@expression) regenerate end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tk_inspect_rails-0.1.0 | lib/tk_inspect_rails/sql_panel/root_component.rb |