Skip to content

Commit

Permalink
changed so if stubble is burnt removed or retained you cannot have graze
Browse files Browse the repository at this point in the history
  • Loading branch information
moisbo committed Nov 27, 2023
1 parent 5a3c1a3 commit 49a66ad
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 49 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "socrates-web",
"private": true,
"version": "1.0.4",
"version": "1.0.5",
"type": "module",
"homepage": "https://soil-and-land.github.io/socrates-web/",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/sample-data-20-year.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"year": 2,
"plant": 0,
"stubble": 0,
"graze": 0,
"graze": null,
"fertiliser": 200
},
{
Expand Down
1 change: 1 addition & 0 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ declare module '@vue/runtime-core' {
ParameterTable: typeof import('./components/ParameterTable.vue')['default']
PieChart: typeof import('./components/PieChart.vue')['default']
ResultsTable: typeof import('./components/ResultsTable.vue')['default']
RotationSelect: typeof import('./components/RotationSelect.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
YearlyTable: typeof import('./components/YearlyTable.vue')['default']
Expand Down
81 changes: 36 additions & 45 deletions src/components/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const grazes = [
{'id': 1, 'name': 'Heavy'},
];
const stubbles = [
{'id': 'null', 'name': 'None'},
{'id': 0, 'name': 'Burnt or Removed'},
{'id': 1, 'name': 'Retained'}
];
Expand Down Expand Up @@ -458,37 +459,39 @@ function isIterable(obj) {
<h3>Climate</h3>
<el-row>
<el-col class="py-1">
<el-row >
<el-row>
<el-col :xl="4" :lg="4" :md="4" :sm="24" :xs="24">
<div>Method of entering data</div>
</el-col>
<el-col :xl="20" :lg="20" :md="20" :sm="24" :xs="24">
<div>
<el-select v-model="store.climateMethodDataEntry" class="w-full" placeholder="Select">
<el-option
label="Enter yearly rainfall & mean temperature"
:value="0"/>
<el-option
label="Enter average rainfall & mean temperature"
:value="1"/>
<!-- <el-option-->
<!-- label="Closest town, stored weather averages"-->
<!-- :value="2"/>-->
<!-- <el-option-->
<!-- label="Closest town, actual weather data"-->
<!-- :value="3"/>-->
<el-option
label="Enter monthly rainfall & mean temperature"
:value="4"/>
</el-select>
<el-button v-if="store.climateMethodDataEntry===4"
@click="store.toggleMonthlyClimate = !store.toggleMonthlyClimate">
{{ store.toggleMonthlyClimate ? 'Hide Monthly Rain/Temperature' : 'Show Monthly Rain/Temperature' }}
</el-button>
<el-button class="my-2" v-if="store.climateMethodDataEntry===0"
@click="store.toggleYearlyClimate = !store.toggleYearlyClimate">
{{ store.toggleYearlyClimate ? 'Hide Yearly Rain' : 'Show Yearly Rain' }}
</el-button>
<el-select v-model="store.climateMethodDataEntry" class="w-full" placeholder="Select">
<el-option
label="Enter yearly rainfall & mean temperature"
:value="0"/>
<el-option
label="Enter average rainfall & mean temperature"
:value="1"/>
<!-- <el-option-->
<!-- label="Closest town, stored weather averages"-->
<!-- :value="2"/>-->
<!-- <el-option-->
<!-- label="Closest town, actual weather data"-->
<!-- :value="3"/>-->
<el-option
label="Enter monthly rainfall & mean temperature"
:value="4"/>
</el-select>
<el-button v-if="store.climateMethodDataEntry===4"
@click="store.toggleMonthlyClimate = !store.toggleMonthlyClimate">
{{
store.toggleMonthlyClimate ? 'Hide Monthly Rain/Temperature' : 'Show Monthly Rain/Temperature'
}}
</el-button>
<el-button class="my-2" v-if="store.climateMethodDataEntry===0"
@click="store.toggleYearlyClimate = !store.toggleYearlyClimate">
{{ store.toggleYearlyClimate ? 'Hide Yearly Rain' : 'Show Yearly Rain' }}
</el-button>
</div>
</el-col>
</el-row>
Expand Down Expand Up @@ -589,26 +592,14 @@ function isIterable(obj) {
</el-select>
</el-col>
<el-col :span="5" class="p-2">
<div v-if="rotation['plant'] < 5 ">
<el-select v-model="rotation['stubble']"
:disabled="rotation['plant'] === 5 || rotation['plant'] === 6 || rotation['plant'] === 7">
<el-option v-for="stubble in stubbles"
:key="stubble.id"
:label="stubble.name"
:value="stubble.id"/>
</el-select>
</div>
<rotation-select :modelValue="rotation['stubble']" :year="rotation['year']" :name="'stubble'"
:posibleValues="stubbles" @update:modelValue="(v)=>{rotation['stubble'] = v}"
:nullify="rotation['plant'] === 5 || rotation['plant'] === 6 || rotation['plant'] === 7"/>
</el-col>
<el-col :span="5" class="p-2">
<div v-if="rotation['plant'] !== 6">
<el-select v-model="rotation['graze']"
:disabled="rotation['plant'] === 6">
<el-option v-for="graze in grazes"
:key="rotation['year'] + '_graze'"
:label="graze.name"
:value="graze.id"/>
</el-select>
</div>
<rotation-select :modelValue="rotation['graze']" :year="rotation['year']" :name="'graze'"
:posibleValues="grazes" @update:modelValue="(v)=>{rotation['graze'] = v}"
:nullify="rotation['plant'] === 6 || rotation['stubble'] === 0 || rotation['stubble'] === 1"/>
</el-col>
<el-col :span="5" class="p-2">
<el-input v-model="rotation['fertiliser']"/>
Expand All @@ -634,7 +625,7 @@ function isIterable(obj) {
<h3>Yields</h3>
<el-row>
<el-col class="py-1">
<el-row >
<el-row>
<el-col :xl="4" :lg="4" :md="4" :sm="24" :xs="24">
<div>
Method of entering yield
Expand Down
38 changes: 38 additions & 0 deletions src/components/RotationSelect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<script setup lang="js">
import {onMounted, watch} from "vue";
const props = defineProps(['posibleValues', 'year', 'modelValue', 'name', 'nullify']);
const emit = defineEmits(['update:modelValue']);
let value = props.modelValue;
onMounted(() => {
if (props.nullify) {
value = 'null'
updateProperty('null');
}
});
watch(() => props.nullify, (newValue, oldValue) => {
if (props.nullify) {
value = 'null'
updateProperty('null');
}
}, {immediate: true});
function updateProperty(value) {
emit('update:modelValue', value);
}
</script>
<template>
<!-- value: {{ value }} props.nullify {{!props.nullify }}-->
<div v-if="!nullify">
<el-select v-model="value" @change="updateProperty($event)">
<el-option v-for="obj in posibleValues"
:key="props.year + props.name"
:label="obj.name"
:value="obj.id"/>
</el-select>
</div>
</template>

0 comments on commit 49a66ad

Please sign in to comment.