added full tank string value inputs

This commit is contained in:
Alex H
2023-04-14 01:54:03 -04:00
parent e389a9ac2a
commit df165dae6e

View File

@@ -27,6 +27,9 @@ export default {
myVehicles: [], myVehicles: [],
selectedVehicle: null, selectedVehicle: null,
invert: false, invert: false,
filledValue: null,
notFilledValue: null,
isFullTankString: false,
fillupModel: { fillupModel: {
fuelQuantity: null, fuelQuantity: null,
perUnitPrice: null, perUnitPrice: null,
@@ -76,17 +79,27 @@ export default {
Papa.parse(this.file, this.papaConfig) Papa.parse(this.file, this.papaConfig)
}, },
importData() { importData() {
if (typeof this.fileData[1][this.fillupModel.isTankFull] !== 'boolean') { if (this.errors.length !== 0) {
this.errors.push('The value of Tank Full needs to be a boolean (true,false).') const content = {
return headings: this.fillupModel,
data: this.fileData.splice(1, this.fileData.length),
fullTankInverted: this.inverted,
vehicleId: this.selectedVehicle.id,
}
alert(JSON.stringify(content))
} else {
this.errors.push('fix errors')
} }
const content = { },
headings: this.fillupModel, checkFieldString() {
data: this.fileData.splice(1, this.fileData.length), const tankFull = this.fileData[1][this.fillupModel.isTankFull]
fullTankInverted: this.inverted, if (typeof tankFull !== 'boolean') {
vehicleId: this.selectedVehicle.id, if (typeof tankFull === 'string' && tankFull.length > 0) {
this.isFullTankString = true
} else {
this.errors.push('The value of Tank Full needs to be a boolean (true,false) or consistent string.')
}
} }
alert(JSON.stringify(content))
}, },
}, },
} }
@@ -206,12 +219,20 @@ export default {
<b-radio-button v-model="invert" native-value="true">{{ $t('partialfillup') }}</b-radio-button> <b-radio-button v-model="invert" native-value="true">{{ $t('partialfillup') }}</b-radio-button>
</b-field> </b-field>
<b-field> <b-field>
<b-select v-model="fillupModel.isTankFull"> <b-select v-model="fillupModel.isTankFull" @input="checkFieldString">
<option v-for="(option, index) in fileHeadings" :key="index" :value="index"> <option v-for="(option, index) in fileHeadings" :key="index" :value="index">
{{ option }} {{ option }}
</option> </option>
</b-select> </b-select>
</b-field> </b-field>
<span v-if="isFullTankString === true">
<b-field label="Value when tank is filled">
<b-input v-model="filledValue"></b-input>
</b-field>
<b-field label="Value when tank was not completely filled">
<b-input v-model="notFilledValue"></b-input>
</b-field>
</span>
<b-field :label="$t('missedfillup')"> <b-field :label="$t('missedfillup')">
<b-select v-model="fillupModel.hasMissedFillup"> <b-select v-model="fillupModel.hasMissedFillup">
<option v-for="(option, index) in fileHeadings" :key="index" :value="index"> <option v-for="(option, index) in fileHeadings" :key="index" :value="index">