Supprimer le bouton trier
This commit is contained in:
parent
514c1d31b7
commit
c2f68a4716
@ -18,6 +18,7 @@ class gallery extends common {
|
||||
'config' => self::GROUP_MODERATOR,
|
||||
'delete' => self::GROUP_MODERATOR,
|
||||
'dirs' => self::GROUP_MODERATOR,
|
||||
'sort' => self::GROUP_MODERATOR,
|
||||
'edit' => self::GROUP_MODERATOR,
|
||||
'index' => self::GROUP_VISITOR
|
||||
];
|
||||
@ -45,39 +46,34 @@ class gallery extends common {
|
||||
const GALLERY_VERSION = '2.1';
|
||||
|
||||
|
||||
/**
|
||||
* Tri sans bouton
|
||||
*/
|
||||
public function sort () {
|
||||
if($_POST['response']) {
|
||||
$data = explode('&',$_POST['response']);
|
||||
$data = str_replace('galleryTable%5B%5D=','',$data);
|
||||
for($i=0;$i<count($data);$i++) {
|
||||
$this->setData(['module', $this->getUrl(0), $data[$i], [
|
||||
'config' => [
|
||||
'name' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','name']),
|
||||
'directory' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','directory']),
|
||||
'homePicture' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','homePicture']),
|
||||
'sort' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','sort']),
|
||||
'position' => $i
|
||||
],
|
||||
'legend' => $this->getData(['module',$this->getUrl(0),$data[$i],'legend'])
|
||||
]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configuration
|
||||
*/
|
||||
public function config() {
|
||||
|
||||
// Le traitement du tri s'effectue en début de fonction
|
||||
// Soumission du formulaire
|
||||
if($this->isPost()) {
|
||||
if ($this->getInput('galleryConfigFilterResponse')) {
|
||||
$data = explode('&',($this->getInput('galleryConfigFilterResponse')));
|
||||
$data = str_replace('galleryTable%5B%5D=','',$data);
|
||||
for($i=0;$i<count($data);$i++) {
|
||||
$this->setData(['module', $this->getUrl(0), $data[$i], [
|
||||
'config' => [
|
||||
'name' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','name']),
|
||||
'directory' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','directory']),
|
||||
'homePicture' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','homePicture']),
|
||||
'sort' => $this->getData(['module',$this->getUrl(0),$data[$i],'config','sort']),
|
||||
'position' => $i
|
||||
],
|
||||
'legend' => $this->getData(['module',$this->getUrl(0),$data[$i],'legend'])
|
||||
]]);
|
||||
}
|
||||
}
|
||||
// Valeurs en sortie
|
||||
//header('Refresh: 0;url='. helper::baseUrl() . $this->getUrl() . '#galleryConfigFilterForm' );
|
||||
$this->addOutput([
|
||||
'redirect' => helper::baseUrl() . $this->getUrl() /* . '#galleryConfigFilterForm'*/,
|
||||
'notification' => 'Modifications enregistrées',
|
||||
'state' => true
|
||||
]);
|
||||
}
|
||||
// Tri pour l'affichage de la galerie
|
||||
//Affichage de la galerie triée
|
||||
$g = $this->getData(['module', $this->getUrl(0)]);
|
||||
$p = helper::arrayCollumn(helper::arrayCollumn($g,'config'),'position');
|
||||
asort($p,SORT_NUMERIC);
|
||||
|
@ -12,26 +12,27 @@
|
||||
* @link http://zwiicms.com/
|
||||
*/
|
||||
|
||||
|
||||
$( document ).ready(function() {
|
||||
|
||||
|
||||
/**
|
||||
* Tri dynamique de la galerie
|
||||
* Tri de la galerie avec drag and drop
|
||||
*/
|
||||
$("#galleryTable").tableDnD({
|
||||
onDrop: function(table, row) {
|
||||
// Stocke dans un champ caché l'ordre de tri modifié
|
||||
$("#galleryTable").tableDnD({
|
||||
onDrop: function(table, row) {
|
||||
$("#galleryConfigFilterResponse").val($.tableDnD.serialize());
|
||||
},
|
||||
onDragStop : function(table, row) {
|
||||
// Affiche le bouton de tri après un déplacement
|
||||
$(":input[type='submit']").prop('disabled', false);
|
||||
// Sauvegarde le tri
|
||||
sort();
|
||||
},
|
||||
// Supprime le tiret des séparateurs
|
||||
serializeRegexp: "[^\_]*$"
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Confirmation de suppression
|
||||
@ -84,3 +85,20 @@ setInterval(function() {
|
||||
directoryDOM.on("change", function() {
|
||||
directoryOldDOM.val($(this).val());
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Tri dynamique des galeries
|
||||
*/
|
||||
|
||||
function sort() {
|
||||
var url = "<?php echo helper::baseUrl() . $this->getUrl(0) . '/sort'; ?>";
|
||||
var data = $("#galleryConfigFilterResponse").val();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url ,
|
||||
data: {
|
||||
response : data
|
||||
}
|
||||
});
|
||||
}
|
@ -51,19 +51,9 @@
|
||||
<div class="col12">
|
||||
<div class="block">
|
||||
<h4>Galeries installées</h4>
|
||||
<div class="col2 offset10">
|
||||
<?php echo template::submit('galleryConfigFilterSubmit', [
|
||||
'value' => 'Trier',
|
||||
'disabled' => true,
|
||||
'class' => 'gallerySubmit'
|
||||
]); ?>
|
||||
</div>
|
||||
<?php if($module::$galleries): ?>
|
||||
<?php echo template::table([1, 4, 5, 1, 1], $module::$galleries, ['','Nom', 'Dossier cible', '', ''], ['id' => 'galleryTable'],$module::$galleriesId); ?>
|
||||
<?php echo template::hidden('galleryConfigFilterResponse'); ?>
|
||||
<?php echo template::hidden('galleryConfigFilterSubmit',[
|
||||
'value' => false
|
||||
]); ?>
|
||||
<?php echo template::hidden('galleryConfigFilterResponse'); ?>
|
||||
<?php else: ?>
|
||||
<?php echo template::speech('Aucune galerie.'); ?>
|
||||
<?php endif; ?>
|
||||
|
Loading…
Reference in New Issue
Block a user