From 60e299ec26ddf61d8df14e06f61e3e43df6a3991 Mon Sep 17 00:00:00 2001 From: FutzMonitor Date: Fri, 10 Mar 2023 10:39:20 -0500 Subject: [PATCH] 1. Changes to transplantingReport.html - Added 'fieldAreas' array which is what's fed to the CustomTableComponent now - New created added that provides 'fieldAreas' with only fieldAreas - Removed the computed method for area names since only the CustomTableComponent was using it and nothing else --- .../transplantingReport.html | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/farmdata2/farmdata2_modules/fd2_barn_kit/transplantingReport/transplantingReport.html b/farmdata2/farmdata2_modules/fd2_barn_kit/transplantingReport/transplantingReport.html index 1eb9ae520c..d45d9168f9 100644 --- a/farmdata2/farmdata2_modules/fd2_barn_kit/transplantingReport/transplantingReport.html +++ b/farmdata2/farmdata2_modules/fd2_barn_kit/transplantingReport/transplantingReport.html @@ -80,6 +80,7 @@

Transplanting Report

reportVisible: false, transplantingLogs: [], updateLog: [], + fieldAreas: [], sessionToken: null, selectedCrop: 'All', @@ -504,15 +505,6 @@

Transplanting Report

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){ @@ -528,7 +520,7 @@

Transplanting Report

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]*$'}}, @@ -541,10 +533,41 @@

Transplanting Report

}, 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