Fixing ObjectAddOnContactPerson.qml conflict
This commit is contained in:
@@ -7,6 +7,21 @@ GridLayout
|
||||
property var contacts: null
|
||||
columns: 2
|
||||
|
||||
Label
|
||||
{
|
||||
text: qsTr("Kontaktdaten")
|
||||
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
||||
}
|
||||
|
||||
ComboBox
|
||||
{
|
||||
property string name: "contacttype"
|
||||
id: contacttype
|
||||
Layout.fillWidth: true
|
||||
editable: false
|
||||
model: [qsTr("Beirat"), qsTr("Hausmeister")]
|
||||
}
|
||||
|
||||
Label
|
||||
{
|
||||
text: qsTr("Anrede")
|
||||
@@ -15,7 +30,7 @@ GridLayout
|
||||
ComboBox
|
||||
{
|
||||
id: title
|
||||
model: [qsTr("Herr"),qsTr("Frau")]
|
||||
model: [qsTr("Herr"), qsTr("Frau"), qsTr("keine Angabe")]
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Label
|
||||
@@ -29,6 +44,7 @@ GridLayout
|
||||
Layout.fillWidth: true
|
||||
placeholderText: "Pflichtfeld"
|
||||
placeholderTextColor: "red"
|
||||
// onTextChanged: checkContactFields()
|
||||
}
|
||||
Label
|
||||
{
|
||||
@@ -51,9 +67,26 @@ GridLayout
|
||||
{
|
||||
id: phonenumber
|
||||
Layout.fillWidth: true
|
||||
placeholderText: "Pflichtfeld"
|
||||
placeholderText: mobile.text ? "" : "Pflichtfeld"
|
||||
placeholderTextColor: "red"
|
||||
|
||||
|
||||
|
||||
}
|
||||
Label
|
||||
{
|
||||
text: qsTr("Mobil")
|
||||
Layout.alignment: Qt.AlignRight
|
||||
}
|
||||
TextField
|
||||
{
|
||||
id: mobile
|
||||
Layout.fillWidth: true
|
||||
placeholderText: phonenumber.text ? "" : "Pflichtfeld"
|
||||
placeholderTextColor: "red"
|
||||
|
||||
|
||||
|
||||
}
|
||||
Label
|
||||
{
|
||||
@@ -82,32 +115,59 @@ GridLayout
|
||||
{
|
||||
id: removeContact
|
||||
text: qsTr("Entfernen")
|
||||
enabled: false
|
||||
onClicked:
|
||||
{
|
||||
|
||||
if (contactView.highlightFollowsCurrentItem)
|
||||
{
|
||||
delete contacts[contactView.currentIndex]
|
||||
contacts = contacts.filter(elm => elm)
|
||||
contactModel.remove(contactView.currentIndex)
|
||||
contactView.highlightFollowsCurrentItem = false
|
||||
contactView.currentIndex = -1
|
||||
if (Object.keys(contacts).length === 0)
|
||||
{
|
||||
enabled = false
|
||||
console.log(contacts)
|
||||
}
|
||||
checkFields()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button
|
||||
{
|
||||
id: addContact
|
||||
text: qsTr("Hinzufügen")
|
||||
enabled: firstname.text.trim() && lastname.text.trim() && (phonenumber.text.trim() || mobile.text.trim()) && posizion.text.trim() && (contacts === null || Object.keys(contacts).length < 3)
|
||||
onClicked:
|
||||
{
|
||||
var num_contacts = 0
|
||||
if (contacts !== null && contacts !== undefined) num_contacts = Object.keys(contacts).length
|
||||
else contacts = {}
|
||||
if (num_contacts < 3 && firstname.text.trim() !== "" && lastname.text.trim() !== "" && phonenumber.text.trim() !== "" && posizion.text.trim() !== "")
|
||||
else contacts = []
|
||||
if (num_contacts < 3 && firstname.text.trim() !== "" && lastname.text.trim() !== "" && (phonenumber.text.trim() !== "" || mobile.text.trim() !== "") && posizion.text.trim() !== "")
|
||||
{
|
||||
contacts[num_contacts] = {}
|
||||
contacts[num_contacts]["title"] = title.currentText
|
||||
contacts[num_contacts]["fname"] = firstname.text.trim()
|
||||
contacts[num_contacts]["lname"] = lastname.text.trim()
|
||||
contacts[num_contacts]["phone"] = phonenumber.text.trim()
|
||||
contacts[num_contacts]["mobile"] = mobile.text.trim()
|
||||
contacts[num_contacts]["position"] = posizion.text.trim()
|
||||
|
||||
contactModel.append({name: title.currentText + " " + firstname.text.trim() + " " + lastname.text.trim(), phone: phonenumber.text.trim(), posizion: posizion.text.trim()})
|
||||
|
||||
contactModel.append({name: title.currentText + " " + firstname.text.trim() + " " + lastname.text.trim(), phone: phonenumber.text.trim(), mobile: mobile.text.trim(), posizion: posizion.text.trim()})
|
||||
if (checkFields())
|
||||
{
|
||||
saveBtn.enabled = true
|
||||
}
|
||||
firstname.text = ""
|
||||
lastname.text = ""
|
||||
phonenumber.text = ""
|
||||
mobile.text = ""
|
||||
posizion.text = ""
|
||||
|
||||
removeContact.enabled = true
|
||||
checkFields()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,7 +196,7 @@ GridLayout
|
||||
width: 175
|
||||
font.bold: true
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
color: "black"
|
||||
color: "white"
|
||||
}
|
||||
|
||||
Text
|
||||
@@ -146,7 +206,17 @@ GridLayout
|
||||
width: 100
|
||||
font.bold: true
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
color: "black"
|
||||
color: "white"
|
||||
}
|
||||
|
||||
Text
|
||||
{
|
||||
id: cpmobile
|
||||
text: qsTr("Mobil")
|
||||
width: 100
|
||||
font.bold: true
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
color: "white"
|
||||
}
|
||||
|
||||
Text
|
||||
@@ -156,7 +226,7 @@ GridLayout
|
||||
width: 150
|
||||
font.bold: true
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
color: "black"
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,30 +252,35 @@ GridLayout
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: mainRect
|
||||
Layout.fillWidth: true
|
||||
implicitHeight: 100
|
||||
color: firstname.palette.base
|
||||
border.color: firstname.activeFocus? firstname.palette.highlight: firstname.palette.base
|
||||
|
||||
ListView
|
||||
{
|
||||
id: contactView
|
||||
implicitHeight: 500
|
||||
implicitHeight: parent.height
|
||||
implicitWidth: parent.width
|
||||
model: contactModel
|
||||
|
||||
|
||||
header: headline
|
||||
|
||||
highlight: highlight
|
||||
|
||||
highlightFollowsCurrentItem: true
|
||||
focus: true
|
||||
|
||||
highlight: Rectangle { color: "grey"}
|
||||
highlightFollowsCurrentItem: false
|
||||
onActiveFocusChanged: if(!focus) currentIndex = -1
|
||||
delegate: Item
|
||||
{
|
||||
//width: parent.width
|
||||
width: contactView.width
|
||||
height: 15
|
||||
MouseArea
|
||||
{
|
||||
anchors.fill: parent
|
||||
onClicked:
|
||||
{
|
||||
contactView.currentIndex = index
|
||||
contactView.highlightFollowsCurrentItem = true
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea
|
||||
{
|
||||
@@ -227,18 +302,28 @@ GridLayout
|
||||
text: model.name
|
||||
width: 175
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
color: "white"
|
||||
}
|
||||
Text
|
||||
{
|
||||
text: model.phone
|
||||
width: 100
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
color: "white"
|
||||
}
|
||||
Text
|
||||
{
|
||||
text: model.mobile
|
||||
width: 100
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
color: "white"
|
||||
}
|
||||
Text
|
||||
{
|
||||
text: model.posizion
|
||||
width: 150
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user