manque récupération données ajax

This commit is contained in:
Fred Tempez 2020-03-24 17:48:54 +01:00
parent 6d200124fd
commit 932b78650a
7 changed files with 51 additions and 23 deletions

View File

@ -3327,7 +3327,7 @@ class template {
if($head) { if($head) {
// Début des entêtes // Début des entêtes
$html .= '<thead>'; $html .= '<thead>';
$html .= '<tr>'; $html .= '<tr class="nodrag">';
$i = 0; $i = 0;
foreach($head as $th) { foreach($head as $th) {
$html .= '<th class="col' . $cols[$i++] . '">' . $th . '</th>'; $html .= '<th class="col' . $cols[$i++] . '">' . $th . '</th>';
@ -3337,12 +3337,12 @@ class template {
$html .= '</thead>'; $html .= '</thead>';
} }
// Début contenu // Début contenu
$html .= '<tbody>'; $j = 1;
foreach($body as $tr) { foreach($body as $tr) {
$html .= '<tr>'; $html .= '<tr id="item' . ($j++) . '">';
$i = 0; $i = 0;
foreach($tr as $td) { foreach($tr as $td) {
$html .= '<td " class="pos' . ($i+1) . ' col' . $cols[$i++] . '">' . $td . '</td>'; $html .= '<td class="col' . $cols[$i++] . '">' . $td . '</td>';
} }
$html .= '</tr>'; $html .= '</tr>';
} }

View File

@ -0,0 +1 @@
https://github.com/lukasoppermann/html5sortable

View File

@ -16,9 +16,10 @@ class gallery extends common {
public static $actions = [ public static $actions = [
'config' => self::GROUP_MODERATOR, 'config' => self::GROUP_MODERATOR,
'filter' =>self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR, 'delete' => self::GROUP_MODERATOR,
'dirs' => self::GROUP_MODERATOR, 'dirs' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR, 'edit' => self::GROUP_MODERATOR,
'index' => self::GROUP_VISITOR 'index' => self::GROUP_VISITOR
]; ];
@ -44,8 +45,6 @@ class gallery extends common {
public function config() { public function config() {
// Liste des galeries // Liste des galeries
$galleries = $this->getData(['module', $this->getUrl(0)]); $galleries = $this->getData(['module', $this->getUrl(0)]);
$countGalleries = count($this->getData(['module',$this->getUrl(0)]));
if($galleries) { if($galleries) {
foreach($galleries as $galleryId => $gallery) { foreach($galleries as $galleryId => $gallery) {
// Erreur dossier vide // Erreur dossier vide
@ -58,9 +57,6 @@ class gallery extends common {
else { else {
$gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . ' (dossier introuvable)</span>'; $gallery['config']['directory'] = '<span class="galleryConfigError">' . $gallery['config']['directory'] . ' (dossier introuvable)</span>';
} }
// Ordre des galeries
// Element 0 chaine vide
$galeryOrder = range(1,count($this->getData(['module',$this->getUrl(0)])));
// Met en forme le tableau // Met en forme le tableau
self::$galleries[] = [ self::$galleries[] = [
$gallery['config']['name'], $gallery['config']['name'],
@ -99,10 +95,25 @@ class gallery extends common {
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => 'Configuration du module', 'title' => 'Configuration du module',
'view' => 'config' 'view' => 'config',
'vendor' => [
'tablednd'
]
]); ]);
} }
/**
* Fonction AJAX tri des galeries
*/
public function filter() {
$data = $_POST['data'];
var_dump(json_decode($data));
var_dump($_POST);
die();
}
/** /**
* Suppression * Suppression
*/ */

View File

@ -0,0 +1,3 @@
[
"tablednd.min.js"
]

View File

@ -0,0 +1 @@
https://github.com/isocra/TableDnD

File diff suppressed because one or more lines are too long

View File

@ -67,15 +67,25 @@ directoryDOM.on("change", function() {
* Tri dynamique de la galerie * Tri dynamique de la galerie
*/ */
$( document ).ready(function() { $( document ).ready(function() {
var $tbody = $('#galleryTable tbody'); $("#galleryTable").tableDnD({
$tbody.find('tr').sort(function (a, b) { onDrop: function(table, row) {
var tda = $(a).find('td.pos3:eq(0)').text(); console.log($.tableDnD.serialize());
var tdb = $(b).find('td.pos3:eq(0)').text(); var url= <?php echo json_encode(helper::baseUrl() . $this->getUrl(0) . '/filter'); ?>;
// if a < b return 1 /*url = "http://localhost/ZwiiCMS/?galeries/filter"; */
return tda > tdb ? 1 $.ajax({
// else if a > b return -1 url: url,
: tda < tdb ? -1 data: $.tableDnD.serialize(),
// else they are equal - return 0 type: "POST",
: 0; success: function (data) {
}).appendTo($tbody); // Je charge les données dans box
alert("ok");
},
// La fonction à appeler si la requête n'a pas abouti
error: function() {
// J'affiche un message d'erreur
alert("Désolé, aucun résultat trouvé.");
}
});
}
});
}); });