mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-15 08:15:58 +08: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
@ -46,33 +46,26 @@ Item
|
|||||||
|
|
||||||
text:
|
text:
|
||||||
{
|
{
|
||||||
if(provider.properties.enabled == "True")
|
if (provider.properties.enabled === "True") return "";
|
||||||
{
|
|
||||||
return ""
|
var key = definition ? definition.key : "";
|
||||||
}
|
var requires = settingDefinitionsModel.getRequires(key, "enabled");
|
||||||
var key = definition ? definition.key : ""
|
|
||||||
var requires = settingDefinitionsModel.getRequires(key, "enabled")
|
if (requires.length === 0) {
|
||||||
if (requires.length == 0)
|
return catalog.i18nc(
|
||||||
{
|
"@item:tooltip",
|
||||||
return catalog.i18nc("@item:tooltip", "This setting has been hidden by the active machine and will not be visible.");
|
"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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 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
|
UM.ColorImage
|
||||||
|
Loading…
x
Reference in New Issue
Block a user