add view, lot and type in formulary new action
This commit is contained in:
parent
7d341c7d64
commit
fd00a3ec34
|
@ -86,6 +86,14 @@ class NewActionForm(FlaskForm):
|
|||
('Warning', 'Warning'),
|
||||
('Error', 'Error')])
|
||||
description = TextAreaField(u'Description')
|
||||
lot = HiddenField()
|
||||
type = HiddenField()
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.instance = None
|
||||
if self.lot.data:
|
||||
self.lot.data = self.lot.data.id
|
||||
|
||||
def save(self):
|
||||
pass
|
||||
|
|
|
@ -30,7 +30,7 @@ class DeviceListView(View):
|
|||
context = {'devices': devices,
|
||||
'lots': lots,
|
||||
'form_lot_device': LotDeviceForm(),
|
||||
'form_new_action': NewActionForm(),
|
||||
'form_new_action': NewActionForm(lot=lot),
|
||||
'lot': lot}
|
||||
return flask.render_template(self.template_name, **context)
|
||||
|
||||
|
@ -96,7 +96,22 @@ class LotDeleteView(View):
|
|||
return flask.redirect(next_url)
|
||||
|
||||
|
||||
class NewActionView(View):
|
||||
methods = ['POST']
|
||||
decorators = [login_required]
|
||||
|
||||
def dispatch_request(self):
|
||||
form = NewActionForm()
|
||||
# import pdb; pdb.set_trace()
|
||||
# from flask import request
|
||||
if form.validate_on_submit():
|
||||
form.save()
|
||||
|
||||
next_url = url_for('inventory.devices.devicelist')
|
||||
return flask.redirect(next_url)
|
||||
|
||||
|
||||
devices.add_url_rule('/action/add/', view_func=NewActionView.as_view('action_add'))
|
||||
devices.add_url_rule('/device/', view_func=DeviceListView.as_view('devicelist'))
|
||||
devices.add_url_rule('/lot/<string:id>/device/', view_func=DeviceListView.as_view('lotdevicelist'))
|
||||
devices.add_url_rule('/lot/devices/add/', view_func=LotDeviceAddView.as_view('lot_devices_add'))
|
||||
|
|
|
@ -35,4 +35,6 @@ function deviceSelect() {
|
|||
|
||||
function newAction(action) {
|
||||
console.log(action);
|
||||
$("#actionModal #type").val(action);
|
||||
$("#activeActionModal").click();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<form action="{{ url_for('inventory.devices.lot_devices_add') }}" method="post">
|
||||
<form action="{{ url_for('inventory.devices.action_add') }}" method="post">
|
||||
{{ form_new_action.csrf_token }}
|
||||
<div class="modal-body">
|
||||
<p class="text-danger">
|
||||
|
@ -17,6 +17,8 @@
|
|||
{% if field != form_new_action.csrf_token %}
|
||||
{% if field == form_new_action.devices %}
|
||||
{{ field(class_="devicesList") }}
|
||||
{% elif field == form_new_action.lot %}
|
||||
{{ field(class_="form-control") }}
|
||||
{% else %}
|
||||
<div class="col-12">
|
||||
{{ field.label(class_="form-label") }}
|
||||
|
|
|
@ -78,12 +78,13 @@
|
|||
<i class="bi bi-plus"></i>
|
||||
New Actions
|
||||
</button>
|
||||
<a href="javascript:void()" class="d-none" id="activeActionModal" data-bs-toggle="modal" data-bs-target="#actionModal" />
|
||||
<ul class="dropdown-menu" aria-labelledby="btnActions"">
|
||||
<li>
|
||||
Status actions
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:newAction('Recycling')" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#actionModal">
|
||||
<a href="javascript:newAction('Recycling')" class="dropdown-item">
|
||||
<i class="bi bi-recycle"></i>
|
||||
Recycling
|
||||
</a>
|
||||
|
|
Reference in New Issue