Docfile commited on
Commit
0e5adf5
·
verified ·
1 Parent(s): 6af242d

Update templates/gere.html

Browse files
Files changed (1) hide show
  1. templates/gere.html +403 -190
templates/gere.html CHANGED
@@ -4,276 +4,489 @@
4
  <meta charset="UTF-8">
5
  <title>Gestion des Données</title>
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
- <script src="https://cdn.tailwindcss.com"></script>
8
- <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
9
  <style>
10
- @keyframes slideIn {
11
- from {
12
- transform: translateY(-20px);
13
- opacity: 0;
14
- }
15
- to {
16
- transform: translateY(0);
17
- opacity: 1;
18
- }
19
  }
20
 
21
- @keyframes fadeIn {
22
- from { opacity: 0; }
23
- to { opacity: 1; }
 
24
  }
25
 
26
- @keyframes scaleIn {
27
- from {
28
- transform: scale(0.95);
29
- opacity: 0;
30
- }
31
- to {
32
- transform: scale(1);
33
- opacity: 1;
34
- }
35
  }
36
 
37
- @keyframes shimmer {
38
- 0% {
39
- background-position: -1000px 0;
40
- }
41
- 100% {
42
- background-position: 1000px 0;
43
- }
44
  }
45
 
46
- .animate-slideIn {
47
- animation: slideIn 0.5s ease-out;
 
 
 
48
  }
49
 
50
- .animate-fadeIn {
51
- animation: fadeIn 0.5s ease-out;
 
52
  }
53
 
54
- .animate-scaleIn {
55
- animation: scaleIn 0.3s ease-out;
 
 
 
 
56
  }
57
 
58
- .card-hover {
59
- transition: all 0.3s ease;
 
60
  }
61
 
62
- .card-hover:hover {
63
- transform: translateY(-5px);
64
- box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
 
 
65
  }
66
 
67
- .shimmer {
68
- background: linear-gradient(90deg, #f6f7f8 0%, #edeef1 50%, #f6f7f8 100%);
69
- background-size: 1000px 100%;
70
- animation: shimmer 2s infinite linear;
71
  }
72
 
73
- .tab-active {
74
- position: relative;
75
  }
76
 
77
- .tab-active::after {
78
- content: '';
79
- position: absolute;
80
- bottom: -2px;
81
- left: 0;
82
- width: 100%;
83
- height: 2px;
84
- background: #3b82f6;
85
- transform: scaleX(0);
86
- transition: transform 0.3s ease;
87
  }
88
 
89
- .tab-active:hover::after,
90
- .tab-active.active::after {
91
- transform: scaleX(1);
 
92
  }
93
 
94
- .btn-primary {
95
- @apply bg-blue-500 hover:bg-blue-600 text-white font-semibold py-2 px-4 rounded-lg transition-all duration-300 transform hover:scale-105 hover:shadow-lg;
 
 
96
  }
97
 
98
- .btn-warning {
99
- @apply bg-yellow-500 hover:bg-yellow-600 text-white font-semibold py-2 px-4 rounded-lg transition-all duration-300 transform hover:scale-105 hover:shadow-lg;
 
 
100
  }
101
 
102
- .btn-danger {
103
- @apply bg-red-500 hover:bg-red-600 text-white font-semibold py-2 px-4 rounded-lg transition-all duration-300 transform hover:scale-105 hover:shadow-lg;
 
 
104
  }
105
 
106
- .form-input {
107
- @apply w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all duration-300;
 
108
  }
109
 
110
  .alert {
111
- @apply p-4 mb-4 rounded-lg shadow-lg animate-slideIn;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
- .alert-success {
115
- @apply bg-green-100 border-l-4 border-green-500 text-green-700;
 
116
  }
117
 
118
- .alert-danger {
119
- @apply bg-red-100 border-l-4 border-red-500 text-red-700;
 
 
 
 
 
 
120
  }
121
  </style>
122
  </head>
123
- <body class="bg-gray-50 min-h-screen">
124
- <div class="container mx-auto px-4 py-8 animate-fadeIn">
125
- <h1 class="text-4xl font-bold text-gray-800 mb-8 animate-slideIn">
126
- Gestion des Données
127
- </h1>
128
 
129
  {% with messages = get_flashed_messages(with_categories=true) %}
130
  {% if messages %}
131
  {% for category, message in messages %}
132
- <div class="alert alert-{{ category }} animate-scaleIn">
133
  {{ message }}
 
 
 
134
  </div>
135
  {% endfor %}
136
  {% endif %}
137
  {% endwith %}
138
 
139
- <!-- Tabs -->
140
- <div class="mb-6 border-b border-gray-200">
141
- <nav class="flex space-x-8" aria-label="Tabs">
142
- <button class="tab-active px-4 py-2 text-gray-600 hover:text-blue-600 active">
143
- <i class="fas fa-book mr-2"></i>Matières
144
- </button>
145
- <button class="tab-active px-4 py-2 text-gray-600 hover:text-blue-600">
146
- <i class="fas fa-list mr-2"></i>Sous-Catégories
147
- </button>
148
- <button class="tab-active px-4 py-2 text-gray-600 hover:text-blue-600">
149
- <i class="fas fa-file-alt mr-2"></i>Textes
150
- </button>
151
- <button class="tab-active px-4 py-2 text-gray-600 hover:text-blue-600">
152
- <i class="fas fa-plus-circle mr-2"></i>Ajouter
153
- </button>
154
- </nav>
155
- </div>
 
 
 
 
 
156
 
157
- <!-- Content -->
158
- <div class="grid gap-6">
159
- <!-- Matières Section -->
160
- <div class="animate-scaleIn">
161
- {% for matiere in matieres %}
162
- <div class="card-hover bg-white rounded-lg shadow-md p-6 mb-4">
163
- <div class="flex justify-between items-center">
164
- <h3 class="text-lg font-semibold text-gray-800">{{ matiere.nom }}</h3>
165
- <div class="flex space-x-2">
166
- <button class="btn-warning edit-button">
167
- <i class="fas fa-edit mr-2"></i>Modifier
168
- </button>
169
- <form method="post" class="inline">
170
- <input type="hidden" name="action" value="delete_matiere_{{ matiere.id }}">
171
- <button type="submit" class="btn-danger">
172
- <i class="fas fa-trash mr-2"></i>Supprimer
173
- </button>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  </div>
176
- </div>
177
-
178
- <!-- Form édition -->
179
- <form method="post" class="hidden editable mt-4">
180
- <input type="hidden" name="action" value="edit_matiere_{{ matiere.id }}">
181
- <div class="flex space-x-4">
182
- <input type="text" name="edit_nom_matiere_{{ matiere.id }}"
183
- value="{{ matiere.nom }}"
184
- class="form-input flex-grow"
185
- placeholder="Nom de la matière">
186
- <button type="submit" class="btn-primary">
187
- <i class="fas fa-check mr-2"></i>Sauvegarder
188
- </button>
189
- <button type="button" class="btn-danger cancel-edit">
190
- <i class="fas fa-times mr-2"></i>Annuler
191
- </button>
 
 
 
 
 
 
 
 
 
 
192
  </div>
 
 
 
193
  </form>
194
  </div>
195
- {% endfor %}
196
- </div>
197
 
198
- <!-- Add Form -->
199
- <div class="bg-white rounded-lg shadow-lg p-6 animate-scaleIn">
200
- <h2 class="text-xl font-bold text-gray-800 mb-4">
201
- <i class="fas fa-plus-circle mr-2"></i>Ajouter une nouvelle matière
202
- </h2>
203
- <form method="post" class="space-y-4">
204
- <input type="hidden" name="action" value="add_matiere">
205
- <div>
206
- <label class="block text-sm font-medium text-gray-700 mb-2">
207
- Nom de la matière
208
- </label>
209
- <input type="text" name="nom_matiere"
210
- class="form-input"
211
- placeholder="Entrez le nom de la matière"
212
- required>
213
  </div>
214
- <button type="submit" class="btn-primary w-full">
215
- <i class="fas fa-plus mr-2"></i>Ajouter la matière
216
- </button>
217
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  </div>
219
  </div>
220
  </div>
221
 
222
- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
 
 
 
223
  <script>
224
  $(document).ready(function() {
225
- // Tab switching with animations
226
- $('.tab-active').click(function() {
227
- $('.tab-active').removeClass('active');
228
- $(this).addClass('active');
229
-
230
- // Add slide animation to content
231
- $('.grid > div').addClass('animate-slideIn');
232
- setTimeout(() => {
233
- $('.grid > div').removeClass('animate-slideIn');
234
- }, 500);
235
- });
236
-
237
- // Edit button functionality with animations
238
  $(document).on('click', '.edit-button', function(e) {
239
  e.preventDefault();
240
- const card = $(this).closest('.card-hover');
241
- const form = card.find('.editable');
242
-
243
- form.slideDown(300).css('display', 'block');
244
- card.find('h3').fadeOut(300);
245
- $(this).fadeOut(300);
246
  });
247
 
248
- // Cancel edit with animations
249
  $(document).on('click', '.cancel-edit', function(e) {
250
  e.preventDefault();
251
- const card = $(this).closest('.card-hover');
252
- const form = card.find('.editable');
253
-
254
- form.slideUp(300);
255
- card.find('h3').fadeIn(300);
256
- card.find('.edit-button').fadeIn(300);
257
  });
258
 
259
- // Smooth deletion animation
260
- $('form[method="post"]').submit(function(e) {
261
- if ($(this).find('.btn-danger').length) {
 
 
 
262
  if (!confirm('Êtes-vous sûr de vouloir supprimer cet élément ?')) {
263
  e.preventDefault();
264
- } else {
265
- $(this).closest('.card-hover').addClass('animate-slideIn').fadeOut(500);
266
  }
267
  }
268
  });
269
-
270
- // Add loading animation
271
- $('.btn-primary').click(function() {
272
- $(this).addClass('shimmer');
273
- setTimeout(() => {
274
- $(this).removeClass('shimmer');
275
- }, 1000);
276
- });
277
  });
278
  </script>
279
  </body>
 
4
  <meta charset="UTF-8">
5
  <title>Gestion des Données</title>
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
8
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" rel="stylesheet">
9
  <style>
10
+ body {
11
+ background-color: #f8f9fa;
12
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
13
+ }
14
+
15
+ .container {
16
+ max-width: 1200px;
17
+ margin: 0 auto;
18
+ padding: 2rem;
19
  }
20
 
21
+ .page-title {
22
+ color: #2c3e50;
23
+ margin-bottom: 2rem;
24
+ font-weight: 600;
25
  }
26
 
27
+ .card {
28
+ margin-bottom: 20px;
29
+ border: none;
30
+ box-shadow: 0 2px 4px rgba(0,0,0,0.1);
31
+ transition: transform 0.2s ease-in-out;
 
 
 
 
32
  }
33
 
34
+ .card:hover {
35
+ transform: translateY(-2px);
 
 
 
 
 
36
  }
37
 
38
+ .card-header {
39
+ background-color: #f8f9fa;
40
+ border-bottom: 2px solid #e9ecef;
41
+ font-weight: 600;
42
+ padding: 1rem 1.25rem;
43
  }
44
 
45
+ .nav-tabs {
46
+ border-bottom: 2px solid #dee2e6;
47
+ margin-bottom: 1rem;
48
  }
49
 
50
+ .nav-tabs .nav-link {
51
+ border: none;
52
+ color: #6c757d;
53
+ font-weight: 500;
54
+ padding: 1rem 1.5rem;
55
+ transition: all 0.2s ease-in-out;
56
  }
57
 
58
+ .nav-tabs .nav-link:hover {
59
+ border: none;
60
+ color: #007bff;
61
  }
62
 
63
+ .nav-tabs .nav-link.active {
64
+ background-color: transparent;
65
+ border: none;
66
+ border-bottom: 2px solid #007bff;
67
+ color: #007bff;
68
  }
69
 
70
+ .list-group-item {
71
+ border: none;
72
+ border-bottom: 1px solid #e9ecef;
73
+ padding: 1rem;
74
  }
75
 
76
+ .list-group-item:last-child {
77
+ border-bottom: none;
78
  }
79
 
80
+ .btn {
81
+ border-radius: 4px;
82
+ padding: 0.5rem 1rem;
83
+ transition: all 0.2s ease-in-out;
 
 
 
 
 
 
84
  }
85
 
86
+ .btn-warning {
87
+ background-color: #ffc107;
88
+ border-color: #ffc107;
89
+ color: #212529;
90
  }
91
 
92
+ .btn-danger {
93
+ background-color: #dc3545;
94
+ border-color: #dc3545;
95
+ color: #fff;
96
  }
97
 
98
+ .btn-success {
99
+ background-color: #28a745;
100
+ border-color: #28a745;
101
+ color: #fff;
102
  }
103
 
104
+ .form-control {
105
+ border-radius: 4px;
106
+ border: 1px solid #ced4da;
107
+ padding: 0.5rem;
108
  }
109
 
110
+ .form-control:focus {
111
+ border-color: #80bdff;
112
+ box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
113
  }
114
 
115
  .alert {
116
+ border-radius: 4px;
117
+ margin-bottom: 1rem;
118
+ animation: fadeInOut 5s ease-in-out;
119
+ }
120
+
121
+ @keyframes fadeInOut {
122
+ 0% { opacity: 0; }
123
+ 10% { opacity: 1; }
124
+ 90% { opacity: 1; }
125
+ 100% { opacity: 0; }
126
+ }
127
+
128
+ .editable {
129
+ display: none;
130
+ background-color: #f8f9fa;
131
+ padding: 1rem;
132
+ border-radius: 4px;
133
+ margin-top: 0.5rem;
134
+ }
135
+
136
+ .display-mode {
137
+ line-height: 1.5;
138
  }
139
 
140
+ .action-buttons {
141
+ display: flex;
142
+ gap: 0.5rem;
143
  }
144
 
145
+ .text-muted {
146
+ font-size: 0.875rem;
147
+ }
148
+
149
+ .btn-icon {
150
+ display: inline-flex;
151
+ align-items: center;
152
+ gap: 0.5rem;
153
  }
154
  </style>
155
  </head>
156
+ <body>
157
+ <div class="container mt-4">
158
+ <h1 class="page-title">Gestion des Données</h1>
 
 
159
 
160
  {% with messages = get_flashed_messages(with_categories=true) %}
161
  {% if messages %}
162
  {% for category, message in messages %}
163
+ <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
164
  {{ message }}
165
+ <button type="button" class="close" data-dismiss="alert" aria-label="Fermer">
166
+ <span aria-hidden="true">&times;</span>
167
+ </button>
168
  </div>
169
  {% endfor %}
170
  {% endif %}
171
  {% endwith %}
172
 
173
+ <ul class="nav nav-tabs" id="gestionTab" role="tablist">
174
+ <li class="nav-item">
175
+ <a class="nav-link active" id="matieres-tab" data-toggle="tab" href="#matieres" role="tab">
176
+ <i class="fas fa-book"></i> Matières
177
+ </a>
178
+ </li>
179
+ <li class="nav-item">
180
+ <a class="nav-link" id="sous-categories-tab" data-toggle="tab" href="#sous-categories" role="tab">
181
+ <i class="fas fa-list"></i> Sous-Catégories
182
+ </a>
183
+ </li>
184
+ <li class="nav-item">
185
+ <a class="nav-link" id="textes-tab" data-toggle="tab" href="#textes" role="tab">
186
+ <i class="fas fa-file-alt"></i> Textes
187
+ </a>
188
+ </li>
189
+ <li class="nav-item">
190
+ <a class="nav-link" id="ajouter-tab" data-toggle="tab" href="#ajouter" role="tab">
191
+ <i class="fas fa-plus-circle"></i> Ajouter
192
+ </a>
193
+ </li>
194
+ </ul>
195
 
196
+ <div class="tab-content" id="gestionTabContent">
197
+ <!-- Onglet Matières -->
198
+ <div class="tab-pane fade show active" id="matieres" role="tabpanel">
199
+ <div class="card">
200
+ <div class="card-header">
201
+ <i class="fas fa-book mr-2"></i>Liste des Matières
202
+ </div>
203
+ <ul class="list-group list-group-flush">
204
+ {% for matiere in matieres %}
205
+ <li class="list-group-item">
206
+ <div class="d-flex justify-content-between align-items-center">
207
+ <span class="display-mode">{{ matiere.nom }}</span>
208
+ <div class="action-buttons">
209
+ <button class="btn btn-warning btn-sm btn-icon edit-button">
210
+ <i class="fas fa-edit"></i> Modifier
211
+ </button>
212
+ <form method="post" class="d-inline">
213
+ <input type="hidden" name="action" value="delete_matiere_{{ matiere.id }}">
214
+ <button type="submit" class="btn btn-danger btn-sm btn-icon" onclick="return confirm('Êtes-vous sûr de vouloir supprimer cette matière ?');">
215
+ <i class="fas fa-trash"></i> Supprimer
216
+ </button>
217
+ </form>
218
+ </div>
219
+ </div>
220
+ <form method="post" class="editable">
221
+ <input type="hidden" name="action" value="edit_matiere_{{ matiere.id }}">
222
+ <div class="input-group">
223
+ <input type="text" name="edit_nom_matiere_{{ matiere.id }}" value="{{ matiere.nom }}" class="form-control">
224
+ <div class="input-group-append">
225
+ <button type="submit" class="btn btn-success btn-icon">
226
+ <i class="fas fa-check"></i> Enregistrer
227
+ </button>
228
+ <button type="button" class="btn btn-secondary btn-icon cancel-edit">
229
+ <i class="fas fa-times"></i> Annuler
230
+ </button>
231
+ </div>
232
+ </div>
233
  </form>
234
+ </li>
235
+ {% else %}
236
+ <li class="list-group-item text-center text-muted">Aucune matière trouvée.</li>
237
+ {% endfor %}
238
+ </ul>
239
+ </div>
240
+ </div>
241
+
242
+ <!-- Onglet Sous-Catégories -->
243
+ <div class="tab-pane fade" id="sous-categories" role="tabpanel">
244
+ <div class="card">
245
+ <div class="card-header">
246
+ <i class="fas fa-list mr-2"></i>Liste des Sous-Catégories
247
+ </div>
248
+ <ul class="list-group list-group-flush">
249
+ {% for sous_categorie in sous_categories %}
250
+ <li class="list-group-item">
251
+ <div class="d-flex justify-content-between align-items-center">
252
+ <span class="display-mode">
253
+ {{ sous_categorie.nom }}
254
+ <small class="text-muted">
255
+ <i class="fas fa-book mr-1"></i>{{ sous_categorie.matiere.nom }}
256
+ </small>
257
+ </span>
258
+ <div class="action-buttons">
259
+ <button class="btn btn-warning btn-sm btn-icon edit-button">
260
+ <i class="fas fa-edit"></i> Modifier
261
+ </button>
262
+ <form method="post" class="d-inline">
263
+ <input type="hidden" name="action" value="delete_sous_categorie_{{ sous_categorie.id }}">
264
+ <button type="submit" class="btn btn-danger btn-sm btn-icon" onclick="return confirm('Êtes-vous sûr de vouloir supprimer cette sous-catégorie ?');">
265
+ <i class="fas fa-trash"></i> Supprimer
266
+ </button>
267
+ </form>
268
+ </div>
269
+ </div>
270
+ <form method="post" class="editable">
271
+ <input type="hidden" name="action" value="edit_sous_categorie_{{ sous_categorie.id }}">
272
+ <div class="form-row">
273
+ <div class="col-md-6 mb-2">
274
+ <input type="text" name="edit_nom_sous_categorie_{{ sous_categorie.id }}" value="{{ sous_categorie.nom }}" class="form-control" placeholder="Nom">
275
+ </div>
276
+ <div class="col-md-4 mb-2">
277
+ <select name="edit_matiere_id_{{ sous_categorie.id }}" class="form-control">
278
+ {% for matiere in matieres %}
279
+ <option value="{{ matiere.id }}" {% if matiere.id == sous_categorie.matiere_id %}selected{% endif %}>
280
+ {{ matiere.nom }}
281
+ </option>
282
+ {% endfor %}
283
+ </select>
284
+ </div>
285
+ <div class="col-md-2">
286
+ <div class="btn-group">
287
+ <button type="submit" class="btn btn-success btn-icon">
288
+ <i class="fas fa-check"></i> Enregistrer
289
+ </button>
290
+ <button type="button" class="btn btn-secondary btn-icon cancel-edit">
291
+ <i class="fas fa-times"></i> Annuler
292
+ </button>
293
+ </div>
294
+ </div>
295
+ </div>
296
+ </form>
297
+ </li>
298
+ {% else %}
299
+ <li class="list-group-item text-center text-muted">Aucune sous-catégorie trouvée.</li>
300
+ {% endfor %}
301
+ </ul>
302
+ </div>
303
+ </div>
304
+
305
+ <!-- Onglet Textes -->
306
+ <div class="tab-pane fade" id="textes" role="tabpanel">
307
+ <div class="card">
308
+ <div class="card-header">
309
+ <i class="fas fa-file-alt mr-2"></i>Liste des Textes
310
+ </div>
311
+ <ul class="list-group list-group-flush">
312
+ {% for texte in textes %}
313
+ <li class="list-group-item">
314
+ <div class="d-flex justify-content-between align-items-center">
315
+ <span class="display-mode">
316
+ <strong>{{ texte.titre }}</strong>
317
+ <br>
318
+ <small class="text-muted">
319
+ <i class="fas fa-list mr-1"></i>{{ texte.sous_categorie.nom }}
320
+ <i class="fas fa-book ml-2 mr-1"></i>{{ texte.sous_categorie.matiere.nom }}
321
+ </small>
322
+ </span>
323
+ <div class="action-buttons">
324
+ <button class="btn btn-warning btn-sm btn-icon edit-button">
325
+ <i class="fas fa-edit"></i> Modifier
326
+ </button>
327
+ <form method="post" class="d-inline">
328
+ <input type="hidden" name="action" value="delete_texte_{{ texte.id }}">
329
+ <button type="submit" class="btn btn-danger btn-sm btn-icon" onclick="return confirm('Êtes-vous sûr de vouloir supprimer ce texte ?');">
330
+ <i class="fas fa-trash"></i> Supprimer
331
+ </button>
332
+ </form>
333
+ </div>
334
+ </div>
335
+ <form method="post" class="editable">
336
+ <input type="hidden" name="action" value="edit_texte_{{ texte.id }}">
337
+ <div class="form-group">
338
+ <input type="text" name="edit_titre_texte_{{ texte.id }}" value="{{ texte.titre }}" class="form-control" placeholder="Titre">
339
+ </div>
340
+ <div class="form-group">
341
+ <textarea name="edit_contenu_texte_{{ texte.id }}" class="form-control" rows="3" placeholder="Contenu">{{ texte.contenu }}</textarea>
342
+ </div>
343
+ <div class="form-row">
344
+ <div class="col-md-8 mb-2">
345
+ <select name="edit_sous_categorie_id_{{ texte.id }}" class="form-control">
346
+ {% for sous_categorie in sous_categories %}
347
+ <option value="{{ sous_categorie.id }}" {% if sous_categorie.id == texte.sous_categorie_id %}selected{% endif %}>
348
+ {{ sous_categorie.nom }} ({{ sous_categorie.matiere.nom }})
349
+ </option>
350
+ {% endfor %}
351
+ </select>
352
+ </div>
353
+ <div class="col-md-4">
354
+ <div class="btn-group">
355
+ <button type="submit" class="btn btn-success btn-icon">
356
+ <i class="fas fa-check"></i> Enregistrer
357
+ </button>
358
+ <button type="button" class="btn btn-secondary btn-icon cancel-edit">
359
+ <i class="fas fa-times"></i> Annuler
360
+ </button>
361
+ </div>
362
+ </div>
363
+ </div>
364
+ </form>
365
+ </li>
366
+ {% else %}
367
+ <li class="list-group-item text-center text-muted">Aucun texte trouvé.</li>
368
+ {% endfor %}
369
+ </ul>
370
+ </div>
371
+ </div>
372
+
373
+ <!-- Onglet Ajouter -->
374
+ <div class="tab-pane fade" id="ajouter" role="tabpanel">
375
+ <!-- Formulaire d'ajout d'une matière -->
376
+ <div class="card mt-3">
377
+ <div class="card-header">
378
+ <i class="fas fa-plus-circle mr-2"></i>Ajouter une Matière
379
+ </div>
380
+ <div class="card-body">
381
+ <form method="post">
382
+ <input type="hidden" name="action" value="add_matiere">
383
+ <div class="form-group">
384
+ <label for="nom_matiere">Nom de la Matière</label>
385
+ <input type="text" id="nom_matiere" name="nom_matiere" class="form-control" required>
386
  </div>
387
+ <button type="submit" class="btn btn-primary btn-icon">
388
+ <i class="fas fa-plus"></i> Ajouter
389
+ </button>
390
+ </form>
391
+ </div>
392
+ </div>
393
+
394
+ <!-- Formulaire d'ajout d'une sous-catégorie -->
395
+ <div class="card mt-3">
396
+ <div class="card-header">
397
+ <i class="fas fa-plus-circle mr-2"></i>Ajouter une Sous-Catégorie
398
+ </div>
399
+ <div class="card-body">
400
+ <form method="post">
401
+ <input type="hidden" name="action" value="add_sous_categorie">
402
+ <div class="form-group">
403
+ <label for="nom_sous_categorie">Nom de la Sous-Catégorie</label>
404
+ <input type="text" id="nom_sous_categorie" name="nom_sous_categorie" class="form-control" required>
405
+ </div>
406
+ <div class="form-group">
407
+ <label for="matiere_id">Matière associée</label>
408
+ <select id="matiere_id" name="matiere_id" class="form-control" required>
409
+ {% for matiere in matieres %}
410
+ <option value="{{ matiere.id }}">{{ matiere.nom }}</option>
411
+ {% endfor %}
412
+ </select>
413
  </div>
414
+ <button type="submit" class="btn btn-primary btn-icon">
415
+ <i class="fas fa-plus"></i> Ajouter
416
+ </button>
417
  </form>
418
  </div>
419
+ </div>
 
420
 
421
+ <!-- Formulaire d'ajout d'un texte -->
422
+ <div class="card mt-3">
423
+ <div class="card-header">
424
+ <i class="fas fa-plus-circle mr-2"></i>Ajouter un Texte
 
 
 
 
 
 
 
 
 
 
 
425
  </div>
426
+ <div class="card-body">
427
+ <form method="post">
428
+ <input type="hidden" name="action" value="add_texte">
429
+ <div class="form-group">
430
+ <label for="titre_texte">Titre du Texte</label>
431
+ <input type="text" id="titre_texte" name="titre_texte" class="form-control" required>
432
+ </div>
433
+ <div class="form-group">
434
+ <label for="contenu_texte">Contenu du Texte</label>
435
+ <textarea id="contenu_texte" name="contenu_texte" class="form-control" rows="5" required></textarea>
436
+ </div>
437
+ <div class="form-group">
438
+ <label for="sous_categorie_id">Sous-Catégorie</label>
439
+ <select id="sous_categorie_id" name="sous_categorie_id" class="form-control" required>
440
+ {% for sous_categorie in sous_categories %}
441
+ <option value="{{ sous_categorie.id }}">{{ sous_categorie.nom }} ({{ sous_categorie.matiere.nom }})</option>
442
+ {% endfor %}
443
+ </select>
444
+ </div>
445
+ <button type="submit" class="btn btn-primary btn-icon">
446
+ <i class="fas fa-plus"></i> Ajouter
447
+ </button>
448
+ </form>
449
+ </div>
450
+ </div>
451
  </div>
452
  </div>
453
  </div>
454
 
455
+ <!-- Scripts -->
456
+ <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
457
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
458
+ <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
459
  <script>
460
  $(document).ready(function() {
461
+ // Gestion des boutons Modifier
 
 
 
 
 
 
 
 
 
 
 
 
462
  $(document).on('click', '.edit-button', function(e) {
463
  e.preventDefault();
464
+ const listItem = $(this).closest('li');
465
+ listItem.find('.editable').slideDown();
466
+ listItem.find('.display-mode').hide();
467
+ $(this).hide();
 
 
468
  });
469
 
470
+ // Gestion des boutons Annuler
471
  $(document).on('click', '.cancel-edit', function(e) {
472
  e.preventDefault();
473
+ const listItem = $(this).closest('li');
474
+ listItem.find('.editable').slideUp();
475
+ listItem.find('.display-mode').show();
476
+ listItem.find('.edit-button').show();
 
 
477
  });
478
 
479
+ // Animation pour les alertes
480
+ $('.alert').delay(4000).fadeOut(500);
481
+
482
+ // Confirmation personnalisée pour la suppression
483
+ $('form[method="post"]').on('submit', function(e) {
484
+ if ($(this).find('button[type="submit"]').hasClass('btn-danger')) {
485
  if (!confirm('Êtes-vous sûr de vouloir supprimer cet élément ?')) {
486
  e.preventDefault();
 
 
487
  }
488
  }
489
  });
 
 
 
 
 
 
 
 
490
  });
491
  </script>
492
  </body>