Commit 2dd93eda authored by Karel Slaný's avatar Karel Slaný Committed by Martin Straka

Displaying data acquired from data box info in e-gov forms.

parent 26f0d464
......@@ -35,7 +35,8 @@ ScrollableListView {
id: formItem
height: root.delegateHeight
width: parent.width
//color: datovkaPalette.base
enabled: gsUserInput
color: enabled ? datovkaPalette.base : readBgColor
Item {
anchors.fill: parent
anchors.margins: defaultMargin
......@@ -46,7 +47,7 @@ ScrollableListView {
anchors.verticalCenter: parent.verticalCenter
Text {
text: gsDescr
//color: headerColor
color: enabled ? datovkaPalette.text : datovkaPalette.mid // dark
font.bold: true
width: parent.width
wrapMode: Text.Wrap
......
......@@ -147,7 +147,7 @@ Item {
onRunSendGovMessageSig: {
actionButton.enabled = false
if (gov.sendGovRequest(userName, gsInternId, govFormModel)) {
pageView.pop(StackView.Immediate)
pageView.pop(null, StackView.Immediate) // back to account list
} else {
actionButton.enabled = govFormModel.haveAllMandatory()
}
......
......@@ -55,6 +55,8 @@ int GovFormListModel::rowCount(const QModelIndex &parent) const
#define PROP_DESCR "gsDescr"
#define PROP_PLACEHOLD "gsPlacehold"
#define PROP_MANDATORY "gsMandatory"
#define PROP_USER_INPUT "gsUserInput"
#define PROP_BOX_INPUT "gsBoxInput"
QHash<int, QByteArray> GovFormListModel::roleNames(void) const
{
......@@ -65,6 +67,8 @@ QHash<int, QByteArray> GovFormListModel::roleNames(void) const
roles[ROLE_GOV_SRVC_DESCR] = PROP_DESCR;
roles[ROLE_GOV_SRVC_PLACEHOLD] = PROP_PLACEHOLD;
roles[ROLE_GOV_SRVC_MANDATORY] = PROP_MANDATORY;
roles[ROLE_GOV_SRVC_USER_INPUT] = PROP_USER_INPUT;
roles[ROLE_GOV_SRVC_BOX_INPUT] = PROP_BOX_INPUT;
}
return roles;
}
......@@ -95,6 +99,12 @@ QVariant GovFormListModel::data(const QModelIndex &index, int role) const
case ROLE_GOV_SRVC_MANDATORY:
return ri.mandatory;
break;
case ROLE_GOV_SRVC_USER_INPUT:
return ri.userInput;
break;
case ROLE_GOV_SRVC_BOX_INPUT:
return ri.boxInput;
break;
default:
/* Do nothing. */
break;
......
......@@ -44,7 +44,9 @@ public:
ROLE_GOV_SRVC_VAL,
ROLE_GOV_SRVC_DESCR,
ROLE_GOV_SRVC_PLACEHOLD,
ROLE_GOV_SRVC_MANDATORY
ROLE_GOV_SRVC_MANDATORY,
ROLE_GOV_SRVC_USER_INPUT,
ROLE_GOV_SRVC_BOX_INPUT
};
Q_ENUM(Roles)
......
......@@ -56,7 +56,10 @@ static const char xml_template[] =
"</d:root>";
Gov::SrvcMvCrrVbh::SrvcMvCrrVbh(void)
: m_drivingLicenceId()
: m_userDrivingLicenceId(),
m_boxName(),
m_boxSurname(),
m_boxBirthDate()
{
}
......@@ -122,6 +125,11 @@ bool Gov::SrvcMvCrrVbh::canSend(enum Isds::Type::DbType dbType) const
}
#define DRILIC_KEY "drivingLicenceId"
#define NAME_KEY "name"
#define SURNAME_KEY "surname"
#define BIRTH_KEY "birthDate"
#define DATE_FORMAT "yyyy-MM-dd"
QList<Gov::RequiredInput> Gov::SrvcMvCrrVbh::requiredFields(void) const
{
......@@ -130,10 +138,46 @@ QList<Gov::RequiredInput> Gov::SrvcMvCrrVbh::requiredFields(void) const
{
RequiredInput ri;
ri.key = DRILIC_KEY;
ri.val = m_drivingLicenceId;
ri.val = m_userDrivingLicenceId;
ri.descr = tr("Driving licence ID");
ri.placeholder = tr("Enter driving licence ID without spaces");
ri.mandatory = true;
ri.userInput = true;
ri.boxInput = false;
formList.append(ri);
}
{
RequiredInput ri;
ri.key = NAME_KEY;
ri.val = m_boxName;
ri.descr = tr("Data-box owner name");
ri.placeholder = QString();
ri.mandatory = true;
ri.userInput = false;
ri.boxInput = true;
formList.append(ri);
}
{
RequiredInput ri;
ri.key = SURNAME_KEY;
ri.val = m_boxSurname;
ri.descr = tr("Data-box owner surname");
ri.placeholder = QString();
ri.mandatory = true;
ri.userInput = false;
ri.boxInput = true;
formList.append(ri);
}
{
RequiredInput ri;
ri.key = BIRTH_KEY;
ri.val = m_boxBirthDate.isNull() ? QString() : m_boxBirthDate.toString(DATE_FORMAT);
ri.descr = tr("Birth date");
ri.placeholder = QString();
ri.mandatory = true;
ri.userInput = false;
ri.boxInput = true;
formList.append(ri);
}
......@@ -142,27 +186,53 @@ QList<Gov::RequiredInput> Gov::SrvcMvCrrVbh::requiredFields(void) const
bool Gov::SrvcMvCrrVbh::setRequiredField(const QString &key, const QString &val)
{
if (key != DRILIC_KEY) {
if (key == DRILIC_KEY) {
m_userDrivingLicenceId = val;
return true;
} else if (key == NAME_KEY) {
m_boxName = val;
return true;
} else if (key == SURNAME_KEY) {
m_boxSurname = val;
return true;
} else if (key == BIRTH_KEY) {
QDate date(QDate::fromString(val, DATE_FORMAT));
if (date.isNull()) {
return false;
}
m_boxBirthDate = date;
return true;
} else {
return false;
}
}
bool Gov::SrvcMvCrrVbh::setOwnerInfoFields(const Isds::DbOwnerInfo &dbOwnerInfo)
{
if (Q_UNLIKELY(dbOwnerInfo.isNull())) {
return false;
}
m_drivingLicenceId = val;
m_boxName = dbOwnerInfo.personName().firstName();
m_boxSurname = dbOwnerInfo.personName().lastName();
m_boxBirthDate = dbOwnerInfo.birthInfo().date();
return true;
return (!m_boxName.isEmpty()) && (!m_boxSurname.isEmpty()) &&
(!m_boxBirthDate.isNull());
}
bool Gov::SrvcMvCrrVbh::haveAllMandatoryFields(void) const
{
return !m_drivingLicenceId.isEmpty();
return (!m_userDrivingLicenceId.isEmpty()) && (!m_boxName.isEmpty()) &&
(!m_boxSurname.isEmpty()) && (!m_boxBirthDate.isNull());
}
QByteArray Gov::SrvcMvCrrVbh::binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const
QByteArray Gov::SrvcMvCrrVbh::binaryXmlContent(void) const
{
QString xml(xml_template);
xml.replace("__repl_NAME__", dbOwnerInfo.personName().firstName());
xml.replace("__repl_SURNAME__", dbOwnerInfo.personName().lastName());
xml.replace("__repl_BIRTH_DATE__", dbOwnerInfo.birthInfo().date().toString("yyyy-MM-dd"));
xml.replace("__repl_DRIVE_LICENSE_ID__", m_drivingLicenceId);
xml.replace("__repl_DRIVE_LICENSE_ID__", m_userDrivingLicenceId);
xml.replace("__repl_NAME__", m_boxName);
xml.replace("__repl_SURNAME__", m_boxSurname);
xml.replace("__repl_BIRTH_DATE__", m_boxBirthDate.toString(DATE_FORMAT));
return xml.toUtf8();
}
......@@ -24,6 +24,7 @@
#pragma once
#include <QCoreApplication> /* Q_DECLARE_TR_FUNCTIONS */
#include <QDate>
#include "src/datovka_shared/gov_services/service/gov_service.h"
......@@ -79,14 +80,20 @@ namespace Gov {
virtual
bool setRequiredField(const QString &key, const QString &val) Q_DECL_OVERRIDE;
virtual
bool setOwnerInfoFields(const Isds::DbOwnerInfo &dbOwnerInfo) Q_DECL_OVERRIDE;
virtual
bool haveAllMandatoryFields(void) const Q_DECL_OVERRIDE;
virtual
QByteArray binaryXmlContent(const Isds::DbOwnerInfo &dbOwnerInfo) const Q_DECL_OVERRIDE;
QByteArray binaryXmlContent(void) const Q_DECL_OVERRIDE;
private:
QString m_drivingLicenceId; /*!< Driving licence identifier (number) without white spaces. */
QString m_userDrivingLicenceId; /*!< Driving licence identifier (number) without white spaces. */
QString m_boxName; /*!< First name derived from box data. */
QString m_boxSurname; /*!< Seurname derived from box data. */
QDate m_boxBirthDate; /*!< Birth date derived from box data. */
};
}
......@@ -490,7 +490,7 @@ static const char xml_template[] =
"</d:root>";
Gov::SrvcMvIrVp::SrvcMvIrVp(void)
: m_ic()
: m_userIc()
{
}
......@@ -574,10 +574,12 @@ QList<Gov::RequiredInput> Gov::SrvcMvIrVp::requiredFields(void) const
{
RequiredInput ri;
ri.key = IC_KEY;
ri.val = m_ic;
ri.val = m_userIc;
ri.descr = tr("Subject ID (IČ)");
ri.placeholder = tr("Enter subject ID (IČ)");
ri.mandatory = true;
ri.userInput = true;
ri.boxInput = false;
formList.append(ri);
}
......@@ -586,26 +588,31 @@ QList<Gov::RequiredInput> Gov::SrvcMvIrVp::requiredFields(void) const
bool Gov::SrvcMvIrVp::setRequiredField(const QString &key, const QString &val)
{
if (key != IC_KEY) {
if (key == IC_KEY) {
m_userIc = val;
return true;
} else {
return false;
}
}
m_ic = val;
bool Gov::SrvcMvIrVp::setOwnerInfoFields(const Isds::DbOwnerInfo &dbOwnerInfo)
{
if (Q_UNLIKELY(dbOwnerInfo.isNull())) {
return false;
}
return true;
}
bool Gov::SrvcMvIrVp::haveAllMandatoryFields(void) const
{
return !m_ic.isEmpty();
return !m_userIc.isEmpty();
}
QByteArray Gov::SrvcMvIrVp::binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const
QByteArray Gov::SrvcMvIrVp::binaryXmlContent(void) const
{
Q_UNUSED(dbOwnerInfo);
QString xml(xml_template);
xml.replace("__repl_IC_SUBJECT__", m_ic);
xml.replace("__repl_IC_SUBJECT__", m_userIc);
return xml.toUtf8();
}
......@@ -78,14 +78,17 @@ namespace Gov {
virtual
bool setRequiredField(const QString &key, const QString &val) Q_DECL_OVERRIDE;
virtual
bool setOwnerInfoFields(const Isds::DbOwnerInfo &dbOwnerInfo) Q_DECL_OVERRIDE;
virtual
bool haveAllMandatoryFields(void) const Q_DECL_OVERRIDE;
virtual
QByteArray binaryXmlContent(const Isds::DbOwnerInfo &dbOwnerInfo) const Q_DECL_OVERRIDE;
QByteArray binaryXmlContent(void) const Q_DECL_OVERRIDE;
private:
QString m_ic; /*!< Identification number. */
QString m_userIc; /*!< Identification number. */
};
}
......@@ -69,6 +69,11 @@ static const char xml_template[] =
"</d:root>";
Gov::SrvcMvRtVt::SrvcMvRtVt(void)
: m_boxName(),
m_boxSurname(),
m_boxBirthDate(),
m_boxBirthRegion(),
m_boxBirthCity()
{
}
......@@ -133,37 +138,136 @@ bool Gov::SrvcMvRtVt::canSend(enum Isds::Type::DbType dbType) const
}
}
#define NAME_KEY "name"
#define SURNAME_KEY "surname"
#define BIRTH_KEY "birthDate"
#define REGION_KEY "region"
#define CITY_KEY "city"
#define DATE_FORMAT "yyyy-MM-dd"
QList<Gov::RequiredInput> Gov::SrvcMvRtVt::requiredFields(void) const
{
/* No fields required. */
return QList<RequiredInput>();
QList<RequiredInput> formList;
{
RequiredInput ri;
ri.key = NAME_KEY;
ri.val = m_boxName;
ri.descr = tr("Data-box owner name");
ri.placeholder = QString();
ri.mandatory = true;
ri.userInput = false;
ri.boxInput = true;
formList.append(ri);
}
{
RequiredInput ri;
ri.key = SURNAME_KEY;
ri.val = m_boxSurname;
ri.descr = tr("Data-box owner surname");
ri.placeholder = QString();
ri.mandatory = true;
ri.userInput = false;
ri.boxInput = true;
formList.append(ri);
}
{
RequiredInput ri;
ri.key = BIRTH_KEY;
ri.val = m_boxBirthDate.isNull() ? QString() : m_boxBirthDate.toString(DATE_FORMAT);
ri.descr = tr("Birth date");
ri.placeholder = QString();
ri.mandatory = true;
ri.userInput = false;
ri.boxInput = true;
formList.append(ri);
}
{
RequiredInput ri;
ri.key = REGION_KEY;
ri.val = m_boxBirthRegion;
ri.descr = tr("Birth region");
ri.placeholder = QString();
ri.mandatory = true;
ri.userInput = false;
ri.boxInput = true;
formList.append(ri);
}
{
RequiredInput ri;
ri.key = CITY_KEY;
ri.val = m_boxBirthCity;
ri.descr = tr("City");
ri.placeholder = QString();
ri.mandatory = true;
ri.userInput = false;
ri.boxInput = true;
formList.append(ri);
}
return formList;
}
bool Gov::SrvcMvRtVt::setRequiredField(const QString &key, const QString &val)
{
Q_UNUSED(key);
Q_UNUSED(val);
if (key == NAME_KEY) {
m_boxName = val;
return true;
} else if (key == SURNAME_KEY) {
m_boxSurname = val;
return true;
} else if (key == BIRTH_KEY) {
QDate date(QDate::fromString(val, DATE_FORMAT));
if (date.isNull()) {
return false;
}
m_boxBirthDate = date;
return true;
} else if (key == REGION_KEY) {
m_boxBirthRegion = val;
return true;
} else if (key == CITY_KEY) {
m_boxBirthCity = val;
return true;
} else {
return false;
}
}
bool Gov::SrvcMvRtVt::setOwnerInfoFields(const Isds::DbOwnerInfo &dbOwnerInfo)
{
if (Q_UNLIKELY(dbOwnerInfo.isNull())) {
return false;
}
m_boxName = dbOwnerInfo.personName().firstName();
m_boxSurname = dbOwnerInfo.personName().lastName();
m_boxBirthDate = dbOwnerInfo.birthInfo().date();
m_boxBirthRegion = dbOwnerInfo.birthInfo().county();
m_boxBirthCity = dbOwnerInfo.birthInfo().city();
/* No fields required. */
return false;
return (!m_boxName.isEmpty()) && (!m_boxSurname.isEmpty()) &&
(!m_boxBirthDate.isNull()) && (!m_boxBirthRegion.isEmpty()) &&
(!m_boxBirthCity.isEmpty());
}
bool Gov::SrvcMvRtVt::haveAllMandatoryFields(void) const
{
/* No fields required. */
return true;
return (!m_boxName.isEmpty()) && (!m_boxSurname.isEmpty()) &&
(!m_boxBirthDate.isNull()) && (!m_boxBirthRegion.isEmpty()) &&
(!m_boxBirthCity.isEmpty());
}
QByteArray Gov::SrvcMvRtVt::binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const
QByteArray Gov::SrvcMvRtVt::binaryXmlContent(void) const
{
QString xml(xml_template);
xml.replace("__repl_NAME__", dbOwnerInfo.personName().firstName());
xml.replace("__repl_SURNAME__", dbOwnerInfo.personName().lastName());
xml.replace("__repl_BIRTH_DATE_DAY__", dbOwnerInfo.birthInfo().date().toString("d"));
xml.replace("__repl_BIRTH_DATE_MONTH__", dbOwnerInfo.birthInfo().date().toString("M"));
xml.replace("__repl_BIRTH_DATE_YEAR__", dbOwnerInfo.birthInfo().date().toString("yyyy"));
xml.replace("__repl_REGION__", dbOwnerInfo.birthInfo().county());
xml.replace("__repl_CITY__", dbOwnerInfo.birthInfo().city());
xml.replace("__repl_NAME__", m_boxName);
xml.replace("__repl_SURNAME__", m_boxSurname);
xml.replace("__repl_BIRTH_DATE_DAY__", m_boxBirthDate.toString("d"));
xml.replace("__repl_BIRTH_DATE_MONTH__", m_boxBirthDate.toString("M"));
xml.replace("__repl_BIRTH_DATE_YEAR__", m_boxBirthDate.toString("yyyy"));
xml.replace("__repl_REGION__", m_boxBirthRegion);
xml.replace("__repl_CITY__", m_boxBirthCity);
return xml.toUtf8();
}
......@@ -78,11 +78,21 @@ namespace Gov {
virtual
bool setRequiredField(const QString &key, const QString &val) Q_DECL_OVERRIDE;
virtual
bool setOwnerInfoFields(const Isds::DbOwnerInfo &dbOwnerInfo) Q_DECL_OVERRIDE;
virtual
bool haveAllMandatoryFields(void) const Q_DECL_OVERRIDE;
virtual
QByteArray binaryXmlContent(const Isds::DbOwnerInfo &dbOwnerInfo) const Q_DECL_OVERRIDE;
QByteArray binaryXmlContent(void) const Q_DECL_OVERRIDE;
private:
QString m_boxName; /*!< First name derived from box data. */
QString m_boxSurname; /*!< Seurname derived from box data. */
QDate m_boxBirthDate; /*!< Birth date derived from box data. */
QString m_boxBirthRegion; /*!< Birth region. */
QString m_boxBirthCity; /*!< Birth city. */
};
}
......@@ -495,7 +495,7 @@ static const char xml_template[] =
"</d:root>";
Gov::SrvcMvRtpoVt::SrvcMvRtpoVt(void)
: m_ic()
: m_userIc()
{
}
......@@ -579,10 +579,12 @@ QList<Gov::RequiredInput> Gov::SrvcMvRtpoVt::requiredFields(void) const
{
RequiredInput ri;
ri.key = IC_KEY;
ri.val = m_ic;
ri.val = m_userIc;
ri.descr = tr("Subject ID (IČ)");
ri.placeholder = tr("Enter subject ID (IČ)");
ri.mandatory = true;
ri.userInput = true;
ri.boxInput = false;
formList.append(ri);
}
......@@ -591,26 +593,31 @@ QList<Gov::RequiredInput> Gov::SrvcMvRtpoVt::requiredFields(void) const
bool Gov::SrvcMvRtpoVt::setRequiredField(const QString &key, const QString &val)
{
if (key != IC_KEY) {
if (key == IC_KEY) {
m_userIc = val;
return true;
} else {
return false;
}
}
m_ic = val;
bool Gov::SrvcMvRtpoVt::setOwnerInfoFields(const Isds::DbOwnerInfo &dbOwnerInfo)
{
if (Q_UNLIKELY(dbOwnerInfo.isNull())) {
return false;
}
return true;
}
bool Gov::SrvcMvRtpoVt::haveAllMandatoryFields(void) const
{
return !m_ic.isEmpty();
return !m_userIc.isEmpty();
}
QByteArray Gov::SrvcMvRtpoVt::binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const
QByteArray Gov::SrvcMvRtpoVt::binaryXmlContent(void) const
{
Q_UNUSED(dbOwnerInfo);
QString xml(xml_template);
xml.replace("__repl_SUBJECT_IC__", m_ic);
xml.replace("__repl_SUBJECT_IC__", m_userIc);
return xml.toUtf8();
}
......@@ -78,14 +78,17 @@ namespace Gov {
virtual
bool setRequiredField(const QString &key, const QString &val) Q_DECL_OVERRIDE;
virtual
bool setOwnerInfoFields(const Isds::DbOwnerInfo &dbOwnerInfo) Q_DECL_OVERRIDE;
virtual
bool haveAllMandatoryFields(void) const Q_DECL_OVERRIDE;
virtual
QByteArray binaryXmlContent(const Isds::DbOwnerInfo &dbOwnerInfo) const Q_DECL_OVERRIDE;
QByteArray binaryXmlContent(void) const Q_DECL_OVERRIDE;
private:
QString m_ic; /*!< Identification number. */
QString m_userIc; /*!< Identification number. */
};
}
......@@ -491,7 +491,7 @@ static const char xml_template[] =
"</d:root>";
Gov::SrvcMvSkdVp::SrvcMvSkdVp(void)
: m_ic()
: m_userIc()
{
}
......@@ -575,10 +575,12 @@ QList<Gov::RequiredInput> Gov::SrvcMvSkdVp::requiredFields(void) const
{
RequiredInput ri;
ri.key = IC_KEY;
ri.val = m_ic;
ri.val = m_userIc;
ri.descr = tr("Subject ID (IČ)");
ri.placeholder = tr("Enter subject ID (IČ)");
ri.mandatory = true;
ri.userInput = true;
ri.boxInput = false;
formList.append(ri);
}
......@@ -587,26 +589,31 @@ QList<Gov::RequiredInput> Gov::SrvcMvSkdVp::requiredFields(void) const
bool Gov::SrvcMvSkdVp::setRequiredField(const QString &key, const QString &val)
{
if (key != IC_KEY) {
if (key == IC_KEY) {
m_userIc = val;
return true;
} else {
return false;
}
}
m_ic = val;
bool Gov::SrvcMvSkdVp::setOwnerInfoFields(const Isds::DbOwnerInfo &dbOwnerInfo)
{
if (Q_UNLIKELY(dbOwnerInfo.isNull())) {
return false;
}
return true;
}
bool Gov::SrvcMvSkdVp::haveAllMandatoryFields(void) const
{
return !m_ic.isEmpty();
return !m_userIc.isEmpty();
}
QByteArray Gov::SrvcMvSkdVp::binaryXmlContent(
const Isds::DbOwnerInfo &dbOwnerInfo) const
QByteArray Gov::SrvcMvSkdVp::binaryXmlContent(void) const
{
Q_UNUSED(dbOwnerInfo);
QString xml(xml_template);
xml.replace("__repl_IC_SUBJECT__", m_ic);
xml.replace("__repl_IC_SUBJECT__", m_userIc);
return xml.toUtf8();
}
......@@ -78,14 +78,17 @@ namespace Gov {
virtual
bool setRequiredField(const QString &key, const QString &val) Q_DECL_OVERRIDE;
virtual
bool setOwnerInfoFields(const Isds::DbOwnerInfo &dbOwnerInfo) Q_DECL_OVERRIDE;
virtual
bool haveAllMandatoryFields(void) const Q_DECL_OVERRIDE;
virtual
QByteArray binaryXmlContent(const Isds::DbOwnerInfo &dbOwnerInfo) const Q_DECL_OVERRIDE;
QByteArray binaryXmlContent(void) const Q_DECL_OVERRIDE;
private:
QString m_ic; /*!< Identification number. */
QString m_userIc; /*!< Identification number. */
};
}
......@@ -524,7 +524,7 @@ static const char xml_template[] =
"</d:root>";
Gov::SrvcMvVrVp::SrvcMvVrVp(void)
: m_ic()
: m_userIc()
{
}
......@@ -608,10 +608,12 @@ QList<Gov::RequiredInput> Gov::SrvcMvVrVp::requiredFields(void) const
{
RequiredInput ri;
ri.key = IC_KEY;
ri.val = m_ic;
ri.val = m_userIc;
ri.descr = tr("Subject ID (IČ)");
ri.placeholder = tr("Enter subject ID (IČ)");
ri.mandatory = true;
ri.userInput = true;
ri.boxInput = false;