[-] BO : fix JS errors and redirection issues on product page
This commit is contained in:
@@ -222,6 +222,8 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".productTabs a.selected").click();
|
||||||
|
|
||||||
{if $show_product_tab_content}
|
{if $show_product_tab_content}
|
||||||
$("div.productTabs a[id$=-{$show_product_tab_content}]").click();
|
$("div.productTabs a[id$=-{$show_product_tab_content}]").click();
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -100,7 +100,9 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
displayFlags(languages, id_language, allowEmployeeFormLang);
|
$(document).ready(function(){
|
||||||
|
displayFlags(languages, id_language, allowEmployeeFormLang);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -410,20 +410,21 @@
|
|||||||
var id_language = {$defaultFormLanguage};
|
var id_language = {$defaultFormLanguage};
|
||||||
var languages = new Array();
|
var languages = new Array();
|
||||||
|
|
||||||
|
// Multilang field setup must happen before document is ready so that calls to displayFlags() to avoid
|
||||||
|
// precedence conflicts with other document.ready() blocks
|
||||||
|
{foreach $languages as $k => $language}
|
||||||
|
languages[{$k}] = {
|
||||||
|
id_lang: {$language.id_lang},
|
||||||
|
iso_code: '{$language.iso_code}',
|
||||||
|
name: '{$language.name}',
|
||||||
|
is_default: "{$language.is_default}"
|
||||||
|
};
|
||||||
|
{/foreach}
|
||||||
|
// we need allowEmployeeFormLang var in ajax request
|
||||||
|
allowEmployeeFormLang = {$allowEmployeeFormLang};
|
||||||
|
displayFlags(languages, id_language, allowEmployeeFormLang);
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
{foreach $languages as $k => $language}
|
|
||||||
languages[{$k}] = {
|
|
||||||
id_lang: {$language.id_lang},
|
|
||||||
iso_code: '{$language.iso_code}',
|
|
||||||
name: '{$language.name}',
|
|
||||||
is_default: "{$language.is_default}"
|
|
||||||
};
|
|
||||||
{/foreach}
|
|
||||||
// we need allowEmployeeFormLang var in ajax request
|
|
||||||
allowEmployeeFormLang = {$allowEmployeeFormLang};
|
|
||||||
displayFlags(languages, id_language, allowEmployeeFormLang);
|
|
||||||
|
|
||||||
{if isset($fields_value.id_state)}
|
{if isset($fields_value.id_state)}
|
||||||
if ($('#id_country') && $('#id_state'))
|
if ($('#id_country') && $('#id_state'))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
'Accounting' => false,
|
'Accounting' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected $default_tab = 'Informations';
|
||||||
|
|
||||||
protected $available_tabs_lang = array ();
|
protected $available_tabs_lang = array ();
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@@ -976,14 +978,19 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
if (!$this->action)
|
if (!$this->action)
|
||||||
parent::initProcess();
|
parent::initProcess();
|
||||||
|
|
||||||
// Set tab to display
|
if ($this->action == 'save'
|
||||||
if ($this->action)
|
&& Tools::getValue('submitAdd'.$this->table.'AndStay')
|
||||||
{
|
&& isset($this->available_tabs[Tools::getValue('key_tab')]))
|
||||||
|
$this->tab_display = Tools::getValue('key_tab');
|
||||||
|
|
||||||
|
// Set tab to display if not decided already
|
||||||
|
if (!$this->tab_display && $this->action)
|
||||||
if (in_array($this->action, array_keys($this->available_tabs)))
|
if (in_array($this->action, array_keys($this->available_tabs)))
|
||||||
$this->tab_display = $this->action;
|
$this->tab_display = $this->action;
|
||||||
elseif ($this->action == 'new' || $this->action == 'save')
|
|
||||||
$this->tab_display = 'Informations';
|
// And if still not set, use default
|
||||||
}
|
if (!$this->tab_display)
|
||||||
|
$this->tab_display = $this->default_tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1427,10 +1434,7 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
if (Tools::getValue('resizer') == 'man' && isset($id_image) && is_int($id_image) && $id_image)
|
if (Tools::getValue('resizer') == 'man' && isset($id_image) && is_int($id_image) && $id_image)
|
||||||
$this->redirect_after = self::$currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category_default'])?$_REQUEST['id_category_default']:'1').'&id_image='.$id_image.'&imageresize&toconf=3&submitAddAndStay='.(Tools::isSubmit('submitAdd'.$this->table.'AndStay') ? 'on' : 'off').'&token='.($token ? $token : $this->token);
|
$this->redirect_after = self::$currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category_default'])?$_REQUEST['id_category_default']:'1').'&id_image='.$id_image.'&imageresize&toconf=3&submitAddAndStay='.(Tools::isSubmit('submitAdd'.$this->table.'AndStay') ? 'on' : 'off').'&token='.($token ? $token : $this->token);
|
||||||
// Save and stay on same form
|
// Save and stay on same form
|
||||||
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
|
if (!Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
|
||||||
$this->redirect_after = self::$currentIndex.'&id_product='.$object->id.'&id_category='.(!empty($_REQUEST['id_category_default'])?$_REQUEST['id_category_default']:'1').'&addproduct&conf=3&action='.Tools::getValue('key_tab').'&token='.($token ? $token : $this->token);
|
|
||||||
else
|
|
||||||
// Default behavior (save and back)
|
|
||||||
$this->redirect_after = self::$currentIndex.'&id_category='.(!empty($_REQUEST['id_category_default'])?$_REQUEST['id_category_default']:'1').'&conf=3&token='.($token ? $token : $this->token);
|
$this->redirect_after = self::$currentIndex.'&id_category='.(!empty($_REQUEST['id_category_default'])?$_REQUEST['id_category_default']:'1').'&conf=3&token='.($token ? $token : $this->token);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1826,8 +1830,6 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
$this->addJS(_PS_JS_DIR_.'admin-products.js');
|
$this->addJS(_PS_JS_DIR_.'admin-products.js');
|
||||||
$this->fields_form = array();
|
$this->fields_form = array();
|
||||||
if (empty($this->tab_display))
|
|
||||||
$this->tab_display = 'Informations';
|
|
||||||
|
|
||||||
if(method_exists($this, 'initForm'.$this->tab_display))
|
if(method_exists($this, 'initForm'.$this->tab_display))
|
||||||
$this->tpl_form = strtolower($this->tab_display).'.tpl';
|
$this->tpl_form = strtolower($this->tab_display).'.tpl';
|
||||||
@@ -1838,8 +1840,8 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
$product_tabs = array();
|
$product_tabs = array();
|
||||||
// tab_display defines which tab to display first
|
// tab_display defines which tab to display first
|
||||||
if (empty($this->tab_display) || !method_exists($this, 'initForm'.$this->tab_display))
|
if (!method_exists($this, 'initForm'.$this->tab_display))
|
||||||
$this->tab_display = 'Informations';
|
$this->tab_display = $this->default_tab;
|
||||||
|
|
||||||
// i is used as product_tab id
|
// i is used as product_tab id
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@@ -1866,9 +1868,6 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
|
|
||||||
$this->tpl_form_vars['product_tabs'] = $product_tabs;
|
$this->tpl_form_vars['product_tabs'] = $product_tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*$languages = Language::getLanguages(false);
|
|
||||||
$default_language = (int)Configuration::get('PS_LANG_DEFAULT');*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user