Clicking the sendInvite button triggers a post request to the server to send a bidding invite via mail.
This commit is contained in:
@ -30,6 +30,8 @@ void EditItemDialog::createContent() {
|
|||||||
/// online user stuff
|
/// online user stuff
|
||||||
connect(m_detailMapper, &ItemDetailMapper::createOnlineAccountTriggered, this,
|
connect(m_detailMapper, &ItemDetailMapper::createOnlineAccountTriggered, this,
|
||||||
&EditItemDialog::createOnlineAccountTriggered);
|
&EditItemDialog::createOnlineAccountTriggered);
|
||||||
|
connect(m_detailMapper, &ItemDetailMapper::sendInviteMailTriggered, this,
|
||||||
|
&EditItemDialog::sendInviteMailTriggered);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditItemDialog::accept() {
|
void EditItemDialog::accept() {
|
||||||
|
|||||||
@ -21,6 +21,8 @@ class EditItemDialog : public AbstractDialog {
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void createOnlineAccountTriggered(const QString& mailAddress);
|
void createOnlineAccountTriggered(const QString& mailAddress);
|
||||||
|
void sendInviteMailTriggered(const QString& mailAddress);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
void reject() override;
|
void reject() override;
|
||||||
|
|||||||
@ -570,4 +570,6 @@ void MainWindow::setupEventTab() {
|
|||||||
void MainWindow::initServerConnection() {
|
void MainWindow::initServerConnection() {
|
||||||
connect(m_editItemDialog.get(), &EditItemDialog::createOnlineAccountTriggered, m_core.get(),
|
connect(m_editItemDialog.get(), &EditItemDialog::createOnlineAccountTriggered, m_core.get(),
|
||||||
&GenericCore::onCreateOnlineAccountTriggered);
|
&GenericCore::onCreateOnlineAccountTriggered);
|
||||||
|
connect(m_editItemDialog.get(), &EditItemDialog::sendInviteMailTriggered, m_core.get(),
|
||||||
|
&GenericCore::onSendInviteMailTriggered);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -165,6 +165,8 @@ ItemDetailMapper::ItemDetailMapper(QWidget* parent)
|
|||||||
|
|
||||||
connect(m_createOnlineAccountButton, &QAbstractButton::clicked, this,
|
connect(m_createOnlineAccountButton, &QAbstractButton::clicked, this,
|
||||||
&ItemDetailMapper::onCreateOnlineAccountTriggered);
|
&ItemDetailMapper::onCreateOnlineAccountTriggered);
|
||||||
|
connect(m_sendInviteMailButton, &QAbstractButton::clicked, this,
|
||||||
|
&ItemDetailMapper::onSendInviteMailTriggered);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemDetailMapper::setModelMappings(QTableView* tableView) {
|
void ItemDetailMapper::setModelMappings(QTableView* tableView) {
|
||||||
@ -243,15 +245,6 @@ void ItemDetailMapper::updateButtons(int row) {
|
|||||||
m_nextButton->setEnabled(row < m_model->rowCount() - 1);
|
m_nextButton->setEnabled(row < m_model->rowCount() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemDetailMapper::emitContentChanged(const QModelIndex& currentIndex) {
|
|
||||||
// BUG QR-Code isn't updated after changes through the ItemDetailMapper #18
|
|
||||||
QString toStringText = "";
|
|
||||||
if (currentIndex.isValid()) {
|
|
||||||
toStringText = currentIndex.data(ToStringRole).toString();
|
|
||||||
}
|
|
||||||
emit contentChanged(toStringText);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ItemDetailMapper::onCurrentIndexChanged(const QModelIndex& current,
|
void ItemDetailMapper::onCurrentIndexChanged(const QModelIndex& current,
|
||||||
const QModelIndex& /*previous*/) {
|
const QModelIndex& /*previous*/) {
|
||||||
if (!isEnabled()) {
|
if (!isEnabled()) {
|
||||||
@ -259,7 +252,6 @@ void ItemDetailMapper::onCurrentIndexChanged(const QModelIndex& current,
|
|||||||
}
|
}
|
||||||
m_mapper->setCurrentModelIndex(current);
|
m_mapper->setCurrentModelIndex(current);
|
||||||
updateButtons(current.row());
|
updateButtons(current.row());
|
||||||
emitContentChanged(current);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ItemDetailMapper::updateQRCode(const QString text) {
|
void ItemDetailMapper::updateQRCode(const QString text) {
|
||||||
@ -311,3 +303,7 @@ void ItemDetailMapper::onAccessCodeChanged(const QString& text) {
|
|||||||
void ItemDetailMapper::onCreateOnlineAccountTriggered() {
|
void ItemDetailMapper::onCreateOnlineAccountTriggered() {
|
||||||
emit createOnlineAccountTriggered(m_mailEdit->text());
|
emit createOnlineAccountTriggered(m_mailEdit->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ItemDetailMapper::onSendInviteMailTriggered() {
|
||||||
|
emit sendInviteMailTriggered(m_mailEdit->text());
|
||||||
|
}
|
||||||
|
|||||||
@ -31,6 +31,7 @@ class ItemDetailMapper : public QWidget {
|
|||||||
void contentChanged(const QString text);
|
void contentChanged(const QString text);
|
||||||
|
|
||||||
void createOnlineAccountTriggered(const QString& mailAddress);
|
void createOnlineAccountTriggered(const QString& mailAddress);
|
||||||
|
void sendInviteMailTriggered(const QString& mailAddress);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void rowsInserted(const QModelIndex& parent, int start, int end);
|
void rowsInserted(const QModelIndex& parent, int start, int end);
|
||||||
@ -38,7 +39,6 @@ class ItemDetailMapper : public QWidget {
|
|||||||
void toPrevious();
|
void toPrevious();
|
||||||
void toNext();
|
void toNext();
|
||||||
void updateButtons(int row);
|
void updateButtons(int row);
|
||||||
void emitContentChanged(const QModelIndex& currentIndex);
|
|
||||||
void onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous);
|
void onCurrentIndexChanged(const QModelIndex& current, const QModelIndex& previous);
|
||||||
|
|
||||||
void updateQRCode(const QString text = "");
|
void updateQRCode(const QString text = "");
|
||||||
@ -46,6 +46,7 @@ class ItemDetailMapper : public QWidget {
|
|||||||
void onOnlineIDChanged(const QString& text);
|
void onOnlineIDChanged(const QString& text);
|
||||||
void onAccessCodeChanged(const QString& text);
|
void onAccessCodeChanged(const QString& text);
|
||||||
void onCreateOnlineAccountTriggered();
|
void onCreateOnlineAccountTriggered();
|
||||||
|
void onSendInviteMailTriggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// *** members ***
|
/// *** members ***
|
||||||
|
|||||||
@ -178,6 +178,12 @@ void GenericCore::onOnlineUserAccountReceived(const QString mailAddress,
|
|||||||
const QString message = QString("Online credentials received for: %1").arg(mailAddress);
|
const QString message = QString("Online credentials received for: %1").arg(mailAddress);
|
||||||
emit displayStatusMessage(message);
|
emit displayStatusMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GenericCore::onSendInviteMailTriggered(const QString& mailAddress) {
|
||||||
|
qInfo() << "Sending invite mail to:" << mailAddress;
|
||||||
|
const QString serverUrl = m_serverCommunicator->getUserLoginUrl();
|
||||||
|
const QJsonDocument mailInviteJsonDoc = m_mainModel->getMailInviteJsonDoc(mailAddress, serverUrl);
|
||||||
|
emit sendPostRequest(MailInvite, mailInviteJsonDoc.toJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericCore::setupModels() {
|
void GenericCore::setupModels() {
|
||||||
|
|||||||
@ -53,6 +53,7 @@ class GenericCore : public QObject {
|
|||||||
void onOnlineUserAccountReceived(const QString mailAddress,
|
void onOnlineUserAccountReceived(const QString mailAddress,
|
||||||
const QString uuid,
|
const QString uuid,
|
||||||
const QString accessToken);
|
const QString accessToken);
|
||||||
|
void onSendInviteMailTriggered(const QString& mailAddress);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void displayStatusMessage(QString message);
|
void displayStatusMessage(QString message);
|
||||||
|
|||||||
@ -91,7 +91,7 @@ enum GetRequestTypes {
|
|||||||
GetBiddingsOfSpecificRound,
|
GetBiddingsOfSpecificRound,
|
||||||
GetBiddingsOfHighestRound
|
GetBiddingsOfHighestRound
|
||||||
};
|
};
|
||||||
enum PostRequestTypes { RegisterUser };
|
enum PostRequestTypes { RegisterUser, MailInvite };
|
||||||
|
|
||||||
/// functions
|
/// functions
|
||||||
static UserRoles GET_ROLE_FOR_COLUMN(const int column) {
|
static UserRoles GET_ROLE_FOR_COLUMN(const int column) {
|
||||||
|
|||||||
@ -239,6 +239,34 @@ void TableModel::setOnlineCredentials(const QString& mail,
|
|||||||
setItemData(itemIndex, {{OnlineIdRole, uuid}, {AccessCodeRole, token}});
|
setItemData(itemIndex, {{OnlineIdRole, uuid}, {AccessCodeRole, token}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonDocument TableModel::getMailInviteJsonDoc(const QString& mail,
|
||||||
|
const QString& serverUrl) const {
|
||||||
|
QJsonDocument doc = QJsonDocument();
|
||||||
|
|
||||||
|
QModelIndex index = getIndexByRoleValue(mail, MailRole);
|
||||||
|
|
||||||
|
if (index.isValid()) {
|
||||||
|
QJsonObject rootObject;
|
||||||
|
|
||||||
|
const QString user_id = data(index, OnlineIdRole).toString();
|
||||||
|
const QString email = data(index, MailRole).toString();
|
||||||
|
const QString name = data(index, FullNameRole).toString();
|
||||||
|
const QString token = data(index, AccessCodeRole).toString();
|
||||||
|
const QString accessUrl = serverUrl + "/" + token;
|
||||||
|
|
||||||
|
QJsonObject userObject;
|
||||||
|
userObject.insert("user_id", user_id);
|
||||||
|
userObject.insert("email", email);
|
||||||
|
userObject.insert("name", name);
|
||||||
|
userObject.insert("access_url", accessUrl);
|
||||||
|
|
||||||
|
rootObject.insert("user", userObject);
|
||||||
|
|
||||||
|
doc.setObject(rootObject);
|
||||||
|
}
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
void TableModel::updateBiddings(const QList<bidding> biddings) {
|
void TableModel::updateBiddings(const QList<bidding> biddings) {
|
||||||
QListIterator<bidding> i(biddings);
|
QListIterator<bidding> i(biddings);
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
@ -352,6 +380,7 @@ qreal TableModel::biddingAverage2() const {
|
|||||||
qInfo() << "average calculation (2):" << averageBidding;
|
qInfo() << "average calculation (2):" << averageBidding;
|
||||||
return averageBidding;
|
return averageBidding;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal TableModel::biddingAverage3() const {
|
qreal TableModel::biddingAverage3() const {
|
||||||
const UserRoles biddingRole = Bidding3Role;
|
const UserRoles biddingRole = Bidding3Role;
|
||||||
const qreal averageBidding = averageBiddingAmount(biddingRole);
|
const qreal averageBidding = averageBiddingAmount(biddingRole);
|
||||||
|
|||||||
@ -46,6 +46,8 @@ class TableModel : public QAbstractTableModel {
|
|||||||
bool updateItem(const ModelItemValues& itemValues);
|
bool updateItem(const ModelItemValues& itemValues);
|
||||||
|
|
||||||
void setOnlineCredentials(const QString& mail, const QString& uuid, const QString& token);
|
void setOnlineCredentials(const QString& mail, const QString& uuid, const QString& token);
|
||||||
|
QJsonDocument getMailInviteJsonDoc(const QString& mail, const QString& serverUrl) const;
|
||||||
|
|
||||||
void updateBiddings(const QList<bidding> biddings);
|
void updateBiddings(const QList<bidding> biddings);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -111,6 +113,7 @@ class TableModel : public QAbstractTableModel {
|
|||||||
qreal totalSharesWithBiddings(const UserRoles biddingRole) const;
|
qreal totalSharesWithBiddings(const UserRoles biddingRole) const;
|
||||||
|
|
||||||
QModelIndex getIndexByRoleValue(const QString& valueString, const int role) const;
|
QModelIndex getIndexByRoleValue(const QString& valueString, const int role) const;
|
||||||
|
QMap<int, QVariant> getItemValues(const bidding bid);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TABLEMODEL_H
|
#endif // TABLEMODEL_H
|
||||||
|
|||||||
@ -5,11 +5,14 @@
|
|||||||
|
|
||||||
// TODO add namespace
|
// TODO add namespace
|
||||||
|
|
||||||
|
static const QString ROUTE_LOG_IN = "/log_in";
|
||||||
|
|
||||||
static const QString apiPrefix = "/api/";
|
static const QString apiPrefix = "/api/";
|
||||||
|
|
||||||
static const QString ROUTE_ITEMS = apiPrefix + "items";
|
static const QString ROUTE_ITEMS = apiPrefix + "items";
|
||||||
|
|
||||||
static const QString ROUTE_REGISTER_USER = apiPrefix + "users";
|
static const QString ROUTE_REGISTER_USER = apiPrefix + "users";
|
||||||
|
static const QString ROUTE_MAIL_INVITE = apiPrefix + "invite";
|
||||||
|
|
||||||
static const QString ROUTE_BIDDINGROUNDS = apiPrefix + "bidding_rounds";
|
static const QString ROUTE_BIDDINGROUNDS = apiPrefix + "bidding_rounds";
|
||||||
static const QString ROUTE_CURRENT_BIDDINGROUND = ROUTE_BIDDINGROUNDS + "/get_current";
|
static const QString ROUTE_CURRENT_BIDDINGROUND = ROUTE_BIDDINGROUNDS + "/get_current";
|
||||||
|
|||||||
@ -58,6 +58,11 @@ void ServerCommunicator::setServerConfiguration(const QString url,
|
|||||||
m_password = password;
|
m_password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ServerCommunicator::getUserLoginUrl() const {
|
||||||
|
const QString logInUrl = m_serviceApi->baseUrl().toString() + ROUTE_LOG_IN;
|
||||||
|
return logInUrl;
|
||||||
|
}
|
||||||
|
|
||||||
void ServerCommunicator::onSendGetRequestTriggered(const GetRequestTypes type,
|
void ServerCommunicator::onSendGetRequestTriggered(const GetRequestTypes type,
|
||||||
QVariant data = QVariant()) {
|
QVariant data = QVariant()) {
|
||||||
QString path;
|
QString path;
|
||||||
@ -143,6 +148,9 @@ void ServerCommunicator::onSendPostRequestTriggered(const PostRequestTypes type,
|
|||||||
case RegisterUser:
|
case RegisterUser:
|
||||||
path = ROUTE_REGISTER_USER;
|
path = ROUTE_REGISTER_USER;
|
||||||
break;
|
break;
|
||||||
|
case MailInvite:
|
||||||
|
path = ROUTE_MAIL_INVITE;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning() << "No route found for PostRequestType:" << type;
|
qWarning() << "No route found for PostRequestType:" << type;
|
||||||
break;
|
break;
|
||||||
@ -184,6 +192,10 @@ void ServerCommunicator::onPostReplySuccessful(const PostRequestTypes type,
|
|||||||
qInfo() << "Register user successful:" << type;
|
qInfo() << "Register user successful:" << type;
|
||||||
onlineUserAccountReply(doc);
|
onlineUserAccountReply(doc);
|
||||||
break;
|
break;
|
||||||
|
case MailInvite:
|
||||||
|
qInfo() << "Mail invite successful sent:" << type;
|
||||||
|
mailInviteSentReply(doc);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning() << "Can't match request type:" << type;
|
qWarning() << "Can't match request type:" << type;
|
||||||
break;
|
break;
|
||||||
@ -228,3 +240,8 @@ void ServerCommunicator::onlineUserAccountReply(const QJsonDocument jsonDoc) {
|
|||||||
emit onlineUserAccountReceived(values[MailRole].toString(), values[OnlineIdRole].toString(),
|
emit onlineUserAccountReceived(values[MailRole].toString(), values[OnlineIdRole].toString(),
|
||||||
values[AccessCodeRole].toString());
|
values[AccessCodeRole].toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerCommunicator::mailInviteSentReply(const QJsonDocument jsonDoc) {
|
||||||
|
qInfo() << "Invitation mail successfully sent.";
|
||||||
|
emit m_core->displayStatusMessage("Invitation mail successfully sent.");
|
||||||
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ class ServerCommunicator : public QObject {
|
|||||||
void setUrl(const QUrl& url);
|
void setUrl(const QUrl& url);
|
||||||
|
|
||||||
void setServerConfiguration(const QString url, const QString email, const QString password);
|
void setServerConfiguration(const QString url, const QString email, const QString password);
|
||||||
|
QString getUserLoginUrl() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onSendGetRequestTriggered(const GetRequestTypes type, QVariant data);
|
void onSendGetRequestTriggered(const GetRequestTypes type, QVariant data);
|
||||||
@ -64,6 +65,7 @@ class ServerCommunicator : public QObject {
|
|||||||
void currentBiddingRoundChangedReply(const QJsonDocument jsonDoc);
|
void currentBiddingRoundChangedReply(const QJsonDocument jsonDoc);
|
||||||
void currentBiddingsReply(const QJsonDocument jsonDoc);
|
void currentBiddingsReply(const QJsonDocument jsonDoc);
|
||||||
void onlineUserAccountReply(const QJsonDocument jsonDoc);
|
void onlineUserAccountReply(const QJsonDocument jsonDoc);
|
||||||
|
void mailInviteSentReply(const QJsonDocument jsonDoc);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SERVERCOMMUNICATOR_H
|
#endif // SERVERCOMMUNICATOR_H
|
||||||
|
|||||||
Reference in New Issue
Block a user