add progression
This commit is contained in:
6
templates/assistantia/_form.html.twig
Normal file
6
templates/assistantia/_form.html.twig
Normal file
@@ -0,0 +1,6 @@
|
||||
{{ form_start(form, {'action': action, 'attr': {'class': 'ajax-form'}}) }}
|
||||
{{ form_widget(form) }}
|
||||
<div class="mt-3 text-end">
|
||||
<button class="btn btn-success">Enregistrer</button>
|
||||
</div>
|
||||
{{ form_end(form) }}
|
||||
19
templates/assistantia/_list.html.twig
Normal file
19
templates/assistantia/_list.html.twig
Normal file
@@ -0,0 +1,19 @@
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr><th>ID</th><th>Nom</th><th>Actions</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for assistant in assistants %}
|
||||
<tr>
|
||||
<td>{{ assistant.id }}</td>
|
||||
<td>{{ assistant.nom }}</td>
|
||||
<td>
|
||||
<button class="btn btn-warning btn-edit" data-url="{{ path('assistantia_edit', {'id': assistant.id}) }}">Modifier</button>
|
||||
<form style="display:inline" method="post" action="{{ path('assistantia_delete', {'id': assistant.id}) }}">
|
||||
<button class="btn btn-danger" onclick="return confirm('Supprimer ?')">Supprimer</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
44
templates/assistantia/crud.html.twig
Normal file
44
templates/assistantia/crud.html.twig
Normal file
@@ -0,0 +1,44 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
{% block title %}CRUD Assistant IA{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>CRUD Assistant IA</h1>
|
||||
<div class="d-flex gap-3">
|
||||
<div style="flex:1;">
|
||||
<h2>Ajouter / Modifier</h2>
|
||||
<button class="btn btn-primary mb-3" id="btnAdd">+ Nouvel assistant IA</button>
|
||||
{% if form is defined %}
|
||||
{% include 'assistantia/_form.html.twig' with {'form': form, 'action': path('assistantia_new')} %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div style="flex:2;">
|
||||
<h2>Liste</h2>
|
||||
{% include 'assistantia/_list.html.twig' %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="crudModal" tabindex="-1">
|
||||
<div class="modal-dialog"><div class="modal-content">
|
||||
<div class="modal-header"><h5 class="modal-title">Formulaire</h5></div>
|
||||
<div class="modal-body" id="modal-body"></div>
|
||||
</div></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('click', async e => {
|
||||
if(e.target.id === 'btnAdd'){
|
||||
const res = await fetch('{{ path("assistantia_new") }}');
|
||||
const html = await res.text();
|
||||
document.getElementById('modal-body').innerHTML = html;
|
||||
new bootstrap.Modal(document.getElementById('crudModal')).show();
|
||||
}
|
||||
if(e.target.classList.contains('btn-edit')){
|
||||
const url = e.target.dataset.url;
|
||||
const res = await fetch(url);
|
||||
const html = await res.text();
|
||||
document.getElementById('modal-body').innerHTML = html;
|
||||
new bootstrap.Modal(document.getElementById('crudModal')).show();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user