1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-01-02 19:18:55 +01:00

Aggiunto riordinamento colonne integrato nel modulo

This commit is contained in:
Thomas Zilio 2020-08-20 15:59:13 +02:00
parent 882afa132a
commit 3652ed92fe
4 changed files with 76 additions and 2 deletions

View File

@ -255,6 +255,8 @@ elseif (post('op') == 'send-email') {
$mail->delete(); $mail->delete();
flash()->error(tr('Errore durante l\'invio email! Verifica i parametri dell\'account SMTP utilizzato.')); flash()->error(tr('Errore durante l\'invio email! Verifica i parametri dell\'account SMTP utilizzato.'));
} }
} elseif (filter('op') == 'aggiorna_colonne') {
include_once DOCROOT.'/include/colonne.php';
} elseif (filter('op') == 'visualizza_riferimenti') { } elseif (filter('op') == 'visualizza_riferimenti') {
include_once DOCROOT.'/include/riferimenti/riferimenti.php'; include_once DOCROOT.'/include/riferimenti/riferimenti.php';
} elseif (filter('op') == 'visualizza_righe_riferimenti') { } elseif (filter('op') == 'visualizza_righe_riferimenti') {

View File

@ -78,6 +78,19 @@ echo '
redirectOperation($id_module, isset($id_parent) ? $id_parent : $id_record); redirectOperation($id_module, isset($id_parent) ? $id_parent : $id_record);
if ($user->is_admin && str_contains($structure['option'], '|select|')) {
echo '
<button type="button" class="btn btn-xs btn-primary pull-right" onclick="modificaColonne(this)">
<i class="fa fa-th-list"></i> '.tr('Modifica colonne').'
</button>
<script>
function modificaColonne(button) {
openModal("'.tr('Modifica colonne').'", globals.rootdir + "/actions.php?id_module=" + globals.id_module + "&id_record=" + globals.id_record + "&op=aggiorna_colonne")
}
</script>';
}
// Widget in basso // Widget in basso
echo '{( "name": "widgets", "id_module": "'.$id_module.'", "position": "right", "place": "controller" )}'; echo '{( "name": "widgets", "id_module": "'.$id_module.'", "position": "right", "place": "controller" )}';

59
include/colonne.php Normal file
View File

@ -0,0 +1,59 @@
<?php
include_once __DIR__.'/../core.php';
// Compatibilità per controller ed editor
$structure = Modules::get($id_module);
$modulo_viste = Modules::get('Viste');
echo '
<p>'.tr('Trascina le colonne per riordinare la struttura della tabella principale').'.</p>
<div class="sortable">';
$fields = $dbo->fetchArray('SELECT * FROM zz_views WHERE id_module='.prepare($id_module).' ORDER BY `order` ASC');
foreach ($fields as $field) {
echo '
<div class="panel panel-default clickable col-md-4" data-id="'.$field['id'].'">
<div class="panel-body">';
if ($field['visible']) {
echo '
<span class="text-success">'.$field['name'].'</span>';
} else {
echo '
<span class="text-danger">'.$field['name'].'</span>';
}
echo '
<i class="fa fa-sort pull-right"></i>
</div>
</div>';
}
echo '
</div>
<div class="clearfix"></div>
<script>
$(document).ready(function() {
$(".sortable").disableSelection();
$(".sortable").each(function() {
$(this).sortable({
cursor: "move",
dropOnEmpty: true,
scroll: true,
update: function(event, ui) {
let order = $(".panel[data-id]").toArray().map(a => $(a).data("id"))
$.post(globals.rootdir + "/actions.php", {
id: ui.item.data("id"),
id_module: '.$modulo_viste->id.',
id_record: '.$id_module.',
op: "update_position",
order: order.join(","),
});
}
});
});
});
</script>';

View File

@ -128,7 +128,7 @@ echo '
foreach ($fields as $field) { foreach ($fields as $field) {
echo ' echo '
<p class="clickable" data-id="'.$field['id'].'"> <p class="clickable" data-id="'.$field['id'].'">
<i class="fa fa-sort" ></i> <i class="fa fa-sort"></i>
'; ';
if ($field['visible']) { if ($field['visible']) {
@ -226,7 +226,7 @@ echo '
$(document).ready(function() { $(document).ready(function() {
$("#save").addClass("hide"); $("#save").addClass("hide");
$(".sortable" ).disableSelection(); $(".sortable").disableSelection();
$(".sortable").each(function() { $(".sortable").each(function() {
$(this).sortable({ $(this).sortable({
axis: "y", axis: "y",