Extract Employee View into own dir

This commit is contained in:
Yuri Becker
2025-04-03 10:56:42 +02:00
parent eda50e036a
commit f172468ba6
12 changed files with 153 additions and 208 deletions

View File

@@ -0,0 +1,178 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import "../../js/qmldict.js" as JsLib
ColumnLayout
{
id: colPar
anchors.fill: parent
Layout.fillWidth: true
Layout.fillHeight: true
implicitWidth: parent.width
Label
{
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
id: headline
text: qsTr("Mitarbeiter / Bewerber hinzufügen")
font.pixelSize: 35
}
ButtonGroup
{
buttons: radio.children
onClicked:
{
checkFields()
personalData.requiredField()
}
}
Row
{
Layout.fillWidth: true
id: radio
//Layout.columnSpan: 2
RadioButton
{
checked: true
text: qsTr("Bewerber")
}
RadioButton
{
text: qsTr("Mitarbeiter")
}
}
// ScrollView
// {
// Layout.fillHeight: true
// Layout.fillWidth: true
// implicitWidth: parent.width
// ColumnLayout
// {
// anchors.fill: parent
// //implicitWidth: parent.width
// //width: parent.width
// //height: parent.height
RowLayout
{
Layout.fillWidth: true
//implicitWidth: parent.width
spacing: 50
Frame
{
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
//implicitWidth: parent.width
ApplicantPersonalData
{
id: personalData
width: parent.width
}
}
Frame
{
Layout.alignment: Qt.AlignTop
Layout.fillWidth: true
visible: radio.children[1].checked
ColumnLayout
{
Layout.alignment: Qt.AlignTop
implicitWidth: parent.width
ApplicantBankData
{
id: bankAccount
}
ApplicantNationalInsurance
{
id: nationalInsurance
}
ApplicantVarious
{
id: applicantVarious
}
}
}
}
Item
{
Layout.fillHeight: true
}
RowLayout
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignRight
Button
{
text: qsTr("Abbrechen")
onClicked: appLoader.source = "Employees/EmployeesView.qml"
}
Button
{
id: saveBtn
text: qsTr("Speichern")
enabled: false
onClicked:
{
var new_applicant
if (radio.children[0].checked)
{
// Ein Bewerber
new_applicant = JsLib.parseForm(personalData)
employee_model.addEmployee(new_applicant, true)
// appLoader.source = "EmployeeTable.qml"
// console.log(JSON.stringify (new_applicant))
}
else
{
// Ein Mitarbeiter
// console.log(personalData, bankAccount, nationalInsurance, applicantVarious)
new_applicant = JsLib.parseForm(personalData, bankAccount, nationalInsurance, applicantVarious)
employee_model.addEmployee(new_applicant, false)
// var new_contact = JsLib.addApplicant(addContactLayout)
// contact_model.addContact(new_contact)
// console.log(JSON.stringify (new_applicant))
}
}
}
}
Component.onCompleted:
{
employee_model.addedNewEmployee.connect(onAddNewEmployee)
}
function onAddNewEmployee(added)
{
if (added)
console.log('addedsuccesfully')
else
console.log('failedtoadd')
appLoader.source = 'Employees/EmployeesView.qml'
}
function checkFields()
{
if(radio.children[1].checked)
{
if(!personalData.checkPersonalField())
saveBtn.enabled = false
else
saveBtn.enabled = true
}
else if (!personalData.checkPersonalField())
saveBtn.enabled = false
else
saveBtn.enabled = true
}
}

View File

@@ -0,0 +1,27 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Item
{
property int selectedEmployee: -1
id: emDet
ColumnLayout
{
Label
{
text: qsTr("Ausgewählter Mitarbeiter " + selectedEmployee)
}
Button
{
text: qsTr("Mitarbeiter zeigen")
onClicked: employeesStack.pop()
}
}
Component.onCompleted:
{
employee_model.onRowClicked(selectedEmployee)
}
}

View File

@@ -0,0 +1,134 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Qt.labs.qmlmodels
ColumnLayout {
anchors.fill: parent
spacing: Dimensions.l
RowLayout {
Layout.fillWidth: true
spacing: Dimensions.l
SearchBar {
}
QuickFilter {
model: ListModel {
ListElement {
name: "Alle"
selected: true
text: qsTr("Alle")
}
ListElement {
name: "Bewerber"
selected: false
text: qsTr("Bewerber")
}
ListElement {
name: "Mitarbeiter"
selected: false
text: qsTr("Kunde")
}
ListElement {
name: "Erledigt"
selected: false
text: qsTr("Erledigt")
}
}
onSelectedChanged: name => {
employee_model.viewCriterion(name);
}
}
Button {
Layout.alignment: Qt.AlignRight
flat: true
icon.source: "qrc:/images/PlusCircle.svg"
text: qsTr("Mitarbeiter Hinzufügen")
onClicked: appLoader.source = "Employees/AddApplicant.qml"
}
}
HorizontalHeaderView {
Layout.fillWidth: true
implicitHeight: 40
movableColumns: true //@disable-check M16
syncView: appliEmpTable
delegate: Rectangle {
Layout.fillWidth: true
border.color: palette.base
color: palette.alternateBase
implicitHeight: 40
implicitWidth: 1
Text {
color: palette.text
elide: Text.ElideRight
height: parent.height
horizontalAlignment: Text.AlignHCenter
text: model.display
verticalAlignment: Text.AlignVCenter
width: parent.width
}
}
}
TableView {
id: appliEmpTable
Layout.fillHeight: true
Layout.fillWidth: true
alternatingRows: true
columnSpacing: 1
model: employee_model
resizableColumns: true
rowSpacing: 2
selectionBehavior: TableView.SelectRows
z: 1
ScrollBar.vertical: ScrollBar {
policy: appliEmpTable.contentHeight > appliEmpTable.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
}
delegate: Rectangle {
required property bool current
required property bool selected
color: selected ? palette.highlight : (appliEmpTable.alternatingRows && row % 2 !== 0 ? palette.base : palette.alternateBase)
implicitHeight: 25
implicitWidth: appliEmpTable.width / appliEmpTable.columns
Text {
color: palette.text
elide: Text.ElideRight
height: parent.height
leftPadding: 9
text: (model.display === null || model.display === undefined) ? "" : model.display
verticalAlignment: Text.AlignVCenter
width: parent.width
}
MouseArea {
property bool hovered: false
anchors.fill: parent
hoverEnabled: true
onDoubleClicked: {
employeesStack.push("EmployeeDetails.qml", {
selectedEmployee: row
});
}
onEntered: {
appliEmpTable.selectionModel.select(appliEmpTable.model.index(row, 0), ItemSelectionModel.SelectCurrent | ItemSelectionModel.Rows);
}
}
}
selectionModel: ItemSelectionModel {
model: appliEmpTable.model
}
}
Item {
Layout.fillWidth: true
}
}

View File

@@ -0,0 +1,16 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import Qt.labs.qmlmodels
Item {
anchors.fill: parent
StackView {
id: employeesStack
anchors.fill: parent
initialItem: "EmployeesTable.qml"
}
}

1
Gui/Employees/qmldir Normal file
View File

@@ -0,0 +1 @@
module Employees