Changeset 1193
- Timestamp:
- 08/01/08 03:06:11
- Files:
-
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/kssactions.zcml (modified) (2 diffs)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py (modified) (5 diffs)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/resources/plonetabs.css (modified) (3 diffs)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/resources/plonetabs.kss (modified) (4 diffs)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/templates/actionslist.pt (modified) (6 diffs)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/configure.zcml (modified) (1 diff)
- qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/plugin.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/kssactions.zcml
r1190 r1193 45 45 <browser:page 46 46 for="plone.app.kss.interfaces.IPortalObject" 47 attribute="editAction" 47 attribute="kss_showEditForm" 48 class=".plonetabs.PloneTabsControlPanel" 49 name="plonetabs-showEditForm" 50 permission="cmf.ManagePortal" 51 /> 52 53 <browser:page 54 for="plone.app.kss.interfaces.IPortalObject" 55 attribute="kss_hideEditForm" 56 class=".plonetabs.PloneTabsControlPanel" 57 name="plonetabs-hideEditForm" 58 permission="cmf.ManagePortal" 59 /> 60 61 <browser:page 62 for="plone.app.kss.interfaces.IPortalObject" 63 attribute="kss_editAction" 48 64 class=".plonetabs.PloneTabsControlPanel" 49 65 name="plonetabs-editAction" … … 51 67 /> 52 68 53 <browser:page54 for="plone.app.kss.interfaces.IPortalObject"55 attribute="editCancel"56 class=".plonetabs.PloneTabsControlPanel"57 name="plonetabs-editCancel"58 permission="cmf.ManagePortal"59 />60 61 69 </configure> qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/plonetabs.py
r1192 r1193 451 451 # XXX TODO: fade effect during removing, to do this we need kukit js action/command plugin 452 452 ksscore.deleteNode(ksscore.getHtmlIdSelector(id)) 453 454 # check reorder controls, whether we should hide them 453 455 self.kss_checkReorderControls(cat_name) 456 457 # issue portal message 458 self.getCommandSet('plone').issuePortalMessage(_(u"'%s' action successfully deleted." % act_id), msgtype="info") 459 460 # update different sections of page depending on actions category 454 461 self.updatePage(cat_name) 455 462 456 463 @kssaction 457 def kss_addAction(self , id, category, title, url_expr, available_expr, visible=False):464 def kss_addAction(self): 458 465 """ KSS method to add new portal action """ 459 466 # extract posted data 460 id, cat_name, data = self.parseAddForm({'id':id, 461 'category': category, 462 'title': title, 463 'url_expr': url_expr, 464 'available_expr': available_expr, 465 'visible': visible}) 467 id, cat_name, data = self.parseAddForm(self.request.form) 466 468 467 469 # validate posted data … … 486 488 self.kss_toggleCollapsible(ksscore.getCssSelector('#addaction .collapseAdvanced .headerAdvanced'), collapse='true') 487 489 490 # set client state var 'plonetabs-addingTitle' to empty string for correct id autogeneration functionality 491 ksscore.setStateVar('plonetabs-addingTitle', '') 492 488 493 # reset adding form 489 494 self.kss_resetForm(ksscore.getHtmlIdSelector('addaction')) … … 502 507 kssplone.issuePortalMessage(_(u"Please correct the indicated errors."), msgtype="error") 503 508 504 # update errors on client fo mr509 # update errors on client form 505 510 self.kss_issueErrors(errors) 506 511 507 512 @kssaction 508 def editAction(self, id, category):513 def kss_showEditForm(self, id, cat_name): 509 514 """ Show edit form for given action """ 510 cat_container, act_id = self.validateAction(id, category)511 512 # collectdata513 action_info = self.copyAction( cat_container[act_id])515 act_id, category, action = self.kss_validateAction(id, cat_name) 516 517 # fetch data 518 action_info = self.copyAction(action) 514 519 action_info["editing"] = True 515 520 521 # update client 516 522 ksscore = self.getCommandSet("core") 517 523 content = self.actionslist_template(tabs=[action_info,]) 518 replace_id = id 519 520 ksscore.replaceHTML(ksscore.getHtmlIdSelector(replace_id), content) 524 ksscore.replaceHTML(ksscore.getHtmlIdSelector(id), content) 521 525 522 526 # focus name field 523 ksscore.focus(ksscore.getCssSelector("#%s input[name= name_%s]" % (id, act_id)))527 ksscore.focus(ksscore.getCssSelector("#%s input[name=title_%s]" % (id, act_id))) 524 528 525 529 @kssaction 526 def editCancel(self, id, category):530 def kss_hideEditForm(self, id, cat_name): 527 531 """ Hide edit form for given action """ 528 cat_container, act_id = self.validateAction(id, category) 529 532 act_id, category, action = self.kss_validateAction(id, cat_name) 533 534 # update client 530 535 ksscore = self.getCommandSet("core") 531 content = self.actionslist_template(tabs=[cat_container[act_id],]) 532 replace_id = id 533 534 ksscore.replaceHTML(ksscore.getHtmlIdSelector(replace_id), content) 536 content = self.actionslist_template(tabs=[action,]) 537 ksscore.replaceHTML(ksscore.getHtmlIdSelector(id), content) 538 539 @kssaction 540 def kss_editAction(self): 541 """ KSS Method to update action """ 542 id, cat_name, data = self.parseEditForm(self.request.form) 543 544 # get category and action to edit 545 category = self.getActionCategory(cat_name) 546 action = category[id] 547 548 # validate posted data 549 errors = self.validateActionFields(cat_name, data, allow_dup=True) 550 551 html_id = '%s%s%s' % (self.prefix, id, self.sufix) 552 ksscore = self.getCommandSet('core') 553 kssplone = self.getCommandSet('plone') 554 if not errors: 555 action = self.updateAction(id, cat_name, data) 556 557 # update client 558 # replace action item with updated one 559 content = self.getActionsList(category=cat_name, tabs=[action,]) 560 ksscore.replaceHTML(ksscore.getHtmlIdSelector(html_id), content) 561 562 # issue portal message 563 kssplone.issuePortalMessage(_(u"'%s' action saved." % action.id), msgtype="info") 564 565 # update page 566 self.updatePage(cat_name) 567 else: 568 # issue error messages 569 self.kss_issueErrors(errors, editform=id) 570 571 # expand advanced section if there are errors in id, action url or condition 572 if errors.has_key('id') or errors.has_key('available_expr') or errors.has_key('url_expr'): 573 self.kss_toggleCollapsible(ksscore.getCssSelector('#%s .headerAdvanced' % html_id), collapse='false') 574 575 # send error message 576 kssplone.issuePortalMessage(_(u"Please correct the indicated errors."), msgtype="error") 535 577 536 578 # … … 540 582 def copyAction(self, action): 541 583 """ Copyt action to dictionary """ 542 action_info = { }584 action_info = {'description':action.description} 543 585 for attr in ACTION_ATTRS: 544 586 action_info[attr] = getattr(action, attr) … … 678 720 return (action_id, category, action) 679 721 680 def kss_issueErrors(self, errors, fields=ACTION_ATTRS):722 def kss_issueErrors(self, errors, editform=False, fields=ACTION_ATTRS): 681 723 """ Display error messages on the client """ 682 724 ksscore = self.getCommandSet('core') 683 725 for field in fields: 684 self.kss_issueFieldError(ksscore, field, errors.get(field, False) )685 686 def kss_issueFieldError(self, ksscore, name, error ):726 self.kss_issueFieldError(ksscore, field, errors.get(field, False), editform) 727 728 def kss_issueFieldError(self, ksscore, name, error, editform): 687 729 """ Issue this error message for the field """ 688 field_selector = ksscore.getCssSelector('#addaction .field-%s' % UI_ATTRS.get(name, name)) 689 field_error_selector = ksscore.getCssSelector('#addaction .field-%s .error-container' % UI_ATTRS.get(name, name)) 730 if editform: 731 id = '%s%s%s' % (self.prefix, editform, self.sufix) 732 field_selector = ksscore.getCssSelector('#%s .edit-field-%s' % (id, UI_ATTRS.get(name, name))) 733 field_error_selector = ksscore.getCssSelector('#%s .edit-field-%s .error-container' % (id, UI_ATTRS.get(name, name))) 734 else: 735 field_selector = ksscore.getCssSelector('#addaction .field-%s' % UI_ATTRS.get(name, name)) 736 field_error_selector = ksscore.getCssSelector('#addaction .field-%s .error-container' % UI_ATTRS.get(name, name)) 737 690 738 if error: 691 739 ksscore.replaceInnerHTML(field_error_selector, _(error)) qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/resources/plonetabs.css
r1190 r1193 36 36 #app #addaction.adding .field-action label,*/ 37 37 #app #addaction .field-action label, 38 #app #addaction.adding .collapseAdvanced,38 .kssTabsActive #app #addaction.adding .collapseAdvanced, 39 39 #app #addaction.adding .field-id, 40 40 #app #addaction.adding .field-condition, … … 56 56 .kssTabsActive #app.viewing #tabslist li.editing .url-helper, 57 57 .kssTabsActive #app.viewing #tabslist li.editing .tab-title, 58 /*#app.viewing #tabslist li .url-helper,59 #app.viewing #tabslist li .tab-title,*/60 58 61 59 #app .drag-handle, … … 64 62 /* .kssTabsActive #app .editform, */ 65 63 .kssTabsActive #app .edit-fields-wrapper, 64 .kssTabsActive #app .editdelete, 65 .kssTabsActive #app .editreset, 66 66 #app.sorting #addaction, 67 67 .kssTabsActive #app .field-visible, 68 68 .kssTabsActive #app .field-name dt, 69 69 .kssTabsActive #app .field-action, 70 .kssTabsActive #app .collapseAdvanced,70 .kssTabsActive #app #addaction .collapseAdvanced, 71 71 .kssTabsActive #app .field-id, 72 72 .kssTabsActive #app .field-condition, qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/resources/plonetabs.kss
r1191 r1193 14 14 action-client: addClass; 15 15 addClass-value: kssTabsActive; 16 } 17 18 .add-controls input:load { 19 action-client: addClass; 20 addClass-value: allowMultiSubmit; 21 } 22 23 .edit-controls input:load { 24 action-client: addClass; 25 addClass-value: allowMultiSubmit; 16 26 } 17 27 … … 123 133 action-client: plonetabs-generateId; 124 134 plonetabs-generateId-target: actid; 135 plonetabs-generateId-var_name: plonetabs-addingTitle; 125 136 } 126 137 127 138 /* Actions edit */ 128 139 #tabslist .tab-title:click { 129 action-server: plonetabs-editAction; 130 plonetabs-editAction-id: nodeAttr(id, true); 131 plonetabs-editAction-category: stateVar(plonetabs-category); 140 action-server: plonetabs-showEditForm; 141 plonetabs-showEditForm-id: nodeAttr(id, true); 142 plonetabs-showEditForm-cat_name: stateVar(plonetabs-category); 143 plonetabs-showEditForm-error: plonetabs-handleServerError; 132 144 } 133 145 … … 143 155 #tabslist .editcancel:click { 144 156 evt-click-preventdefault: true; 145 action-server: plonetabs-editCancel; 146 plonetabs-editCancel-id: nodeAttr(id, true); 147 plonetabs-editCancel-category: stateVar(plonetabs-category); 157 action-server: plonetabs-hideEditForm; 158 plonetabs-hideEditForm-id: nodeAttr(id, true); 159 plonetabs-hideEditForm-cat_name: stateVar(plonetabs-category); 160 plonetabs-hideEditForm-error: plonetabs-handleServerError; 148 161 } 149 162 … … 151 164 #tabslist .editsave:click { 152 165 evt-click-preventdefault: true; 153 action-server: plonetabs-edit Save;154 plonetabs-edit Save-id: nodeAttr(id, true);155 plonetabs-edit Save-category: stateVar(plonetabs-category);166 action-server: plonetabs-editAction; 167 plonetabs-editAction-kssSubmitForm: currentForm(); 168 plonetabs-editAction-error: plonetabs-handleServerError; 156 169 } 157 170 qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/browser/templates/actionslist.pt
r1190 r1193 2 2 dummy python:request.RESPONSE.setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT'); 3 3 category python:options.get('category', None) or 'portal_tabs'; 4 errors options/errors| nothing"4 errors options/errors|python:{}" 5 5 tal:repeat="tab options/tabs|python:view.getPortalActions(category)"> 6 6 <li tal:define="id tab/id; … … 40 40 <span class="edit-fields-wrapper"> 41 41 42 <dl tal:define="name string:title_${id}; 42 <dl class="edit-field-name" 43 tal:define="name string:title_${id}; 43 44 error python:errors.get(name, ''); 44 45 tab_title tab/title" 45 tal:attributes="class python:test(error, ' error', '')">46 tal:attributes="class python:test(error, '%s error' % attrs['class'], attrs['class'])"> 46 47 <dt><label>Name</label></dt> 47 48 <dd> … … 55 56 <dt class="headerAdvanced">Advanced</dt> 56 57 <dd class="contentAdvanced"> 57 <dl tal:define="name string:url_expr_${id}; 58 <dl class="edit-field-action" 59 tal:define="name string:url_expr_${id}; 58 60 error python:errors.get(name, ''); 59 61 tab_url tab/url_expr" 60 tal:attributes="class python:test(error, ' error', '')">62 tal:attributes="class python:test(error, '%s error' % attrs['class'], attrs['class'])"> 61 63 <dt><label>URL (Expression)</label></dt> 62 64 <dd> … … 66 68 name name" /></dd> 67 69 </dl> 68 <dl tal:define="name string:id_${id}; 70 <dl class="edit-field-id" 71 tal:define="name string:id_${id}; 69 72 error python:errors.get(name, ''); 70 73 tab_id tab/id" 71 tal:attributes="class python:test(error, ' error', '')">74 tal:attributes="class python:test(error, '%s error' % attrs['class'], attrs['class'])"> 72 75 <dt><label>Id</label></dt> 73 76 <dd> … … 77 80 name name" /></dd> 78 81 </dl> 79 <dl tal:define="name string:available_expr_${id}; 82 <dl class="edit-field-condition" 83 tal:define="name string:available_expr_${id}; 80 84 error python:errors.get(name, ''); 81 85 tab_cond tab/available_expr" 82 tal:attributes="class python:test(error, ' error', '')">86 tal:attributes="class python:test(error, '%s error' % attrs['class'], attrs['class'])"> 83 87 <dt><label>Condition (Expression)</label></dt> 84 88 <dd> … … 92 96 </dl> 93 97 94 <div >98 <div class="edit-controls"> 95 99 <input type="submit" class="editsave" i18n:attributes="value" name="edit.save" value="Save" /> 96 100 <input type="submit" class="editcancel" i18n:attributes="value" name="edit.cancel" value="Cancel" /> qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/configure.zcml
r1191 r1193 44 44 command_factory="selector" 45 45 jsfile="plugin.js" 46 params_mandatory="target "46 params_mandatory="target var_name" 47 47 params_optional="" 48 48 /> qPloneTabs/branches/quintagroup.plonetabs/trunk/quintagroup/plonetabs/plugins/plugin.js
r1191 r1193 94 94 kukit.actionsGlobalRegistry.register("plonetabs-generateId", function(oper) { 95 95 oper.componentName = "[plonetabs-generateId] action"; 96 oper.evaluateParameters(["target" ], {});96 oper.evaluateParameters(["target", "var_name"], {}); 97 97 98 98 var source = oper.node; 99 var var_name = oper.parms.var_name; 100 var initialValue = typeof(kukit.engine.stateVariables[var_name]) != "undefined" ? kukit.engine.stateVariables[var_name] : ''; 99 101 var target = document.getElementById(oper.parms.target); 100 102 … … 104 106 } 105 107 106 if (target.value == kukit.engine.stateVariables['plonetabs-addingTitle'].replace(PLONETABS_ADD_PATTERN, '')) {108 if (target.value == initialValue.replace(PLONETABS_ADD_PATTERN, '')) { 107 109 target.value = source.value.replace(PLONETABS_ADD_PATTERN, ''); 108 110 } 109 kukit.engine.stateVariables[ 'plonetabs-addingTitle'] = source.value;111 kukit.engine.stateVariables[var_name] = source.value; 110 112 111 113 });
