Skip to content

Commit

Permalink
Merge pull request #389 from hargata/Hargata/odo.changes
Browse files Browse the repository at this point in the history
added support for meta key for MacOS users
  • Loading branch information
hargata authored Mar 11, 2024
2 parents 91e8526 + f277048 commit 7fb3a80
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Controllers/VehicleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,14 @@ public IActionResult DeletePlanRecordById(int planRecordId)
#endregion
#region "Odometer Records"
[TypeFilter(typeof(CollaboratorFilter))]
[HttpPost]
public IActionResult ForceRecalculateDistanceByVehicleId(int vehicleId)
{
var result = _odometerRecordDataAccess.GetOdometerRecordsByVehicleId(vehicleId);
result = _odometerLogic.AutoConvertOdometerRecord(result);
return Json(result.Any());
}
[TypeFilter(typeof(CollaboratorFilter))]
[HttpGet]
public IActionResult GetOdometerRecordsByVehicleId(int vehicleId)
{
Expand Down
2 changes: 2 additions & 0 deletions Views/Vehicle/_OdometerRecords.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@
<ul class="table-context-menu dropdown-menu" style="display:none;">
<li><a class="context-menu-multiple context-menu-select-all dropdown-item" href="#" onclick="selectAllRows()">@translator.Translate(userLanguage, "Select All")</a></li>
<li><a class="context-menu-multiple context-menu-deselect-all dropdown-item" href="#" onclick="clearSelectedRows()">@translator.Translate(userLanguage, "Deselect All")</a></li>
<li><hr class="context-menu-multiple context-menu-deselect-all dropdown-divider"></li>
<li><a class="context-menu-multiple context-menu-deselect-all dropdown-item" href="#" onclick="recalculateDistance()">@translator.Translate(userLanguage, "Recalculate Distance")</a></li>
<li><hr class="context-menu-multiple dropdown-divider"></li>
<li><a class="dropdown-item" href="#" onclick="duplicateRecords(selectedRow, 'OdometerRecord')">@translator.Translate(userLanguage, "Duplicate")</a></li>
<li><a class="dropdown-item" href="#" onclick="deleteRecords(selectedRow, 'OdometerRecord')">@translator.Translate(userLanguage, "Delete")</a></li>
Expand Down
2 changes: 1 addition & 1 deletion wwwroot/defaults/en_US.json

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions wwwroot/js/odometerrecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,18 @@ function getAndValidateOdometerRecordValues() {
files: uploadedFiles,
extraFields: extraFields.extraFields
}
}

function recalculateDistance() {
//force distance recalculation
//reserved for when data is incoherent with negative distances due to non-chronologica order of odometer records.
var vehicleId = GetVehicleId().vehicleId
$.post(`/Vehicle/ForceRecalculateDistanceByVehicleId?vehicleId=${vehicleId}`, function (data) {
if (data) {
successToast("Odometer Records Updated")
getVehicleOdometerRecords(vehicleId);
} else {
errorToast(genericErrorMessage());
}
});
}
6 changes: 3 additions & 3 deletions wwwroot/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ $(window).on('mousedown', function (e) {
$(window).on('keydown', function (e) {
var userOnInput = $(e.target).is("input") || $(e.target).is("textarea");
if (!userOnInput) {
if (e.ctrlKey && e.which == 65) {
if ((e.ctrlKey || e.metaKey) && e.which == 65) {
e.preventDefault();
e.stopPropagation();
selectAllRows();
Expand All @@ -672,7 +672,7 @@ function rangeMouseDown(e) {
return;
}
var contextMenuAction = $(e.target).is(".table-context-menu > li > .dropdown-item")
if (!e.ctrlKey && !contextMenuAction) {
if (!(e.ctrlKey || e.metaKey) && !contextMenuAction) {
clearSelectedRows();
}
isDragging = true;
Expand Down Expand Up @@ -796,7 +796,7 @@ function getMenuPosition(mouse, direction, scrollDir) {
return position;
}
function handleTableRowClick(e, callBack, rowId) {
if (!event.ctrlKey) {
if (!(event.ctrlKey || event.metaKey)) {
callBack(rowId);
} else if (!$(e).hasClass('table-active')) {
addToSelectedRows($(e).attr('data-rowId'));
Expand Down

0 comments on commit 7fb3a80

Please sign in to comment.