From fcb3900459c2e945e6f6840d09af4a363682ff66 Mon Sep 17 00:00:00 2001 From: acatchpole Date: Mon, 16 Sep 2024 11:23:12 -0700 Subject: [PATCH] btn text and datepicker fixes and cleanup Co-authored-by: dallascrichmond --- .../Controllers/NutrientsController.cs | 19 +++++-------------- .../ViewModels/FertigationDetailsViewModel.cs | 17 ----------------- .../Views/Nutrients/FertigationDetails.cshtml | 13 ++++++++++--- 3 files changed, 15 insertions(+), 34 deletions(-) diff --git a/app/Server/src/SERVERAPI/Controllers/NutrientsController.cs b/app/Server/src/SERVERAPI/Controllers/NutrientsController.cs index a3008842..c64463e8 100644 --- a/app/Server/src/SERVERAPI/Controllers/NutrientsController.cs +++ b/app/Server/src/SERVERAPI/Controllers/NutrientsController.cs @@ -257,6 +257,7 @@ public IActionResult ManureDetails(string fldName, int? id) public IActionResult FertigationDetails(string fldName, int? id, string? groupID) { + var thign = ModelState.IsValid; var fgvm = new FertigationDetailsViewModel() { fieldName = fldName, @@ -266,9 +267,12 @@ public IActionResult FertigationDetails(string fldName, int? id, string? groupID isFertigation = true, groupID = groupID, }; + if(id == null){ + ModelState.AddModelError("start", "invalid"); + } if (id != null){ - NutrientFertilizer nf = _ud.GetFieldNutrientsFertilizer(fldName, id.Value);// Not sure how this is working for fertigation. might need to change + NutrientFertilizer nf = _ud.GetFieldNutrientsFertilizer(fldName, id.Value); FertilizerType ft = _sd.GetFertilizerType(nf.fertilizerTypeId.ToString()); @@ -476,9 +480,6 @@ public IActionResult FertigationDetails(FertigationDetailsViewModel fgvm) origFertilizer.isFertigation = true; origFertilizer.applDate = origFertilizer.applDate?.Date; - //Utility.CalculateNutrients calculateNutrients = new CalculateNutrients(_env, _ud, _sd); - //NOrganicMineralizations nOrganicMineralizations = new NOrganicMineralizations(); - FertigationDetailsSetup(ref fgvm); try @@ -529,12 +530,10 @@ public IActionResult FertigationDetails(FertigationDetailsViewModel fgvm) ModelState.Clear(); fgvm.buttonPressed = ""; fgvm.btnText = "Calculate"; - //FertilizerDetail_Reset(ref fvm); if (fgvm.selFertOption != 0 && !fgvm.manualEntry) { - //Removed () around Fertilizer ft = GetFertigationFertilizer(fgvm.selFertOption ?? 0); fgvm.valN = ft.Nitrogen.ToString("0"); fgvm.valP2o5 = ft.Phosphorous.ToString("0"); @@ -641,12 +640,6 @@ public IActionResult FertigationDetails(FertigationDetailsViewModel fgvm) if (fgvm.buttonPressed == "Calculate" && ModelState.IsValid) { - // if (!ModelState.IsValid) - // { - // ModelState.Clear(); - // FertigationDetailsSetup(ref fgvm); - // return PartialView(fgvm); - // } ModelState.Clear(); fgvm.buttonPressed = ""; FertilizerType ft = _sd.GetFertilizerType(fgvm.selTypOption.ToString()); @@ -844,7 +837,6 @@ private List FertigationInsert(FertigationDetailsViewModel fgvm) isFertigation = true, injectionRate = Convert.ToDecimal(fgvm.injectionRate), injectionRateUnitId = Convert.ToInt32(fgvm.selInjectionRateUnitOption), - //eventsPerSeason = fgvm.eventsPerSeason, groupID = groupID }; ids.Add( _ud.AddFieldNutrientsFertilizer(fgvm.fieldName, nf)); @@ -905,7 +897,6 @@ private void FertigationUpdate(FertigationDetailsViewModel fgvm) groupID = fgvm.groupID, injectionRate = Convert.ToDecimal(fgvm.injectionRate), injectionRateUnitId = Convert.ToInt32(fgvm.selInjectionRateUnitOption), - //eventsPerSeason = fgvm.eventsPerSeason, isFertigation = true }; diff --git a/app/Server/src/SERVERAPI/ViewModels/FertigationDetailsViewModel.cs b/app/Server/src/SERVERAPI/ViewModels/FertigationDetailsViewModel.cs index 2e9e9375..b8489647 100644 --- a/app/Server/src/SERVERAPI/ViewModels/FertigationDetailsViewModel.cs +++ b/app/Server/src/SERVERAPI/ViewModels/FertigationDetailsViewModel.cs @@ -79,23 +79,6 @@ public class FertigationDetailsViewModel [DisplayFormat(DataFormatString = "{0:dd-MMM-yyyy}", ApplyFormatInEditMode = true)] public DateTime? applDate { get; set; } public bool manualEntry { get; set; } - //calculated - //total product volume per fertigation - //product volume per fertigation - //product vol per growing season - //fertigation time - //applied nutrients per fertigation - //n - //p2Os - //k2o - //total applied nutrients - //n - //p2Os - //k2o - //still required this year - //n - //p2Os - //k2o public string valN { get; set; } public string valP2o5 { get; set; } public string valK2o { get; set; } diff --git a/app/Server/src/SERVERAPI/Views/Nutrients/FertigationDetails.cshtml b/app/Server/src/SERVERAPI/Views/Nutrients/FertigationDetails.cshtml index d19ffbc9..ec638e1d 100644 --- a/app/Server/src/SERVERAPI/Views/Nutrients/FertigationDetails.cshtml +++ b/app/Server/src/SERVERAPI/Views/Nutrients/FertigationDetails.cshtml @@ -256,7 +256,15 @@ @Html.HiddenFor(x => x.fieldName) @Html.HiddenFor(x => x.title) @@ -300,8 +308,7 @@ todayHighlight: true, clearBtn: true, startView: 0, - minViewMode: 0, - startDate: new Date(), + minViewMode: 0, endDate: '+10y', defaultViewDate: new Date() }).on('changeDate', function(e) {