Compare commits

...

5 Commits

Author SHA1 Message Date
Cayo Puigdefabregas fae8882c21 Merge branch 'tau_placeholder-add-ux-bug' into tau 2024-09-26 11:23:44 +02:00
cayop ce80d1f3c2 Merge branch 'tau' into tau_placeholder-add-ux-bug 2024-09-26 09:09:23 +00:00
pedro e3b0d70f04 fix typo: customer_id -> custom_id 2024-09-25 23:10:41 -03:00
pedro 5b84d81590 new_device: UX: clarify add component details 2024-09-25 22:48:03 -03:00
pedro b5b90c50f6 placeholder form: route to unassigned devices
An empty form can be filled, and if you press multiple times save, it
saves multiple devices/placeholders

edit device goes to unassigned devices, so probably is the same for
new device
2024-09-25 22:32:26 -03:00
3 changed files with 16 additions and 14 deletions

View File

@ -23,7 +23,7 @@ DEVICE_TYPES = [
class DeviceForm(forms.Form):
type = forms.ChoiceField(choices = DEVICE_TYPES, required=False)
amount = forms.IntegerField(required=False, initial=1)
customer_id = forms.CharField(required=False)
custom_id = forms.CharField(required=False)
name = forms.CharField(required=False)
value = forms.CharField(required=False)
@ -49,8 +49,8 @@ class BaseDeviceFormSet(forms.BaseFormSet):
row["amount"] = d["amount"]
if d.get("name"):
row[d["name"]] = d.get("value", '')
if d.get("customer_id"):
row['CUSTOMER_ID']= d["customer_id"]
if d.get("custom_id"):
row['CUSTOM_ID']= d["custom_id"]
doc = create_doc(row)
if not commit:

View File

@ -40,15 +40,6 @@
{% endif %}
{{ form.management_form }}
<div class="container" id="formset-container">
<div class="row mb-2">
<div class="col"></div>
<div class="col-2 text-center">
<a href="javascript:void()" onclick="addForm(this);" type="button" class="btn btn-green-admin">
<i class="bi bi-plus"></i>
{% trans 'Add' %}
</a>
</div>
</div>
<div class="row mb-2">
<div class="col">
{% bootstrap_field form.0.type %}
@ -61,7 +52,18 @@
</div>
<div class="row mb-2">
<div class="col">
{% bootstrap_field form.0.customer_id %}
{% bootstrap_field form.0.custom_id %}
</div>
</div>
<div class="row mb-2">
<div class="col-10">
<span class="fw-bold">{% trans 'Component details' %}</span>
</div>
<div class="col-2 text-center">
<a href="javascript:void()" onclick="addForm(this);" type="button" class="btn btn-green-admin text-nowrap">
<i class="bi bi-plus"></i>
{% trans 'Add component' %}
</a>
</div>
</div>
{% for f in form %}

View File

@ -21,7 +21,7 @@ class NewDeviceView(DashboardView, FormView):
template_name = "new_device.html"
title = _("New Device")
breadcrumb = "Device / New Device"
success_url = reverse_lazy('device:add')
success_url = reverse_lazy('dashboard:unassigned_devices')
form_class = DeviceFormSet
def form_valid(self, form):