|
|
@@ -20,32 +20,65 @@ $allTags = tags::getAll(2);
|
|
|
<thead>
|
|
|
<tr>
|
|
|
<th scope="col">#</th>
|
|
|
+ <th scope="col">Nb. Documents</th>
|
|
|
<th scope="col">Tags</th>
|
|
|
<th scope="col"></th>
|
|
|
</tr>
|
|
|
</thead>
|
|
|
<tbody>
|
|
|
-<?php
|
|
|
- foreach ($allTags as $value) {
|
|
|
- echo " <tr>
|
|
|
+ <?php
|
|
|
+ foreach ($allTags as $value) {
|
|
|
+ $nbDocuments = tags::getAllAttachment($value["id"]);
|
|
|
+ $texteDocument = "<a href=\"/documents.html?tag=" . $value["label"] . "\" class=\"btn btn-outline-primary btn-sm\">" . (($nbDocuments > 1) ? $nbDocuments . " documents associés" : "1 document associé") . "</a>";
|
|
|
+
|
|
|
+
|
|
|
+ echo " <tr>
|
|
|
<th scope=\"row\">" . $value["id"] . "</th>
|
|
|
- <td><input type=\"text\" class=\"form-control form-control-sm\" id=\"tags-".$value["id"]."\" value=\"" . $value["label"] . "\"></td>
|
|
|
- <td><button type=\"button\" class=\"btn btn-primary btn-sm\" onclick=\"majTags(".$value["id"].");\">Modifier</button></td>
|
|
|
+ <td>" . $texteDocument . "</td>
|
|
|
+ <td><input type=\"text\" class=\"form-control form-control-sm\" id=\"tags-" . $value["id"] . "\" value=\"" . $value["label"] . "\"></td>
|
|
|
+ <td>";
|
|
|
+ echo "<button type=\"button\" class=\"btn btn-outline-primary btn-sm\" onclick=\"majTags(" . $value["id"] . ");\">Renommer</button> ";
|
|
|
+ echo "<button type=\"button\" class=\"btn btn-outline-primary btn-sm\" data-toggle=\"modal\" data-target=\"#mergeModal\" data-tag=\"" . $value["label"] . "\" data-id=\"" . $value["id"] . "\" onclick=\"buttonMergeTags(" . $value["id"] . ");\">Fusionner</button> ";
|
|
|
+ echo "</td>
|
|
|
</tr>";
|
|
|
- }
|
|
|
-?>
|
|
|
+ }
|
|
|
+ ?>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
|
|
|
+<div class="modal fade" id="mergeModal" tabindex="-1" role="dialog" aria-labelledby="mergeModalLabel" aria-hidden="true">
|
|
|
+ <form id="mergeFormTag" method="post" action="/submit.php">
|
|
|
+ <input type="hidden" name="from" value="tag-merge">
|
|
|
+ <div class="modal-dialog modal-lg" role="document">
|
|
|
+ <div class="modal-content">
|
|
|
+ <input type="hidden" name="idMaster" value="">
|
|
|
+ <div class="modal-header">
|
|
|
+ <h5 class="modal-title" id="mergeModalLabel"></h5>
|
|
|
+ <button type="button" class="close btn" style="font-size: 1.5rem; padding:3px; line-height: 1;" data-dismiss="modal" aria-label="Close">
|
|
|
+ <i class="bi bi-x"></i>
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
+ <div class="modal-body">
|
|
|
+ <div class="input-group">
|
|
|
+ <select id="menuTags" class="form-select" name="idSalve" required></select>
|
|
|
+ <button class="btn btn-outline-primary" type="submit" onclick="return confirm('Le tag sélectionné sera supprimé, vous êtes certain de vouloir continuer ?')">Valider</button>
|
|
|
+ </div>
|
|
|
+ <hr>
|
|
|
+ <p class="alert alert-warning" id="mergeModalDescription"></p>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+</div>
|
|
|
+
|
|
|
<script>
|
|
|
- function majTags(id){
|
|
|
+ function majTags(id) {
|
|
|
$.ajax({
|
|
|
url: '/submit.php',
|
|
|
type: 'POST',
|
|
|
data: {
|
|
|
from: "tag-change",
|
|
|
id: id,
|
|
|
- value: $('#tags-'+id).val()
|
|
|
+ value: $('#tags-' + id).val()
|
|
|
},
|
|
|
success: function(response) {
|
|
|
$("#printToastSuccessTxt").html("Le tag vient d'être mis à jour");
|
|
|
@@ -57,4 +90,34 @@ $allTags = tags::getAll(2);
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ $('#mergeModal').on('show.bs.modal', function(event) {
|
|
|
+ const button = $(event.relatedTarget);
|
|
|
+ const tag = button.data('tag');
|
|
|
+ const id = button.data('id');
|
|
|
+ const modal = $(this);
|
|
|
+ modal.find('input[name="idMaster"]').val(id);
|
|
|
+ modal.find('.modal-title').text(`Vous souhaitez fusionner "${tag}" avec ...`);
|
|
|
+ modal.find('#mergeModalDescription').text(`Une fois fusionné, tous les documents seront rattachés à "${tag} et le tag sélectionné sera supprimé.`);
|
|
|
+ });
|
|
|
+
|
|
|
+ function buttonMergeTags(id) {
|
|
|
+ <?php
|
|
|
+ echo "const donnees = [";
|
|
|
+ foreach ($allTags as $value) {
|
|
|
+ echo "{id: " . $value["id"] . ", label: '" . addslashes($value["label"]) . "'},";
|
|
|
+ }
|
|
|
+ echo "];";
|
|
|
+ ?>
|
|
|
+
|
|
|
+ const options = donnees.filter(item => item.id !== id)
|
|
|
+
|
|
|
+ const $menu = $('#menuTags');
|
|
|
+ $menu.empty();
|
|
|
+ $menu.append('<option value="">Sélectionner le tag avec lequel fusionner</option>');
|
|
|
+ options.forEach(item => {
|
|
|
+ $menu.append(`<option value="${item.id}">${item.label}</option>`);
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
</script>
|