// Improving admin list action "details"

This commit is contained in:
mDeflotte
2011-10-17 15:50:54 +00:00
parent ef0184a6fb
commit 3ebbab2084
2 changed files with 30 additions and 16 deletions
@@ -26,7 +26,6 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$('#details_{$id}').click(function() { $('#details_{$id}').click(function() {
if (typeof(this.dataMaped) == 'undefined') { if (typeof(this.dataMaped) == 'undefined') {
$.ajax({ $.ajax({
url: 'index.php', url: 'index.php',
@@ -42,25 +41,33 @@ $(document).ready(function() {
context: this, context: this,
async: false, async: false,
success: function(data) { success: function(data) {
$.each(data.data, function(it, row) if(typeof(data.use_parent_structure) == 'undefined' || data.use_parent_structure)
$.each(data.data, function(it, row)
{
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></td>'));
$.each(data.fields_display, function(it, line)
{
if (typeof(row[it]) == 'undefined')
content.append($('<td class="'+this.align+'"></td>'));
else
content.append($('<td class="'+this.align+'">'+row[it]+'</td>'));
});
content.append($('<td></td>'));
$('#details_{$id}').parent().parent().after(content);
});
else
{ {
//console.log(row);
if($('#details_{$id}').parent().parent().hasClass('alt_row')) if($('#details_{$id}').parent().parent().hasClass('alt_row'))
var content = $('<tr class="details_{$id} alt_row"></tr>'); var content = $('<tr class="details_{$id} alt_row"></tr>');
else else
var content = $('<tr class="details_{$id}"></tr>'); var content = $('<tr class="details_{$id}"></tr>');
content.append($('<td></td>')); content.append($('<td>'+data+'</td>').attr('colspan', $('#details_{$id}').parent().parent().find('td').length));
$.each(data.fields_display, function(it, line)
{
if (typeof(row[it]) == 'undefined')
content.append($('<td class="'+this.align+'"></td>'));
else
content.append($('<td class="'+this.align+'">'+row[it]+'</td>'));
});
console.log($(this));
content.append($('<td></td>'));
$('#details_{$id}').parent().parent().after(content); $('#details_{$id}').parent().parent().after(content);
}); }
this.dataMaped = true; this.dataMaped = true;
this.opened = false; this.opened = false;
} }
@@ -69,7 +76,6 @@ $(document).ready(function() {
if(this.opened) if(this.opened)
{ {
console.log($(this).find('img'));
$(this).find('img').attr('src', '../img/admin/more.png'); $(this).find('img').attr('src', '../img/admin/more.png');
$(this).parent().parent().parent().find('.details_{$id}').hide(); $(this).parent().parent().parent().find('.details_{$id}').hide();
this.opened = false this.opened = false
+9 -1
View File
@@ -318,15 +318,23 @@ class HelperListCore extends Helper
/** /**
* Display action to see details of a table row * Display action show details of a table row
* This action need an ajax request with a return like this: * This action need an ajax request with a return like this:
* { * {
* use_parent_structure: true // If false, data need to be an html
* data: * data:
* [ * [
* {field_name: 'value'} * {field_name: 'value'}
* ], * ],
* fields_display: // attribute $fieldsDisplay of the admin controller * fields_display: // attribute $fieldsDisplay of the admin controller
* } * }
* or somethins like this:
* {
* use_parent_structure: false // If false, data need to be an html
* data:
* '<p>My html content</p>',
* fields_display: // attribute $fieldsDisplay of the admin controller
* }
*/ */
protected function _displayDetailsLink($token = null, $id) protected function _displayDetailsLink($token = null, $id)
{ {