def present(self, **kwargs: object) -> XMLContent: form = cast(_FormPresenter, kwargs['form']) attributes = self._attributes name = cast(Optional[str], attributes.get('name')) focus = form.addControl(name, True) value = cast(Optional[str], attributes.get('value')) if value is None: value = 'submit' attributes = dict(attributes, value = value) label: XMLContent = tuple(self._presentContents(**kwargs)) if not label: # Automatically create label. words: Sequence[str] if isinstance(value, Enum): words = (value.name.lower(), ) else: words = value.split('_') label = ' '.join(word.capitalize() for word in words) button = xhtml.button(autofocus=focus, **attributes)[ label ] if button.attrs['value'] == 'cancel': return button(formnovalidate=True) else: return button
def present(self, **kwargs: object) -> XMLContent: form = cast(_FormPresenter, kwargs['form']) form.hasClearButton = True label: XMLContent = tuple(self._presentContents(**kwargs)) if not label: label = 'Clear' return xhtml.button(**self._attributes)[ label ]
def presentCell(self, record: Scheduled, **kwargs: object) -> XMLContent: if record.isDone(): return None else: suspend = not record.isSuspended() return xhtml.button( name=f'action.{record.getId()}', type='submit', value=Actions.SUSPEND if suspend else Actions.RESUME)['Suspend' if suspend else 'Resume']
def present(self, **kwargs: object) -> XMLContent: form = cast(_FormPresenter, kwargs['form']) attributes = self._attributes name = cast(Optional[str], attributes.get('name')) # Note: Add the back button as no-focus control instead of # visible control, since the latter would give the # top back button focus in Dialog-based pages. form.addControl(name, False) if name is None: attributes = dict(attributes, disabled = True) label: XMLContent = tuple(self._presentContents(**kwargs)) if not label: label = '< Back' return xhtml.button(**attributes)[ label ]
def _scriptButton(select: bool, inputName: str = 'sel') -> XMLNode: return xhtml.button(type='button', tabindex=1, onclick=f"setSelection(form, '{inputName}', " f"{'true' if select else 'false'});")
def present(self, **kwargs: object) -> XMLContent: label: XMLContent = tuple(self._presentContents(**kwargs)) if not label: label = 'Revert' return xhtml.button(**self._attributes)[ label ]
if name is None: attributes = dict(attributes, disabled = True) label: XMLContent = tuple(self._presentContents(**kwargs)) if not label: label = '< Back' return xhtml.button(**attributes)[ label ] backButton = _BackButton( (), dict(tabindex=2, formnovalidate=True, type='submit', value='back') ) disabledButton = xhtml.button( type = 'button', tabindex = 1, disabled = True ) def actionButtons(*values: Union[XMLAttributeValue, Type[Enum]], name: str = 'action', **kwargs: XMLAttributeValue ) -> XML: '''Creates a series of buttons with the given submission values and labels derived from those values. Returns an XML node containing the button widgets, separated by spaces. The keyword arguments are used as HTML attributes on each button. The value arguments can either be string and Enums. ''' valueStrings = [] for value in values: if isinstance(value, str):