Add Safety Data Sheet links to materials in Marketplace. [CURA-5922]

This commit is contained in:
Remco Burema 2018-11-09 13:44:42 +01:00
parent 80bf7bb989
commit 21d4cd8f9f

View file

@ -11,7 +11,8 @@ Item
id: base id: base
property var packageData property var packageData
property var technicalDataSheetUrl: { property var technicalDataSheetUrl:
{
var link = undefined var link = undefined
if ("Technical Data Sheet" in packageData.links) if ("Technical Data Sheet" in packageData.links)
{ {
@ -25,10 +26,16 @@ Item
} }
return link return link
} }
property var safetyDataSheetUrl:
{
var sds_name = "safetyDataSheet"
return (sds_name in packageData.links) ? packageData.links[sds_name] : undefined
}
anchors.topMargin: UM.Theme.getSize("default_margin").height anchors.topMargin: UM.Theme.getSize("default_margin").height
height: visible ? childrenRect.height : 0 height: visible ? childrenRect.height : 0
visible: packageData.type == "material" && (packageData.has_configs || technicalDataSheetUrl != undefined) visible: packageData.type == "material" &&
(packageData.has_configs || technicalDataSheetUrl !== undefined || safetyDataSheetUrl !== undefined)
Item Item
{ {
@ -163,23 +170,31 @@ Item
Label Label
{ {
id: technical_data_sheet id: data_sheet_links
anchors.top: combatibilityItem.bottom anchors.top: combatibilityItem.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height / 2 anchors.topMargin: UM.Theme.getSize("default_margin").height / 2
visible: base.technicalDataSheetUrl !== undefined visible: base.technicalDataSheetUrl !== undefined || base.safetyDataSheetUrl !== undefined
height: visible ? contentHeight : 0 height: visible ? contentHeight : 0
text: text:
{ {
var result = ""
if (base.technicalDataSheetUrl !== undefined) if (base.technicalDataSheetUrl !== undefined)
{ {
return "<a href='%1'>%2</a>".arg(base.technicalDataSheetUrl).arg("Technical Data Sheet") result += "<a href='%1'>%2</a>".arg(base.technicalDataSheetUrl).arg("Technical Data Sheet")
} }
return "" if (base.safetyDataSheetUrl !== undefined)
{
if (result.length > 0)
{
result += "<br/>"
}
result += "<a href='%1'>%2</a>".arg(base.safetyDataSheetUrl).arg("Safety Data Sheet")
}
return result
} }
font: UM.Theme.getFont("very_small") font: UM.Theme.getFont("very_small")
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
linkColor: UM.Theme.getColor("text_link") linkColor: UM.Theme.getColor("text_link")
onLinkActivated: Qt.openUrlExternally(link) onLinkActivated: Qt.openUrlExternally(link)
} }
} }