From bef4bdf58901576f4e8a4b333184320871c6c174 Mon Sep 17 00:00:00 2001 From: zrekey Date: Mon, 11 Mar 2024 16:55:21 +0800 Subject: [PATCH] remove empty followUps && historyBack validation && references display more clear && clear unnecessary console && init new qa data --- .../latest-annotation-data.component.html | 16 +++++++-- .../project-analyze.component.ts | 33 ++++++++----------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/annotation-app/src/app/component/projects/project-analyze/latest-annotation-data/latest-annotation-data.component.html b/annotation-app/src/app/component/projects/project-analyze/latest-annotation-data/latest-annotation-data.component.html index c1262bdd..6554dc0b 100644 --- a/annotation-app/src/app/component/projects/project-analyze/latest-annotation-data/latest-annotation-data.component.html +++ b/annotation-app/src/app/component/projects/project-analyze/latest-annotation-data/latest-annotation-data.component.html @@ -280,7 +280,13 @@

Assigned Labels Data

{{ innerCell.prompt }} {{ innerCell.response }} - {{ innerCell.reference }} + + + + {{ link }} + + + @@ -408,7 +414,13 @@

Assigned Labels Data

{{ innerCell.prompt }} {{ innerCell.response }} - {{ innerCell.reference }} + + + + {{ link }} + + + diff --git a/annotation-app/src/app/component/projects/project-analyze/project-analyze.component.ts b/annotation-app/src/app/component/projects/project-analyze/project-analyze.component.ts index c59e84c7..aababa75 100644 --- a/annotation-app/src/app/component/projects/project-analyze/project-analyze.component.ts +++ b/annotation-app/src/app/component/projects/project-analyze/project-analyze.component.ts @@ -589,19 +589,21 @@ export class ProjectAnalyzeComponent implements OnInit { } sortQaChatData(sr) { + let arr = []; for (let i = 0; i < this.followUps.length; i++) { if (this.followUps[i].prompt && this.followUps[i].response) { - let arr = []; + let links = []; + for (let j = 0; j < this.followUps[i].reference.length; j++) { if (this.followUps[i].reference[j].text && !this.followUps[i].reference[j].textErrMessage) { - arr.push(this.followUps[i].reference[j].text); + links.push(this.followUps[i].reference[j].text); } } - this.followUps[i].reference = arr; + arr.push({ prompt: this.followUps[i].prompt, response: this.followUps[i].response, reference: links }); } } sr.pid = this.projectId; - sr.userInput[0].questionForText[0]['followUps'] = this.followUps; + sr.userInput[0].questionForText[0]['followUps'] = arr; if (sr._id) { sr.userInput[0]['tid'] = sr._id; } @@ -632,7 +634,6 @@ export class ProjectAnalyzeComponent implements OnInit { this.annotationHistory.unshift(addSubmit); this.annotationPrevious = JSON.parse(JSON.stringify(this.annotationHistory)); } - console.log(611, this.annotationHistory); } else { if (from === 'review') { if (this.srInHistory() == -1) { @@ -1883,6 +1884,7 @@ export class ProjectAnalyzeComponent implements OnInit { } else { if (this.projectType == 'qaChat' && this.isQaChatModified()) { this.isSkipOrBack('history'); + return; } this.clearCheckbox(); const param = { @@ -1894,9 +1896,12 @@ export class ProjectAnalyzeComponent implements OnInit { } isQaChatModified() { - let old = JSON.stringify(this.sr['originalUserInputs'][0]); + let old = this.sr['originalUserInputs'] ? JSON.stringify(this.sr['originalUserInputs'][0]) : ''; this.sr = this.sortQaChatData(this.sr); - let fresh = JSON.stringify(this.sr.questionForText[0]); + let fresh = + this.sr.questionForText && this.sr.questionForText[0].prompt && this.sr.questionForText[0].response + ? JSON.stringify(this.sr.questionForText[0]) + : ''; return old == fresh ? false : true; } @@ -2216,8 +2221,8 @@ export class ProjectAnalyzeComponent implements OnInit { if (this.projectType == 'qaChat') { if (this.isQaChatModified()) { this.isSkipOrBack('previous'); + return; } - console.log(222, this.sr); let tid; if (this.sr._id) { tid = this.sr._id; @@ -3284,14 +3289,6 @@ export class ProjectAnalyzeComponent implements OnInit { produceQaChatInit(res, from?) { this.sr['originalUserInputs'] = res.questionForText; this.sr._id = res._id; - // this.sr.userInputs = from == 'review' ? res.reviewInfo.userInputs : res.userInputs; - // this.sr.questionForText = from == 'review' ? [res.reviewInfo.userInputs[0].problemCategory] : res.questionForText; - // this.sr.userInput[0].questionForText[0] = - // from == 'review' ? res.reviewInfo.userInputs[0].problemCategory : res.userInputs[0].problemCategory[0]; - // let links = - // from == 'review' ? res.reviewInfo.userInputs[0].problemCategory.reference : res.questionForText[0].reference; - // let follow = - // from == 'review' ? res.reviewInfo.userInputs[0].problemCategory.followUps : res.questionForText[0].followUps; this.sr.userInputs = res.userInputs; this.sr.questionForText = res.questionForText; this.sr.userInput[0].questionForText[0] = res.userInputs[0].problemCategory[0]; @@ -3306,7 +3303,6 @@ export class ProjectAnalyzeComponent implements OnInit { } } this.followUps = follow; - console.log(4.1, this.followUps); for (let i = 0; i < this.followUps.length; i++) { if (this.followUps[i].prompt && this.followUps[i].response) { let arr = []; @@ -3319,8 +3315,6 @@ export class ProjectAnalyzeComponent implements OnInit { this.followUps[i].reference = arr; } } - console.log(4.2, this.followUps); - // make next item btn available this.editQuestionError = ''; this.isValidQaChat(); @@ -3417,6 +3411,7 @@ export class ProjectAnalyzeComponent implements OnInit { this.sr.userInputs = responseSr.userInputs; this.sr.questionForText = responseSr.questionForText; if (this.projectType === 'qaChat') { + this.clearUserInput(); this.produceQaChatInit(responseSr); } if (!this.sr.userInputs.length && this.labelType === 'HTL') {