// Improve details action in BO ...
This commit is contained in:
@@ -23,110 +23,7 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#details_{$id}').click(function() {
|
||||
if (typeof(this.dataMaped) == 'undefined') {
|
||||
$.ajax({
|
||||
url: 'index.php',
|
||||
data: {
|
||||
id: '{$id}',
|
||||
controller: '{$controller}',
|
||||
token: '{$token}',
|
||||
action: '{$action}',
|
||||
ajax: true,
|
||||
{foreach $params as $key => $param}
|
||||
{$key}: {$param},
|
||||
{/foreach}
|
||||
},
|
||||
context: document.body,
|
||||
dataType: 'json',
|
||||
context: this,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
if (typeof(data.use_parent_structure) == 'undefined' || (data.use_parent_structure == true))
|
||||
{
|
||||
if ($('#details_{$id}').parent().parent().hasClass('alt_row'))
|
||||
var alt_row = true;
|
||||
else
|
||||
var alt_row = false;
|
||||
$('#details_{$id}').parent().parent().after($('<tr class="details_{$id} small '+(alt_row ? 'alt_row' : '')+'"></tr>')
|
||||
.append($('<td style="border:none!important;" class="empty"></td>')
|
||||
.attr('colspan', $('#details_{$id}').parent().parent().find('td').length)));
|
||||
$.each(data.data, function(it, row)
|
||||
{
|
||||
var bg_color = ''; // Color
|
||||
if (row.color)
|
||||
bg_color = 'style="background:' + row.color +';"';
|
||||
|
||||
var content = $('<tr class="action_details details_{$id} '+(alt_row ? 'alt_row' : '')+'"></tr>');
|
||||
content.append($('<td class="empty"></td>'));
|
||||
var first = true;
|
||||
var count = 0; // Number of non-empty collum
|
||||
$.each(row, function(it)
|
||||
{
|
||||
if(typeof(data.fields_display[it]) != 'undefined')
|
||||
count++;
|
||||
});
|
||||
$.each(data.fields_display, function(it, line)
|
||||
{
|
||||
if (typeof(row[it]) == 'undefined')
|
||||
{
|
||||
if (first || count == 0)
|
||||
content.append($('<td class="'+this.align+' empty"' + bg_color + '></td>'));
|
||||
else
|
||||
content.append($('<td class="'+this.align+'"' + bg_color + '></td>'));
|
||||
}
|
||||
else
|
||||
{
|
||||
count--;
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
content.append($('<td class="'+this.align+' first"' + bg_color + '>'+row[it]+'</td>'));
|
||||
}
|
||||
else if (count == 0)
|
||||
content.append($('<td class="'+this.align+' last"' + bg_color + '>'+row[it]+'</td>'));
|
||||
else
|
||||
content.append($('<td class="'+this.align+' '+count+'"' + bg_color + '>'+row[it]+'</td>'));
|
||||
}
|
||||
});
|
||||
content.append($('<td class="empty"></td>'));
|
||||
$('#details_{$id}').parent().parent().after(content.show('slow'));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($('#details_{$id}').parent().parent().hasClass('alt_row'))
|
||||
var content = $('<tr class="details_{$id} alt_row"></tr>');
|
||||
else
|
||||
var content = $('<tr class="details_{$id}"></tr>');
|
||||
content.append($('<td style="border:none!important;">'+data.data+'</td>').attr('colspan', $('#details_{$id}').parent().parent().find('td').length));
|
||||
$('#details_{$id}').parent().parent().after(content.show('slow'));
|
||||
}
|
||||
this.dataMaped = true;
|
||||
this.opened = false;
|
||||
initTableDnD('.details_{$id} table.tableDnD');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (this.opened)
|
||||
{
|
||||
$(this).find('img').attr('src', '../img/admin/more.png');
|
||||
$(this).parent().parent().parent().find('.details_{$id}').hide('slow');
|
||||
this.opened = false
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).find('img').attr('src', '../img/admin/less.png');
|
||||
$(this).parent().parent().parent().find('.details_{$id}').show('slow');
|
||||
this.opened = true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<a class="pointer" id="details_{$id}" title="{$action}">
|
||||
<a class="pointer" id="details_{$params.action}_{$id}" title="{$action}" onclick="display_action_details('{$id}', '{$controller}', '{$token}', '{$params.action}', {$json_params|escape}); return false">
|
||||
<img src="../img/admin/more.png" alt="{$action}" />
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user