// Adding a new admin list action "details"
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
{*
|
||||
* 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 : {$id},
|
||||
controller: '{$controller}',
|
||||
token: '{$token}',
|
||||
action: '{$action}',
|
||||
ajax: true
|
||||
},
|
||||
context: document.body,
|
||||
dataType: 'json',
|
||||
context: this,
|
||||
async: false,
|
||||
success: function(data) {
|
||||
$.each(data.data, function(it, row)
|
||||
{
|
||||
//console.log(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>'));
|
||||
});
|
||||
console.log($(this));
|
||||
content.append($('<td></td>'));
|
||||
$('#details_{$id}').parent().parent().after(content);
|
||||
});
|
||||
this.dataMaped = true;
|
||||
this.opened = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(this.opened)
|
||||
{
|
||||
console.log($(this).find('img'));
|
||||
$(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>
|
||||
+43
-21
@@ -140,10 +140,10 @@ class HelperListCore extends Helper
|
||||
*/
|
||||
protected function _displayEnableLink($token, $id, $value, $active, $id_category = null, $id_product = null)
|
||||
{
|
||||
return '<a href="'.$this->currentIndex.'&'.$this->identifier.'='.$id.'&'.$active.$this->table.
|
||||
((int)$id_category && (int)$id_product ? '&id_category='.$id_category : '').'&token='.($token != null ? $token : $this->token).'">
|
||||
<img src="../img/admin/'.($value ? 'enabled.gif' : 'disabled.gif').'"
|
||||
alt="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" title="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" /></a>';
|
||||
return '<a href="'.$this->currentIndex.'&'.$this->identifier.'='.$id.'&'.$active.$this->table.
|
||||
((int)$id_category && (int)$id_product ? '&id_category='.$id_category : '').'&token='.($token != null ? $token : $this->token).'">
|
||||
<img src="../img/admin/'.($value ? 'enabled.gif' : 'disabled.gif').'"
|
||||
alt="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" title="'.($value ? $this->l('Enabled') : $this->l('Disabled')).'" /></a>';
|
||||
}
|
||||
|
||||
public function displayListContent($token = null)
|
||||
@@ -236,11 +236,11 @@ class HelperListCore extends Helper
|
||||
}
|
||||
else if (isset($params['icon']) && (isset($params['icon'][$tr[$key]]) || isset($params['icon']['default'])))
|
||||
$this->_list[$index][$key] = isset($params['icon'][$tr[$key]]) ? $params['icon'][$tr[$key]] : $params['icon']['default'];
|
||||
else if (isset($params['price']))
|
||||
{
|
||||
$currency = isset($params['currency']) ? Currency::getCurrencyInstance($tr['id_currency']) : $this->context->currency;
|
||||
$this->_list[$index][$key] = Tools::displayPrice($tr[$key], ($currency), false);
|
||||
}
|
||||
else if (isset($params['price']))
|
||||
{
|
||||
$currency = isset($params['currency']) ? Currency::getCurrencyInstance($tr['id_currency']) : $this->context->currency;
|
||||
$this->_list[$index][$key] = Tools::displayPrice($tr[$key], ($currency), false);
|
||||
}
|
||||
else if (isset($params['float']))
|
||||
$this->_list[$index][$key] = rtrim(rtrim($tr[$key], '0'), '.');
|
||||
else if (isset($params['type']) && $params['type'] == 'date')
|
||||
@@ -295,26 +295,48 @@ class HelperListCore extends Helper
|
||||
/**
|
||||
* Display duplicate action link
|
||||
*/
|
||||
protected function _displayDuplicateLink($token = null, $id)
|
||||
{
|
||||
if (!array_key_exists('Duplicate', self::$cache_lang))
|
||||
self::$cache_lang['Duplicate'] = $this->l('Duplicate');
|
||||
protected function _displayDuplicateLink($token = null, $id)
|
||||
{
|
||||
if (!array_key_exists('Duplicate', self::$cache_lang))
|
||||
self::$cache_lang['Duplicate'] = $this->l('Duplicate');
|
||||
|
||||
if (!array_key_exists('Copy images too?', self::$cache_lang))
|
||||
self::$cache_lang['Copy images too?'] = $this->l('Copy images too?', __CLASS__, true, false);
|
||||
if (!array_key_exists('Copy images too?', self::$cache_lang))
|
||||
self::$cache_lang['Copy images too?'] = $this->l('Copy images too?', __CLASS__, true, false);
|
||||
|
||||
$duplicate = $this->currentIndex.'&'.$this->identifier.'='.$id.'&duplicate'.$this->table;
|
||||
$duplicate = $this->currentIndex.'&'.$this->identifier.'='.$id.'&duplicate'.$this->table;
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
$this->context->smarty->assign(array(
|
||||
'href' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&view'.$this->table.'&token='.($token != null ? $token : $this->token),
|
||||
'action' => self::$cache_lang['Duplicate'],
|
||||
'confirm' => self::$cache_lang['Copy images too?'],
|
||||
'location_ok' => $duplicate.'&token='.($token != null ? $token : $this->token),
|
||||
'location_ko' => $duplicate.'&noimage=1&token='.($token ? $token : $this->token).'\\',
|
||||
'confirm' => self::$cache_lang['Copy images too?'],
|
||||
'location_ok' => $duplicate.'&token='.($token != null ? $token : $this->token),
|
||||
'location_ko' => $duplicate.'&noimage=1&token='.($token ? $token : $this->token).'\\',
|
||||
));
|
||||
|
||||
return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/list_action_duplicate.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Display action to see details of a table row
|
||||
* This action need an ajax request with a return like this:
|
||||
* {
|
||||
* data:
|
||||
* [
|
||||
* {field_name: 'value'}
|
||||
* ],
|
||||
* fields_display: // attribute $fieldsDisplay of the admin controller
|
||||
* }
|
||||
*/
|
||||
protected function _displayDetailsLink($token = null, $id)
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'id' => $id,
|
||||
'controller' => str_replace('Controller', '', get_class($this->context->controller)),
|
||||
'token' => $this->token
|
||||
));
|
||||
return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/list_action_details.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display view action link
|
||||
|
||||
Reference in New Issue
Block a user