Skip to content

Commit 6d3c755

Browse files
feat(poc3): Show warning message for undetermined questions
1 parent 8291dde commit 6d3c755

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

app/poc3.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<body>
6060
<section class="section" id="app">
6161
<div class="container is-fluid" :class="{'container': true, 'is-fluid': true, 'is-responding': isResponding}">
62-
<p :class="['notification', 'is-light', `is-${message.level}`, `${message.content ? '' : 'in'}visible`]">{{ message.content }}</p>
62+
<p v-if="message.content" :class="['notification', 'is-light', `is-${message.level}`, `${message.content ? '' : 'in'}visible`]">{{ message.content }}</p>
6363
<div id="tab-poc3">
6464
<div class="block">
6565
<div class="select is-multiple full-width">
@@ -74,7 +74,10 @@ <h3 class="title is-4">Select a case to review:</h3>
7474
<h2 class="title is-3">Automated review ✨</h2>
7575
<a v-if="!areDetailsShown" class="button is-primary" @click.prevent="onClickShowDetails()">Show details</a>
7676
<template v-else>
77-
<p class="box title is-4">Suggested penalty: £{{penalty}}</p>
77+
<div class="box">
78+
<p class="title is-4">Suggested penalty: £{{penalty}}</p>
79+
<p v-if="undeterminedWarningMessage">{{undeterminedWarningMessage}}</p>
80+
</div>
7881
<table class="table">
7982
<thead>
8083
<tr>

app/poc3.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,30 @@ createApp({
139139
}
140140
return ret
141141
},
142+
undeterminedWarningMessage() {
143+
let ret = ''
144+
let answersIndexes = []
145+
146+
for (const [i, row] of this.reviewRows.entries()) {
147+
if (!['yes', 'no'].includes(row.answer)) {
148+
answersIndexes.push(i+1)
149+
}
150+
}
151+
152+
let questionForm = 'question' + (answersIndexes.length > 1 ? 's' : '');
153+
154+
if (answersIndexes.length) {
155+
let lastIndex = answersIndexes.pop()
156+
let questionsStr = answersIndexes.join(', ')
157+
if (questionsStr) {
158+
questionsStr += ` and `
159+
}
160+
questionsStr += lastIndex
161+
ret = `⚠️ Warning: the tool could not resolve ${questionForm} ${questionsStr} confidently.`
162+
}
163+
164+
return ret
165+
}
142166
},
143167
methods: {
144168
initSettings() {

0 commit comments

Comments
 (0)