how to fix the tab switch in backend

Before you ask about IDnR Addon see the VirtueMart - Invoice, Delivery Note and Receipt Addon
nk111
Phoca Member
Phoca Member
Posts: 14
Joined: 05 Aug 2008, 14:11

how to fix the tab switch in backend

Post by nk111 »

Hi,

some of you might know this problem. When you are on the delivery tab in backend and click a button like "new delivery", "save" or "cancel" then after the postback the "order status change" tab is active and you have to switch back to "delivery" to continue.

This seems to be a known problem. In the install instructions article you can find:
It can happen that after some action in Delivery folder (clicking on button), you will be redirect to the first folder (Order Status Change). Just click on Delivery folder again to process the action.
I think the author of the invoice mod wanted to fix this by adding these lines to ps_order_delivery.php:

Code: Select all

        if( vmRequest::getVar ( 'delivery_pane' ) == '1') {
            ?>
<script type="text/javascript">
    var current = document.getElementById( "delivery_pane" );
    current.tabPage.select();
</script>
            <?php
        }
This tries to re-select the delivery tab after a postback. Unfortunately this doesn't work for me. I only get a javascript error. I think its because of a timing problem with the tab-panel initialisation or something.

Nevermind. After looking at the code for the tab panel init I found a better solution I think. Looks like the code for the tab panel init which is part of virtuemart has an error in it. The active panels ID is stored in a cookie whenever you change the active tab. When the new page is loaded this cookie should be read and the tab should be re-selected. But this doesn't work at all I think.

In order to fix this just change

/administrator/components/com_virtuemart/classes/htmlTools.class.php

line ~443

from this:

Code: Select all

if( $this->useCookies ) {
			$scripttag .= "tabs_{$this->panel_id}.activate(state.get('{$this->panel_id}-active', '".key($this->tabs)."'));"; 
		} else {
			$scripttag .= "tabs_{$this->panel_id}.activate( '".key($this->tabs)."'); ";
		}
		
		if( $this->useCookies ) {
			$scripttag .= "
	Ext.state.Manager.setProvider(new Ext.state.CookieProvider());	
	tabs_{$this->panel_id}.on('tabchange', function(tp, tab){
     state.set('{$this->panel_id}-active', tab.id);
     });
	";
to this:

Code: Select all

if( $this->useCookies ) {
			$scripttag .= "Ext.state.Manager.setProvider(new Ext.state.CookieProvider());tabs_{$this->panel_id}.activate(state.get('{$this->panel_id}-active', '".key($this->tabs)."'));"; 
		} else {
			$scripttag .= "tabs_{$this->panel_id}.activate( '".key($this->tabs)."'); ";
		}
		
		if( $this->useCookies ) {
			$scripttag .= "
	tabs_{$this->panel_id}.on('tabchange', function(tp, tab){
     state.set('{$this->panel_id}-active', tab.id);
     });
	";
Now the active panel is restored after a postback like it should be.

I hope this helps :wink:
nk111
Phoca Member
Phoca Member
Posts: 14
Joined: 05 Aug 2008, 14:11

Re: how to fix the tab switch in backend

Post by nk111 »

I just played around a bit and it seems this also affects the other tab panels in virtuemart.

So when I apply changes to a tab on the products page I will stay now on this tab which is what I would expect. So maybe I should post this fix to the virtuemart forum too :?:
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: how to fix the tab switch in backend

Post by Jan »

Hi, yes, this is known issue in VM, that the tabs "don't remember their positions" :(
If you find Phoca extensions useful, please support the project
nk111
Phoca Member
Phoca Member
Posts: 14
Joined: 05 Aug 2008, 14:11

Re: how to fix the tab switch in backend

Post by nk111 »

Jan wrote:Hi, yes, this is known issue in VM, that the tabs "don't remember their positions" :(
yes. but with the fix above all is good :twisted:
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: how to fix the tab switch in backend

Post by Jan »

Yes, will be great to implement it to VM directly.

Jan
If you find Phoca extensions useful, please support the project
Post Reply