Changeset 1188
- Timestamp:
- 07/29/08 07:18:47
- Files:
-
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py (modified) (5 diffs)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/resources/plonetabs.kss (modified) (1 diff)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/templates/actionslist.pt (modified) (1 diff)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/configure.zcml (modified) (1 diff)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/plugin.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py
r1186 r1188 42 42 # custom templates used to update page sections 43 43 sections_template = ViewPageTemplateFile("templates/sections.pt") 44 45 # configuration variables 46 prefix = "tabslist_" 47 sufix = "" 44 48 45 49 def __call__(self): … … 367 371 ########################## 368 372 369 def validateAction(self, id, category, prefix="tabslist_"):370 """ If action with given id and category doesn't exist - raise kss exception """371 portal_actions = getToolByName(self.context, "portal_actions")372 373 # remove prefix, added for making ids on configlet unique ("tabslist_")374 act_id = id[len("tabslist_"):]375 376 if category not in portal_actions.objectIds():377 raise KSSExplicitError, "Unexistent root portal actions category %s" % category378 379 cat_container = portal_actions[category]380 if act_id not in map(lambda x: x.id, filter(lambda x: IAction.providedBy(x), cat_container.objectValues())):381 raise KSSExplicitError, "%s action does not exist in %s category" % (act_id, category)382 383 return (cat_container, act_id)384 385 373 @kssaction 386 374 def toggleGeneratedTabs(self, field, checked='0'): … … 421 409 ksscore.addClass(ksscore.getHtmlIdSelector(id), value="invisible") 422 410 423 self.updatePage(cat egory)411 self.updatePage(cat_name) 424 412 425 413 @kssaction … … 451 439 452 440 @kssaction 453 def kss_deleteAction(self, id, cat egory):441 def kss_deleteAction(self, id, cat_name): 454 442 """ Delete portal action with given id & category """ 455 portal_actions = getToolByName(self.context, "portal_actions") 456 cat_container, act_id = self.validateAction(id, category) 457 458 cat_container.manage_delObjects(ids=[act_id,]) 459 460 # update action list on client 443 # validate input 444 act_id, category, action = self.kss_validateAction(id, cat_name) 445 self.deleteAction(act_id, cat_name) 446 447 # update client 461 448 ksscore = self.getCommandSet("core") 462 463 449 ksscore.deleteNode(ksscore.getHtmlIdSelector(id)) 464 465 # add "noitems" class to Reorder controls to hide it 466 if not filter(lambda x: IAction.providedBy(x), cat_container.objectValues()): 467 ksscore.addClass(ksscore.getHtmlIdSelector("reorder"), value="noitems") 468 450 self.kss_checkReorderControls(category) 469 451 # XXX TODO: fade effect during removing, for this kukit js action/command plugin needed 470 471 self.updatePage(category) 452 self.updatePage(cat_name) 472 453 473 454 @kssaction … … 617 598 site_properties.manage_changeProperties(**kw) 618 599 return True 600 601 # 602 # Utility methods for the kss actions management 603 # 604 605 def kss_checkReorderControls(self, category): 606 """ Add "noitems" class to Reorder controls to hide them if category is empty """ 607 if not filter(lambda x: IAction.providedBy(x), category.objectValues()): 608 ksscore = self.getCommandSet('core') 609 ksscore.addClass(ksscore.getHtmlIdSelector("reorder"), value="noitems") 610 611 def kss_validateAction(self, id, cat_name): 612 """ Check whether action with given id exists in cat_name category """ 613 try: 614 category = self.getActionCategory(cat_name) 615 except Exception: 616 raise KSSExplicitError, "'%s' action category does not exist" % cat_name 617 618 # extract action id from given list item id on client 619 action_id = self.sufix and id[len(self.prefix):-len(self.sufix)] or id[len(self.prefix):] 620 try: 621 action = category[action_id] 622 except Exception: 623 raise KSSExplicitError, "No '%s' action in '%s' category." % (action_id, cat_name) 624 625 return (action_id, category, action) 626 627 def validateAction(self, id, category, prefix="tabslist_"): 628 """ If action with given id and category doesn't exist - raise kss exception """ 629 portal_actions = getToolByName(self.context, "portal_actions") 630 631 # remove prefix, added for making ids on configlet unique self.prefix 632 act_id = id[len(self.prefix):] 633 634 if category not in portal_actions.objectIds(): 635 raise KSSExplicitError, "Unexistent root portal actions category %s" % category 636 637 cat_container = portal_actions[category] 638 if act_id not in map(lambda x: x.id, filter(lambda x: IAction.providedBy(x), cat_container.objectValues())): 639 raise KSSExplicitError, "%s action does not exist in %s category" % (act_id, category) 640 641 return (cat_container, act_id) 619 642 620 643 # qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/resources/plonetabs.kss
r1174 r1188 72 72 action-server: plonetabs-deleteAction; 73 73 plonetabs-deleteAction-id: nodeAttr(id, true); 74 plonetabs-deleteAction-category: stateVar(plonetabs-category); 74 plonetabs-deleteAction-cat_name: stateVar(plonetabs-category); 75 plonetabs-deleteAction-error: plonetabs-handleServerError; 75 76 } 76 77 qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/templates/actionslist.pt
r1179 r1188 9 9 klass python:test(visible, [], ['invisible']); 10 10 klass python:test(editing, klass + ['editing'], klass)" 11 tal:attributes="id string: tabslist_${id};11 tal:attributes="id string:${view/prefix}${id}; 12 12 title tab/description; 13 13 class python:' '.join(klass)"> 14 14 15 15 <img class="drag-handle" src="++resource++drag.gif" alt="" height="11" width="25" /> 16 17 <a class="delete" href="#" 18 tal:attributes="href string:${context/portal_url}/@@plonetabs-controlpanel?action=delete_action&category=${category}&id=${id}">Delete</a> 16 <a class="delete" href="#">Delete</a> 19 17 20 18 <span class="url-helper" tal:content="tab/url_expr">Tab Action</span> qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/configure.zcml
r1174 r1188 24 24 params_optional="collapsed expanded" 25 25 /> 26 27 <kss:action 28 name="plonetabs-handleServerError" 29 jsfile="plugin.js" 30 params_mandatory="" 31 params_optional="message" 32 /> 26 33 27 34 </configure> qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/plugin.js
r1174 r1188 58 58 kukit.commandsGlobalRegistry.registerFromAction("plonetabs-toggleCollapsible", kukit.cr.makeSelectorCommand); 59 59 60 60 kukit.actionsGlobalRegistry.register("plonetabs-handleServerError", function(oper) { 61 oper.componentName = "[plonetabs-handleServerError] action"; 62 oper.evaluateParameters([], {"message" : kukit.E}); 63 alert(oper.parms.message); 64 });
