devicehub-django/device/templates/new_device.html

66 lines
2.0 KiB
HTML
Raw Normal View History

2024-07-05 13:32:07 +00:00
{% extends "base.html" %}
{% load i18n %}
{% block content %}
<div class="row">
<div class="col">
<h3>{{ subtitle }}</h3>
</div>
</div>
2024-07-19 15:40:01 +00:00
<script>
function addForm(button) {
var formCount = parseInt(document.getElementById('id_form-TOTAL_FORMS').value);
2024-07-22 11:48:10 +00:00
var formCopy = $(document.querySelector('#id_form-0-name')).parent().parent().parent()[0].cloneNode(true);
// formCopy.style.display = 'block';
2024-07-19 15:40:01 +00:00
formCopy.innerHTML = formCopy.innerHTML.replace(/__prefix__/g, formCount);
document.getElementById('formset-container').appendChild(formCopy);
document.getElementById('id_form-TOTAL_FORMS').value = formCount + 1;
}
</script>
2024-07-22 11:48:10 +00:00
{% load django_bootstrap5 %}
<form role="form" method="post">
{% csrf_token %}
{% if form.errors %}
<div class="alert alert-danger alert-icon alert-icon-border alert-dismissible" role="alert">
<div class="icon"><span class="mdi mdi-close-circle-o"></span></div>
<div class="message">
{% for field, error in form.errors.items %}
{{ error }}<br />
{% endfor %}
<button class="btn-close" type="button" data-dismiss="alert" aria-label="Close"></button>
</div>
</div>
{% 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>
2024-07-19 15:40:01 +00:00
</div>
2024-07-22 11:48:10 +00:00
{% for f in form %}
<div class="row mb-2">
<div class="col">
{% bootstrap_field f.name %}
</div>
<div class="col">
{% bootstrap_field f.value %}
</div>
</div>
{% endfor %}
</div>
<div class="container">
<a class="btn btn-grey" href="{% url 'dashboard:unassigned_devices' %}">{% translate "Cancel" %}</a>
<input class="btn btn-green-admin" type="submit" name="submit" value="{% translate 'Save' %}" />
</div>
2024-07-05 13:32:07 +00:00
</form>
2024-07-22 11:48:10 +00:00
2024-07-05 13:32:07 +00:00
{% endblock %}