Skip to content

Commit

Permalink
Enhanced FertigationDetails Layout and Styling plus Fertigation Modal…
Browse files Browse the repository at this point in the history
… Build pt 1 (#681)

* Form select fields setup complete

* WIP

* feat: Enhance FertigationDetails view layout and spacing
- added spacer to FertilizerDetails to match with design
- Improve overall UI readability in FertigationDetails while maintaining functionality

* fix: Correct form tag in FertigationDetails view

* change div to h4 for headings

---------

Co-authored-by: Dallas Richmond <[email protected]>
Co-authored-by: Paul Garewal <[email protected]>
Co-authored-by: luna <[email protected]>
  • Loading branch information
4 people authored Aug 28, 2024
1 parent 23ee6fc commit f2c3ecb
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 110 deletions.
90 changes: 86 additions & 4 deletions app/Agri.Data/SeedData/FertigationData.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,36 @@
"StaticDataVersionId": 14
}
],




"FertigationTypes":[
{
"Id": 1,
"Name": "Liquid Fertilizer",
"LiquidSolid": "Liquid",
"Custom": false,
"StaticDataVersionId": 14
},
{
"Id": 2,
"Name": "Liquid Fertilizer (Custom)",
"LiquidSolid": "Liquid",
"Custom": true,
"StaticDataVersionId": 14
},
{
"Id": 1,
"Name": "Solid Fertilizer",
"LiquidSolid": "Solid",
"Custom": false,
"StaticDataVersionId": 14
},
{
"Id": 1,
"Name": "Solid Fertilizer (Custom)",
"LiquidSolid": "Solid",
"Custom": true,
"StaticDataVersionId": 14
}
],
"LiquidFertilizerDensities":[
{
"Id": 1,
Expand Down Expand Up @@ -612,5 +638,61 @@
"InputUnitName": "Litres",
"StaticDataVersionId": 14
}
],
"ProductRateUnits": [
{
"Id": 1,
"Name": "US gallon/ac",
"StaticDataVersionId": 14
},
{
"Id": 2,
"Name": "L/ac",
"StaticDataVersionId": 14
},
{
"Id": 3,
"Name": "Imp. gallon/ac",
"StaticDataVersionId": 14
}
],
"DensityUnits": [
{
"Id": 1,
"Name": "lb/US gallon",
"StaticDataVersionId": 14
},
{
"Id": 2,
"Name": "lb/Imp. Gallon",
"StaticDataVersionId": 14
},
{
"Id": 3,
"Name": "kg/L",
"StaticDataVersionId": 14
},
{
"Id": 4,
"Name": "kg/US gallon",
"StaticDataVersionId": 14
}
],
"InjectionRateUnits": [
{
"Id": 1,
"Name": "US gallon/min",
"StaticDataVersionId": 14
},
{
"Id": 2,
"Name": "L/min",
"StaticDataVersionId": 14
},
{
"Id": 3,
"Name": "Imp. gallon/min",
"StaticDataVersionId": 14
}
]
}
23 changes: 23 additions & 0 deletions app/Agri.Models/Configuration/Fertigation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Agri.Models.Configuration
{
public class Fertigation
{
public Fertigation()
{
// LiquidFertilizerDensities = new List<LiquidFertilizerDensity>();
}

public List<Fertilizer> Fertilizers { get; set; }
public List<LiquidFertilizerDensity> LiquidFertilizerDensities { get; set; }
public List<LiquidMaterialApplicationUSGallonsPerAcreRateConversion> LiquidMaterialApplicationUsGallonsPerAcreRateConversions { get; set; }
public List<LiquidMaterialsConversionFactor> LiquidMaterialsConversionFactors { get; set; }
public List<FertigationType> FertigationTypes { get; set; }
public List<ProductRateUnit> ProductRateUnits { get; set; }
public List<DensityUnit> DensityUnits { get; set; }
public List<InjectionRateUnit> InjectionRateUnits { get; set; }

}
}
14 changes: 14 additions & 0 deletions app/Agri.Models/Configuration/FertigationType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Agri.Models.Configuration
{
public class FertigationType : Versionable
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string LiquidSolid { get; set; }
public bool Custom { get; set; }
}
}
13 changes: 13 additions & 0 deletions app/Agri.Models/Configuration/InjectionRateUnit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Agri.Models.Configuration
{
public class InjectionRateUnit : Versionable
{
[Key]
public int Id { get; set; }
public string Name { get; set; }

}
}
18 changes: 18 additions & 0 deletions app/Agri.Models/Configuration/ProductRateUnit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Agri.Models.Configuration
{
public class ProductRateUnit
{
public ProductRateUnit()
{

}

public int Id { get; set; }
public string Name { get; set; }
// public decimal ConvFactor { get; set; }

}
}
112 changes: 93 additions & 19 deletions app/Server/src/SERVERAPI/Controllers/NutrientsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using Newtonsoft.Json;
using Agri.Models;

namespace SERVERAPI.Controllers
{
Expand Down Expand Up @@ -248,54 +251,125 @@ public IActionResult ManureDetails(string fldName, int? id)

public IActionResult FertigationDetails(string fldName, int? id)
{
var mvm = new FertigationDetailsViewModel()
var fgvm = new FertigationDetailsViewModel()
{
fieldName = fldName,
title = id == null ? "Add" : "Edit",
btnText = id == null ? "Add to Field" : "Update Field",
id = id,

//selMethOption = 0
};

// FertigationStillRequired(rev fvm);
//FertigationDetailsSetup(rev fvm);
FertigationDetailsSetup(ref fgvm);

return PartialView(mvm);
return PartialView(fgvm);
}

// private void FertigationStillRequired(ref FertilizerDetailsViewModel fvm)
// {

// }

// private void FertigationDetailsSetup(ref FertigationDetailsViewModel fvm)
// {
// fvm.typOptions = new List<SelectListItem>();
// fvm.typOptions = _sd.GetFertilizerTypesDll().ToList();
private List<SelectListItem> GetFertigationTypes(){

// fvm.denOptions = new List<SelectListItem>();
// fvm.denOptions = _sd.GetDensityUnitsDll().ToList();
Fertigation fg = GetFertigationData();
List<FertigationType> types = fg.FertigationTypes;
List<SelectListItem> list = new List<SelectListItem>();
foreach (var r in types)
{
var li = new SelectListItem()
{ Id = r.Id, Value = r.Name };
list.Add(li);
}
return list;
}
private List<SelectListItem> GetFertigationFertilizers(){

// fvm.methOptions = new List<SelectListItem>();
// fvm.methOptions = _sd.GetFertilizerMethodsDll().ToList();
Fertigation fg = GetFertigationData();
List<Fertilizer> fertilizers = fg.Fertilizers;
List<SelectListItem> list = new List<SelectListItem>();
foreach (var r in fertilizers)
{
var li = new SelectListItem()
{ Id = r.Id, Value = r.Name };
list.Add(li);
}
return list;
}
private List<SelectListItem> GetProductRateUnits(){

// FertilizerDetailSetup_Fertilizer(ref fvm);
Fertigation fg = GetFertigationData();
List<ProductRateUnit> types = fg.ProductRateUnits;
List<SelectListItem> list = new List<SelectListItem>();
foreach (var r in types)
{
var li = new SelectListItem()
{ Id = r.Id, Value = r.Name };
list.Add(li);
}
return list;
}

// fvm.rateOptions = _sd.GetFertilizerUnitsDll(fvm.currUnit).ToList();
private List<SelectListItem> GetInjectionRateUnits(){

// return;
// }
Fertigation fg = GetFertigationData();
List<InjectionRateUnit> rates = fg.InjectionRateUnits;
List<SelectListItem> list = new List<SelectListItem>();
foreach (var r in rates)
{
var li = new SelectListItem()
{ Id = r.Id, Value = r.Name };
list.Add(li);
}
return list;
}

// public IActionResult FertigationDetails(FertigationViewsModel fvm)
// {
private List<SelectListItem> GetDensityUnits(){

// }
Fertigation fg = GetFertigationData();
List<DensityUnit> rates = fg.DensityUnits;
List<SelectListItem> list = new List<SelectListItem>();
foreach (var r in rates)
{
var li = new SelectListItem()
{ Id = r.Id, Value = r.Name };
list.Add(li);
}
return list;
}

private void FertigationDetailsSetup(ref FertigationDetailsViewModel fvm)
{
Fertigation fg = GetFertigationData();

fvm.fertilizers = GetFertigationFertilizers();

fvm.typOptions = GetFertigationTypes();

fvm.productRateOptions = GetProductRateUnits();

fvm.injectionRateOptions = GetInjectionRateUnits();

fvm.denOptions = GetDensityUnits();

// FertilizerDetailSetup_Fertilizer(ref fvm);

return;
}

// private int FertigationInsert(FertigationViewsModel fvm)
// {

// }

public Fertigation GetFertigationData()
{
var filePath = "../../../Agri.Data/SeedData/FertigationData.json";
var jsonData = System.IO.File.ReadAllText(filePath);
return JsonConvert.DeserializeObject<Fertigation>(jsonData);
}

private void MaunureStillRequired(ref ManureDetailsViewModel mvm)
{
//recalc totals for display
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ public class FertigationDetailsViewModel
[Required(ErrorMessage = "Required")]
[Range(1, 9999, ErrorMessage = "Required")]
public string selTypOption { get; set; }
public string selFertOption { get; set; }
public List<SelectListItem> typOptions { get; set; }
public List<SelectListItem> fertilizers { get; set; }
//fertilizer
public List<SelectListItem> FertigationList { get; set; }
[Required(ErrorMessage = "Required")]
[Range(1, 9999, ErrorMessage = "Required")]
public int selFertOption { get; set; }
public List<SelectListItem> fertOptions { get; set; }
//product rate
[Required(ErrorMessage = "Required")]
Expand Down
Loading

0 comments on commit f2c3ecb

Please sign in to comment.