[*] BO : Admin Modules now works in Ajax :)

This commit is contained in:
fSerny
2011-11-21 21:44:52 +00:00
parent 71b182976e
commit 2999ca608f
4 changed files with 64 additions and 35 deletions
+44
View File
@@ -77,6 +77,50 @@
});
});
// Method to reload filter in ajax
$(document).ready(function(){
$('.categoryModuleFilterLink').click(function()
{
$('.categoryModuleFilterLink').css('background-color', 'white');
$(this).css('background-color', '#EBEDF4');
var ajaxReloadCurrentIndex = $(this).find('a').attr('href').replace('index.php', 'ajax-tab.php');
try
{
resAjax = $.ajax({
type:"POST",
url : ajaxReloadCurrentIndex,
async: true,
data : {
ajax : "1",
token : token,
controller : "AdminModules",
action : "reloadModulesList",
},
beforeSend: function(xhr)
{
$('#moduleContainer').html('<img src="../img/loader.gif" border="0">');
},
success : function(data)
{
$('#moduleContainer').html(data);
},
error: function(res,textStatus,jqXHR)
{
//alert("TECHNICAL ERROR"+res);
}
});
}
catch(e){}
return false;
});
});
// Method to get modules_list.xml from prestashop.com and default_country_modules_list.xml from addons.prestashop.com
$(document).ready(function(){
try
+1 -1
View File
@@ -55,7 +55,7 @@
<div class="subHeadline">{$nb_modules}</div>
<ul class="categorieList">
{foreach from=$list_modules_categories item=module_category key=module_category_key}
<li {if isset($categoryFiltered[$module_category_key])}style="background-color:#EBEDF4"{/if}>
<li {if isset($categoryFiltered[$module_category_key])}style="background-color:#EBEDF4"{/if} class="categoryModuleFilterLink">
<div class="categorieWidth"><a href="{$currentIndex}&token={$token}&{if isset($categoryFiltered[$module_category_key])}un{/if}filterCategory={$module_category_key}"><span>{$module_category.name}</span></a></div>
<div class="count">{$module_category.nb}</div>
</li>
+2 -2
View File
@@ -785,8 +785,8 @@ abstract class ModuleCore
}
}
//echo '<pre>'.print_r($moduleList, 1).'</pre>';
echo round($current_memory / 1024 / 1024, 2).'Mo<br />';
//echo round($current_memory / 1024 / 1024, 2).'Mo<br />';
if ($errors)
{
+17 -32
View File
@@ -218,6 +218,21 @@ class AdminModulesControllerCore extends AdminController
die('OK');
}
public function ajaxProcessReloadModulesList()
{
if (Tools::getValue('filterCategory'))
Configuration::updateValue('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee, Tools::getValue('filterCategory'));
if (Tools::getValue('unfilterCategory'))
Configuration::updateValue('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee, '');
$this->initContent();
$this->context->smarty->display('modules/list.tpl');
exit;
}
/*
** Get current URL
@@ -333,45 +348,15 @@ class AdminModulesControllerCore extends AdminController
public function postProcessFilterCategory()
{
// Retrieve filter categories configuration and the new filter category
$filterCategory = Tools::getValue('filterCategory');
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee));
// Check if category filter not already exists
foreach ($filterCategories as $fc)
if ($fc == $filterCategories)
$filterCategories = '';
// If not, add the new filter
if ($filterCategories != '')
$filterCategories[] = $filterCategory;
$filterCategories = implode('|', $filterCategories);
// For the moment, we will filter only one category a time
$filterCategories = $filterCategory;
// Save configuration and redirect employee
Configuration::updateValue('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee, $filterCategories);
Configuration::updateValue('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee, Tools::getValue('filterCategory'));
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
}
public function postProcessUnfilterCategory()
{
// Retrieve filter categories configuration and the filter category to remove
$unfilterCategory = Tools::getValue('unfilterCategory');
$filterCategories = explode('|', Configuration::get('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee));
// Remove the filter category
foreach ($filterCategories as $k => $fc)
if ($fc == $unfilterCategory)
unset($filterCategories[$k]);
// For the moment, we will filter only one category a time
$filterCategories = '';
// Save configuration and redirect employee
$filterCategories = implode('|', $filterCategories);
Configuration::updateValue('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee, $filterCategories);
Configuration::updateValue('PS_SHOW_CAT_MODULES_'.(int)$this->id_employee, '');
Tools::redirectAdmin(self::$currentIndex.'&token='.$this->token);
}