@ -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
Text {
text: "Quantity"
color: productDialog . palette . text
font.bold: true
/ / v i s i b l e : f a l s e
Row {
spacing: 10
Text {
text: qsTr ( "Quantity" )
color: productDialog . palette . text
font.bold: true
}
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 {
@ -250,298 +330,298 @@ Popup {
}
}
Row {
spacing: 5
TextField {
id: productCodeField
width: 500 - parent . children [ 1 ] . width - parent . spacing ; height: 50
placeholderText: qsTr ( "Enter product code" )
color: productDialog . inputTextColor
selectByMouse: true
background: Rectangle {
color: "transparent"
border.color: productDialog . inputBorderColor
border.width: parent . activeFocus ? 2 : 1
radius: productDialog . inputRadius
}
}
NeroshopComponents . ComboBox {
id: productCodeType
height: parent . children [ 0 ] . height / / L a y o u t . p r e f e r r e d W i d t h : 1 0 0 ; L a y o u t . p r e f e r r e d H e i g h t : p a r e n t . c h i l d r e n [ 0 ] . h e i g h t
model: [ "EAN" , "ISBN" , "JAN" , "SKU" , "UPC" ] / / d e f a u l t i s U P C ( e a c h c o d e w i l l b e v a l i d a t e d b e f o r e p r o d u c t i s l i s t e d )
Component.onCompleted: currentIndex = find ( "UPC" )
radius: productDialog . inputRadius
color: productDialog . inputBaseColor
textColor: productDialog . inputTextColor
}
}
Row {
spacing: 5
TextField {
id: productCodeField
width: 500 - parent . children [ 1 ] . width - parent . spacing ; height: 50
placeholderText: qsTr ( "Enter product code" )
color: productDialog . inputTextColor
selectByMouse: true
background: Rectangle {
color: "transparent"
border.color: productDialog . inputBorderColor
border.width: parent . activeFocus ? 2 : 1
radius: productDialog . inputRadius
}
}
}
/ / P r o d u c t c a t e g o r i e s
Item {
/ / L a y o u t . r o w :
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: childrenRect . width
Layout.preferredHeight: childrenRect . height
function getCategoryStringList ( ) {
let categoryStringList = [ ]
let categories = Backend . getCategoryList ( true )
for ( let i = 0 ; i < categories . length ; i ++ ) {
categoryStringList [ i ] = categories [ i ] . name / /console.log(parent.parent.parent.categoryStringList[i])/ / console . log ( categories [ i ] . name )
}
return categoryStringList ;
NeroshopComponents . ComboBox {
id: productCodeType
height: parent . children [ 0 ] . height / / L a y o u t . p r e f e r r e d W i d t h : 1 0 0 ; L a y o u t . p r e f e r r e d H e i g h t : p a r e n t . c h i l d r e n [ 0 ] . h e i g h t
model: [ "EAN" , "ISBN" , "JAN" , "SKU" , "UPC" ] / / d e f a u l t i s U P C ( e a c h c o d e w i l l b e v a l i d a t e d b e f o r e p r o d u c t i s l i s t e d )
Component.onCompleted: currentIndex = find ( "UPC" )
radius: productDialog . inputRadius
color: productDialog . inputBaseColor
textColor: productDialog . inputTextColor
}
}
}
}
/ / P r o d u c t c a t e g o r i e s
Item {
/ / L a y o u t . r o w :
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: childrenRect . width
Layout.preferredHeight: childrenRect . height
function getCategoryStringList ( ) {
let categoryStringList = [ ]
let categories = Backend . getCategoryList ( true )
for ( let i = 0 ; i < categories . length ; i ++ ) {
categoryStringList [ i ] = categories [ i ] . name / /console.log(parent.parent.parent.categoryStringList[i])/ / console . log ( categories [ i ] . name )
}
return categoryStringList ;
}
Column {
spacing: productDialog . titleSpacing
Text {
text: "Category"
color: productDialog . palette . text
font.bold: true
}
Column {
spacing: productDialog . titleSpacing
Text {
text: "Category"
color: productDialog . palette . text
font.bold: true
}
Row {
spacing: 5
NeroshopComponents . ComboBox {
id: productCategoryBox
width: addSubCategoryButton . visible ? ( 500 - addSubCategoryButton . width - parent . spacing ) : 500 ; height: 50
model: parent . parent . parent . getCategoryStringList ( )
Component.onCompleted: {
currentIndex = find ( "Miscellaneous" )
}
function reset ( ) {
let subcategories = Backend . getSubCategoryList ( Backend . getCategoryIdByName ( productCategoryBox . currentText ) , true )
addSubCategoryButton . visible = ( subcategories . length > 0 )
subCategoryRepeater . model = 0 / / r e s e t
}
onActivated: {
productCategoryBox . reset ( )
}
radius: productDialog . inputRadius
color: productDialog . inputBaseColor
textColor: productDialog . inputTextColor
}
Button {
id: addSubCategoryButton
width: 50 ; height: 50
text: qsTr ( "+" )
visible: Backend . hasSubCategory ( Backend . getCategoryIdByName ( productCategoryBox . currentText ) )
background: Rectangle {
color: parent . hovered ? "#698b22" : "#506a1a" / / " # 6 0 5 1 8 5 "
radius: productDialog . inputRadius
}
contentItem: Text {
text: parent . text
color: "#ffffff"
verticalAlignment: Text . AlignVCenter
horizontalAlignment: Text . AlignHCenter
}
onClicked: {
let subcategories = Backend . getSubCategoryList ( Backend . getCategoryIdByName ( productCategoryBox . currentText ) , true )
let max_subcategories = Math . min ( 2 , subcategories . length )
if ( subCategoryRepeater . count == max_subcategories ) {
console . log ( "Cannot add no more than " + max_subcategories + " subcategories" )
return
}
subCategoryRepeater . model = subCategoryRepeater . model + 1
}
}
Row {
spacing: 5
NeroshopComponents . ComboBox {
id: productCategoryBox
width: addSubCategoryButton . visible ? ( 500 - addSubCategoryButton . width - parent . spacing ) : 500 ; height: 50
model: parent . parent . parent . getCategoryStringList ( )
Component.onCompleted: {
currentIndex = find ( "Miscellaneous" )
}
}
}
/ / S u b c a t e g o r i e s ( w i l l b e d e t e r m i n e d b a s e d o n s e l e c t e d c a t e g o r i e s )
Item {
id: subCategoryItem
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: childrenRect . width
Layout.preferredHeight: childrenRect . height
visible: ( subCategoryRepeater . count > 0 ) / / B a c k e n d . h a s S u b C a t e g o r y ( B a c k e n d . g e t C a t e g o r y I d B y N a m e ( p r o d u c t C a t e g o r y B o x . c u r r e n t T e x t ) )
function getSubCategoryStringList ( ) {
let subCategoryStringList = [ ]
let subcategories = Backend . getSubCategoryList ( Backend . getCategoryIdByName ( productCategoryBox . currentText ) , true )
for ( let i = 0 ; i < subcategories . length ; i ++ ) {
subCategoryStringList [ i ] = subcategories [ i ] . name / /console.log(parent.parent.parent.categoryStringList[i])/ / console . log ( categories [ i ] . name )
}
return subCategoryStringList ;
}
Column {
spacing: productDialog . titleSpacing
Text {
text: "Subcategory"
color: productDialog . palette . text
font.bold: true
function reset ( ) {
let subcategories = Backend . getSubCategoryList ( Backend . getCategoryIdByName ( productCategoryBox . currentText ) , true )
addSubCategoryButton . visible = ( subcategories . length > 0 )
subCategoryRepeater . model = 0 / / r e s e t
}
Repeater {
id: subCategoryRepeater
model: 0
delegate: Row {
spacing: 5
NeroshopComponents . ComboBox {
id: productSubCategoryBox
width: removeSubCategoryButton . visible ? ( 500 - removeSubCategoryButton . width - parent . spacing ) : 500 ; height: 50
model: parent . parent . parent . getSubCategoryStringList ( )
currentIndex: 0
radius: productDialog . inputRadius
color: productDialog . inputBaseColor
textColor: productDialog . inputTextColor
}
Button {
id: removeSubCategoryButton
width: 50 ; height: 50
text: qsTr ( "x" )
background: Rectangle {
color: parent . hovered ? "#b22222" : "#921c1c"
radius: productDialog . inputRadius
}
contentItem: Text {
text: parent . text
color: "#ffffff"
verticalAlignment: Text . AlignVCenter
horizontalAlignment: Text . AlignHCenter
}
onClicked: {
subCategoryRepeater . model = subCategoryRepeater . model - 1
}
}
} / / R o w
onActivated: {
productCategoryBox . reset ( )
}
radius: productDialog . inputRadius
color: productDialog . inputBaseColor
textColor: productDialog . inputTextColor
}
}
/ / W e i g h t
Item {
/ / L a y o u t . r o w :
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: childrenRect . width
Layout.preferredHeight: childrenRect . height
Column {
spacing: productDialog . titleSpacing
Row {
spacing: 10
Text {
text: "Weight"
color: productDialog . palette . text
font.bold: true
}
Text {
text: "(OPTIONAL)"
color: productDialog . optTextColor
font.bold: true
font.pointSize: 8
anchors.verticalCenter: parent . children [ 0 ] . verticalCenter
}
Button {
id: addSubCategoryButton
width: 50 ; height: 50
text: qsTr ( "+" )
visible: Backend . hasSubCategory ( Backend . getCategoryIdByName ( productCategoryBox . currentText ) )
background: Rectangle {
color: parent . hovered ? "#698b22" : "#506a1a" / / " # 6 0 5 1 8 5 "
radius: productDialog . inputRadius
}
Row {
spacing: 5
TextField {
id: productWeightField
width: 500 - parent . children [ 1 ] . width - parent . spacing ; height: 50
placeholderText: qsTr ( "Enter weight" )
color: productDialog . inputTextColor
selectByMouse: true
validator: RegExpValidator { regExp: new RegExp ( "^-?[0-9]+(\\.[0-9]{1," + 8 + "})?$" ) }
background: Rectangle {
color: "transparent"
border.color: productDialog . inputBorderColor
border.width: parent . activeFocus ? 2 : 1
radius: productDialog . inputRadius
}
}
NeroshopComponents . ComboBox {
id: weightMeasurementUnit
height: parent . children [ 0 ] . height
model: [ "kg" , "lb" ] / / d e f a u l t i s k g ( e v e r y u n i t o f m e a s u r e m e n t w i l l b e c o n v e r t e d t o k g )
Component.onCompleted: currentIndex = find ( "kg" )
radius: productDialog . inputRadius
color: productDialog . inputBaseColor
textColor: productDialog . inputTextColor
contentItem: Text {
text: parent . text
color: "#ffffff"
verticalAlignment: Text . AlignVCenter
horizontalAlignment: Text . AlignHCenter
}
onClicked: {
let subcategories = Backend . getSubCategoryList ( Backend . getCategoryIdByName ( productCategoryBox . currentText ) , true )
let max_subcategories = Math . min ( 2 , subcategories . length )
if ( subCategoryRepeater . count == max_subcategories ) {
console . log ( "Cannot add no more than " + max_subcategories + " subcategories" )
return
}
subCategoryRepeater . model = subCategoryRepeater . model + 1
}
}
}
/ / S i z e
/ * I t e m {
/ / L a y o u t . r o w :
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: childrenRect . width
Layout.preferredHeight: childrenRect . height
}
}
}
/ / S u b c a t e g o r i e s ( w i l l b e d e t e r m i n e d b a s e d o n s e l e c t e d c a t e g o r i e s )
Item {
id: subCategoryItem
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: childrenRect . width
Layout.preferredHeight: childrenRect . height
visible: ( subCategoryRepeater . count > 0 ) / / B a c k e n d . h a s S u b C a t e g o r y ( B a c k e n d . g e t C a t e g o r y I d B y N a m e ( p r o d u c t C a t e g o r y B o x . c u r r e n t T e x t ) )
Column {
spacing: productDialog . titleSpacing
Row {
spacing: 10
Text {
text: "Size"
color: productDialog . palette . text
font.bold: true
function getSubCategoryStringList ( ) {
let subCategoryStringList = [ ]
let subcategories = Backend . getSubCategoryList ( Backend . getCategoryIdByName ( productCategoryBox . currentText ) , true )
for ( let i = 0 ; i < subcategories . length ; i ++ ) {
subCategoryStringList [ i ] = subcategories [ i ] . name / /console.log(parent.parent.parent.categoryStringList[i])/ / console . log ( categories [ i ] . name )
}
return subCategoryStringList ;
}
Column {
spacing: productDialog . titleSpacing
Text {
text: "Subcategory"
color: productDialog . palette . text
font.bold: true
}
Repeater {
id: subCategoryRepeater
model: 0
delegate: Row {
spacing: 5
NeroshopComponents . ComboBox {
id: productSubCategoryBox
width: removeSubCategoryButton . visible ? ( 500 - removeSubCategoryButton . width - parent . spacing ) : 500 ; height: 50
model: parent . parent . parent . getSubCategoryStringList ( )
currentIndex: 0
radius: productDialog . inputRadius
color: productDialog . inputBaseColor
textColor: productDialog . inputTextColor
}
Button {
id: removeSubCategoryButton
width: 50 ; height: 50
text: qsTr ( "x" )
background: Rectangle {
color: parent . hovered ? "#b22222" : "#921c1c"
radius: productDialog . inputRadius
}
Text {
text: "(OPTIONAL)"
color: productDialog . optTextColor
font.bold: true
font.pointSize: 8
anchors.verticalCenter: parent . children [ 0 ] . verticalCenter
contentItem: Text {
text: parent . text
color: "#ffffff"
verticalAlignment: Text . AlignVCenter
horizontalAlignment: Text . AlignHCenter
}
}
Row {
spacing: 5
TextField {
id: productSizeField
width: 500 ; height: 50
placeholderText: qsTr ( "Enter size" )
color: productDialog . inputTextColor
selectByMouse: true
background: Rectangle {
color: "transparent"
border.color: productDialog . inputBorderColor
border.width: parent . activeFocus ? 2 : 1
radius: productDialog . inputRadius
}
onClicked: {
subCategoryRepeater . model = subCategoryRepeater . model - 1
}
/ / C o m b o B o x
}
}
} * /
/ / V a r i a t i o n s / A t t r i b u t e s ( i . e . C o l o r , S i z e , T y p e , M o d e l , e t c . o p t i o n s t o c h o o s e f r o m - o p t i o n a l )
/ / P r o d u c t l o c a t i o n ( s h i p t o a n d s h i p f r o m )
Item {
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: childrenRect . width
Layout.preferredHeight: childrenRect . height
property var countriesModel: [ "Afghanistan" , "Albania" , "Algeria" , "Andorra" , "Angola" , "Antigua & Deps" , "Argentina" , "Armenia" , "Australia" , "Austria" , "Azerbaijan" , "Bahamas" , "Bahrain" , "Bangladesh" , "Barbados" , "Belarus" , "Belgium" , "Belize" , "Benin" , "Bermuda" , "Bhutan" , "Bolivia" , "Bosnia Herzegovina" , "Botswana" , "Brazil" , "Brunei" , "Bulgaria" , "Burkina" , "Burundi" , "Cambodia" , "Cameroon" , "Canada" , "Cape Verde" , "Central African Rep" , "Chad" , "Chile" , "China" , "Colombia" , "Comoros" , "Congo" , "Congo (Democratic Rep)" , "Costa Rica" , "Croatia" , "Cuba" , "Cyprus" , "Czech Republic" , "Denmark" , "Djibouti" , "Dominica" , "Dominican Republic" , "East Timor" , "Ecuador" , "Egypt" , "El Salvador" , "Equatorial Guinea" , "Eritrea" , "Estonia" , "Eswatini" , "Ethiopia" , "Fiji" , "Finland" , "France" , "Gabon" , "Gambia" , "Georgia" , "Germany" , "Ghana" , "Greece" , "Grenada" , "Guatemala" , "Guinea" , "Guinea-Bissau" , "Guyana" , "Haiti" , "Honduras" , "Hungary" , "Iceland" , "India" , "Indonesia" , "Iran" , "Iraq" , "Ireland (Republic)" , "Israel" , "Italy" , "Ivory Coast" , "Jamaica" , "Japan" , "Jordan" , "Kazakhstan" , "Kenya" , "Kiribati" , "Korea North" , "Korea South" , "Kosovo" , "Kuwait" , "Kyrgyzstan" , "Laos" , "Latvia" , "Lebanon" , "Lesotho" , "Liberia" , "Libya" , "Liechtenstein" , "Lithuania" , "Luxembourg" , "Macedonia" , "Madagascar" , "Malawi" , "Malaysia" , "Maldives" , "Mali" , "Malta" , "Marshall Islands" , "Mauritania" , "Mauritius" , "Mexico" , "Micronesia" , "Moldova" , "Monaco" , "Mongolia" , "Montenegro" , "Morocco" , "Mozambique" , "Myanmar" , "Namibia" , "Nauru" , "Nepal" , "Netherlands" , "New Zealand" , "Nicaragua" , "Niger" , "Nigeria" , "Norway" , "Oman" , "Pakistan" , "Palau" , "Palestine" , "Panama" , "Papua New Guinea" , "Paraguay" , "Peru" , "Philippines" , "Poland" , "Portugal" , "Qatar" , "Romania" , "Russian Federation" , "Rwanda" , "St Kitts & Nevis" , "St Lucia" , "Saint Vincent & the Grenadines" , "Samoa" , "San Marino" , "Sao Tome & Principe" , "Saudi Arabia" , "Senegal" , "Serbia" , "Seychelles" , "Sierra Leone" , "Singapore" , "Slovakia" , "Slovenia" , "Solomon Islands" , "Somalia" , "South Africa" , "South Sudan" , "Spain" , "Sri Lanka" , "Sudan" , "Suriname" , "Sweden" , "Switzerland" , "Syria" , "Taiwan" , "Tajikistan" , "Tanzania" , "Thailand" , "Togo" , "Tonga" , "Trinidad & Tobago" , "Tunisia" , "Turkey" , "Turkmenistan" , "Tuvalu" , "Uganda" , "Ukraine" , "United Arab Emirates" , "United Kingdom" , "United States" , "Unspecified" , "Uruguay" , "Uzbekistan" , "Vanuatu" , "Vatican City" , "Venezuela" , "Vietnam" , "Yemen" , "Zambia" , "Zimbabwe" , "Worldwide" , ]
} / / R o w
}
}
}
/ / W e i g h t
Item {
/ / L a y o u t . r o w :
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: childrenRect . width
Layout.preferredHeight: childrenRect . height
Column {
spacing: productDialog . titleSpacing
Text {
text: "Location"
color: productDialog . palette . text
font.bold: true
}
Column {
spacing: productDialog . titleSpacing
Row {
spacing: 10
Text {
text: "Weight"
color: productDialog . palette . text
font.bold: true
}
Text {
text: "(OPTIONAL)"
color: productDialog . optTextColor
font.bold: true
font.pointSize: 8
anchors.verticalCenter: parent . children [ 0 ] . verticalCenter
}
}
NeroshopComponents . ComboBox {
id: productLocationBox
width: 500 ; height: 50
model: parent . parent . countriesModel
Component.onCompleted: {
contentItem . selectByMouse = true
currentIndex = find ( "Unspecified" ) / / f i n d ( " W o r l d w i d e " )
}
editable: true
onAccepted: {
if ( find ( editText ) === - 1 )
model . append ( { text: editText } )
}
Row {
spacing: 5
TextField {
id: productWeightField
width: 500 - parent . children [ 1 ] . width - parent . spacing ; height: 50
placeholderText: qsTr ( "Enter weight" )
color: productDialog . inputTextColor
selectByMouse: true
validator: RegExpValidator { regExp: new RegExp ( "^-?[0-9]+(\\.[0-9]{1," + 8 + "})?$" ) }
background: Rectangle {
color: "transparent"
border.color: productDialog . inputBorderColor
border.width: parent . activeFocus ? 2 : 1
radius: productDialog . inputRadius
color: productDialog . inputBaseColor
textColor: productDialog . inputTextColor
}
}
}
NeroshopComponents . ComboBox {
id: weightMeasurementUnit
height: parent . children [ 0 ] . height
model: [ "kg" , "lb" ] / / d e f a u l t i s k g ( e v e r y u n i t o f m e a s u r e m e n t w i l l b e c o n v e r t e d t o k g )
Component.onCompleted: currentIndex = find ( "kg" )
radius: productDialog . inputRadius
color: productDialog . inputBaseColor
textColor: productDialog . inputTextColor
}
}
}
}
/ / S i z e
/ * I t e m {
/ / L a y o u t . r o w :
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: childrenRect . width
Layout.preferredHeight: childrenRect . height
Column {
spacing: productDialog . titleSpacing
Row {
spacing: 10
Text {
text: "Size"
color: productDialog . palette . text
font.bold: true
}
Text {
text: "(OPTIONAL)"
color: productDialog . optTextColor
font.bold: true
font.pointSize: 8
anchors.verticalCenter: parent . children [ 0 ] . verticalCenter
}
}
Row {
spacing: 5
TextField {
id: productSizeField
width: 500 ; height: 50
placeholderText: qsTr ( "Enter size" )
color: productDialog . inputTextColor
selectByMouse: true
background: Rectangle {
color: "transparent"
border.color: productDialog . inputBorderColor
border.width: parent . activeFocus ? 2 : 1
radius: productDialog . inputRadius
}
}
/ / C o m b o B o x
}
}
} * /
/ / V a r i a t i o n s / A t t r i b u t e s ( i . e . C o l o r , S i z e , T y p e , M o d e l , e t c . o p t i o n s t o c h o o s e f r o m - o p t i o n a l )
/ / P r o d u c t l o c a t i o n ( s h i p t o a n d s h i p f r o m )
Item {
Layout.alignment: Qt . AlignHCenter
Layout.preferredWidth: childrenRect . width
Layout.preferredHeight: childrenRect . height
property var countriesModel: [ "Afghanistan" , "Albania" , "Algeria" , "Andorra" , "Angola" , "Antigua & Deps" , "Argentina" , "Armenia" , "Australia" , "Austria" , "Azerbaijan" , "Bahamas" , "Bahrain" , "Bangladesh" , "Barbados" , "Belarus" , "Belgium" , "Belize" , "Benin" , "Bermuda" , "Bhutan" , "Bolivia" , "Bosnia Herzegovina" , "Botswana" , "Brazil" , "Brunei" , "Bulgaria" , "Burkina" , "Burundi" , "Cambodia" , "Cameroon" , "Canada" , "Cape Verde" , "Central African Rep" , "Chad" , "Chile" , "China" , "Colombia" , "Comoros" , "Congo" , "Congo (Democratic Rep)" , "Costa Rica" , "Croatia" , "Cuba" , "Cyprus" , "Czech Republic" , "Denmark" , "Djibouti" , "Dominica" , "Dominican Republic" , "East Timor" , "Ecuador" , "Egypt" , "El Salvador" , "Equatorial Guinea" , "Eritrea" , "Estonia" , "Eswatini" , "Ethiopia" , "Fiji" , "Finland" , "France" , "Gabon" , "Gambia" , "Georgia" , "Germany" , "Ghana" , "Greece" , "Grenada" , "Guatemala" , "Guinea" , "Guinea-Bissau" , "Guyana" , "Haiti" , "Honduras" , "Hungary" , "Iceland" , "India" , "Indonesia" , "Iran" , "Iraq" , "Ireland (Republic)" , "Israel" , "Italy" , "Ivory Coast" , "Jamaica" , "Japan" , "Jordan" , "Kazakhstan" , "Kenya" , "Kiribati" , "Korea North" , "Korea South" , "Kosovo" , "Kuwait" , "Kyrgyzstan" , "Laos" , "Latvia" , "Lebanon" , "Lesotho" , "Liberia" , "Libya" , "Liechtenstein" , "Lithuania" , "Luxembourg" , "Macedonia" , "Madagascar" , "Malawi" , "Malaysia" , "Maldives" , "Mali" , "Malta" , "Marshall Islands" , "Mauritania" , "Mauritius" , "Mexico" , "Micronesia" , "Moldova" , "Monaco" , "Mongolia" , "Montenegro" , "Morocco" , "Mozambique" , "Myanmar" , "Namibia" , "Nauru" , "Nepal" , "Netherlands" , "New Zealand" , "Nicaragua" , "Niger" , "Nigeria" , "Norway" , "Oman" , "Pakistan" , "Palau" , "Palestine" , "Panama" , "Papua New Guinea" , "Paraguay" , "Peru" , "Philippines" , "Poland" , "Portugal" , "Qatar" , "Romania" , "Russian Federation" , "Rwanda" , "St Kitts & Nevis" , "St Lucia" , "Saint Vincent & the Grenadines" , "Samoa" , "San Marino" , "Sao Tome & Principe" , "Saudi Arabia" , "Senegal" , "Serbia" , "Seychelles" , "Sierra Leone" , "Singapore" , "Slovakia" , "Slovenia" , "Solomon Islands" , "Somalia" , "South Africa" , "South Sudan" , "Spain" , "Sri Lanka" , "Sudan" , "Suriname" , "Sweden" , "Switzerland" , "Syria" , "Taiwan" , "Tajikistan" , "Tanzania" , "Thailand" , "Togo" , "Tonga" , "Trinidad & Tobago" , "Tunisia" , "Turkey" , "Turkmenistan" , "Tuvalu" , "Uganda" , "Ukraine" , "United Arab Emirates" , "United Kingdom" , "United States" , "Unspecified" , "Uruguay" , "Uzbekistan" , "Vanuatu" , "Vatican City" , "Venezuela" , "Vietnam" , "Yemen" , "Zambia" , "Zimbabwe" , "Worldwide" , ]
Column {
spacing: productDialog . titleSpacing
Text {
text: "Location"
color: productDialog . palette . text
font.bold: true
}
NeroshopComponents . ComboBox {
id: productLocationBox
width: 500 ; height: 50
model: parent . parent . countriesModel
Component.onCompleted: {
contentItem . selectByMouse = true
currentIndex = find ( "Unspecified" ) / / f i n d ( " W o r l d w i d e " )
}
editable: true
onAccepted: {
if ( find ( editText ) === - 1 )
model . append ( { text: editText } )
}
radius: productDialog . inputRadius
color: productDialog . inputBaseColor
textColor: productDialog . inputTextColor
}
}
}
/ / P r o d u c t d e s c r i p t i o n a n d b u l l e t p o i n t s
Item {
/ / L a y o u t . r o w :
@ -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 ( ) ,