{# main form macros #} {# /\ #} {# / \ #} {# / | \ #} {# / | \ #} {# / | \ #} {# / o \ #} {# /____________\ #} {# Note: NEVER EVER use the macros' parameters in a positional style, always #} {# use keyword parameters!!! #} {# NEW style: bscwSegment #} {# REMOVED keyword param 'last' #} {# NOTE: for compatibility we could consume kwargs: #} {# {% if kwargs %}{% endif %} #} {%- macro segment(title='', cl='bscwSegment', content=None, extra='') -%} {%- if not request.is_mobile -%}
{%- if title -%}

{{ title }}

{%- endif -%} {%- endif -%} {{ content or caller() }} {%- if not request.is_mobile -%}
{%- endif -%} {%- endmacro -%} {# NEW style: bscwFieldTable #} {%- macro fieldtable() -%} {%- if not request.is_mobile -%} {{ caller() }}
{%- else -%} {{ caller() }} {%- endif -%} {%- endmacro -%} {# NEW style: bscwBox #} {%- macro box(title='', table=False, cl='bscwBox', title_field_type=None, title_field_name='', title_field_id='', title_field_value=None, title_field_checked=False, title_field_extra='', content=None) -%} {%- if title or title_field_type -%}

{%- if title_field_type -%} {{ title }} {%- else -%} {{ title }} {%- endif -%}

{%- endif -%} {%- set __caller__=content or caller() -%} {%- if __caller__.strip() -%} {%- if not request.is_mobile -%}
{%- endif -%} {%- if table -%} {%- call fieldtable() %}{{ __caller__ }}{% endcall -%} {%- else -%} {{ __caller__ }} {%- endif -%} {%- if not request.is_mobile -%}
{%- endif -%} {%- endif -%} {%- endmacro -%} {# NEW style: bscwMsgBox #} {%- macro msgbox(title='', cl='bscwMsgBox', content=None) -%} {%- set __caller__=content or caller() -%} {%- call box(title=title, table=False, cl='ui-body ui-body-e' if request.is_mobile else cl) -%} {{ __caller__ }} {%- endcall -%} {%- endmacro -%} {# NEW style: bscwError #} {%- macro err(text='', cl='bscwError') -%} {{ text }}
{%- endmacro -%} {# input error handling #} {%- macro field_error(errorid='', errormsg='') -%} {%- set errorids = errorid.split(',') if errorid != '' else [] -%} {%- set errormsgs = errormsg.split(',') if errormsg != '' else [] -%} {%- for errorid in errorids -%} {%- set errorid=errorid.strip() -%} {%- if get_variable(errorid + '_Err_') -%} {{ err(get_variable(errorid + '_Err_')) }} {%- endif -%} {%- endfor -%} {%- for errormsg in errormsgs -%} {%- set errormsg=errormsg.strip() -%} {%- if is_defined(errormsg) -%} {{ err(trans(errormsg)) }} {%- endif -%} {%- endfor -%} {%- endmacro -%} {# _field_label is an inner macro used for a {%- endif -%} {%- endmacro -%} {# _field_input is an inner macro used for an #} {# NEW style: bscwInputField #} {%- macro _field_input(checked=False, cl='bscwInputField ', extra='', name='', multiple=False, size='long', id='', type='text', value=None, disabled=False) -%} {%- if type == 'content' -%} {%- if request.is_mobile -%}
{%- endif -%} {{ caller() }} {%- if request.is_mobile -%}
{%- endif -%} {%- else -%} {%- if type in ('checkbox', 'radio') -%} {%- set value = value if not value == None else '1' -%} {%- endif -%} {%- set __caller__=caller() if caller is defined else '' -%} <{% if type == 'select' %}select{% elif type == 'textarea' %}textarea{% else %}input type="{{ type }}"{% endif -%} {%- if id or name %} id="{{ id or name }}"{% endif -%} {%- if name %} name="{{ name }}"{% endif -%} {%- if not type == 'textarea' %} value="{{ value if not value == None else '' }}"{% endif -%} {%- if not request.is_mobile -%} {%- if type not in ('checkbox', 'radio') %} class="{{ cl }}{% if size != 'auto' %} {{ size }}{% endif %}"{% endif -%} {%- endif -%} {%- if checked %} checked="checked"{% endif -%} {%- if disabled %} disabled="disabled"{% endif -%} {%- if multiple %} multiple="multiple"{% endif -%} {%- if extra %} {{ extra }}{% endif -%} {%- if not __caller__ and type != 'textarea' %} /{% endif %}> {%- if __caller__ or type == 'textarea' -%} {%- if type == 'textarea' %}{{ value or __caller__ }}{% else %}{{ __caller__ }}{% endif -%} {%- endif -%} {%- endif -%} {%- endmacro %} {# NEW style: bscwWideCol #} {# NEW style: bscwInputField #} {%- macro tablefield(checked=False, cl='bscwInputField', errorid='', errormsg='', extra='', help='', id='', label='', multiple=False, name='', nocolon=False, rowid='', rowspan=1, size='long', title='', type='text', value=None, disabled=False) -%} {%- if not request.is_mobile -%} {########## DesktopMode ##########} {%- set __caller__=caller() if caller is defined else '' -%} {%- if rowspan != 0 -%} 1 %} rowspan="{{ rowspan }}"{% endif %}> {%- call _field_label(label=label if type not in ('checkbox', 'radio') else title, name=name, nocolon=nocolon, id=id, type=type) -%} {{ __caller__ }} {%- endcall -%} {%- endif -%} {{ field_error(errorid=errorid, errormsg=errormsg) }} {%- call _field_input(checked=checked, cl=cl, extra=extra, name=name, multiple=multiple, size=size, id=id, type=type, value=value, disabled=disabled) -%} {%- if label != '@inside' %}{{ __caller__ }}{% endif -%} {%- endcall -%} {%- if type in ('checkbox', 'radio') -%} {%- call _field_label(label=label, name=name, nocolon=True, id=id, type=type) -%} {{ __caller__ }} {%- endcall -%} {%- endif -%} {%- if help != '' -%} {{ help }} {%- endif -%} {########## /DesktopMode ##########} {%- else -%} {########## MobileMode ##########} {%- set __caller__=caller() if caller is defined else '' -%}
{%- if type in ('checkbox', 'radio') -%}
{%- if title %}{{ title }}{% if not nocolon %}:{% endif %}{% endif -%} {%- call _field_input(checked=checked, cl=cl, extra=extra, name=name, multiple=multiple, size=size, id=id, type=type, value=value, disabled=disabled) -%} {%- if label != '@inside' -%} {{ __caller__ }} {%- endif -%} {%- endcall -%} {{ field_error(errorid=errorid, errormsg=errormsg) }} {%- call _field_label(label=label, name=name, nocolon=nocolon, id=id, type=type) -%} {{ __caller__ }} {%- endcall -%}
{%- else -%} {%- call _field_label(label=label, name=name, nocolon=nocolon, id=id, type=type) -%} {{ __caller__ }} {%- endcall -%} {{ field_error(errorid=errorid, errormsg=errormsg) }} {%- call _field_input(checked=checked, cl=cl, extra=extra, name=name, multiple=multiple, size=size, id=id, type=type, value=value, disabled=disabled) -%} {%- if label != '@inside' -%} {{ __caller__ }} {%- endif -%} {%- endcall -%} {%- endif -%}
{########## /MobileMode ##########} {%- endif -%} {%- endmacro -%} {# NEW style: bscwInputField #} {%- macro singlefield(label='', checked=False, cl='bscwInputField', errorid='', errormsg='', extra='', name='', multiple=False, id='', nocolon=False, size='long', type='text', value=None, disabled=False) -%} {%- set __caller__=caller() if caller is defined else '' -%} {%- if type not in ('checkbox', 'radio') -%} {%- call _field_label(label=label, name=name, nocolon=nocolon, type=type, id=id) -%}) {{ __caller__ }} {%- endcall -%}{{ ' ' }} {%- endif -%} {{ field_error(errorid=errorid, errormsg=errormsg) }} {%- call _field_input(checked=checked, cl=cl, extra=extra, name=name, multiple=multiple, size=size, id=id, type=type, value=value, disabled=disabled) -%} {{ __caller__ }} {%- endcall -%} {%- if type in ('checkbox', 'radio') -%} {{ ' ' }}{%- call _field_label(label=label, name=name, nocolon=True, type=type, id=id) -%}) {{ __caller__ }} {%- endcall -%} {%- endif -%} {%- endmacro -%} {# NEW style: bscwInputButtonWrapper #} {%- macro innerbtngroup(cl='bscwInputButtonWrapper', content=None) -%} {%- if cl and not request.is_mobile -%}
{%- endif -%} {{ content or caller() }} {%- if cl and not request.is_mobile -%}
{%- endif -%} {%- endmacro -%} {# NEW style: bscwInputButton #} {# TODO: minor button 'html' #} {%- macro innerbtn(extra='', icon='', id='', name='', type='submit', cl='bscwInputButton', value=None) -%} {%- set name = name or id -%} {%- set id = id or name -%} {%- if type != 'html' -%} {%- endif -%} {%- if not request.is_mobile -%}
{%- endif -%} {%- if caller is defined -%} {{ caller() or value }} {%- else -%} {{ value }} {%- endif -%} {%- if not request.is_mobile -%}
{%- endif -%} {%- if type != 'html' -%} {%- endif -%} {%- endmacro -%}