Merge pull request #327 from hargata/Hargata/generic.editor
added clear overrides
This commit is contained in:
@@ -2264,6 +2264,15 @@ namespace CarCareTracker.Controllers
|
||||
var costIsEdited = genericRecordEditModel.EditRecord.Cost != default;
|
||||
var noteIsEdited = !string.IsNullOrWhiteSpace(genericRecordEditModel.EditRecord.Notes);
|
||||
var tagsIsEdited = genericRecordEditModel.EditRecord.Tags.Any();
|
||||
//handle clear overrides
|
||||
if (tagsIsEdited && genericRecordEditModel.EditRecord.Tags.Contains("---"))
|
||||
{
|
||||
genericRecordEditModel.EditRecord.Tags = new List<string>();
|
||||
}
|
||||
if (noteIsEdited && genericRecordEditModel.EditRecord.Notes == "---")
|
||||
{
|
||||
genericRecordEditModel.EditRecord.Notes = "";
|
||||
}
|
||||
bool result = false;
|
||||
foreach (int recordId in genericRecordEditModel.RecordIds)
|
||||
{
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
<input type="text" id="genericRecordDescription" class="form-control" placeholder="@translator.Translate(userLanguage,"(multiple)")">
|
||||
<label for="genericRecordCost">@translator.Translate(userLanguage, "Cost")</label>
|
||||
<input type="text" inputmode="decimal" id="genericRecordCost" class="form-control" placeholder="@translator.Translate(userLanguage,"(multiple)")">
|
||||
<label for="genericRecordTag">@translator.Translate(userLanguage, "Tags(optional)")</label>
|
||||
<label for="genericRecordTag">@translator.Translate(userLanguage, "Tags(use --- to clear all existing tags)")</label>
|
||||
<select multiple class="form-select" id="genericRecordTag"></select>
|
||||
</div>
|
||||
<div class="col-md-6 col-12">
|
||||
<label for="genericRecordNotes">@translator.Translate(userLanguage, "Notes(optional)")<a class="link-underline link-underline-opacity-0" onclick="showLinks(this)"><i class="bi bi-markdown ms-2"></i></a></label>
|
||||
<label for="genericRecordNotes">@translator.Translate(userLanguage, "Notes(use --- to clear all existing notes)")<a class="link-underline link-underline-opacity-0" onclick="showLinks(this)"><i class="bi bi-markdown ms-2"></i></a></label>
|
||||
<textarea id="genericRecordNotes" class="form-control" rows="5"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<div class="input-group">
|
||||
<input type="number" inputmode="numeric" id="reminderMileage" class="form-control" placeholder="@translator.Translate(userLanguage,"Future Odometer Reading")" value="@(isNew ? "" : Model.Mileage)">
|
||||
<div class="input-group-text">
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="appendMileageToOdometer(500)">+500</button>
|
||||
<button type="button" class="btn btn-sm btn-primary zero-y-padding" onclick="appendMileageToOdometer(500)">+500</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
|
||||
@@ -31,7 +31,12 @@
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-12">
|
||||
<label for="supplyRecordQuantity">@translator.Translate(userLanguage,"Quantity")</label>
|
||||
<input type="text" inputmode="decimal" id="supplyRecordQuantity" class="form-control" placeholder="@translator.Translate(userLanguage,"Quantity")" value="@(isNew ? "1" : Model.Quantity)">
|
||||
<div class="input-group">
|
||||
<input type="text" inputmode="decimal" id="supplyRecordQuantity" class="form-control" placeholder="@translator.Translate(userLanguage,"Quantity")" value="@(isNew ? "1" : Model.Quantity)">
|
||||
<div class="input-group-text">
|
||||
<button type="button" class="btn btn-sm zero-y-padding btn-primary" onclick="replenishSupplies()">+</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-12">
|
||||
<label for="supplyRecordCost">@translator.Translate(userLanguage,"Cost")</label>
|
||||
|
||||
@@ -354,4 +354,8 @@ input[type="file"] {
|
||||
}
|
||||
.reminder-calendar-item{
|
||||
cursor: pointer;
|
||||
}
|
||||
.zero-y-padding{
|
||||
padding-top: 0rem;
|
||||
padding-bottom: 0rem;
|
||||
}
|
||||
@@ -890,4 +890,53 @@ function getAndValidateGenericRecordValues() {
|
||||
tags: genericTags
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function replenishSupplies() {
|
||||
Swal.fire({
|
||||
title: 'Replenish Supplies',
|
||||
html: `
|
||||
<input type="text" id="inputSupplyAddQuantity" class="swal2-input" placeholder="Quantity">
|
||||
<br />
|
||||
<input type="text" id="inputSupplyAddCost" class="swal2-input" placeholder="Cost">
|
||||
<br />
|
||||
<span class='small'>leave blank to use unit cost calculation</span>
|
||||
`,
|
||||
confirmButtonText: 'Replenish',
|
||||
focusConfirm: false,
|
||||
preConfirm: () => {
|
||||
const replquantity = globalParseFloat($("#inputSupplyAddQuantity").val());
|
||||
const replcost = $("#inputSupplyAddCost").val();
|
||||
const parsedReplCost = globalParseFloat(replcost);
|
||||
var quantitybeforeRepl = globalParseFloat($('#supplyRecordQuantity').val());
|
||||
if (isNaN(replquantity) || (replcost.trim() != '' && isNaN(parsedReplCost))) {
|
||||
Swal.showValidationMessage(`Please enter a valid quantity and cost`);
|
||||
} else if (replcost.trim() == '' && (isNaN(quantitybeforeRepl) || quantitybeforeRepl == 0)){
|
||||
Swal.showValidationMessage(`Unable to use unit cost calculation, please provide cost`);
|
||||
}
|
||||
return { replquantity, replcost, parsedReplCost }
|
||||
},
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
var replenishedCost = result.value.replcost;
|
||||
var parsedReplenishedCost = result.value.parsedReplCost;
|
||||
var replenishedQuantity = result.value.replquantity;
|
||||
var currentCost = globalParseFloat($('#supplyRecordCost').val())
|
||||
var currentQuantity = globalParseFloat($('#supplyRecordQuantity').val());
|
||||
var newQuantity = currentQuantity + replenishedQuantity;
|
||||
if (replenishedCost.trim() == '') {
|
||||
|
||||
var unitCost = currentCost / currentQuantity;
|
||||
var newCost = newQuantity * unitCost;
|
||||
//set text fields.
|
||||
$('#supplyRecordCost').val(globalFloatToString(newCost.toFixed(3).toString()));
|
||||
$('#supplyRecordQuantity').val(globalFloatToString(newQuantity.toFixed(3).toString()));
|
||||
} else {
|
||||
var newCost = currentCost + parsedReplenishedCost;
|
||||
//set text fields.
|
||||
$('#supplyRecordCost').val(globalFloatToString(newCost.toFixed(3).toString()));
|
||||
$('#supplyRecordQuantity').val(globalFloatToString(newQuantity.toFixed(3).toString()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user