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

View File

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

View File

@ -16,6 +16,7 @@ class gallery extends common {
public static $actions = [
'config' => self::GROUP_MODERATOR,
'filter' =>self::GROUP_MODERATOR,
'delete' => self::GROUP_MODERATOR,
'dirs' => self::GROUP_MODERATOR,
'edit' => self::GROUP_MODERATOR,
@ -44,8 +45,6 @@ class gallery extends common {
public function config() {
// Liste des galeries
$galleries = $this->getData(['module', $this->getUrl(0)]);
$countGalleries = count($this->getData(['module',$this->getUrl(0)]));
if($galleries) {
foreach($galleries as $galleryId => $gallery) {
// Erreur dossier vide
@ -58,9 +57,6 @@ class gallery extends common {
else {
$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
self::$galleries[] = [
$gallery['config']['name'],
@ -99,10 +95,25 @@ class gallery extends common {
// Valeurs en sortie
$this->addOutput([
'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
*/

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
*/
$( document ).ready(function() {
var $tbody = $('#galleryTable tbody');
$tbody.find('tr').sort(function (a, b) {
var tda = $(a).find('td.pos3:eq(0)').text();
var tdb = $(b).find('td.pos3:eq(0)').text();
// if a < b return 1
return tda > tdb ? 1
// else if a > b return -1
: tda < tdb ? -1
// else they are equal - return 0
: 0;
}).appendTo($tbody);
$("#galleryTable").tableDnD({
onDrop: function(table, row) {
console.log($.tableDnD.serialize());
var url= <?php echo json_encode(helper::baseUrl() . $this->getUrl(0) . '/filter'); ?>;
/*url = "http://localhost/ZwiiCMS/?galeries/filter"; */
$.ajax({
url: url,
data: $.tableDnD.serialize(),
type: "POST",
success: function (data) {
// 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é.");
}
});
}
});
});