lib/openc3/models/widget_model.rb in openc3-5.6.1 vs lib/openc3/models/widget_model.rb in openc3-5.7.0
- old
+ new
@@ -70,36 +70,40 @@
# Called by the PluginModel to allow this class to validate it's top-level keyword: "WIDGET"
def self.handle_config(parser, keyword, parameters, plugin: nil, needs_dependencies: false, scope:)
case keyword
when 'WIDGET'
- parser.verify_num_parameters(1, 1, "WIDGET <Name>")
- return self.new(name: parameters[0], plugin: plugin, needs_dependencies: needs_dependencies, scope: scope)
+ parser.verify_num_parameters(1, 2, "WIDGET <Name> <Label>")
+ # Label is optional and if it doesn't exist nil is fine
+ return self.new(name: parameters[0], plugin: plugin, label: parameters[1], needs_dependencies: needs_dependencies, scope: scope)
else
raise ConfigParser::Error.new(parser, "Unknown keyword and parameters for Widget: #{keyword} #{parameters.join(" ")}")
end
return nil
end
def initialize(
name:,
updated_at: nil,
plugin: nil,
+ label: nil,
needs_dependencies: false,
scope:
)
super("#{scope}__#{PRIMARY_KEY}", name: name, plugin: plugin, updated_at: updated_at, scope: scope)
@full_name = @name.capitalize + 'Widget'
@filename = @full_name + '.umd.min.js'
@bucket_key = 'widgets/' + @full_name + '/' + @filename
+ @label = label
@needs_dependencies = needs_dependencies
end
def as_json(*a)
{
'name' => @name,
'updated_at' => @updated_at,
'plugin' => @plugin,
+ 'label' => @label,
'needs_dependencies' => @needs_dependencies,
}
end
def handle_config(parser, keyword, parameters)