Skip to content
This repository has been archived by the owner on May 17, 2018. It is now read-only.

Commit

Permalink
Fixes #6 - disable indecision in statistics & es queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Gross committed Aug 9, 2017
1 parent ff8490e commit 39bff5a
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 49 deletions.
7 changes: 5 additions & 2 deletions src/assets/js/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ function search (query, fields) {
})
}

function updateDone (entry) {
function updateDone (entry, indecision) {
let script =
'ctx._source.validation_decision = ' + entry.validation_decision + ';' +
'ctx._source.validation_indecision = ' + entry.validation_indecision + ';' +
'ctx._source.validation_done = ' + Date.now() + 'L;'

if (indecision) {
script += 'ctx._source.validation_indecision = ' + entry.validation_indecision + ';'
}

return updateDocument(entry['_id'], script)
}

Expand Down
11 changes: 6 additions & 5 deletions src/components/Navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<a
class="navbar-item is-hidden-desktop"
:class="{'has-text-danger mID-unclickable' : errorMarker}"
v-show="validationDisplay"
v-show="validationConf.display"
@click="statisticsRender"
>
<i class="fa fa-bar-chart-o mID-margin-right-8" aria-hidden="true"></i> {{ localization.navbar.statistics[lang] }}
Expand Down Expand Up @@ -52,7 +52,7 @@
<a
class="navbar-item"
:class="{'has-text-danger mID-unclickable' : errorMarker}"
v-show="validationDisplay"
v-show="validationConf.display"
@click="statisticsRender"
>
<i class="fa fa-bar-chart-o mID-margin-right-8" aria-hidden="true"></i> {{ localization.navbar.statistics[lang] }}
Expand All @@ -62,14 +62,15 @@
</nav>

<statistics
v-show="validationDisplay && statisticsShow"
v-show="validationConf.display && statisticsShow"
@close="statisticsShow = false"
:dataResults="statisticsResults"
:validationIndecisionDisplay="validationConf.action.indecision_display"
></statistics>

<keyboard
v-show="keyboardShow"
:validationDisplay="validationDisplay"
:validationDisplay="validationConf.display"
@close="keyboardShow = false"
></keyboard>
</div>
Expand All @@ -94,7 +95,7 @@ export default {
errorMarker: false,
statisticsShow: false,
keyboardShow: false,
validationDisplay: validationConf.display,
validationConf: validationConf,
localization: localization,
langs: localization.available,
lang: localization.default,
Expand Down
80 changes: 46 additions & 34 deletions src/components/Statistics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export default {
dataResults: {
required: true,
type: Object
},
validationIndecisionDisplay: {
required: true,
type: Boolean
}
},
data () {
Expand Down Expand Up @@ -96,37 +100,40 @@ export default {
methods: {
dataFormattedForChartJs (statistics) {
if (Object.keys(this.dataResults).length === 0) return {}
return {
labels: statistics.intervals,
datasets: [
{
label: 'Total occurences',
backgroundColor: '#f87979',
data: statistics.intervals_count,
fill: false,
yAxisID: 'y-total'
},
{
label: 'Done',
backgroundColor: '#79abff',
data: statistics.done_count,
fill: false,
yAxisID: 'y-done'
},
{
label: 'Decision True',
backgroundColor: '#d17e64',
data: statistics.decision.true,
fill: false,
yAxisID: 'y-done'
},
{
label: 'Decision False',
backgroundColor: '#b2d164',
data: statistics.decision.false,
fill: false,
yAxisID: 'y-done'
},
let datasets = [
{
label: 'Total occurences',
backgroundColor: '#f87979',
data: statistics.intervals_count,
fill: false,
yAxisID: 'y-total'
},
{
label: 'Done',
backgroundColor: '#79abff',
data: statistics.done_count,
fill: false,
yAxisID: 'y-done'
},
{
label: 'Decision True',
backgroundColor: '#d17e64',
data: statistics.decision.true,
fill: false,
yAxisID: 'y-done'
},
{
label: 'Decision False',
backgroundColor: '#b2d164',
data: statistics.decision.false,
fill: false,
yAxisID: 'y-done'
}
]
if (this.validationIndecisionDisplay) {
datasets.push(
{
label: 'Indecision True',
backgroundColor: '#ffcd79',
Expand All @@ -141,7 +148,14 @@ export default {
fill: false,
yAxisID: 'y-done'
}
]
)
}
console.log(datasets)
return {
labels: statistics.intervals,
datasets: datasets
}
},
optionsForChartJs () {
Expand All @@ -162,8 +176,6 @@ export default {
display: true,
position: 'left',
id: 'y-done',
// grid line settings
gridLines: {
drawOnChartArea: false // only want the grid lines for one axis to show up
}
Expand Down
21 changes: 13 additions & 8 deletions src/components/Validation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@
</td>

<td v-show="validationConf.display">
<div class="field is-grouped has-text-centered">
<p class="has-text-centered mID-nowrap mID-margin-right-8">
<div class="field has-text-centered" :class="{'is-grouped' : indecisionDisplay}">
<p class="has-text-centered mID-nowrap" :class="{'mID-margin-right-8' : indecisionDisplay}">
<label class="checkbox">
<input
type="checkbox"
Expand All @@ -190,7 +190,7 @@
<i class="fa" :class="entry.validation_decision ? 'fa-check has-text-success' : 'fa-times has-text-danger'" aria-hidden="true"></i>
</label>
</p>
<p class="has-text-centered mID-nowrap">
<p class="has-text-centered mID-nowrap" v-show="indecisionDisplay">
<label class="checkbox">
<input
type="checkbox"
Expand Down Expand Up @@ -295,6 +295,7 @@ export default {
max: scoresConf.range[1]
}
},
indecisionDisplay: validationConf.action.indecision_display,
scoresDisplay: !!scoresConf.column,
valuesRangeSlider: scoresConf.range,
error: {
Expand Down Expand Up @@ -394,7 +395,7 @@ export default {
self.filteredData[self.activeRow].validation_decision = !self.filteredData[self.activeRow].validation_decision
}
if (event.keyCode === 69) { // change indecision
if (event.keyCode === 69 && self.indecisionDisplay) { // change indecision
self.filteredData[self.activeRow].validation_indecision = !self.filteredData[self.activeRow].validation_indecision
}
Expand Down Expand Up @@ -461,13 +462,17 @@ export default {
element._source.validation_done = !element._source.validation_done ? false : element._source.validation_done
element._source.validation_indecision = !element._source.validation_indecision ? Array.isArray(scoresConf.preComputed.indecision) && element._source[scoresConf.column] <= scoresConf.preComputed.indecision[1] && element._source[scoresConf.column] >= scoresConf.preComputed.indecision[0] : element._source.validation_indecision
if (self.indecisionDisplay) {
element._source.validation_indecision = !element._source.validation_indecision ? Array.isArray(scoresConf.preComputed.indecision) && element._source[scoresConf.column] <= scoresConf.preComputed.indecision[1] && element._source[scoresConf.column] >= scoresConf.preComputed.indecision[0] : element._source.validation_indecision
}
} else {
element._source.validation_decision = !element._source.validation_decision ? false : element._source.validation_decision
element._source.validation_done = !element._source.validation_done ? false : element._source.validation_done
element._source.validation_indecision = !element._source.validation_indecision ? false : element._source.validation_indecision
if (self.indecisionDisplay) {
element._source.validation_indecision = !element._source.validation_indecision ? false : element._source.validation_indecision
}
}
element._source.validation = false
Expand All @@ -487,7 +492,7 @@ export default {
updateData (entry, type) {
if (type === 'done') {
if (entry.validation_done) {
es.updateDone(entry).then(function (response) {
es.updateDone(entry, this.indecisionDisplay).then(function (response) {
entry.validation = 'success'
}, function (error) {
console.log(error)
Expand All @@ -504,7 +509,7 @@ export default {
})
}
} else {
es.updateDone(entry).then(function (response) {
es.updateDone(entry, this.indecisionDisplay).then(function (response) {
entry.validation = 'success'
entry.validation_done = true
}, function (error) {
Expand Down

0 comments on commit 39bff5a

Please sign in to comment.