def get_ajax_script(my, tab_name): widget = my.get_widget(tab_name) # load tab thru ajax ajax = AjaxLoader(my.content_div_id) load_args = None widget_class = widget.get_class_name() ajax.set_load_class(widget_class, load_args) if isinstance(widget, MethodWdg): ajax.set_option('method', widget.get_function_name()) for input in my.inputs: ajax.add_element_name(input) for name, value in my.options.items(): ajax.set_option(name, value) script = [] if my.preload_script: script.append(my.preload_script) script.append(ajax.get_on_script()) script.append(my._get_update_script(tab_name)) return ';'.join(script)
def get_ajax_script(my, tab_name): widget = my.get_widget(tab_name) # load tab thru ajax ajax = AjaxLoader(my.content_div_id) load_args = None widget_class = widget.get_class_name() ajax.set_load_class(widget_class, load_args) if isinstance(widget, MethodWdg): ajax.set_option('method', widget.get_function_name()) for input in my.inputs: ajax.add_element_name(input) for name, value in my.options.items(): ajax.set_option(name, value) script = [] if my.preload_script: script.append(my.preload_script) script.append(ajax.get_on_script()) script.append(my._get_update_script(tab_name)) return ';'.join(script)
def setup_ajax(my, display_id): # set up ajax ajax = AjaxLoader() ajax.set_load_class(Common.get_full_class_name(my)) ajax.set_display_id(display_id) ajax_inputs = my.get_ajax_inputs() for input in ajax_inputs: ajax.set_option(input, my.__dict__.get(input)) ajax_elements = my.get_ajax_elements() for element in ajax_elements: ajax.add_element_name(element) return ajax.get_on_script()
def setup_ajax(self, display_id): # set up ajax ajax = AjaxLoader() ajax.set_load_class(Common.get_full_class_name(self)) ajax.set_display_id(display_id) ajax_inputs = self.get_ajax_inputs() for input in ajax_inputs: ajax.set_option(input, self.__dict__.get(input)) ajax_elements = self.get_ajax_elements() for element in ajax_elements: ajax.add_element_name(element) return ajax.get_on_script()
def get_display(self): div = DivWdg() select = SelectWdg("browser_search_type") select.add_empty_option("<- Select ->") search = Search("sthpw/search_object") search.add_order_by("search_type") search_types = self.get_option("search_types") if search_types: search_types = search_types.split("|") search.add_filters("search_type", search_types) select.set_persist_on_submit() select.set_search_for_options(search,"search_type","title") div.add(select) text = TextWdg("browser_search_text") text.set_persist_on_submit() div.add(text) # draw the sobjects sobject_element_id = "sobject_browser" button = ButtonWdg("Search") div.add(button) ajax = AjaxLoader() ajax.set_display_id(sobject_element_id) ajax.set_load_class("pyasm.widget.SObjectBrowserListWdg") ajax.add_element_name("browser_search_type") ajax.add_element_name("browser_search_text") script = ajax.get_on_script() button.add_event("onclick", script) div2 = DivWdg() div2.add_style("display: block") div2.set_id(sobject_element_id) div.add(div2) return div
def get_display(my): div = DivWdg() select = SelectWdg("browser_search_type") select.add_empty_option("<- Select ->") search = Search("sthpw/search_object") search.add_order_by("search_type") search_types = my.get_option("search_types") if search_types: search_types = search_types.split("|") search.add_filters("search_type", search_types) select.set_persist_on_submit() select.set_search_for_options(search,"search_type","title") div.add(select) text = TextWdg("browser_search_text") text.set_persist_on_submit() div.add(text) # draw the sobjects sobject_element_id = "sobject_browser" button = ButtonWdg("Search") div.add(button) ajax = AjaxLoader() ajax.set_display_id(sobject_element_id) ajax.set_load_class("pyasm.widget.SObjectBrowserListWdg") ajax.add_element_name("browser_search_type") ajax.add_element_name("browser_search_text") script = ajax.get_on_script() button.add_event("onclick", script) div2 = DivWdg() div2.add_style("display: block") div2.set_id(sobject_element_id) div.add(div2) return div
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