// Improve details action in BO ...
This commit is contained in:
-130
@@ -1,130 +0,0 @@
|
||||
{*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision$
|
||||
* @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_supply_order_detail: '{$id}',
|
||||
controller: '{$controller}',
|
||||
token: '{$token}',
|
||||
action: '{$action}',
|
||||
ajax: true
|
||||
},
|
||||
beforeSend : function(data)
|
||||
{
|
||||
// don't display the loading notification bar
|
||||
if (typeof(ajax_running_timeout) !== 'undefined')
|
||||
clearTimeout(ajax_running_timeout);
|
||||
},
|
||||
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 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"></td>'));
|
||||
else
|
||||
content.append($('<td class="'+this.align+'"></td>'));
|
||||
}
|
||||
else
|
||||
{
|
||||
count--;
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
content.append($('<td class="'+this.align+' first">'+row[it]+'</td>'));
|
||||
}
|
||||
else if (count == 0)
|
||||
content.append($('<td class="'+this.align+' last">'+row[it]+'</td>'));
|
||||
else
|
||||
content.append($('<td class="'+this.align+' '+count+'">'+row[it]+'</td>'));
|
||||
}
|
||||
});
|
||||
content.append($('<td class="empty"></td>'));
|
||||
$('#details_{$id}').parent().parent().after(content);
|
||||
});
|
||||
}
|
||||
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);
|
||||
}
|
||||
this.dataMaped = true;
|
||||
this.opened = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (this.opened)
|
||||
{
|
||||
$(this).find('img').attr('src', '../img/admin/more.png');
|
||||
$(this).parent().parent().parent().find('.details_{$id}').hide();
|
||||
this.opened = false
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).find('img').attr('src', '../img/admin/less.png');
|
||||
$(this).parent().parent().parent().find('.details_{$id}').show();
|
||||
this.opened = true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<a href="#" id="details_{$id}">
|
||||
<img src="../img/admin/more.png" alt="{$action}" title="{$action}" />
|
||||
</a>
|
||||
@@ -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>
|
||||
|
||||
@@ -392,12 +392,18 @@ class HelperListCore extends Helper
|
||||
$tpl = $this->createTemplate('list_action_details.tpl');
|
||||
if (!array_key_exists('Details', self::$cache_lang))
|
||||
self::$cache_lang['Details'] = $this->l('Details', 'helper');
|
||||
|
||||
$ajax_params = $this->ajax_params;
|
||||
if (!is_array($ajax_params) || !isset($ajax_params['action']))
|
||||
$ajax_params['action'] = 'details';
|
||||
|
||||
$tpl->assign(array(
|
||||
'id' => $id,
|
||||
'controller' => str_replace('Controller', '', get_class($this->context->controller)),
|
||||
'token' => $token != null ? $token : $this->token,
|
||||
'action' => self::$cache_lang['Details'],
|
||||
'params' => $this->ajax_params
|
||||
'params' => $ajax_params,
|
||||
'json_params' => Tools::jsonEncode($ajax_params)
|
||||
));
|
||||
return $tpl->fetch();
|
||||
}
|
||||
|
||||
@@ -79,10 +79,9 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
* method call when ajax request is made with the details row action
|
||||
* @see AdminController::postProcess()
|
||||
*/
|
||||
public function ajaxProcess()
|
||||
public function ajaxProcessDetails()
|
||||
{
|
||||
// test if an id is submit
|
||||
if (($id = Tools::getValue('id')) && Tools::isSubmit('id'))
|
||||
if (($id = Tools::getValue('id')))
|
||||
{
|
||||
$this->table = 'attribute';
|
||||
$this->className = 'Attribute';
|
||||
@@ -150,9 +149,9 @@ class AdminAttributesGroupsControllerCore extends AdminController
|
||||
$helper->bulk_actions = $this->bulk_actions;
|
||||
$content = $helper->generateList($this->_list, $this->fieldsDisplay);
|
||||
|
||||
$this->content = Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content));
|
||||
echo Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content));
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,9 +91,8 @@ class AdminFeaturesControllerCore extends AdminController
|
||||
* method call when ajax request is made with the details row action
|
||||
* @see AdminController::postProcess()
|
||||
*/
|
||||
public function ajaxProcess()
|
||||
public function ajaxProcessDetails()
|
||||
{
|
||||
// test if an id is submit
|
||||
if (($id = Tools::getValue('id')))
|
||||
{
|
||||
$this->table = 'feature_value';
|
||||
@@ -143,7 +142,8 @@ class AdminFeaturesControllerCore extends AdminController
|
||||
$helper->bulk_actions = $this->bulk_actions;
|
||||
$content = $helper->generateList($this->_list, $this->fieldsDisplay);
|
||||
|
||||
$this->content = Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content));
|
||||
echo Tools::jsonEncode(array('use_parent_structure' => false, 'data' => $content));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -196,10 +196,9 @@ class AdminTabsControllerCore extends AdminController
|
||||
* method call when ajax request is made with the details row action
|
||||
* @see AdminController::postProcess()
|
||||
*/
|
||||
public function ajaxProcess()
|
||||
public function ajaxProcessDetails()
|
||||
{
|
||||
// test if an id is submit
|
||||
if (($id = Tools::getValue('id')) && Tools::isSubmit('id'))
|
||||
if (($id = Tools::getValue('id')))
|
||||
{
|
||||
// override attributes
|
||||
$this->display = 'list';
|
||||
|
||||
+109
@@ -1061,3 +1061,112 @@ function showAjaxOverlay()
|
||||
clearTimeout(ajax_running_timeout);
|
||||
}
|
||||
|
||||
function display_action_details(row_id, controller, token, action, params) {
|
||||
var id = action+'_'+row_id;
|
||||
var current_element = $('#details_'+id);
|
||||
if (!current_element.data('dataMaped')) {
|
||||
var ajax_params = {
|
||||
'id': row_id,
|
||||
'controller': controller,
|
||||
'token': token,
|
||||
'action': action,
|
||||
'ajax': true
|
||||
};
|
||||
|
||||
$.each(params, function(k, v)
|
||||
{
|
||||
ajax_params[k] = v;
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
url: 'index.php',
|
||||
data: ajax_params,
|
||||
dataType: 'json',
|
||||
context: current_element,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
if (typeof(data.use_parent_structure) == 'undefined' || (data.use_parent_structure == true))
|
||||
{
|
||||
if (current_element.parent().parent().hasClass('alt_row'))
|
||||
var alt_row = true;
|
||||
else
|
||||
var alt_row = false;
|
||||
current_element.parent().parent().after($('<tr class="details_'+id+' small '+(alt_row ? 'alt_row' : '')+'"></tr>')
|
||||
.append($('<td style="border:none!important;" class="empty"></td>')
|
||||
.attr('colspan', current_element.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="'+current_element.align+' empty"' + bg_color + '></td>'));
|
||||
else
|
||||
content.append($('<td class="'+current_element.align+'"' + bg_color + '></td>'));
|
||||
}
|
||||
else
|
||||
{
|
||||
count--;
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
content.append($('<td class="'+current_element.align+' first"' + bg_color + '>'+row[it]+'</td>'));
|
||||
}
|
||||
else if (count == 0)
|
||||
content.append($('<td class="'+current_element.align+' last"' + bg_color + '>'+row[it]+'</td>'));
|
||||
else
|
||||
content.append($('<td class="'+current_element.align+' '+count+'"' + bg_color + '>'+row[it]+'</td>'));
|
||||
}
|
||||
});
|
||||
content.append($('<td class="empty"></td>'));
|
||||
current_element.parent().parent().after(content.show('slow'));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (current_element.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;"><div class="details_content">'+data.data+'</div></td>').attr('colspan', current_element.parent().parent().find('td').length));
|
||||
current_element.parent().parent().after(content);
|
||||
current_element.parent().parent().parent().find('.details_'+id+' div.details_content').hide();
|
||||
}
|
||||
current_element.data('dataMaped',true);
|
||||
current_element.data('opened', false);
|
||||
initTableDnD('.details_'+id+' table.tableDnD');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (current_element.data('opened'))
|
||||
{
|
||||
current_element.find('img').attr('src', '../img/admin/more.png');
|
||||
current_element.parent().parent().parent().find('.details_'+id+' div.details_content').slideUp('slow', function()
|
||||
{
|
||||
current_element.parent().parent().parent().find('.details_'+id).hide();
|
||||
});
|
||||
current_element.data('opened', false);
|
||||
}
|
||||
else
|
||||
{
|
||||
current_element.find('img').attr('src', '../img/admin/less.png');
|
||||
current_element.parent().parent().parent().find('.details_'+id).show();
|
||||
current_element.parent().parent().parent().find('.details_'+id+' div.details_content').slideDown('slow');
|
||||
current_element.data('opened', true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user