Page#page now accepts an options hash, booleans are now supported, search result buttons now redirect to to Editor page

This commit is contained in:
2021-01-30 21:54:00 -06:00
parent 4e9d3c0759
commit 9f54d21932
3 changed files with 46 additions and 14 deletions

View File

@@ -17,6 +17,13 @@ module TAC
@var_type = list_box items: [:float, :double, :integer, :long, :string, :boolean], choose: @type ? @type : :double, width: 1.0 do |item|
@type = item
if @type == :boolean
@value.hide
@value_boolean.show
else
@value.show
@value_boolean.hide
end
end
@type ||= @var_type.value.to_sym
@@ -26,7 +33,13 @@ module TAC
@value_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
@value_error.hide
@value = edit_line @options[:variable] ? @options[:variable].value : "", width: 1.0
@value_boolean = check_box "Variable", checked: @options[:variable] ? @options[:variable].value == true : false
@value_boolean = check_box "Boolean", checked: @options[:variable] ? @options[:variable].value == "true" : false
unless @options[:variable] && @options[:variable].type == :boolean
@value_boolean.hide
else
@value.hide
end
end
flow width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
@@ -36,10 +49,12 @@ module TAC
button @options[:variable] ? "Update" : "Add", width: 0.475 do |b|
if valid?
value = @type == :boolean ? @value_boolean.value.to_s : @value.value.strip
if @options[:variable]
@options[:callback_method].call(@options[:variable], @name.value.strip, @type, @value.value.strip)
@options[:callback_method].call(@options[:variable], @name.value.strip, @type, value)
else
@options[:callback_method].call(@name.value.strip, @type, @value.value.strip)
@options[:callback_method].call(@name.value.strip, @type, value)
end
close
@@ -105,9 +120,6 @@ module TAC
end
elsif @type == :boolean
@value_error.value = "Error: Boolean not yet supported."
@value_error.show
valid = false
else
@value_error.value = "Error: Type not set or\ntype #{@var_type.value.inspect} is not valid."

View File

@@ -19,8 +19,8 @@ module TAC
@options = options
end
def page(klass)
@host.page(klass)
def page(klass, options = {})
@host.page(klass, options)
end
def header_bar(text)

View File

@@ -26,7 +26,9 @@ module TAC
search_results.groups.each do |result|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
button result.highlight(result.group.name), width: 1.0
button result.highlight(result.group.name), width: 1.0 do
page(TAC::Pages::Editor, { group: result.group, is_search: true })
end
end
shared_index += 1
@@ -39,7 +41,9 @@ module TAC
search_results.actions.each do |result|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
button result.highlight(result.action.name), width: 1.0
button result.highlight(result.action.name), width: 1.0 do
page(TAC::Pages::Editor, { group: result.group, action: result.action, is_search: true })
end
if result.from_comment?
para result.highlight(result.action.comment), width: 1.0
@@ -56,7 +60,9 @@ module TAC
search_results.variables.each do |result|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
button "#{result.highlight(result.variable.name)} [#{result.highlight(result.variable.value)}]", width: 1.0
button "#{result.highlight(result.variable.name)} [#{result.highlight(result.variable.value)}]", width: 1.0 do
page(TAC::Pages::Editor, { group: result.group, action: result.action, variable: result.variable, is_search: true })
end
end
shared_index += 1
@@ -71,7 +77,9 @@ module TAC
search_results.group_presets.each do |result|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
button result.highlight(result.group.name), width: 1.0
button result.highlight(result.group.name), width: 1.0 do
page(TAC::Pages::Editor, { group: result.group, group_is_preset: true, is_search: true })
end
end
shared_index += 1
@@ -85,7 +93,13 @@ module TAC
search_results.action_presets.each do |result|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
button result.highlight(result.action.name), width: 1.0
button result.highlight(result.action.name), width: 1.0 do
if result.group.nil?
page(TAC::Pages::Editor, { action: result.action, action_is_preset: true, is_search: true })
else
page(TAC::Pages::Editor, { group: result.group, action: result.action, group_is_preset: true, is_search: true })
end
end
if result.from_comment?
para result.highlight(result.action.comment), width: 1.0
@@ -102,7 +116,13 @@ module TAC
search_results.variables_from_presets.each do |result|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
button "#{result.highlight(result.variable.name)} [#{result.highlight(result.variable.value)}]", width: 1.0
button "#{result.highlight(result.variable.name)} [#{result.highlight(result.variable.value)}]", width: 1.0 do
if result.group.nil?
page(TAC::Pages::Editor, { action: result.action, variable: result.variable, action_is_preset: true, is_search: true })
else
page(TAC::Pages::Editor, { group: result.group, action: result.action, variable: result.variable, group_is_preset: true, is_search: true })
end
end
end
shared_index += 1