Display inactive batteries on edit vehicle form, exclude inactive batteries on battery recommendations API endpoint #779

This commit is contained in:
Ramon Gutierrez 2023-12-18 17:17:40 +08:00
parent a7c7b03d06
commit d8bd2803e0
2 changed files with 18 additions and 2 deletions

View file

@ -254,7 +254,7 @@ class VehicleController extends ApiController
// batteries
$batt_list = [];
$batts = $vehicle->getBatteries();
$batts = $vehicle->getActiveBatteries();
foreach ($batts as $batt) {
// TODO: Add warranty_tnv to battery information
$batt_list[] = [

View file

@ -233,13 +233,14 @@ $(function() {
var batteryIds = [];
var battMfgModelSize = []
{% for batt in obj.getActiveBatteries %}
{% for batt in obj.getBatteries %}
trow = {
id: "{{ batt.getID }}",
manufacturer: "{{ batt.getManufacturer.getName|default('') }} ",
model: "{{ batt.getModel.getName|default('') }}",
size: "{{ batt.getSize.getName|default('') }}",
sell_price: "{{ batt.getSellingPrice }}",
flag_active: {{ batt.isActive ? "true" : "false" }},
};
battRows.push(trow);
@ -360,6 +361,21 @@ $(function() {
title: 'Model',
width: 150
},
{
field: 'flag_active',
title: 'Active',
template: function (row, index, datatable) {
var tag = '';
if (row.flag_active === true) {
tag = '<span class="m-badge m-badge--success m-badge--wide">Yes</span>';
} else {
tag = '<span class="m-badge m-badge--danger m-badge--wide">No</span>';
}
return tag;
},
},
{
field: 'sell_price',
title: 'Price'