mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-09 06:45:09 -06:00
Replace for loop with map() and remove redundant else
- map().join is a better fit that replaces the for loop and a if/else since there is no complex logic involved. - there is a return inside the if statement for requires.length ===0, so no need for else statement as the code execution stops with return
This commit is contained in:
parent
e1430c76fd
commit
0e5f282238
1 changed files with 18 additions and 25 deletions
|
@ -46,33 +46,26 @@ Item
|
|||
|
||||
text:
|
||||
{
|
||||
if(provider.properties.enabled == "True")
|
||||
{
|
||||
return ""
|
||||
}
|
||||
var key = definition ? definition.key : ""
|
||||
var requires = settingDefinitionsModel.getRequires(key, "enabled")
|
||||
if (requires.length == 0)
|
||||
{
|
||||
return catalog.i18nc("@item:tooltip", "This setting has been hidden by the active machine and will not be visible.");
|
||||
}
|
||||
else
|
||||
{
|
||||
var requires_text = ""
|
||||
for (var i in requires)
|
||||
{
|
||||
if (requires_text == "")
|
||||
{
|
||||
requires_text = requires[i].label
|
||||
}
|
||||
else
|
||||
{
|
||||
requires_text += ", " + requires[i].label
|
||||
}
|
||||
}
|
||||
if (provider.properties.enabled === "True") return "";
|
||||
|
||||
return catalog.i18ncp("@item:tooltip %1 is list of setting names", "This setting has been hidden by the value of %1. Change the value of that setting to make this setting visible.", "This setting has been hidden by the values of %1. Change the values of those settings to make this setting visible.", requires.length) .arg(requires_text);
|
||||
var key = definition ? definition.key : "";
|
||||
var requires = settingDefinitionsModel.getRequires(key, "enabled");
|
||||
|
||||
if (requires.length === 0) {
|
||||
return catalog.i18nc(
|
||||
"@item:tooltip",
|
||||
"This setting has been hidden by the active machine and will not be visible."
|
||||
);
|
||||
}
|
||||
|
||||
var requiresText = requires.map(r => r.label).join(", ");
|
||||
|
||||
return catalog.i18ncp(
|
||||
"@item:tooltip %1 is list of setting names",
|
||||
"This setting has been hidden by the value of %1. Change the value of that setting to make this setting visible.",
|
||||
"This setting has been hidden by the values of %1. Change the values of those settings to make this setting visible.",
|
||||
requires.length
|
||||
).arg(requiresText);
|
||||
}
|
||||
|
||||
UM.ColorImage
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue