mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 22:02:34 +00:00
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:
@@ -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|
|
@var_type = list_box items: [:float, :double, :integer, :long, :string, :boolean], choose: @type ? @type : :double, width: 1.0 do |item|
|
||||||
@type = item
|
@type = item
|
||||||
|
if @type == :boolean
|
||||||
|
@value.hide
|
||||||
|
@value_boolean.show
|
||||||
|
else
|
||||||
|
@value.show
|
||||||
|
@value_boolean.hide
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@type ||= @var_type.value.to_sym
|
@type ||= @var_type.value.to_sym
|
||||||
@@ -26,7 +33,13 @@ module TAC
|
|||||||
@value_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
@value_error = label "Error", color: TAC::Palette::TACNET_CONNECTION_ERROR
|
||||||
@value_error.hide
|
@value_error.hide
|
||||||
@value = edit_line @options[:variable] ? @options[:variable].value : "", width: 1.0
|
@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
|
end
|
||||||
|
|
||||||
flow width: 1.0, margin_top: THEME_DIALOG_BUTTON_PADDING do
|
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|
|
button @options[:variable] ? "Update" : "Add", width: 0.475 do |b|
|
||||||
if valid?
|
if valid?
|
||||||
|
value = @type == :boolean ? @value_boolean.value.to_s : @value.value.strip
|
||||||
|
|
||||||
if @options[:variable]
|
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
|
else
|
||||||
@options[:callback_method].call(@name.value.strip, @type, @value.value.strip)
|
@options[:callback_method].call(@name.value.strip, @type, value)
|
||||||
end
|
end
|
||||||
|
|
||||||
close
|
close
|
||||||
@@ -105,9 +120,6 @@ module TAC
|
|||||||
end
|
end
|
||||||
|
|
||||||
elsif @type == :boolean
|
elsif @type == :boolean
|
||||||
@value_error.value = "Error: Boolean not yet supported."
|
|
||||||
@value_error.show
|
|
||||||
valid = false
|
|
||||||
|
|
||||||
else
|
else
|
||||||
@value_error.value = "Error: Type not set or\ntype #{@var_type.value.inspect} is not valid."
|
@value_error.value = "Error: Type not set or\ntype #{@var_type.value.inspect} is not valid."
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ module TAC
|
|||||||
@options = options
|
@options = options
|
||||||
end
|
end
|
||||||
|
|
||||||
def page(klass)
|
def page(klass, options = {})
|
||||||
@host.page(klass)
|
@host.page(klass, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def header_bar(text)
|
def header_bar(text)
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ module TAC
|
|||||||
search_results.groups.each do |result|
|
search_results.groups.each do |result|
|
||||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
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
|
end
|
||||||
|
|
||||||
shared_index += 1
|
shared_index += 1
|
||||||
@@ -39,7 +41,9 @@ module TAC
|
|||||||
search_results.actions.each do |result|
|
search_results.actions.each do |result|
|
||||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
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?
|
if result.from_comment?
|
||||||
para result.highlight(result.action.comment), width: 1.0
|
para result.highlight(result.action.comment), width: 1.0
|
||||||
@@ -56,7 +60,9 @@ module TAC
|
|||||||
search_results.variables.each do |result|
|
search_results.variables.each do |result|
|
||||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
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
|
end
|
||||||
|
|
||||||
shared_index += 1
|
shared_index += 1
|
||||||
@@ -71,7 +77,9 @@ module TAC
|
|||||||
search_results.group_presets.each do |result|
|
search_results.group_presets.each do |result|
|
||||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
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
|
end
|
||||||
|
|
||||||
shared_index += 1
|
shared_index += 1
|
||||||
@@ -85,7 +93,13 @@ module TAC
|
|||||||
search_results.action_presets.each do |result|
|
search_results.action_presets.each do |result|
|
||||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
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?
|
if result.from_comment?
|
||||||
para result.highlight(result.action.comment), width: 1.0
|
para result.highlight(result.action.comment), width: 1.0
|
||||||
@@ -102,7 +116,13 @@ module TAC
|
|||||||
search_results.variables_from_presets.each do |result|
|
search_results.variables_from_presets.each do |result|
|
||||||
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
stack(width: 1.0, **THEME_ITEM_CONTAINER_PADDING) do
|
||||||
background shared_index.even? ? THEME_EVEN_COLOR : THEME_ODD_COLOR
|
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
|
end
|
||||||
|
|
||||||
shared_index += 1
|
shared_index += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user