Add saving of status. Add Active column for list of battery models. #732
This commit is contained in:
parent
57b5fcf7ed
commit
9db833f0b5
3 changed files with 22 additions and 4 deletions
|
|
@ -88,6 +88,7 @@ class BatteryModelController extends Controller
|
||||||
// add row data
|
// add row data
|
||||||
$row['id'] = $orow->getID();
|
$row['id'] = $orow->getID();
|
||||||
$row['name'] = $orow->getName();
|
$row['name'] = $orow->getName();
|
||||||
|
$row['flag_active'] = $orow->isActive();
|
||||||
|
|
||||||
// add row metadata
|
// add row metadata
|
||||||
$row['meta'] = [
|
$row['meta'] = [
|
||||||
|
|
@ -134,7 +135,8 @@ class BatteryModelController extends Controller
|
||||||
$row = new BatteryModel();
|
$row = new BatteryModel();
|
||||||
|
|
||||||
// set and save values
|
// set and save values
|
||||||
$row->setName($req->request->get('name'));
|
$row->setName($req->request->get('name'))
|
||||||
|
->setActive($req->request->get('flag_active', false));
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
$errors = $validator->validate($row);
|
$errors = $validator->validate($row);
|
||||||
|
|
@ -202,7 +204,8 @@ class BatteryModelController extends Controller
|
||||||
throw $this->createNotFoundException('The item does not exist');
|
throw $this->createNotFoundException('The item does not exist');
|
||||||
|
|
||||||
// set and save values
|
// set and save values
|
||||||
$row->setName($req->request->get('name'));
|
$row->setName($req->request->get('name'))
|
||||||
|
->setActive($req->request->get('flag_active', false));
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
$errors = $validator->validate($row);
|
$errors = $validator->validate($row);
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,6 @@ class BatteryModel
|
||||||
public function setActive($flag_active = true)
|
public function setActive($flag_active = true)
|
||||||
{
|
{
|
||||||
$this->flag_active = $flag_active;
|
$this->flag_active = $flag_active;
|
||||||
return this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,21 @@
|
||||||
field: 'name',
|
field: 'name',
|
||||||
title: 'Name'
|
title: 'Name'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
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: 'Actions',
|
field: 'Actions',
|
||||||
width: 110,
|
width: 110,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue