feat(GODT-3121): forward user input to bridge.

This commit is contained in:
Xavier Michelon 2023-12-05 15:41:05 +01:00
parent 88c4737ba4
commit 3309137b80
5 changed files with 27 additions and 15 deletions

View File

@ -304,11 +304,11 @@ void QMLBackend::openExternalLink(QString const &url) {
//****************************************************************************************************************************************************
//
/// \param[in] categoryID The ID of the bug report category.
//****************************************************************************************************************************************************
void QMLBackend::requestKnowledgeBaseSuggestions() const {
void QMLBackend::requestKnowledgeBaseSuggestions(qint8 categoryID) const {
HANDLE_EXCEPTION(
app().grpc().requestKnowledgeBaseSuggestions("Test");
app().grpc().requestKnowledgeBaseSuggestions(reportFlow_.collectUserInput(categoryID));
)
}

View File

@ -66,7 +66,7 @@ public: // member functions.
Q_INVOKABLE void clearAnswers(); ///< Clear all collected answers.
Q_INVOKABLE bool isTLSCertificateInstalled(); ///< Check if the bridge certificate is installed in the OS keychain.
Q_INVOKABLE void openExternalLink(QString const & url = QString()); ///< Open a knowledge base article.
Q_INVOKABLE void requestKnowledgeBaseSuggestions() const; ///< Request knowledgebase article suggestions.
Q_INVOKABLE void requestKnowledgeBaseSuggestions(qint8 categoryID) const; ///< Request knowledgebase article suggestions.
public: // Qt/QML properties. Note that the NOTIFY-er signal is required even for read-only properties (QML warning otherwise)
Q_PROPERTY(bool showOnStartup READ showOnStartup NOTIFY showOnStartupChanged)

View File

@ -78,7 +78,7 @@ Item {
root.showBugCategory();
}
onQuestionAnswered: {
Backend.requestKnowledgeBaseSuggestions();
Backend.requestKnowledgeBaseSuggestions(categoryId);
root.showBugReport();
}
}

View File

@ -30,13 +30,6 @@ namespace {
namespace bridgepp {
//****************************************************************************************************************************************************
//
//****************************************************************************************************************************************************
BugReportFlow::BugReportFlow() {
}
//****************************************************************************************************************************************************
/// \param[in] filepath The path of the file to parse.
/// \return True iff the file can be properly parsed.
@ -92,7 +85,7 @@ bool BugReportFlow::setAnswer(quint8 questionId, QString const &answer) {
//****************************************************************************************************************************************************
/// \param[in] questionId The id of the question.
/// \param[in] categoryId The id of the question.
/// \return answer the given question.
//****************************************************************************************************************************************************
QString BugReportFlow::getCategory(quint8 categoryId) const {
@ -128,7 +121,7 @@ QString BugReportFlow::collectAnswers(quint8 categoryId) const {
QVariantList sets = this->questionSet(categoryId);
for (QVariant const &var: sets) {
const QString& answer = getAnswer(var.toInt());
const QString answer = getAnswer(var.toInt());
if (answer.isEmpty())
continue;
answers += "#### " + questions_[var.toInt()].toMap()["text"].toString() + "\n\r";
@ -139,6 +132,24 @@ QString BugReportFlow::collectAnswers(quint8 categoryId) const {
}
//****************************************************************************************************************************************************
/// \param[in] categoryId The id of the question set.
//****************************************************************************************************************************************************
QString BugReportFlow::collectUserInput(quint8 categoryId) const {
if (categoryId > categories_.count() - 1)
return {};
QString input = this->getCategory(categoryId);
for (QVariant const &var: this->questionSet(categoryId)) {
QString const answer = getAnswer(var.toInt());
if (!answer.isEmpty())
input += " " + answer;
}
return input;
}
//****************************************************************************************************************************************************
//
//****************************************************************************************************************************************************

View File

@ -28,7 +28,7 @@ namespace bridgepp {
class BugReportFlow {
public: // member functions.
BugReportFlow(); ///< Default constructor.
BugReportFlow() = default; ///< Default constructor.
BugReportFlow(BugReportFlow const &) = delete; ///< Disabled copy-constructor.
BugReportFlow(BugReportFlow &&) = delete; ///< Disabled assignment copy-constructor.
~BugReportFlow() = default; ///< Destructor.
@ -42,6 +42,7 @@ public: // member functions.
[[nodiscard]] QString getCategory(quint8 categoryId) const; ///< Get category name.
[[nodiscard]] QString getAnswer(quint8 questionId) const; ///< Get answer for a given question.
[[nodiscard]] QString collectAnswers(quint8 categoryId) const; ///< Collect answer for a given set of questions.
[[nodiscard]] QString collectUserInput(quint8 categoryId) const; ///< Collect the user input (user answers without quesitons) for a given set of questions.
void clearAnswers(); ///< Clear all collected answers.