Compare commits

...

3 commits

Author SHA1 Message Date
Korina Cordero
9db833f0b5 Add saving of status. Add Active column for list of battery models. #732 2023-02-02 01:49:30 +00:00
Korina Cordero
57b5fcf7ed Add active flag to create battery model form. #732 2023-02-01 10:41:57 +00:00
Korina Cordero
f5c351b179 Add flag_active to battery model. #732 2023-02-01 10:10:51 +00:00
4 changed files with 84 additions and 33 deletions

View file

@ -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);

View file

@ -33,9 +33,17 @@ class BatteryModel
*/ */
protected $batteries; protected $batteries;
// flag if model is active
/**
* @ORM\Column(type="boolean", options={"default": true})
*/
protected $flag_active;
public function __construct() public function __construct()
{ {
$this->batteries = new ArrayCollection(); $this->batteries = new ArrayCollection();
$this->flag_active = true;
} }
public function getID() public function getID()
@ -76,4 +84,15 @@ class BatteryModel
return $str_batteries; return $str_batteries;
} }
public function isActive()
{
return $this->flag_active;
}
public function setActive($flag_active = true)
{
$this->flag_active = $flag_active;
return $this;
}
} }

View file

@ -14,37 +14,51 @@
<!--Begin::Section--> <!--Begin::Section-->
<div class="row"> <div class="row">
<div class="col-xl-6"> <div class="col-xl-6">
<div class="m-portlet m-portlet--mobile"> <div class="m-portlet m-portlet--mobile">
<div class="m-portlet__head"> <div class="m-portlet__head">
<div class="m-portlet__head-caption"> <div class="m-portlet__head-caption">
<div class="m-portlet__head-title"> <div class="m-portlet__head-title">
<span class="m-portlet__head-icon"> <span class="m-portlet__head-icon">
<i class="fa fa-cube"></i> <i class="fa fa-cube"></i>
</span> </span>
<h3 class="m-portlet__head-text"> <h3 class="m-portlet__head-text">
{% if mode == 'update' %} {% if mode == 'update' %}
Edit Model Edit Model
<small>{{ obj.getName() }}</small> <small>{{ obj.getName() }}</small>
{% else %} {% else %}
New Model New Model
{% endif %} {% endif %}
</h3> </h3>
</div> </div>
</div> </div>
</div> </div>
<form id="row-form" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ mode == 'update' ? url('bmodel_update_submit', {'id': obj.getId()}) : url('bmodel_create_submit') }}"> <form id="row-form" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ mode == 'update' ? url('bmodel_update_submit', {'id': obj.getId()}) : url('bmodel_create_submit') }}">
<div class="m-portlet__body"> <div class="m-portlet__body">
<div class="form-group m-form__group row"> <div class="form-group m-form__group row no-border">
<label class="col-lg-3 col-form-label" data-field="name"> <label class="col-lg-3 col-form-label" data-field="name">
Name: Name:
</label> </label>
<div class="col-lg-9"> <div class="col-lg-9">
<input type="text" name="name" class="form-control m-input" value="{{ obj.getName() }}"> <input type="text" name="name" class="form-control m-input" value="{{ obj.getName() }}">
<div class="form-control-feedback hide" data-field="name"></div> <div class="form-control-feedback hide" data-field="name"></div>
<span class="m-form__help">Display name for this model</span> <span class="m-form__help">Display name for this model</span>
</div> </div>
</div> </div>
</div> <div class="form-group m-form__group row">
<div class="col-lg-3">
</div>
<div class="col-lg-9">
<span class="m-switch m-switch--icon block-switch">
<label>
<input type="checkbox" name="flag_active" id="flag_active" value="1"{{ obj.isActive() ? ' checked' }}>
<label class="switch-label">Active</label>
<span></span>
</label>
</span>
<div class="form-control-feedback hide" data-field="flag_active"></div>
</div>
</div>
</div>
<div class="m-portlet__foot m-portlet__foot--fit"> <div class="m-portlet__foot m-portlet__foot--fit">
<div class="m-form__actions m-form__actions--solid m-form__actions--right"> <div class="m-form__actions m-form__actions--solid m-form__actions--right">
<div class="row"> <div class="row">

View file

@ -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,
@ -143,4 +158,4 @@
}); });
}); });
</script> </script>
{% endblock %} {% endblock %}