Commit 606f12d6 authored by Karel Slaný's avatar Karel Slaný Committed by Martin Straka

Identifying data source in e-gov service form page.

parent 2dd93eda
......@@ -31,6 +31,19 @@ ScrollableListView {
id: root
delegateHeight: listItemHeight
/*
* Return asterisks.
*/
function asterisks(mandatory, userInput, boxInput) {
if (mandatory && userInput) {
return " *"
} else if (boxInput) {
return " **"
} else {
return ""
}
}
delegate: Rectangle {
id: formItem
height: root.delegateHeight
......@@ -46,7 +59,7 @@ ScrollableListView {
spacing: formItemVerticalSpacing
anchors.verticalCenter: parent.verticalCenter
Text {
text: gsDescr
text: gsDescr + asterisks(gsMandatory, gsUserInput, gsBoxInput)
color: enabled ? datovkaPalette.text : datovkaPalette.mid // dark
font.bold: true
width: parent.width
......
......@@ -42,6 +42,8 @@ Item {
Component.onCompleted: {
gov.loadFormToModel(userName, gsInternId, govFormModel)
actionButton.enabled = govFormModel.haveAllMandatory()
userMandatoryText.visible = govFormModel.containsMandatoryUser()
fromDataBoxText.visible = govFormModel.containsBoxOwnerData()
}
GovFormListModel {
......@@ -49,6 +51,8 @@ Item {
onDataChanged: {
actionButton.enabled = govFormModel.haveAllMandatory()
userMandatoryText.visible = govFormModel.containsMandatoryUser()
fromDataBoxText.visible = govFormModel.containsBoxOwnerData()
}
Component.onCompleted: {
......@@ -106,14 +110,18 @@ Item {
text: " "
}
AccessibleText {
id: userMandatoryText
font.bold: false
width: parent.width
wrapMode: Text.Wrap
text: (formList.count !== 0) ? qsTr("Following information are required:") : ""
text: "(*) " + qsTr("Required information")
}
Text {
AccessibleText {
id: fromDataBoxText
font.bold: false
text: " "
width: parent.width
wrapMode: Text.Wrap
text: "(**) " + qsTr("Acquired from data box")
}
}
}
......
......@@ -172,6 +172,28 @@ bool GovFormListModel::haveAllMandatory(void) const
return true;
}
bool GovFormListModel::containsMandatoryUser(void) const
{
foreach (const Gov::RequiredInput &ri, m_requiredInputList) {
if (ri.mandatory && ri.userInput) {
return true;
}
}
return false;
}
bool GovFormListModel::containsBoxOwnerData(void) const
{
foreach (const Gov::RequiredInput &ri, m_requiredInputList) {
if (ri.boxInput) {
return true;
}
}
return false;
}
GovFormListModel *GovFormListModel::fromVariant(const QVariant &modelVariant)
{
if (!modelVariant.canConvert<QObject *>()) {
......
......@@ -157,6 +157,24 @@ public:
Q_INVOKABLE
bool haveAllMandatory(void) const;
/*!
* @brief Return true if model contains mandatory data that must be
* provided by the user.
*
* @return True if at least one such field is in the model.
*/
Q_INVOKABLE
bool containsMandatoryUser(void) const;
/*!
* @brief Return true if model contains data that have been acquired
* from the data box.
*
* @return true if at least on such field is in the model.
*/
Q_INVOKABLE
bool containsBoxOwnerData(void) const;
/*!
* @brief Converts QVariant obtained from QML into model pointer.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment