def get_add_tab_wdg(my): span = SpanWdg(css="hand") span.add("+Add+") from web_wdg import EditLinkWdg link = EditLinkWdg(search_type="sthpw/widget_extend", search_id=-1, text="Create New Tab", config_base="tab_extend", action='CreateTabCmd') link.set_refresh_mode("page") span.add(link) popup = PopupMenuWdg("add_tab"); popup.add("Add New Tab") span.add(popup) span.add_event("onclick", "toggle_display('add_tab')") return span
def get_button_wdg(self, script_name): func_name = script_name custom_script = self.get_custom_script(script_name) script = HtmlElement.script(''' %s = function() { %s } ''' % (func_name, custom_script)) button = SpanWdg() button.add_class("hand") button.add(script) button.add("[%s]" % script_name) button.add_event("onclick", "%s()" % func_name) return button
def get_button_wdg(my, script_name): func_name = script_name custom_script = my.get_custom_script(script_name) script = HtmlElement.script(''' %s = function() { %s } ''' % (func_name, custom_script) ) button = SpanWdg() button.add_class("hand") button.add(script) button.add("[%s]" % script_name) button.add_event("onclick", "%s()" % func_name) return button
def get_add_tab_wdg(my): span = SpanWdg(css="hand") span.add("+Add+") from web_wdg import EditLinkWdg link = EditLinkWdg(search_type="sthpw/widget_extend", search_id=-1, text="Create New Tab", config_base="tab_extend", action='CreateTabCmd') link.set_refresh_mode("page") span.add(link) popup = PopupMenuWdg("add_tab") popup.add("Add New Tab") span.add(popup) span.add_event("onclick", "toggle_display('add_tab')") return span
def get_link_wdg(my, section_id, target_id, title, options): view_link_wdg = SpanWdg(css="hand") view_link_wdg.add_class("SPT_DTS") view_link_wdg.add_style("color: #292929") view_link_wdg.add_event("onmouseover", "this.style.background='#696969'") view_link_wdg.add_event("onmouseout", "this.style.background='#949494'") view_link_wdg.add(title) path = title options['path'] = "/%s" % title if not options.get('class_name'): options['class_name'] = "tactic.ui.panel.ViewPanelWdg" behavior = { 'type': 'click_up', 'cbfn_action': 'spt.side_bar.display_link_cbk', 'target_id': target_id, 'title': title, 'options': options, } view_link_wdg.add_behavior(behavior) options2 = options.copy() options2['inline_search'] = "true" behavior = { 'type': 'click_up', 'modkeys': 'SHIFT', 'cbfn_action': 'spt.side_bar.display_link_cbk', 'is_popup': 'true', 'target_id': path, 'title': title, 'options': options2, } view_link_wdg.add_behavior(behavior) return view_link_wdg
def get_link_wdg(my, section_id, target_id, title, options): view_link_wdg = SpanWdg(css="hand") view_link_wdg.add_class("SPT_DTS") view_link_wdg.add_style("color: #292929") view_link_wdg.add_event("onmouseover", "this.style.background='#696969'") view_link_wdg.add_event("onmouseout", "this.style.background='#949494'") view_link_wdg.add(title) path = title options['path'] = "/%s" % title if not options.get('class_name'): options['class_name'] = "tactic.ui.panel.ViewPanelWdg" behavior = { 'type': 'click_up', 'cbfn_action': 'spt.side_bar.display_link_cbk', 'target_id': target_id, 'title': title, 'options': options, } view_link_wdg.add_behavior( behavior ) options2 = options.copy() options2['inline_search'] = "true" behavior = { 'type': 'click_up', 'modkeys': 'SHIFT', 'cbfn_action': 'spt.side_bar.display_link_cbk', 'is_popup': 'true', 'target_id': path, 'title': title, 'options': options2, } view_link_wdg.add_behavior( behavior ) return view_link_wdg
def get_display(my): web = WebContainer.get_web() widget = DivWdg() widget.add_class("spt_search_limit_top") #widget.add_style("border", "solid 1px blue") widget.add_color("background", "background") widget.add_color("color", "color") widget.add_style("padding: 5px") hidden = HiddenWdg("prefix", my.prefix) widget.add(hidden) if not my.search and not my.sobjects: widget.add("No search or sobjects found") return widget # my.count should have been set in alter_search() # which can be called explicitly thru this instance, my. if not my.count: my.count = my.search.get_count(no_exception=True) # if my.sobjects exist thru inheriting from parent widgets # or explicitly set, (this is not mandatory though) if my.sobjects and len(my.sobjects) < my.search_limit: limit = len(my.sobjects) elif my.search and my.count < my.search_limit: # this is only true if the total result of the search is # less than the limit and so this wdg will not display limit = my.count else: limit = my.search_limit if not limit: limit = 50 my.search_limit = limit if my.refresh: prev = SpanWdg( IconButtonWdg("Prev", IconWdg.LEFT, False ) ) prev.add_style("margin-left: 8px") prev.add_style("margin-right: 6px") prev.add_style("margin-top: -2px") next = IconButtonWdg("Next", IconWdg.RIGHT, False, icon_pos="right" ) next.add_style("margin-left: 6px") prev.add_behavior( { 'type': 'click_up', 'cbjs_action': my.refresh_script } ) next.add_behavior( { 'type': 'click_up', 'cbjs_action': my.refresh_script } ) else: # the old code pre 2.5 prev = IconButtonWdg("Prev", IconWdg.LEFT, False ) hidden_name = my.prev_hidden_name hidden = HiddenWdg(hidden_name,"") prev.add(hidden) prev.add_event('onclick'," spt.api.Utility.get_input(document,'%s').value ='Prev';%s"\ %(hidden_name, my.refresh_script)) next = IconButtonWdg("Next", IconWdg.RIGHT, False, icon_pos="right" ) hidden_name = my.next_hidden_name hidden = HiddenWdg(hidden_name,"") next.add(hidden) next.add_event('onclick',"spt.api.Utility.get_input(document,'%s').value ='Next';%s" \ %(hidden_name, my.refresh_script)) showing_wdg = DivWdg() widget.add(showing_wdg) showing_wdg.add_style("padding: 10px") showing_wdg.add_style("margin: 10px") showing_wdg.add_color("background", "background", -5) showing_wdg.add_border() label_span = SpanWdg("Showing: ") showing_wdg.add(label_span) showing_wdg.add( prev ) # this min calculation is used so that if my.sobjects is not set # above for the calculation of the limit, which will make the last # set of range numbers too big left_bound = my.current_offset+1 if not limit: # prevent error in ItemsNavigatorWdg if a search encounters query error limit = 50 my.search_limit = limit right_bound = min(my.current_offset+limit, my.count) if left_bound > right_bound: left_bound = 1 current_value = "%d - %d" % (left_bound, right_bound) if my.style == my.SIMPLE: showing_wdg.add( current_value ) else: # add a range selector using ItemsNavigatorWdg from pyasm.widget import ItemsNavigatorWdg selector = ItemsNavigatorWdg(my.label, my.count, my.search_limit) selector.select.add_behavior( { 'type': 'change', 'cbjs_action': my.refresh_script } ) selector.set_style(my.style) selector.set_value(current_value) selector.set_display_label(False) showing_wdg.add( selector) showing_wdg.add( next ) #showing_wdg.add( " x ") showing_wdg.add(my.text) my.text.add_style("margin-top: -3px") my.text.set_attr("size", "1") my.text.add_attr("title", "Set number of items per page") widget.add("<hr/>") # set the limit set_limit_wdg = my.get_set_limit_wdg() widget.add(set_limit_wdg) from tactic.ui.widget.button_new_wdg import ActionButtonWdg button = ActionButtonWdg(title='Search') widget.add(button) button.add_style("float: right") button.add_style("margin-top: 8px") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_search_limit_top"); var select = top.getElement(".spt_search_limit_select"); var value = select.value; if (value == 'Custom') { custom = top.getElement(".spt_search_limit_custom_text"); value = custom.value; } if (value == '') { value = 20; } var text = top.getElement(".spt_search_limit_text"); text.value = value; spt.dg_table.search_cbk({}, bvr) ''' } ) offset_wdg = HiddenWdg("%s_last_search_offset" %my.label) offset_wdg.set_value(my.current_offset) widget.add(offset_wdg) widget.add("<br clear='all'/>") return widget
def get_display(my): web = WebContainer.get_web() widget = DivWdg() widget.add_class("spt_search_limit_top") #widget.add_style("border", "solid 1px blue") widget.add_color("background", "background") widget.add_color("color", "color") widget.add_style("padding: 5px") hidden = HiddenWdg("prefix", my.prefix) widget.add(hidden) if not my.search and not my.sobjects: widget.add("No search or sobjects found") return widget # my.count should have been set in alter_search() # which can be called explicitly thru this instance, my. if not my.count: my.count = my.search.get_count(no_exception=True) # if my.sobjects exist thru inheriting from parent widgets # or explicitly set, (this is not mandatory though) if my.sobjects and len(my.sobjects) < my.search_limit: limit = len(my.sobjects) elif my.search and my.count < my.search_limit: # this is only true if the total result of the search is # less than the limit and so this wdg will not display limit = my.count else: limit = my.search_limit if not limit: limit = 50 my.search_limit = limit if my.refresh: prev = SpanWdg(IconButtonWdg("Prev", IconWdg.LEFT, False)) prev.add_style("margin-left: 8px") prev.add_style("margin-right: 6px") prev.add_style("margin-top: -2px") next = IconButtonWdg("Next", IconWdg.RIGHT, False, icon_pos="right") next.add_style("margin-left: 6px") prev.add_behavior({ 'type': 'click_up', 'cbjs_action': my.refresh_script }) next.add_behavior({ 'type': 'click_up', 'cbjs_action': my.refresh_script }) else: # the old code pre 2.5 prev = IconButtonWdg("Prev", IconWdg.LEFT, False) hidden_name = my.prev_hidden_name hidden = HiddenWdg(hidden_name, "") prev.add(hidden) prev.add_event('onclick'," spt.api.Utility.get_input(document,'%s').value ='Prev';%s"\ %(hidden_name, my.refresh_script)) next = IconButtonWdg("Next", IconWdg.RIGHT, False, icon_pos="right") hidden_name = my.next_hidden_name hidden = HiddenWdg(hidden_name, "") next.add(hidden) next.add_event('onclick',"spt.api.Utility.get_input(document,'%s').value ='Next';%s" \ %(hidden_name, my.refresh_script)) showing_wdg = DivWdg() widget.add(showing_wdg) showing_wdg.add_style("padding: 10px") showing_wdg.add_style("margin: 10px") showing_wdg.add_color("background", "background", -5) showing_wdg.add_border() label_span = SpanWdg("Showing: ") showing_wdg.add(label_span) showing_wdg.add(prev) # this min calculation is used so that if my.sobjects is not set # above for the calculation of the limit, which will make the last # set of range numbers too big left_bound = my.current_offset + 1 if not limit: # prevent error in ItemsNavigatorWdg if a search encounters query error limit = 50 my.search_limit = limit right_bound = min(my.current_offset + limit, my.count) if left_bound > right_bound: left_bound = 1 current_value = "%d - %d" % (left_bound, right_bound) if my.style == my.SIMPLE: showing_wdg.add(current_value) else: # add a range selector using ItemsNavigatorWdg from pyasm.widget import ItemsNavigatorWdg selector = ItemsNavigatorWdg(my.label, my.count, my.search_limit) selector.select.add_behavior({ 'type': 'change', 'cbjs_action': my.refresh_script }) selector.set_style(my.style) selector.set_value(current_value) selector.set_display_label(False) showing_wdg.add(selector) showing_wdg.add(next) #showing_wdg.add( " x ") showing_wdg.add(my.text) my.text.add_style("margin-top: -3px") my.text.set_attr("size", "1") my.text.add_attr("title", "Set number of items per page") widget.add("<hr/>") # set the limit set_limit_wdg = my.get_set_limit_wdg() widget.add(set_limit_wdg) from tactic.ui.widget.button_new_wdg import ActionButtonWdg button = ActionButtonWdg(title='Search') widget.add(button) button.add_style("float: right") button.add_style("margin-top: 8px") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_search_limit_top"); var select = top.getElement(".spt_search_limit_select"); var value = select.value; if (value == 'Custom') { custom = top.getElement(".spt_search_limit_custom_text"); value = custom.value; } if (value == '') { value = 20; } var text = top.getElement(".spt_search_limit_text"); text.value = value; spt.dg_table.search_cbk({}, bvr) ''' }) offset_wdg = HiddenWdg("%s_last_search_offset" % my.label) offset_wdg.set_value(my.current_offset) widget.add(offset_wdg) widget.add("<br clear='all'/>") return widget
def get_display(my): my.task_per_process_dict = {} # get the sobject and relevent parameters sobject = my.get_current_sobject() search_type = sobject.get_search_type() if my.pipeline_code: pipeline = Pipeline.get_by_code(my.pipeline_code) else: pipeline = Pipeline.get_by_sobject(sobject, allow_default=True) if not pipeline: # while default is auto-generated, an empty pipeline code will trigger this Environment.add_warning('missing pipeline code', \ "Pipeline code is empty for [%s]" %sobject.get_code()) return if my.include_sub_task_value: my.recurse = True processes = pipeline.get_processes(recurse=my.recurse) # filter out process names if my.process_names != None: filtered_processes = [] for process in processes: if process.get_name() in my.process_names: filtered_processes.append(process) processes = filtered_processes # draw the proceses top = DivWdg() action = DivWdg() action.add_style("float: right") top.add(action) table = Table() table.add_style("font-size: 11px") top.add(table) #if my.max_count: # percent_width = float(len(processes)) / float(my.max_count+1) * 100 #else: # percent_width = 100 # we want them more squeezed together when in abbr mode if my.label_select_value != 'abbr': percent_width = 100 table.add_style("width: %d%%" % percent_width) tr = table.add_row() for process in processes: completion_wdg = my.get_completion(sobject, process,\ len(processes)) if not completion_wdg: continue td = table.add_cell( completion_wdg ) td.add_style('border-width: 0px') tr = table.add_row(css='underline') tr.add_color("color", "color") label_format = my.get_option("label_format") if not label_format: label_format = my.label_select_value tup_list = my._get_labels(processes, label_format, show_sub_pipeline=my.is_ajax()) style = '' for i, tup in enumerate(tup_list): name, process = tup span = SpanWdg() child_pipeline = process.get_child_pipeline() if child_pipeline: title = SpanWdg() title.add("[%s]" % name) title.add_style("margin-left: -5px") swap = SwapDisplayWdg.get_triangle_wdg() content_id = '%s_%s' %(sobject.get_search_key(), child_pipeline.get_id()) content_id = my.generate_unique_id(content_id) content = DivWdg(id=content_id) SwapDisplayWdg.create_swap_title(title, swap, content) dyn_load = AjaxLoader(display_id=content_id) args_dict = {'search_type': sobject.get_search_type()} args_dict['search_id'] = sobject.get_id() args_dict['pipeline_skey'] = child_pipeline.get_search_key() dyn_load.set_load_method('_get_child_wdg') dyn_load.set_load_class('pyasm.widget.ParallelStatusWdg', load_args=args_dict) dyn_load.add_element_name('cal_sub_task') on_script = dyn_load.get_on_script(load_once=True) swap.add_action_script(on_script, "set_display_off('%s')" %content_id) script = "if ($(%s).getStyle('display')=='none') {%s}" \ %(swap.swap1_id, on_script) title.add_event('onclick', script) span.add(swap) span.add(title) span.add(HtmlElement.br()) span.add(HtmlElement.br()) span.add(content) else: span.add(name) if my.task_per_process_dict.get(process) == 0: span.add_class('unused') if label_format == 'small' or label_format == 'abbr': span.add_class('smaller') if not label_format == "none": table.add_cell(span) return top
def get_display(self): self.task_per_process_dict = {} # get the sobject and relevent parameters sobject = self.get_current_sobject() search_type = sobject.get_search_type() if self.pipeline_code: pipeline = Pipeline.get_by_code(self.pipeline_code) else: pipeline = Pipeline.get_by_sobject(sobject, allow_default=True) if not pipeline: # while default is auto-generated, an empty pipeline code will trigger this Environment.add_warning('missing pipeline code', \ "Pipeline code is empty for [%s]" %sobject.get_code()) return if self.include_sub_task_value: self.recurse = True processes = pipeline.get_processes(recurse=self.recurse) # filter out process names if self.process_names != None: filtered_processes = [] for process in processes: if process.get_name() in self.process_names: filtered_processes.append(process) processes = filtered_processes # draw the proceses top = DivWdg() action = DivWdg() action.add_style("float: right") top.add(action) table = Table() table.add_style("font-size: 11px") top.add(table) #if self.max_count: # percent_width = float(len(processes)) / float(self.max_count+1) * 100 #else: # percent_width = 100 # we want them more squeezed together when in abbr mode if self.label_select_value != 'abbr': percent_width = 100 table.add_style("width: %d%%" % percent_width) tr = table.add_row() for process in processes: completion_wdg = self.get_completion(sobject, process,\ len(processes)) if not completion_wdg: continue td = table.add_cell(completion_wdg) td.add_style('border-width: 0px') tr = table.add_row(css='underline') tr.add_color("color", "color") label_format = self.get_option("label_format") if not label_format: label_format = self.label_select_value tup_list = self._get_labels(processes, label_format, show_sub_pipeline=self.is_ajax()) style = '' for i, tup in enumerate(tup_list): name, process = tup span = SpanWdg() child_pipeline = process.get_child_pipeline() if child_pipeline: title = SpanWdg() title.add("[%s]" % name) title.add_style("margin-left: -5px") swap = SwapDisplayWdg.get_triangle_wdg() content_id = '%s_%s' % (sobject.get_search_key(), child_pipeline.get_id()) content_id = self.generate_unique_id(content_id) content = DivWdg(id=content_id) SwapDisplayWdg.create_swap_title(title, swap, content) dyn_load = AjaxLoader(display_id=content_id) args_dict = {'search_type': sobject.get_search_type()} args_dict['search_id'] = sobject.get_id() args_dict['pipeline_skey'] = child_pipeline.get_search_key() dyn_load.set_load_method('_get_child_wdg') dyn_load.set_load_class('pyasm.widget.ParallelStatusWdg', load_args=args_dict) dyn_load.add_element_name('cal_sub_task') on_script = dyn_load.get_on_script(load_once=True) swap.add_action_script(on_script, "set_display_off('%s')" % content_id) script = "if ($(%s).getStyle('display')=='none') {%s}" \ %(swap.swap1_id, on_script) title.add_event('onclick', script) span.add(swap) span.add(title) span.add(HtmlElement.br()) span.add(HtmlElement.br()) span.add(content) else: span.add(name) if self.task_per_process_dict.get(process) == 0: span.add_class('unused') if label_format == 'small' or label_format == 'abbr': span.add_class('smaller') if not label_format == "none": table.add_cell(span) return top