Design gestion des tags

This commit is contained in:
Fred Tempez 2024-09-04 19:26:29 +02:00
parent 1aca92b1c7
commit f9faaa651e
2 changed files with 61 additions and 20 deletions

View File

@ -1147,12 +1147,12 @@ class user extends common
// Exclure les espaces des cours
/*
foreach (array_keys($this->getData(['course'])) as $courseId) {
self::$sharePath = array_filter(self::$sharePath, function ($key) use ($courseId) {
return strpos($key, $courseId) === false;
});
}
*/
foreach (array_keys($this->getData(['course'])) as $courseId) {
self::$sharePath = array_filter(self::$sharePath, function ($key) use ($courseId) {
return strpos($key, $courseId) === false;
});
}
*/
self::$sharePath = array_flip(self::$sharePath);
self::$sharePath = array_merge(['none' => 'Aucun Accès'], self::$sharePath);
@ -1664,6 +1664,33 @@ class user extends common
]);
}
// Inscription des utilisateurs cochés
if (
isset($_POST['usersTagSubmit'])
) {
$notification = helper::translate('Modification de %s étiquette');
$success = true;
$count = 0;
$newTags = $this->getInput('usersTagLabel', null, true);
foreach ($_POST as $keyPost => $valuePost) {
// Exclure les variables post qui ne sont pas des userId et ne traiter que les non inscrits
if (
$this->getData(['user', $keyPost]) !== null
) {
$this->setData(['user', $keyPost, 'tags', $newTags]);
$count += 1;
}
}
// Valeurs en sortie
$this->addOutput([
'redirect' => helper::baseUrl() . 'user/tag',
'notification' => sprintf($count > 1 ? $notification . 's' : $notification, $count),
'state' => $success
]);
}
// Liste des groupes et des profils
$usersGroups = $this->getData(['profil']);

View File

@ -7,20 +7,22 @@
'value' => template::ico('left')
]); ?>
</div>
<div class="col1 offset7">
<?php echo template::button('usersTagSelectAll', [
'value' => template::ico('square-check'),
'help' => 'Tout sélectionner'
]); ?>
</div>
<div class="col1">
<?php echo template::button('usersTagSelectNone', [
'value' => template::ico('square-check-empty'),
'help' => 'Tout désélectionner'
]); ?>
</div>
<div class="col2">
<?php echo template::submit('usersTagSubmit'); ?>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>Étiquette de remplacement</h4>
<div class="row">
<div class="col8">
<?php echo template::text('usersTagLabel', [
'placeholder' => 'Les étiquettes saisis remplaceront celles existantes. Les étiquettes sont séparées par des espaces'
]); ?>
</div>
<div class="col2 offset2 verticalAlignBottom">
<?php echo template::submit('usersTagSubmit'); ?>
</div>
</div>
</div>
</div>
</div>
<div class="row" id="Bfrtip">
@ -42,6 +44,18 @@
'selected' => isset($_POST['usersFilterLastName']) ? $_POST['usersFilterLastName'] : 'all',
]); ?>
</div>
<div class="col1 offset1 verticalAlignBottom">
<?php echo template::button('usersTagSelectAll', [
'value' => template::ico('square-check'),
'help' => 'Tout sélectionner'
]); ?>
</div>
<div class="col1 verticalAlignBottom">
<?php echo template::button('usersTagSelectNone', [
'value' => template::ico('square-check-empty'),
'help' => 'Tout désélectionner'
]); ?>
</div>
</div>
<?php if ($module::$users): ?>
<?php echo template::table([1, 2, 3, 3, 3], $module::$users, ['', 'Id', 'Prénom', 'Nom', 'Étiquettes'], ['id' => 'dataTables']); ?>