@ -3,6 +3,8 @@ import QtQuick.Controls 2.12
import QtQuick . Layouts 1.12
import Qt . labs . platform 1.1 / / F i l e D i a l o g
import FontAwesome 1.0
import "." as NeroshopComponents
Popup {
@ -22,14 +24,69 @@ Popup {
background: Rectangle {
radius: 8
color: ( NeroshopComponents . Style . darkTheme ) ? ( NeroshopComponents . Style . themeName == "PurpleDust" ? "#0e0e11" : "#101010" ) : "#f0f0f0"
/ / h e a d e r
Rectangle {
id: titleBar
color: "#202020"
height: 40
width: parent . width
anchors.left: parent . left
anchors.right: parent . right
radius: 6
/ / R o u n d e d t o p c o r n e r s
Rectangle {
anchors.left: parent . left
anchors.right: parent . right
anchors.bottom: parent . bottom
height: parent . height / 2
color: parent . color
}
Label {
text: "Add item"
color: "#ffffff"
font.bold: true
anchors.horizontalCenter: parent . horizontalCenter
anchors.verticalCenter: parent . verticalCenter
}
Button {
id: closeButton
width: 25
height: this . width
anchors.verticalCenter: titleBar . verticalCenter
anchors.right: titleBar . right
anchors.rightMargin: 10
text: qsTr ( FontAwesome . xmark )
contentItem: Text {
text: closeButton . text
color: "#ffffff"
font.bold: true
font.family: FontAwesome . fontFamily
horizontalAlignment: Text . AlignHCenter
verticalAlignment: Text . AlignVCenter
}
background: Rectangle {
color: "#ff4d4d"
radius: 100
}
onClicked: {
productDialog . close ( )
mainScrollView . ScrollBar . vertical . position = 0.0 / / r e s e t s c r o l l b a r
}
}
}
}
contentItem: ScrollView {
id: mainScrollView
anchors.fill: parent
anchors.topMargin: 20 ; anchors.bottomMargin: anchors . topMargin / / / / a n c h o r s . m a r g i n s : 2 0
anchors.topMargin: titleBar . height + 20 ; anchors.bottomMargin: 20 / /anchors.topMargin/ // / a n c h o r s . m a r g i n s : 2 0
clip: true
ScrollBar.vertical.policy: ScrollBar . AsNeeded
ScrollBar.vertical.policy: ScrollBar . A lway sOn/ / A s N e e d e d
ColumnLayout {
width: productDialog . availableWidth ; height: productDialog . availableHeight
spacing: 30
@ -41,7 +98,7 @@ Popup {
Column {
spacing: productDialog . titleSpacing
Text {
text: " Product nam e"
text: " Name / Titl e"
color: productDialog . palette . text
font.bold: true
}
@ -124,11 +181,34 @@ Popup {
Column {
spacing: productDialog . titleSpacing
Row {
spacing: 10
Text {
text: "Quantity"
text: qsTr ( "Quantity" )
color: productDialog . palette . text
font.bold: true
/ / v i s i b l e : f a l s e
}
Text {
text: qsTr ( FontAwesome . circleInfo )
color: productDialog . optTextColor
font.bold: true
/ / f o n t . p o i n t S i z e :
anchors.verticalCenter: parent . children [ 0 ] . verticalCenter
property bool hovered: false
NeroshopComponents . Hint {
x: parent . width + 10 ; y: ( ( parent . height - height ) / 2 ) - 3
visible: parent . hovered
height: contentHeight + 20 ; width: contentWidth + 20
text: qsTr ( "The total number of items in stock" )
pointer.visible: false ; / / d e l a y : 0
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: parent . hovered = true
onExited: parent . hovered = false
}
}
}
TextField {
@ -625,7 +705,7 @@ Popup {
contentWidth: ( 210 * productImageRepeater . count ) + ( 5 * ( productImageRepeater . count - 1 ) ) / /<- 5 is the Flow.spacing/ / ; contentHeight: 210 / / < - c o n t e n t H e i g h t i s n o t n e e d e d u n l e s s a n e w l i n e i s s u p p o r t e d
clip: true
ScrollBar.horizontal: ScrollBar {
policy: ScrollBar . A sNeeded
policy: ScrollBar . A lway sOn/ / A s N e e d e d
}
Flow {
width: parent . contentWidth ; height: parent . height / /anchors.fill: parent/ / Note: Flow width must be large enough to fit all items horizontally so that there won ' t be a need to move an item to a newline
@ -662,6 +742,44 @@ Popup {
/ / i f ( t h i s . s t a t u s = = I m a g e . N u l l ) c o n s o l e . l o g ( " N o i m a g e h a s b e e n s e t " + p a r e n t . p a r e n t . i n d e x )
}
}
/ / P o s i t i o n t h e c l o s e b u t t o n
Button {
id: removeImageButton
anchors.right: parent . right
anchors.top: parent . top
anchors.margins: 8
width: 20 ; height: 20 / / 3 2
text: qsTr ( FontAwesome . xmark )
hoverEnabled: true
visible: ( parent . children [ 0 ] . status === Image . Ready )
contentItem: Text {
horizontalAlignment: Text . AlignHCenter
verticalAlignment: Text . AlignVCenter
text: removeImageButton . text
color: removeImageButton . hovered ? "#ffffff" : "#000000"
font.bold: true
font.family: FontAwesome . fontFamily
}
background: Rectangle {
width: parent . width
height: parent . height
radius: 5 / / 5 0
color: removeImageButton . hovered ? "firebrick" : "transparent"
opacity: 0.7
}
onClicked: {
parent . children [ 0 ] . source = ""
}
MouseArea {
anchors.fill: parent
onPressed: mouse . accepted = false
cursorShape: Qt . PointingHandCursor
}
}
}
Button {
@ -735,7 +853,7 @@ Popup {
id: listProductButton
width: 333.333333333 ; height: contentItem . contentHeight + 30
hoverEnabled: true
text: qsTr ( " Add ")
text: qsTr ( " Submit ")
background: Rectangle {
color: parent . hovered ? "#698b22" : "#506a1a"
radius: productDialog . inputRadius
@ -750,6 +868,12 @@ Popup {
/ / C h e c k i n p u t f i e l d s t o s e e i f e n t e r e d i n f o i s v a l i d
/ / . . .
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if ( productNameField . text . length < 3 ) {
messageBox . text = qsTr ( "Product name is too short" )
messageBox . open ( )
return ; / / e x i t f u n c t i o n
}
/ / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
let subcategory_ids = [ ] / / l e t s u b c a t e g o r i e s = [ ]
for ( let i = 0 ; i < subCategoryRepeater . count ; i ++ ) {
subcategory_ids . push ( Backend . getSubCategoryIdByName ( subCategoryRepeater . itemAt ( i ) . children [ 0 ] . currentText ) ) / /subcategories.push(subCategoryRepeater.itemAt(i).children[0].currentText)/ / console . log ( "Added subcategory: " , subcategories [ i ] )
@ -767,7 +891,12 @@ Popup {
let attributes = [ ] ;
let attribute_object = { } ;
if ( productWeightField . text . length > 0 && Number ( productWeightField . text ) > 0.00 ) {
attribute_object . weight = productWeightField . text
if ( weightMeasurementUnit . currentText !== "kg" ) {
console . log ( "weight is in " + weightMeasurementUnit . currentText + ". Converting to kg ..." )
attribute_object . weight = Backend . weightToKg ( Number ( productWeightField . text ) , weightMeasurementUnit . currentText )
} else {
attribute_object . weight = Number ( productWeightField . text )
}
}
/ / A d d a t t r i b u t e o b j t o l i s t a s l o n g a s i t s f i l l e d w i t h p r o p e r t i e s
if ( Object . keys ( attribute_object ) . length > 0 ) {
@ -799,7 +928,7 @@ Popup {
productNameField . text ,
productDescriptionEdit . text ,
attributes ,
productCode Field. text ,
productCode Type. currentText . toLowerCase ( ) + ":" + productCode Field. text ,
Backend . getCategoryIdByName ( productCategoryBox . currentText ) ,
( subCategoryRepeater . count > 0 ) ? subcategory_ids : [ ] , / / s u b c a t e g o r y I d s
productTagsField . tags ( ) ,