Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only Field Areas While Editing a Transplanting Log #633

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ <h1 class="text-center">Transplanting Report</h1>
reportVisible: false,
transplantingLogs: [],
updateLog: [],
fieldAreas: [],

sessionToken: null,
selectedCrop: 'All',
Expand Down Expand Up @@ -504,15 +505,6 @@ <h1 class="text-center">Transplanting Report</h1>
return userNameArray
},

areaNameArray(){
let areaNameArray = []
const areaKeyIterator = this.areaToIDMap.keys()
for(i = 0; i < this.areaToIDMap.size; i++){
areaNameArray.push(areaKeyIterator.next().value)
}
return areaNameArray
},

cropNameArray(){
let cropNameArray = []
for(let [key, info] of this.cropToIDMap){
Expand All @@ -528,7 +520,7 @@ <h1 class="text-center">Transplanting Report</h1>
return [
{"header": 'Date', "visible": true, "inputType" : {'type': 'date'}},
{"header": 'Crop', "visible": true, "inputType" : {'type': 'dropdown', value: this.cropNameArray}},
{"header": 'Area', "visible": true, "inputType" : {'type': 'dropdown', value: this.areaNameArray}},
{"header": 'Area', "visible": true, "inputType" : {'type': 'dropdown', value: this.fieldAreas}},
{"header": 'Row Feet', "visible": true, "inputType" : {'type': 'regex', 'regex': '^[1-9]+[0-9]*$'}},
{"header": 'Bed Feet', "visible": true, "inputType" : {'type': 'no input'}},
{"header": 'Rows/Bed', "visible": true, "inputType" : {'type': 'regex', 'regex': '^[1-9]+[0-9]*$'}},
Expand All @@ -541,10 +533,41 @@ <h1 class="text-center">Transplanting Report</h1>
},
pageLoaded() {
// Check here that the correct number of API calls have completed.
return this.createdCount == 8
return this.createdCount == 9
},
},
created() {
let areaResponse = []
if(localStorage.getItem('areas') == null){
getAllPages('/taxonomy_term.json?bundle=farm_areas', this.areaResponse)
.then(() => {
localStorage.setItem('areas', JSON.stringify(this.areaResponse))

this.fieldAreas = this.areaResponse.filter((x) => x.area_type === 'field' || x.area_type === 'bed')
this.fieldAreas = (this.fieldAreas).map((h) => h.name)

this.createdCount++
})
.catch((err) => {
this.errBannerVisibility = true
})
}
else{
this.areaResponse = JSON.parse(localStorage.getItem('areas'))
getAllPages('/taxonomy_term.json?bundle=farm_areas')
.then((resp) => {
this.areaResponse = resp
localStorage.setItem('areas', JSON.stringify(resp))

this.fieldAreas = this.areaResponse.filter((x) => x.area_type === 'field' || x.area_type === 'bed')
this.fieldAreas = (this.fieldAreas).map((h) => h.name)

this.createdCount++
})
.catch((err) => {
this.errBannerVisibility = true
})
}
getSessionToken()
.then((response) => {
this.sessionToken = response
Expand Down