Changeset 11437
- Timestamp:
- 26 Feb 2014, 07:54:30 (11 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r11436 r11437 4 4 1.0.1dev (unreleased) 5 5 ===================== 6 7 * JSAction has been deprecated. KofaAction can be used instead. Additional 8 parameters can be used in @action decorators to enable tooltips and/or 9 warning windows. The old @jsaction decorator still triggers a default 10 warning message. 6 11 7 12 * jquery-ui.min.js is also used for tooltips. -
main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
r11254 r11437 47 47 from waeup.kofa.browser.breadcrumbs import Breadcrumb 48 48 from waeup.kofa.browser.layout import ( 49 NullValidator, jsaction, action, UtilityView , JSAction)49 NullValidator, jsaction, action, UtilityView) 50 50 from waeup.kofa.browser.pages import ( 51 51 add_local_role, del_local_roles, doll_up, ExportCSVView) … … 64 64 grok.context(IKofaObject) # Make IKofaObject the default context 65 65 66 class SubmitJSAction(JSAction): 67 68 msg = _('\'You can not edit your application records after final submission.' 69 ' You really want to submit?\'') 70 71 class submitaction(grok.action): 72 73 def __call__(self, success): 74 action = SubmitJSAction(self.label, success=success, **self.options) 75 self.actions.append(action) 76 return action 66 WARNING = _('You can not edit your application records after final submission.' 67 ' You really want to submit?') 77 68 78 69 class ApplicantsRootPage(KofaDisplayFormPage): … … 1033 1024 return 1034 1025 1035 @ submitaction(_('Final Submit'))1026 @action(_('Final Submit'), warning=WARNING) 1036 1027 def finalsubmit(self, **data): 1037 1028 if self.upload_success is False: # False is not None! -
main/waeup.kofa/trunk/src/waeup/kofa/browser/layout.py
r11254 r11437 69 69 class KofaAction(Action): 70 70 71 def __init__(self, label, style='', **options):71 def __init__(self, label, style='', tooltip='', warning='', **options): 72 72 super(KofaAction, self).__init__(label, **options) 73 73 self.style = style 74 self.tooltip = tooltip 75 self.warning = warning 74 76 if style == '': 75 77 self.style = 'default' 76 77 78 78 79 def render(self): … … 82 83 if isinstance(label, Message): 83 84 label = translate(self.label, context=self.form.request) 84 return ('<input type="submit" id="%s" name="%s" value="%s"' 85 ' class="btn btn-%s"/>' % 86 (self.__name__, self.__name__, escape(label, quote=True), 87 self.style)) 85 if self.warning: 86 warning = translate(self.warning, context=self.form.request) 87 self.warning = ' onclick="return window.confirm(\'%s\')"' % warning 88 if self.tooltip: 89 tooltip = translate(self.tooltip, context=self.form.request) 90 self.tooltip = ' data-toggle="tooltip" title="%s"' % tooltip 91 if self.style: 92 style = ' class="btn btn-%s"' % self.style 93 else: 94 style = ' class="btn btn-default"' 95 html = ('<input type="submit" id="%s" name="%s" value="%s"' % 96 (self.__name__, self.__name__, escape(label, quote=True)) 97 + style + self.tooltip + self.warning 98 + ' />') 99 return html 88 100 89 101 class jsaction(grok.action): 90 102 103 msg = _('Are you sure?') 104 91 105 def __call__(self, success): 92 action = JSAction(self.label, success=success, **self.options) 106 action = KofaAction(self.label, 107 success=success, warning=self.msg, 108 **self.options) 93 109 self.actions.append(action) 94 110 return action 95 96 class JSAction(Action):97 98 msg = _('\'Are you sure?\'')99 100 def __init__(self, label, style='', **options):101 super(JSAction, self).__init__(label, **options)102 self.style = style103 if style == '':104 self.style = 'default'105 106 def render(self):107 if not self.available():108 return ''109 label = self.label110 if isinstance(label, Message):111 label = translate(self.label, context=self.form.request)112 msg = translate(self.msg, context=self.form.request)113 return ('<input type="submit" id="%s" name="%s" value="%s"'114 ' class="btn btn-%s" onclick="return window.confirm(%s)" />' %115 (self.__name__, self.__name__, escape(label, quote=True),116 self.style, msg)117 )118 111 119 112 def NullValidator(*args, **kw):
Note: See TracChangeset for help on using the changeset viewer.