Fixed project dropdown
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
#include "stripfactory.h"
|
#include "stripfactory.h"
|
||||||
#include "stripswidget.h"
|
#include "stripswidget.h"
|
||||||
#include "dialogs/settingsdialog.h"
|
#include "dialogs/settingsdialog.h"
|
||||||
#include "replies/getprojectsreply.h"
|
#include "replies/getcomboboxreply.h"
|
||||||
#include "replies/createbookingreply.h"
|
#include "replies/createbookingreply.h"
|
||||||
#include "replies/createtimeassignmentreply.h"
|
#include "replies/createtimeassignmentreply.h"
|
||||||
#include "replies/updatetimeassignmentreply.h"
|
#include "replies/updatetimeassignmentreply.h"
|
||||||
@@ -185,7 +185,7 @@ void MainWindow::getProjectsFinished()
|
|||||||
{
|
{
|
||||||
m_projects.clear();
|
m_projects.clear();
|
||||||
|
|
||||||
for(const auto &project : m_getProjectsReply->projects())
|
for(const auto &project : m_getProjectsReply->items())
|
||||||
m_projects.insert(project.value, project.label);
|
m_projects.insert(project.value, project.label);
|
||||||
|
|
||||||
updateComboboxes();
|
updateComboboxes();
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include "zeiterfassungguilib_global.h"
|
#include "zeiterfassungguilib_global.h"
|
||||||
#include "replies/getuserinforeply.h"
|
#include "replies/getuserinforeply.h"
|
||||||
#include "replies/getprojectsreply.h"
|
#include "replies/getcomboboxreply.h"
|
||||||
#include "replies/getpresencestatusreply.h"
|
#include "replies/getpresencestatusreply.h"
|
||||||
|
|
||||||
class QMenu;
|
class QMenu;
|
||||||
@@ -77,7 +77,7 @@ private:
|
|||||||
StripFactory &m_stripFactory;
|
StripFactory &m_stripFactory;
|
||||||
const QSet<ZeiterfassungPlugin*> &m_plugins;
|
const QSet<ZeiterfassungPlugin*> &m_plugins;
|
||||||
|
|
||||||
std::unique_ptr<GetProjectsReply> m_getProjectsReply;
|
std::unique_ptr<GetComboboxReply> m_getProjectsReply;
|
||||||
|
|
||||||
QMap<QString, QString> m_projects;
|
QMap<QString, QString> m_projects;
|
||||||
|
|
||||||
|
@@ -11,9 +11,9 @@ set(HEADERS
|
|||||||
replies/deletetimeassignmentreply.h
|
replies/deletetimeassignmentreply.h
|
||||||
replies/getabsencesreply.h
|
replies/getabsencesreply.h
|
||||||
replies/getbookingsreply.h
|
replies/getbookingsreply.h
|
||||||
|
replies/getcomboboxreply.h
|
||||||
replies/getdayinforeply.h
|
replies/getdayinforeply.h
|
||||||
replies/getpresencestatusreply.h
|
replies/getpresencestatusreply.h
|
||||||
replies/getprojectsreply.h
|
|
||||||
replies/getreportreply.h
|
replies/getreportreply.h
|
||||||
replies/gettimeassignmentsreply.h
|
replies/gettimeassignmentsreply.h
|
||||||
replies/getuserinforeply.h
|
replies/getuserinforeply.h
|
||||||
@@ -32,9 +32,9 @@ set(SOURCES
|
|||||||
replies/deletetimeassignmentreply.cpp
|
replies/deletetimeassignmentreply.cpp
|
||||||
replies/getabsencesreply.cpp
|
replies/getabsencesreply.cpp
|
||||||
replies/getbookingsreply.cpp
|
replies/getbookingsreply.cpp
|
||||||
|
replies/getcomboboxreply.cpp
|
||||||
replies/getdayinforeply.cpp
|
replies/getdayinforeply.cpp
|
||||||
replies/getpresencestatusreply.cpp
|
replies/getpresencestatusreply.cpp
|
||||||
replies/getprojectsreply.cpp
|
|
||||||
replies/getreportreply.cpp
|
replies/getreportreply.cpp
|
||||||
replies/gettimeassignmentsreply.cpp
|
replies/gettimeassignmentsreply.cpp
|
||||||
replies/getuserinforeply.cpp
|
replies/getuserinforeply.cpp
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include "getprojectsreply.h"
|
#include "getcomboboxreply.h"
|
||||||
|
|
||||||
#include <QJsonParseError>
|
#include <QJsonParseError>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@@ -8,19 +8,19 @@
|
|||||||
|
|
||||||
#include "zeiterfassungapi.h"
|
#include "zeiterfassungapi.h"
|
||||||
|
|
||||||
GetProjectsReply::GetProjectsReply(std::unique_ptr<QNetworkReply> &&reply, ZeiterfassungApi *zeiterfassung) :
|
GetComboboxReply::GetComboboxReply(std::unique_ptr<QNetworkReply> &&reply, ZeiterfassungApi *zeiterfassung) :
|
||||||
ZeiterfassungReply(zeiterfassung),
|
ZeiterfassungReply(zeiterfassung),
|
||||||
m_reply(std::move(reply))
|
m_reply(std::move(reply))
|
||||||
{
|
{
|
||||||
connect(m_reply.get(), &QNetworkReply::finished, this, &GetProjectsReply::requestFinished);
|
connect(m_reply.get(), &QNetworkReply::finished, this, &GetComboboxReply::requestFinished);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QVector<GetProjectsReply::Project> &GetProjectsReply::projects() const
|
const QVector<GetComboboxReply::Item> &GetComboboxReply::items() const
|
||||||
{
|
{
|
||||||
return m_projects;
|
return m_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetProjectsReply::requestFinished()
|
void GetComboboxReply::requestFinished()
|
||||||
{
|
{
|
||||||
if(m_reply->error() != QNetworkReply::NoError)
|
if(m_reply->error() != QNetworkReply::NoError)
|
||||||
{
|
{
|
||||||
@@ -67,13 +67,13 @@ void GetProjectsReply::requestFinished()
|
|||||||
auto elementsArr = elements.toArray();
|
auto elementsArr = elements.toArray();
|
||||||
|
|
||||||
setSuccess(true);
|
setSuccess(true);
|
||||||
m_projects.clear();
|
m_items.clear();
|
||||||
m_projects.reserve(elementsArr.count());
|
m_items.reserve(elementsArr.count());
|
||||||
for(const auto &val : elementsArr)
|
for(const auto &val : elementsArr)
|
||||||
{
|
{
|
||||||
auto obj = val.toObject();
|
auto obj = val.toObject();
|
||||||
|
|
||||||
m_projects.append({
|
m_items.append({
|
||||||
obj.value(QStringLiteral("label")).toString(),
|
obj.value(QStringLiteral("label")).toString(),
|
||||||
obj.value(QStringLiteral("value")).toString()
|
obj.value(QStringLiteral("value")).toString()
|
||||||
});
|
});
|
@@ -10,25 +10,25 @@
|
|||||||
|
|
||||||
class ZeiterfassungApi;
|
class ZeiterfassungApi;
|
||||||
|
|
||||||
class ZEITERFASSUNGNETWORKLIB_EXPORT GetProjectsReply : public ZeiterfassungReply
|
class ZEITERFASSUNGNETWORKLIB_EXPORT GetComboboxReply : public ZeiterfassungReply
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GetProjectsReply(std::unique_ptr<QNetworkReply> &&reply, ZeiterfassungApi *zeiterfassung);
|
explicit GetComboboxReply(std::unique_ptr<QNetworkReply> &&reply, ZeiterfassungApi *zeiterfassung);
|
||||||
|
|
||||||
struct Project
|
struct Item
|
||||||
{
|
{
|
||||||
QString label;
|
QString label;
|
||||||
QString value;
|
QString value;
|
||||||
};
|
};
|
||||||
|
|
||||||
const QVector<Project> &projects() const;
|
const QVector<Item> &items() const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void requestFinished();
|
void requestFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<QNetworkReply> m_reply;
|
std::unique_ptr<QNetworkReply> m_reply;
|
||||||
QVector<Project> m_projects;
|
QVector<Item> m_items;
|
||||||
};
|
};
|
@@ -71,6 +71,29 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>GetComboboxReply</name>
|
||||||
|
<message>
|
||||||
|
<source>Request error occured: %0</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Parsing JSON failed: %0</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>JSON document is not an object!</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>JSON does not contain elements!</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>elements is not an array!</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>GetDayinfoReply</name>
|
<name>GetDayinfoReply</name>
|
||||||
<message>
|
<message>
|
||||||
@@ -101,29 +124,6 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
|
||||||
<name>GetProjectsReply</name>
|
|
||||||
<message>
|
|
||||||
<source>Request error occured: %0</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Parsing JSON failed: %0</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>JSON document is not an object!</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>JSON does not contain elements!</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>elements is not an array!</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
|
||||||
<context>
|
<context>
|
||||||
<name>GetReportReply</name>
|
<name>GetReportReply</name>
|
||||||
<message>
|
<message>
|
||||||
|
@@ -71,6 +71,29 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>GetComboboxReply</name>
|
||||||
|
<message>
|
||||||
|
<source>Request error occured: %0</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Parsing JSON failed: %0</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>JSON document is not an object!</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>JSON does not contain elements!</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>elements is not an array!</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>GetDayinfoReply</name>
|
<name>GetDayinfoReply</name>
|
||||||
<message>
|
<message>
|
||||||
@@ -101,29 +124,6 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
|
||||||
<name>GetProjectsReply</name>
|
|
||||||
<message>
|
|
||||||
<source>Request error occured: %0</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>Parsing JSON failed: %0</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>JSON document is not an object!</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>JSON does not contain elements!</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
|
||||||
<source>elements is not an array!</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
</context>
|
|
||||||
<context>
|
<context>
|
||||||
<name>GetReportReply</name>
|
<name>GetReportReply</name>
|
||||||
<message>
|
<message>
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#include "replies/createtimeassignmentreply.h"
|
#include "replies/createtimeassignmentreply.h"
|
||||||
#include "replies/updatetimeassignmentreply.h"
|
#include "replies/updatetimeassignmentreply.h"
|
||||||
#include "replies/deletetimeassignmentreply.h"
|
#include "replies/deletetimeassignmentreply.h"
|
||||||
#include "replies/getprojectsreply.h"
|
#include "replies/getcomboboxreply.h"
|
||||||
#include "replies/getreportreply.h"
|
#include "replies/getreportreply.h"
|
||||||
#include "replies/getpresencestatusreply.h"
|
#include "replies/getpresencestatusreply.h"
|
||||||
#include "replies/getabsencesreply.h"
|
#include "replies/getabsencesreply.h"
|
||||||
@@ -247,15 +247,26 @@ std::unique_ptr<DeleteTimeAssignmentReply> ZeiterfassungApi::doDeleteTimeAssignm
|
|||||||
return std::make_unique<DeleteTimeAssignmentReply>(std::unique_ptr<QNetworkReply>(m_manager->deleteResource(request)), this);
|
return std::make_unique<DeleteTimeAssignmentReply>(std::unique_ptr<QNetworkReply>(m_manager->deleteResource(request)), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<GetProjectsReply> ZeiterfassungApi::doGetProjects(int userId, const QDate &date)
|
std::unique_ptr<GetComboboxReply> ZeiterfassungApi::doGetCostcentres(int userId, const QDate &date)
|
||||||
{
|
{
|
||||||
QNetworkRequest request(QUrl(QStringLiteral("%0json/combobox?persnr=%1&date=%2&dqkey=KOST&kowert0=&kowert1=&kowert2=&term=")
|
QNetworkRequest request(QUrl(QStringLiteral("%0json/combobox?persnr=%1&date=%2&dqkey=KOST")
|
||||||
.arg(m_url.toString())
|
.arg(m_url.toString())
|
||||||
.arg(userId)
|
.arg(userId)
|
||||||
.arg(formatDate(date))));
|
.arg(formatDate(date))));
|
||||||
request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar"));
|
request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar"));
|
||||||
|
|
||||||
return std::make_unique<GetProjectsReply>(std::unique_ptr<QNetworkReply>(m_manager->get(request)), this);
|
return std::make_unique<GetComboboxReply>(std::unique_ptr<QNetworkReply>(m_manager->get(request)), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<GetComboboxReply> ZeiterfassungApi::doGetProjects(int userId, const QDate &date)
|
||||||
|
{
|
||||||
|
QNetworkRequest request(QUrl(QStringLiteral("%0json/combobox?persnr=%1&date=%2&dqkey=PROJEKT")
|
||||||
|
.arg(m_url.toString())
|
||||||
|
.arg(userId)
|
||||||
|
.arg(formatDate(date))));
|
||||||
|
request.setRawHeader(QByteArrayLiteral("sisAppName"), QByteArrayLiteral("bookingCalendar"));
|
||||||
|
|
||||||
|
return std::make_unique<GetComboboxReply>(std::unique_ptr<QNetworkReply>(m_manager->get(request)), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<GetReportReply> ZeiterfassungApi::doGetReport(int userId, const QDate &date)
|
std::unique_ptr<GetReportReply> ZeiterfassungApi::doGetReport(int userId, const QDate &date)
|
||||||
|
@@ -23,7 +23,7 @@ class GetTimeAssignmentsReply;
|
|||||||
class CreateTimeAssignmentReply;
|
class CreateTimeAssignmentReply;
|
||||||
class UpdateTimeAssignmentReply;
|
class UpdateTimeAssignmentReply;
|
||||||
class DeleteTimeAssignmentReply;
|
class DeleteTimeAssignmentReply;
|
||||||
class GetProjectsReply;
|
class GetComboboxReply;
|
||||||
class GetReportReply;
|
class GetReportReply;
|
||||||
class GetPresenceStatusReply;
|
class GetPresenceStatusReply;
|
||||||
class GetAbsencesReply;
|
class GetAbsencesReply;
|
||||||
@@ -61,7 +61,8 @@ public:
|
|||||||
const QString &workpackage, const QString &text);
|
const QString &workpackage, const QString &text);
|
||||||
std::unique_ptr<DeleteTimeAssignmentReply> doDeleteTimeAssignment(int timeAssignmentId);
|
std::unique_ptr<DeleteTimeAssignmentReply> doDeleteTimeAssignment(int timeAssignmentId);
|
||||||
|
|
||||||
std::unique_ptr<GetProjectsReply> doGetProjects(int userId, const QDate &date);
|
std::unique_ptr<GetComboboxReply> doGetCostcentres(int userId, const QDate &date);
|
||||||
|
std::unique_ptr<GetComboboxReply> doGetProjects(int userId, const QDate &date);
|
||||||
std::unique_ptr<GetReportReply> doGetReport(int userId, const QDate &date);
|
std::unique_ptr<GetReportReply> doGetReport(int userId, const QDate &date);
|
||||||
std::unique_ptr<GetPresenceStatusReply> doGetPresenceStatus();
|
std::unique_ptr<GetPresenceStatusReply> doGetPresenceStatus();
|
||||||
std::unique_ptr<GetAbsencesReply> doGetAbsences(int userId, const QDate &start, const QDate &end);
|
std::unique_ptr<GetAbsencesReply> doGetAbsences(int userId, const QDate &start, const QDate &end);
|
||||||
|
Reference in New Issue
Block a user