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

[TASK][NMP-687] Finalize Liquid Fertigation - btn text, datepicker, cleanup #692

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
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
19 changes: 5 additions & 14 deletions app/Server/src/SERVERAPI/Controllers/NutrientsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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());

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -844,7 +837,6 @@ private List<int> 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));
Expand Down Expand Up @@ -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
};

Expand Down
17 changes: 0 additions & 17 deletions app/Server/src/SERVERAPI/ViewModels/FertigationDetailsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
13 changes: 10 additions & 3 deletions app/Server/src/SERVERAPI/Views/Nutrients/FertigationDetails.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,15 @@

<div class="modal-footer">
<button class="btn" type="button" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary" id="submit_button" value="@Model.btnText">@Model.btnText</button>
@if(@Model.btnText == "Add to Field" && ViewContext.ViewData.ModelState.IsValid){
<button type="submit" class="btn btn-primary" id="submit_button" value="@Model.btnText" >Add to Field</button>
} else if (@Model.btnText == "Update Field" && ViewContext.ViewData.ModelState.IsValid){
<button type="submit" class="btn btn-primary" id="submit_button" value="@Model.btnText" >Update Field</button>

}
else {
<button type="submit" class="btn btn-primary" disabled id="submit_button" value="@Model.btnText">Fertigation not yet Valid</button>
}
</div>
@Html.HiddenFor(x => x.fieldName)
@Html.HiddenFor(x => x.title)
Expand Down Expand Up @@ -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) {
Expand Down
Loading