Commit 975401db authored by Karel Slaný's avatar Karel Slaný Committed by Martin Straka

Setting content of gov form model.

parent 41a21c62
......@@ -25,6 +25,7 @@ import QtQuick 2.7
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2
import cz.nic.mobileDatovka 1.0
import cz.nic.mobileDatovka.models 1.0
Item {
id: pageGovService
......@@ -40,6 +41,8 @@ Item {
property string gsReqField
Component.onCompleted: {
gov.loadFormToModel(userName, gsInternId, govFormModel)
if (gsReqField === "ic") {
icoLabel.visible = true
icoText.visible = icoLabel.visible
......@@ -54,6 +57,13 @@ Item {
}
}
GovFormListModel {
id: govFormModel
Component.onCompleted: {
}
}
PageHeader {
id: headerBar
title: qsTr("Service:") + " " + gsInternId
......
......@@ -40,7 +40,7 @@ Component {
property string gsInternIdSelected
Component.onCompleted: {
gov.loadGovServicesToModel(govServiceModel)
gov.loadServicesToModel(govServiceModel)
proxyGovServiceModel.setSourceModel(govServiceModel)
}
......
......@@ -113,6 +113,13 @@ void GovFormListModel::appendEntry(const RequiredInput &entry)
endInsertRows();
}
void GovFormListModel::setEntries(const QList<RequiredInput> &entries)
{
beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_requiredInputList = entries;
endInsertRows();
}
void GovFormListModel::clearAll(void)
{
beginResetModel();
......
......@@ -120,6 +120,13 @@ public:
*/
void appendEntry(const RequiredInput &entry);
/*!
* @brief Sets all model entries.
*
* @param[in] entryList List of entires.
*/
void setEntries(const QList<RequiredInput> &entries);
/*!
* @brief Clears the model.
*/
......
......@@ -102,8 +102,21 @@ const QString &GovMvCrrVbh::dmFileDescr(void) const
return dmFileDescr;
}
QList<RequiredInput> &GovMvCrrVbh::requiredFields(void) const
QList<RequiredInput> GovMvCrrVbh::requiredFields(void) const
{
QList<RequiredInput> formList;
{
RequiredInput ri;
ri.key = "drivingLicenceId";
ri.val = QString();
ri.descr = tr("Driving licence ID");
ri.placeholder = tr("Enter driving licence ID without spaces");
ri.mandatory = true;
formList.append(ri);
}
return formList;
}
bool GovMvCrrVbh::setRequiredField(const QString &key, const QString &val)
......
......@@ -66,13 +66,13 @@ public:
const QString &dmFileDescr(void) const Q_DECL_OVERRIDE;
virtual
QList<RequiredInput> &requiredFields(void) const;
QList<RequiredInput> requiredFields(void) const Q_DECL_OVERRIDE;
virtual
bool setRequiredField(const QString &key, const QString &val);
bool setRequiredField(const QString &key, const QString &val) Q_DECL_OVERRIDE;
virtual
bool haveAllRequiredFields(void);
bool haveAllRequiredFields(void) Q_DECL_OVERRIDE;
virtual
QByteArray binaryXmlContent(
......
......@@ -140,7 +140,7 @@ public:
* @return Additional information.
*/
virtual
QList<RequiredInput> &requiredFields(void) const = 0;
QList<RequiredInput> requiredFields(void) const = 0;
virtual
bool setRequiredField(const QString &key, const QString &val) = 0;
......
......@@ -21,6 +21,7 @@
* the two.
*/
#include "src/datovka_shared/gov_services/model/gov_form_list_model.h"
#include "src/datovka_shared/gov_services/model/gov_service_list_model.h"
#include "src/datovka_shared/gov_services/service/gov_mv_crr_vbh.h"
#include "src/datovka_shared/gov_services/service/gov_mv_ir_vp.h"
......@@ -115,22 +116,22 @@ void Gov::initGovServices(void)
m_govServices.insert(gs10->serviceId(), gs10);
}
void Gov::loadGovServicesToModel(const QVariant &govModelVariant)
void Gov::loadServicesToModel(const QVariant &srvcModelVariant) const
{
debugFuncCall();
GovServiceListModel *govModel =
GovServiceListModel::fromVariant(govModelVariant);
if (Q_UNLIKELY(govModel == Q_NULLPTR)) {
GovServiceListModel *srvcModel =
GovServiceListModel::fromVariant(srvcModelVariant);
if (Q_UNLIKELY(srvcModel == Q_NULLPTR)) {
Q_ASSERT(0);
logErrorNL("%s", "Cannot access gov services model.");
return;
}
govModel->clearAll();
srvcModel->clearAll();
foreach (const QString &key, m_govServices.keys()) {
govModel->appendEntry(GovServiceListModel::Entry(
srvcModel->appendEntry(GovServiceListModel::Entry(
m_govServices.value(key)->internalId(),
m_govServices.value(key)->fullName(),
m_govServices.value(key)->instituteName(),
......@@ -139,6 +140,32 @@ void Gov::loadGovServicesToModel(const QVariant &govModelVariant)
}
}
void Gov::loadFormToModel(const QString &userName,
const QString &serviceInternalId, const QVariant &formModelVariant) const
{
debugFuncCall();
Q_UNUSED(userName); /* Currently unused. */
GovFormListModel *formModel =
GovFormListModel::fromVariant(formModelVariant);
if (Q_UNLIKELY(formModel == Q_NULLPTR)) {
logErrorNL("%s", "Cannot access gov form model.");
Q_ASSERT(0);
return;
}
GovService *govService = m_govServices.value(serviceInternalId, Q_NULLPTR);
if (Q_UNLIKELY(govService == Q_NULLPTR)) {
logErrorNL("Cannot access gov service '%s'.",
serviceInternalId.toUtf8().constData());
Q_ASSERT(0);
return;
}
formModel->setEntries(govService->requiredFields());
}
bool Gov::sendGovRequest(const QString &userName, const QString &gsId,
const QString &ic, const QString &rpId, const QString &dFrom,
const QString &dTo)
......
......@@ -60,10 +60,22 @@ public:
/*!
* @brief Load Gov services into QML.
*
* @param[in,out] govModelVariant QVariant holding gov model.
* @param[in,out] srvcModelVariant QVariant holding gov model.
*/
Q_INVOKABLE
void loadGovServicesToModel(const QVariant &govModelVariant);
void loadServicesToModel(const QVariant &srvcModelVariant) const;
/*!
* @brief Load gof form data into QML model.
*
* @param[in] userName Account login.
* @param[in] serviceInternalId Internal service identifier.
* @param[in,out] formModelVariant QVariant holding gov form model to be set.
*/
Q_INVOKABLE
void loadFormToModel(const QString &userName,
const QString &serviceInternalId,
const QVariant &formModelVariant) const;
/*!
* @brief Create and send gov service request.
......
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