Object contact logic implemented
This commit is contained in:
@@ -8,6 +8,7 @@ import "../js/qmldict.js" as JsLib
|
||||
ColumnLayout
|
||||
{
|
||||
property var new_object: null
|
||||
property alias checkAddContact: checkAddContact
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
spacing: 15
|
||||
@@ -74,18 +75,7 @@ ColumnLayout
|
||||
new_object = JsLib.parseForm(newObject)
|
||||
new_object['lift'] = new_object['lift'] === 'Ja' ? 1 : 0
|
||||
new_object['mezzanin'] = new_object['mezzanin'] === 'Ja' ? 1 : 0
|
||||
if (!checkAddContact.checked)
|
||||
{
|
||||
var list = []
|
||||
object_model.addObject(new_object, list, false)
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var new_objecto = addObjectLayout.getForm()
|
||||
object_model.addObject(new_object, new_objecto, true)
|
||||
}
|
||||
object_model.addObject(new_object)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,6 +88,7 @@ ColumnLayout
|
||||
Component.onCompleted:
|
||||
{
|
||||
object_model.objectAdded.connect(onObjectAdded)
|
||||
contact_model.objectContactAdded.connect(onObjectContact)
|
||||
}
|
||||
|
||||
// Connections
|
||||
@@ -112,11 +103,27 @@ ColumnLayout
|
||||
// }
|
||||
// }
|
||||
|
||||
function onObjectAdded(added)
|
||||
function onObjectAdded(added, oid)
|
||||
{
|
||||
if (!added)
|
||||
console.log(qsTr("Fehler beim Objekt-Anlegen!"))
|
||||
appLoader.source = "ObjectTable.qml"
|
||||
if (checkAddContact.checked && oid)
|
||||
{
|
||||
var new_objecto = addObjectLayout.getForm()
|
||||
contact_model.addObjectContact(new_objecto, oid)
|
||||
}
|
||||
else appLoader.source = "ObjectTable.qml"
|
||||
}
|
||||
|
||||
function onObjectContact(added)
|
||||
{
|
||||
if (!added)
|
||||
console.log(qsTr("Fehler beim Objekt-Kontakt-Anlegen!"))
|
||||
else
|
||||
{
|
||||
//object_model.viewCriterion("Alle")
|
||||
appLoader.source = "ObjectTable.qml"
|
||||
}
|
||||
}
|
||||
|
||||
function checkFields()
|
||||
|
||||
@@ -16,7 +16,7 @@ GridLayout
|
||||
ComboBox
|
||||
{
|
||||
//property string name: "contacttype"
|
||||
id: contacttype
|
||||
id: posizion
|
||||
Layout.fillWidth: true
|
||||
editable: false
|
||||
model: [qsTr("Beirat"), qsTr("Hausmeister"), qsTr("Hausbewohner"), qsTr("Sonstiges")]
|
||||
@@ -30,7 +30,7 @@ GridLayout
|
||||
ComboBox
|
||||
{
|
||||
id: title
|
||||
model: [qsTr("Herr"), qsTr("Frau"), qsTr("keine Angabe")]
|
||||
model: [qsTr("Herr"), qsTr("Frau"), qsTr("Keine Angabe")]
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Label
|
||||
@@ -140,23 +140,22 @@ GridLayout
|
||||
{
|
||||
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)
|
||||
enabled: firstname.text.trim() && lastname.text.trim() && (phonenumber.text.trim() || mobile.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() !== "" || mobile.text.trim() !== "") && posizion.text.trim() !== "")
|
||||
if (num_contacts < 3 && firstname.text.trim() !== "" && lastname.text.trim() !== "" && (phonenumber.text.trim() !== "" || mobile.text.trim() !== ""))
|
||||
{
|
||||
contacts[num_contacts] = {}
|
||||
contacts[num_contacts]["title"] = title.currentText
|
||||
contacts[num_contacts]["ctype"] = contacttype.currentText
|
||||
contacts[num_contacts]["position"] = posizion.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(), mobile: mobile.text.trim(), posizion: posizion.text.trim(), cdata: contacttype.currentText})
|
||||
contactModel.append({name: title.currentText + " " + firstname.text.trim() + " " + lastname.text.trim(), phone: phonenumber.text.trim(), mobile: mobile.text.trim(), posizion: posizion.currentText})
|
||||
if (checkFields())
|
||||
{
|
||||
saveBtn.enabled = true
|
||||
@@ -165,7 +164,8 @@ GridLayout
|
||||
lastname.text = ""
|
||||
phonenumber.text = ""
|
||||
mobile.text = ""
|
||||
posizion.text = ""
|
||||
posizion.currentIndex = 0
|
||||
title.currentIndex = 0
|
||||
|
||||
removeContact.enabled = true
|
||||
checkFields()
|
||||
|
||||
@@ -142,5 +142,15 @@ Item
|
||||
// object_model.viewCriterion(criterion.text)
|
||||
// }
|
||||
|
||||
Component.onCompleted: objectsStack.pop()
|
||||
Component.onCompleted:
|
||||
{
|
||||
contact_model.objectContactAdded.connect(onObjectContactAdded)
|
||||
objectsStack.pop()
|
||||
}
|
||||
|
||||
function onObjectContactAdded(added)
|
||||
{
|
||||
console.log(added)
|
||||
if (added) object_model.viewCriterion("")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import QtCore
|
||||
|
||||
ApplicationWindow
|
||||
{
|
||||
//property alias appLoader: appLoader
|
||||
id: appWindow
|
||||
width: Screen.width * .75
|
||||
height: Screen.height * .85
|
||||
@@ -150,6 +151,14 @@ ApplicationWindow
|
||||
}
|
||||
}
|
||||
|
||||
onWindowStateChanged: (windowState) => {
|
||||
if (windowState !== Qt.WindowMinimized)
|
||||
{
|
||||
systray.setVisible(false)
|
||||
appWindow.show()
|
||||
}
|
||||
}
|
||||
|
||||
onClosing: (close) =>
|
||||
{
|
||||
if (false)
|
||||
|
||||
Reference in New Issue
Block a user