adding rendering template for new action
This commit is contained in:
parent
483f674957
commit
7d341c7d64
|
@ -1,5 +1,5 @@
|
|||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, validators
|
||||
from wtforms import StringField, HiddenField, DateField, TextAreaField, SelectField, validators
|
||||
from flask import g
|
||||
|
||||
from ereuse_devicehub.db import db
|
||||
|
@ -78,10 +78,14 @@ class LotForm(FlaskForm):
|
|||
|
||||
|
||||
class NewActionForm(FlaskForm):
|
||||
name = StringField(u'Name')
|
||||
date = StringField(u'Date')
|
||||
severity = StringField(u'Severity')
|
||||
description = StringField(u'Description')
|
||||
name = StringField(u'Name', [validators.length(max=50)])
|
||||
devices = HiddenField()
|
||||
date = DateField(u'Date')
|
||||
severity = SelectField(u'Severity', choices=[('Info', 'Ok'),
|
||||
('Notice', 'Notice'),
|
||||
('Warning', 'Warning'),
|
||||
('Error', 'Error')])
|
||||
description = TextAreaField(u'Description')
|
||||
|
||||
def save(self):
|
||||
pass
|
||||
|
|
|
@ -5,7 +5,7 @@ from flask_login import login_required, current_user
|
|||
|
||||
from ereuse_devicehub.resources.lot.models import Lot
|
||||
from ereuse_devicehub.resources.device.models import Device
|
||||
from ereuse_devicehub.inventory.forms import LotDeviceForm, LotForm
|
||||
from ereuse_devicehub.inventory.forms import LotDeviceForm, LotForm, NewActionForm
|
||||
|
||||
devices = Blueprint('inventory.devices', __name__, url_prefix='/inventory')
|
||||
|
||||
|
@ -30,6 +30,7 @@ class DeviceListView(View):
|
|||
context = {'devices': devices,
|
||||
'lots': lots,
|
||||
'form_lot_device': LotDeviceForm(),
|
||||
'form_new_action': NewActionForm(),
|
||||
'lot': lot}
|
||||
return flask.render_template(self.template_name, **context)
|
||||
|
||||
|
|
|
@ -9,15 +9,24 @@ function deviceSelect() {
|
|||
if (devices_id == "") {
|
||||
$("#addingLotModal .text-danger").show();
|
||||
$("#addingLotModal .btn-primary").hide();
|
||||
|
||||
$("#removeLotModal .text-danger").show();
|
||||
$("#removeLotModal .btn-primary").hide();
|
||||
|
||||
$("#actionModal .text-danger").show();
|
||||
$("#actionModal .btn-primary").hide();
|
||||
} else {
|
||||
$("#addingLotModal .text-danger").hide();
|
||||
$("#addingLotModal .btn-primary").removeClass('d-none');
|
||||
$("#addingLotModal .btn-primary").show();
|
||||
|
||||
$("#removeLotModal .text-danger").hide();
|
||||
$("#removeLotModal .btn-primary").removeClass('d-none');
|
||||
$("#removeLotModal .btn-primary").show();
|
||||
|
||||
$("#actionModal .text-danger").hide();
|
||||
$("#actionModal .btn-primary").removeClass('d-none');
|
||||
$("#actionModal .btn-primary").show();
|
||||
}
|
||||
$.map($(".devicesList"), function(x) {
|
||||
$(x).val(devices_id);
|
||||
|
|
|
@ -8,15 +8,33 @@
|
|||
</div>
|
||||
|
||||
<form action="{{ url_for('inventory.devices.lot_devices_add') }}" method="post">
|
||||
{{ form_lot_device.csrf_token }}
|
||||
{{ form_new_action.csrf_token }}
|
||||
<div class="modal-body">
|
||||
Please write a name of a lot
|
||||
<input class="devicesList" type="hidden" name="devices" />
|
||||
<p class="text-danger">
|
||||
You need select first some device before to do one action
|
||||
</p>
|
||||
{% for field in form_new_action %}
|
||||
{% if field != form_new_action.csrf_token %}
|
||||
{% if field == form_new_action.devices %}
|
||||
{{ field(class_="devicesList") }}
|
||||
{% else %}
|
||||
<div class="col-12">
|
||||
{{ field.label(class_="form-label") }}
|
||||
{{ field(class_="form-control") }}
|
||||
{% if field.errors %}
|
||||
<p class="text-danger">
|
||||
{% for error in field.errors %}
|
||||
{{ error }}<br/>
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<input type="submit" class="btn btn-primary d-none" value="Create" />
|
||||
|
|
Reference in New Issue