def _get_swap_wdg(my, event_id=''): swap_wdg = SwapDisplayWdg(on_event_name='on_%s'%event_id, off_event_name='off_%s'%event_id) icon1 = IconWdg('open', IconWdg.INFO_CLOSED_SMALL) icon2 = IconWdg('close', IconWdg.INFO_OPEN_SMALL) swap_wdg.set_display_widgets(icon1, icon2) return swap_wdg
def _get_swap_wdg(self, event_id=''): swap_wdg = SwapDisplayWdg(on_event_name='on_%s' % event_id, off_event_name='off_%s' % event_id) icon1 = IconWdg('open', IconWdg.INFO_CLOSED_SMALL) icon2 = IconWdg('close', IconWdg.INFO_OPEN_SMALL) swap_wdg.set_display_widgets(icon1, icon2) return swap_wdg
def get_info_wdg(my): widget = Widget() table = Table() table.set_class("minimal") table.add_style("font-size: 0.8em") context_option = my.kwargs.get('context') context_expr_option = my.kwargs.get('context_expr') pipeline_option = my.kwargs.get('pipeline') in ['true', True, 'True'] setting_option = my.kwargs.get('setting') context_name = "%s|context" % my.get_input_name() text = None span1 = SpanWdg("Context", id='context_mode') span2 = SpanWdg("Context<br/>/Subcontext", id='subcontext_mode') span2.add_style('display', 'none') table.add_cell(span1) table.add_data(span2) if context_expr_option or context_option or setting_option: # add swap display for subcontext only if there is setting or context option swap = SwapDisplayWdg() table.add_data(SpanWdg(swap, css='small')) swap.set_display_widgets(StringWdg('[+]'), StringWdg('[-]')) subcontext_name = "%s|subcontext" % my.get_input_name() subcontext = SpanWdg('/ ', css='small') subcontext.add(TextWdg(subcontext_name)) subcontext.add_style('display', 'none') subcontext.set_id(subcontext_name) on_script = "set_display_on('%s');swap_display('subcontext_mode','context_mode')" % subcontext_name off_script = "set_display_off('%s');get_elements('%s').set_value(''); "\ "swap_display('context_mode','subcontext_mode')"%(subcontext_name, subcontext_name) swap.add_action_script(on_script, off_script) text = SelectWdg(context_name) if my.sobjects: text.set_sobject(my.sobjects[0]) if context_expr_option: text.set_option('values_expr', context_expr_option) elif context_option: text.set_option('values', context_option) elif setting_option: text.set_option('setting', setting_option) td = table.add_cell(text) table.add_data(subcontext) elif pipeline_option: from pyasm.biz import Pipeline sobject = my.sobjects[0] pipeline = Pipeline.get_by_sobject(sobject) context_names = [] process_names = pipeline.get_process_names(recurse=True) for process in process_names: context_names.append(pipeline.get_output_contexts(process)) text = SelectWdg(context_name) text.set_option('values', process_names) table.add_cell(text) else: text = TextWdg(context_name) table.add_cell(text) hint = HintWdg('If not specified, the default is [publish]') table.add_data(hint) revision_cb = CheckboxWdg('%s|is_revision' %my.get_input_name(),\ label='is revision', css='med') table.add_data(revision_cb) table.add_row() table.add_cell("Comment") textarea = TextAreaWdg("%s|description" % my.get_input_name()) table.add_cell(textarea) widget.add(table) return widget
def get_info_wdg(my): widget = Widget() table = Table() table.set_class("minimal") table.add_style("font-size: 0.8em") context_option = my.kwargs.get('context') context_expr_option = my.kwargs.get('context_expr') pipeline_option = my.kwargs.get('pipeline') in ['true', True, 'True'] setting_option = my.kwargs.get('setting') context_name = "%s|context" % my.get_input_name() text = None span1 = SpanWdg("Context", id='context_mode') span2 = SpanWdg("Context<br/>/Subcontext", id='subcontext_mode') span2.add_style('display','none') table.add_cell(span1) table.add_data(span2) if context_expr_option or context_option or setting_option: # add swap display for subcontext only if there is setting or context option swap = SwapDisplayWdg() table.add_data(SpanWdg(swap, css='small')) swap.set_display_widgets(StringWdg('[+]'), StringWdg('[-]')) subcontext_name = "%s|subcontext" % my.get_input_name() subcontext = SpanWdg('/ ', css='small') subcontext.add(TextWdg(subcontext_name)) subcontext.add_style('display','none') subcontext.set_id(subcontext_name) on_script = "set_display_on('%s');swap_display('subcontext_mode','context_mode')"%subcontext_name off_script = "set_display_off('%s');get_elements('%s').set_value(''); "\ "swap_display('context_mode','subcontext_mode')"%(subcontext_name, subcontext_name) swap.add_action_script(on_script, off_script) text = SelectWdg(context_name) if my.sobjects: text.set_sobject(my.sobjects[0]) if context_expr_option: text.set_option('values_expr', context_expr_option) elif context_option: text.set_option('values', context_option) elif setting_option: text.set_option('setting', setting_option) td = table.add_cell(text) table.add_data(subcontext) elif pipeline_option: from pyasm.biz import Pipeline sobject = my.sobjects[0] pipeline = Pipeline.get_by_sobject(sobject) context_names = [] process_names = pipeline.get_process_names(recurse=True) for process in process_names: context_names.append(pipeline.get_output_contexts(process)) text = SelectWdg(context_name) text.set_option('values', process_names) table.add_cell(text) else: text = TextWdg(context_name) table.add_cell(text) hint = HintWdg('If not specified, the default is [publish]') table.add_data(hint) revision_cb = CheckboxWdg('%s|is_revision' %my.get_input_name(),\ label='is revision', css='med') table.add_data(revision_cb) table.add_row() table.add_cell("Comment") textarea = TextAreaWdg("%s|description"% my.get_input_name()) table.add_cell(textarea) widget.add(table) return widget