Index: qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py
===================================================================
--- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py	(revision 484)
+++ qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py	(revision 507)
@@ -1,17 +1,15 @@
-import copy
-import sys
 import urllib
 import re
 
 from Acquisition import aq_inner
-from OFS.CopySupport import CopyError
 
 from zope.interface import implements
-from zope.component import getUtility, getMultiAdapter
-from zope.i18n import translate
-from zope.schema.interfaces import IVocabularyFactory
-from zope.exceptions import UserError
+from zope.component import getMultiAdapter
 from zope.app.container.interfaces import INameChooser
 from zope.viewlet.interfaces import IViewletManager, IViewlet
+
+from plone.app.layout.navigation.root import getNavigationRoot
+from plone.app.kss.plonekssview import PloneKSSView
+from kss.core import kssaction, KSSExplicitError
 
 from Products.CMFCore.utils import getToolByName
@@ -22,13 +20,6 @@
 from Products.CMFPlone import utils
 from Products.CMFPlone.browser.navigation import get_view_url
-from Products.Five.browser import BrowserView
 from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
 from Products.statusmessages.interfaces import IStatusMessage
-
-from plone.app.layout.navigation.root import getNavigationRoot
-from plone.app.kss.plonekssview import PloneKSSView
-from plone.app.workflow.remap import remap_workflow
-from plone.memoize.instance import memoize
-from kss.core import kssaction, KSSExplicitError
 
 from quintagroup.plonetabs.config import *
@@ -403,4 +394,7 @@
         section = self.getAutoGenereatedSection(cat_name)
         ksscore.replaceHTML(ksscore.getHtmlIdSelector('autogeneration_section'), section)
+        # and title
+        ksscore.replaceInnerHTML(ksscore.getHtmlIdSelector('plonetabs-form-title'),
+                                 self.getPageTitle(cat_name))
         
         # update category hidden field on adding form
@@ -411,5 +405,8 @@
         
         # hide portal status message
-#        IStatusMessage(self.request).addStatusMessage("")
+        self.kss_hideStatusMessage(ksscore)
+        
+        # hide adding form
+        self.kss_hideAddForm()
     
     @kssaction
@@ -484,7 +481,4 @@
         ksscore.deleteNode(ksscore.getHtmlIdSelector(id))
         
-        # check reorder controls, whether we should hide them
-        #self.kss_checkReorderControls(cat_name)
-        
         # issue portal message
         self.getCommandSet('plone').issuePortalMessage(_(u"'%s' action successfully deleted." % act_id), msgtype="info")
@@ -518,5 +512,5 @@
             # hide adding form
             ksscore.removeClass(ksscore.getHtmlIdSelector('addaction'), 'adding')
-            self.kss_toggleCollapsible(ksscore.getCssSelector('#addaction .collapseAdvanced .headerAdvanced'), collapse='true')
+            self.kss_toggleCollapsible(ksscore.getCssSelector('#addaction .headerAdvanced'), collapse='true')
             
             # set client state var 'plonetabs-addingTitle' to empty string for correct id autogeneration functionality
@@ -534,5 +528,5 @@
             # expand advanced section if there are errors in id or condition
             if errors.has_key('id') or errors.has_key('available_expr'):
-                self.kss_toggleCollapsible(ksscore.getCssSelector('#addaction .collapseAdvanced .headerAdvanced'), collapse='false')
+                self.kss_toggleCollapsible(ksscore.getCssSelector('#addaction .headerAdvanced'), collapse='false')
             
             # send error message
@@ -543,6 +537,20 @@
     
     @kssaction
+    def kss_hideAddForm(self):
+        """"Hide Add form, reset it and remove error messages"""
+        # no server changes, only update client
+        ksscore = self.getCommandSet("core")
+        # hide form itself
+        ksscore.removeClass(ksscore.getHtmlIdSelector('addaction'), 'adding')
+        # collapse advanced section
+        self.kss_toggleCollapsible(ksscore.getCssSelector('#addaction .headerAdvanced'), collapse='true')
+        # reset form inputs
+        self.kss_resetForm(ksscore.getHtmlIdSelector('addaction'))
+        # remove form errors if such exist
+        self.kss_issueErrors({})
+    
+    @kssaction
     def kss_showEditForm(self, id, cat_name):
-        """ Show edit form for given action """
+        """Show edit form for given action"""
         act_id, category, action = self.kss_validateAction(id, cat_name)
         
@@ -561,5 +569,5 @@
     @kssaction
     def kss_hideEditForm(self, id, cat_name):
-        """ Hide edit form for given action """
+        """Hide edit form for given action"""
         act_id, category, action = self.kss_validateAction(id, cat_name)
         
@@ -631,4 +639,17 @@
     # Utility Methods
     #
+    
+    def fixExpression(self, expr):
+        """Fix expression appropriatly for tal format"""
+        if expr.find('/') == 0:
+            return 'string:${portal_url}%s' % expr
+        elif re.compile('^(ht|f)tps?\:', re.I).search(expr):
+            return 'string:%s' % expr
+        #elif re.compile('^(python:|string:|not:|exists:|nocall:|path:)', re.I).search(expr):
+            #return expr
+        elif expr.find(':') != -1:
+            return expr
+        else:
+            return 'string:${object_url}/%s' % expr
     
     def copyAction(self, action):
@@ -719,4 +740,7 @@
             form['visible'] = False
         
+        # fix expression fields
+        form['url_expr'] = self.fixExpression(form['url_expr'])
+        
         # collect all action fields
         for attr in ACTION_ATTRS:
@@ -745,4 +769,8 @@
     # Utility methods for the kss actions management
     #
+    
+    def kss_hideStatusMessage(self, ksscore):
+        """Hide Portal Status Message"""
+        ksscore.setStyle(ksscore.getHtmlIdSelector('kssPortalMessage'), 'display', 'none')
     
     def kss_validateAction(self, id, cat_name):
