Skip to content

Commit

Permalink
Refs #99. Added project id in test invitations
Browse files Browse the repository at this point in the history
  • Loading branch information
SBriere committed Dec 19, 2024
1 parent b35ee69 commit 8c0800b
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 15 deletions.
18 changes: 16 additions & 2 deletions client/src/dialogs/TestInvitationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void TestInvitationDialog::setEnableEmail(const bool &enable_email)

if (!m_enableEmails){
ui->chkInviteEmail->setCheckState(Qt::Unchecked);
on_chkInviteEmail_checkStateChanged(Qt::Unchecked); // Force check since it's the default value
}else{
// Default value is on
ui->chkInviteEmail->setCheckState(Qt::Checked);
Expand All @@ -91,6 +92,11 @@ void TestInvitationDialog::setEnableInviteesList(const bool &enable)
ui->stackedPages->addWidget(ui->pageTargets);
}

void TestInvitationDialog::setCurrentProjectId(const int &id_project)
{
m_currentProjectId = id_project;
}

void TestInvitationDialog::setInvitableDevices(QHash<int, TeraData> *devices)
{
if (devices)
Expand Down Expand Up @@ -242,6 +248,9 @@ void TestInvitationDialog::on_stackedPages_currentChanged(int current_index)
if (ui->btnNext->isEnabled() && ui->stackedPages->currentWidget() == ui->pageTargets){
ui->btnNext->setEnabled(ui->widgetInvitees->getInviteesCount() > 0);
}
if (ui->btnOK->isVisible() && ui->stackedPages->currentWidget() == ui->pageTargets){
ui->btnOK->setEnabled(ui->widgetInvitees->getInviteesCount() > 0);
}
}


Expand Down Expand Up @@ -273,6 +282,7 @@ void TestInvitationDialog::on_btnOK_clicked()
QJsonObject invitation;
invitation["id_test_invitation"] = 0;
invitation["id_participant"] = id;
invitation["id_project"] = m_currentProjectId;
if (m_currentSessionId)
invitation["id_session"] = m_currentSessionId;
invitation["id_test_type"] = ui->cmbTestType->currentData().toInt();
Expand All @@ -286,6 +296,7 @@ void TestInvitationDialog::on_btnOK_clicked()
QJsonObject invitation;
invitation["id_test_invitation"] = 0;
invitation["id_device"] = id;
invitation["id_project"] = m_currentProjectId;
if (m_currentSessionId)
invitation["id_session"] = m_currentSessionId;
invitation["id_test_type"] = ui->cmbTestType->currentData().toInt();
Expand All @@ -299,6 +310,7 @@ void TestInvitationDialog::on_btnOK_clicked()
QJsonObject invitation;
invitation["id_test_invitation"] = 0;
invitation["id_user"] = id;
invitation["id_project"] = m_currentProjectId;
if (m_currentSessionId)
invitation["id_session"] = m_currentSessionId;
invitation["id_test_type"] = ui->cmbTestType->currentData().toInt();
Expand Down Expand Up @@ -355,8 +367,10 @@ void TestInvitationDialog::on_chkInviteEmail_checkStateChanged(const Qt::CheckSt

void TestInvitationDialog::inviteesCountChanged(int count)
{
qDebug() << count;
if (ui->stackedPages->currentWidget() == ui->pageTargets)
if (ui->stackedPages->currentWidget() == ui->pageTargets && ui->stackedPages->currentIndex() < ui->stackedPages->count() - 1)
ui->btnNext->setEnabled(count > 0);

if (ui->stackedPages->currentIndex() == ui->stackedPages->count() - 1)
ui->btnOK->setEnabled(count > 0);
}

4 changes: 3 additions & 1 deletion client/src/dialogs/TestInvitationDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TestInvitationDialog : public QDialog
void setCurrentData(TeraData* data);
void setEnableEmail(const bool& enable_email);
void setEnableInviteesList(const bool& enable);
void setCurrentProjectId(const int& id_project);

void setInvitableDevices(QHash<int, TeraData>* devices);
void setInvitableParticipants(QHash<int, TeraData>* participants);
Expand Down Expand Up @@ -55,7 +56,8 @@ private slots:
bool m_enableEmails = false;

QList<TeraData> m_pendingInvitations;
int m_currentSessionId = 0;
int m_currentSessionId = 0;
int m_currentProjectId = 0;

void initUI();
void processNextEmail();
Expand Down
1 change: 1 addition & 0 deletions client/src/editors/ParticipantWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ void ParticipantWidget::processServicesReply(QList<TeraData> services, QUrlQuery

ui->btnEmailWeb->setVisible(has_email_service);
ui->wdgInvitations->setEnableEmail(has_email_service);
ui->wdgSessions->enableEmails(has_email_service);

// Find and select VideoRehab by default in the combobox
int default_index = ui->cmbServices->findData("VideoRehabService");
Expand Down
4 changes: 3 additions & 1 deletion client/src/editors/ProjectWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1316,8 +1316,10 @@ void ProjectWidget::on_tabNav_currentChanged(int index)

// Test invitations
if (current_tab == ui->tabInvitations){
if (m_data)
if (m_data){
ui->wdgInvitations->setCurrentProject(m_data->getId());
ui->wdgInvitations->loadForProject(m_data->getId());
}
}

}
Expand Down
12 changes: 12 additions & 0 deletions client/src/editors/SessionWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include "SessionWidget.h"
#include "ui_SessionWidget.h"

#include "GlobalMessageBox.h"

#include "TeraSessionStatus.h"
#include "TeraSessionEvent.h"

#include <QFileDialog>
#include <QStandardPaths>

Expand Down Expand Up @@ -46,6 +51,7 @@ SessionWidget::SessionWidget(ComManager *comMan, const TeraData *data, QWidget *

if (data->hasFieldName("id_project")){
m_idProject = data->getFieldValue("id_project").toInt();
ui->wdgInvitations->setCurrentProject(m_idProject);
ui->tabAssets->setAssociatedProject(m_idProject);
}

Expand Down Expand Up @@ -188,6 +194,12 @@ void SessionWidget::setTestTypes(QList<TeraData> *test_types)
}
}

void SessionWidget::enableEmails(const bool &enable)
{
m_allowEmails = enable;
ui->wdgInvitations->setEnableEmail(m_allowEmails);
}

void SessionWidget::updateControlsState()
{
ui->grpSummary->setVisible(!dataIsNew());
Expand Down
8 changes: 2 additions & 6 deletions client/src/editors/SessionWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
#include <QTableWidgetItem>

#include "DataEditorWidget.h"
#include "GlobalMessageBox.h"

#include "TeraSessionStatus.h"
#include "TeraSessionEvent.h"
#include "data/DownloadingFile.h"
#include "dialogs/BaseDialog.h"

namespace Ui {
class SessionWidget;
Expand All @@ -32,6 +26,7 @@ class SessionWidget : public DataEditorWidget
void showTests();

void setTestTypes(QList<TeraData>* test_types);
void enableEmails(const bool& enable);

void connectSignals();
private:
Expand All @@ -40,6 +35,7 @@ class SessionWidget : public DataEditorWidget
int m_idProject;
QString m_baseParticipantUuid; // Base participant UUID when editing a new session
bool m_alwaysShowAssets; // Allow creation of new assets, even when no assets are present
bool m_allowEmails = false;

//QMap<int, QTableWidgetItem*> m_listDeviceDatas;
QMap<int, QTableWidgetItem*> m_listSessionEvents;
Expand Down
6 changes: 6 additions & 0 deletions client/src/widgets/SessionsListWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ void SessionsListWidget::enableTestInvitations(QList<TeraData> *test_types)
m_testTypes = test_types;
}

void SessionsListWidget::enableEmails(const bool &enable)
{
m_allowEmails = enable;
}

void SessionsListWidget::setSessionsCount(const int &count)
{
m_totalSessions = count;
Expand Down Expand Up @@ -813,6 +818,7 @@ void SessionsListWidget::showSessionEditor(TeraData *session_info)
ses_widget->showAssets();
if (m_currentSessionShowTests)
ses_widget->showTests();
ses_widget->enableEmails(m_allowEmails);

m_diag_editor->setCentralWidget(ses_widget);

Expand Down
7 changes: 2 additions & 5 deletions client/src/widgets/SessionsListWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class SessionsListWidget : public QWidget
void enableDeletion(const bool& enable);
void enableFileTransfers(const bool& enable);
void enableTestInvitations(QList<TeraData>* test_types);
void enableEmails(const bool& enable);

void setSessionsCount(const int& count);
int getSessionsCount();
Expand Down Expand Up @@ -70,6 +71,7 @@ class SessionsListWidget : public QWidget

bool m_allowDeletion;
bool m_allowFileTransfers;
bool m_allowEmails;

QString m_currentUuid;
int m_currentId;
Expand Down Expand Up @@ -123,15 +125,10 @@ private slots:
void currentCalendarDateActivated(QDate current_date);

void on_btnCheckSessionTypes_clicked();

void on_btnUncheckSessionTypes_clicked();

void on_btnFilterSessionsTypes_clicked();

void on_tableSessions_itemDoubleClicked(QTableWidgetItem *item);

void on_btnAssetsBrowser_clicked();

void on_btnTestsBrowser_clicked();

signals:
Expand Down
8 changes: 8 additions & 0 deletions client/src/widgets/TestInvitationsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ void TestInvitationsWidget::setEnableEmail(const bool &enable_email)
m_enableEmails = enable_email;
}

void TestInvitationsWidget::setCurrentProject(const int &id_project)
{
m_idProject = id_project;
}

void TestInvitationsWidget::loadForProject(const int &id_project)
{
setViewMode(ViewMode::VIEWMODE_PROJECT);
Expand All @@ -92,6 +97,8 @@ void TestInvitationsWidget::loadForParticipant(TeraData* participant)
m_listInvitations_items.clear();
m_invitations.clear();

m_idProject = participant->getFieldValue("id_project").toInt();

if (m_comManager){
QUrlQuery args;
args.addQueryItem(WEB_QUERY_ID_PARTICIPANT, QString::number(participant->getId()));
Expand Down Expand Up @@ -351,6 +358,7 @@ void TestInvitationsWidget::on_btnInvite_clicked()

m_invitationDialog = new TestInvitationDialog(m_comManager, this);
m_invitationDialog->setTestTypes(m_testTypes);
m_invitationDialog->setCurrentProjectId(m_idProject);
m_invitationDialog->setInvitableDevices(m_invitableDevices);
m_invitationDialog->setInvitableParticipants(m_invitableParticipants);
m_invitationDialog->setInvitableUsers(m_invitableUsers);
Expand Down
3 changes: 3 additions & 0 deletions client/src/widgets/TestInvitationsWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class TestInvitationsWidget : public QWidget
void setInvitableParticipants(QHash<int, TeraData>* participants);
void setInvitableUsers(QHash<int, TeraData>* users);
void setEnableEmail(const bool& enable_email);
void setCurrentProject(const int& id_project);

void loadForProject(const int& id_project);
void loadForParticipant(TeraData *participant);
Expand Down Expand Up @@ -88,6 +89,8 @@ private slots:
QHash<int, TeraData>* m_invitableParticipants = nullptr;
QHash<int, TeraData>* m_invitableUsers = nullptr;

int m_idProject = -1;

// Icons are defined here (speed up load)
QIcon m_deleteIcon;
QIcon m_viewIcon;
Expand Down

0 comments on commit 8c0800b

Please sign in to comment.