def get_display(my): widget = DivWdg() pipeline_code = my.get_option('pipeline') pipeline = Pipeline.get_by_code(pipeline_code) if not pipeline: widget.add("No pipeline defined") return widget processes = pipeline.get_process_names() widget.add_style("border: solid 1px blue") widget.add_style("position: absolute") widget.add_style("top: 300") widget.add_style("left: -500") for process in processes: #inputs = pipeline.get_input_processes(process) outputs = pipeline.get_output_processes(process) div = DivWdg() widget.add(div) div.add_class("spt_input_option") div.add_attr("spt_input_key", process) #if not outputs: # # then we can't go anywhere, so just add a message # text = "" # div.add(text) # continue values = [] #values.extend( [str(x) for x in inputs] ) values.append(process) values.extend( [str(x) for x in outputs] ) select = SelectWdg(my.get_input_name()) select.set_value(process) select.add_empty_option('-- Select --') select.set_option("values", values) div.add(select) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) return widget
def get_display(self): widget = DivWdg() pipeline_code = self.get_option('pipeline') pipeline = Pipeline.get_by_code(pipeline_code) if not pipeline: widget.add("No pipeline defined") return widget processes = pipeline.get_process_names() widget.add_style("border: solid 1px blue") widget.add_style("position: absolute") widget.add_style("top: 300") widget.add_style("left: -500") for process in processes: #inputs = pipeline.get_input_processes(process) outputs = pipeline.get_output_processes(process) div = DivWdg() widget.add(div) div.add_class("spt_input_option") div.add_attr("spt_input_key", process) #if not outputs: # # then we can't go anywhere, so just add a message # text = "" # div.add(text) # continue values = [] #values.extend( [str(x) for x in inputs] ) values.append(process) values.extend( [str(x) for x in outputs] ) select = SelectWdg(self.get_input_name()) select.set_value(process) select.add_empty_option('-- Select --') select.set_option("values", values) div.add(select) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) return widget
def get_display(my): from calendar_wdg import CalendarInputWdg top = DivWdg() top.add_class("spt_input_top") if not my.calendar_key: my.calendar_key = 'read' top.add_attr("spt_cbjs_get_input_key", \ "var value=spt.dg_table.get_element_value(cell_to_edit, '%s'); return value" %my.get_name()) #top.add_style("background: black") # put in a default default_sel = SelectWdg(my.get_name()) for key, value in my.kwargs.items(): default_sel.set_option(key, value) sel_div = DivWdg(css='spt_input_option') sel_div.add_attr("spt_input_key", "default") #default_div.add("No options for selected [%s]" % depend_element) sel_div.add(default_sel) top.add(sel_div) cal = CalendarInputWdg(my.get_name()) cal_div = DivWdg(css='spt_input_option') cal_div.add_attr("spt_input_key", my.calendar_key) cal_div.add(cal) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(default_sel) top.add(cal_div) return top
def get_display(self): from calendar_wdg import CalendarInputWdg top = DivWdg() top.add_class("spt_input_top") if not self.calendar_key: self.calendar_key = 'read' top.add_attr("spt_cbjs_get_input_key", \ "var value=spt.dg_table.get_element_value(cell_to_edit, '%s'); return value" %self.get_name()) #top.add_style("background: black") # put in a default default_sel = SelectWdg(self.get_name()) for key, value in self.kwargs.items(): default_sel.set_option(key, value) sel_div = DivWdg(css='spt_input_option') sel_div.add_attr("spt_input_key", "default") #default_div.add("No options for selected [%s]" % depend_element) sel_div.add(default_sel) top.add(sel_div) cal = CalendarInputWdg(self.get_name()) cal_div = DivWdg(css='spt_input_option') cal_div.add_attr("spt_input_key", self.calendar_key) cal_div.add(cal) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(default_sel) top.add(cal_div) return top
def get_display(my): top = DivWdg() top.add_class("spt_input_top") div = DivWdg() div.add_class("spt_input_option") key = 'main' div.add_attr("spt_input_key", key) query = my.kwargs.get("query"); query_filter = my.kwargs.get("query_filter"); input_name = my.kwargs.get("name"); select = SelectWdg(input_name) select.add_empty_option('-- Select --') values = my.kwargs.get("values") if values: select.set_option("values", values) labels = my.kwargs.get("labels") if labels: select.set_option("labels", labels) else: select.set_option("query", query) select.set_option("query_filter", query_filter) div.add(select) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) top.add(div) return top
def get_display(self): top = DivWdg() top.add_class("spt_input_top") div = DivWdg() div.add_class("spt_input_option") key = 'main' div.add_attr("spt_input_key", key) query = self.kwargs.get("query"); query_filter = self.kwargs.get("query_filter"); input_name = self.kwargs.get("name"); select = SelectWdg(input_name) select.add_empty_option('-- Select --') values = self.kwargs.get("values") if values: select.set_option("values", values) labels = self.kwargs.get("labels") if labels: select.set_option("labels", labels) else: select.set_option("query", query) select.set_option("query_filter", query_filter) div.add(select) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) top.add(div) return top
def get_display(my): query = my.get_option("query") depend_col = my.get_option("dependency") # for example # FIXME: this has to be fleshed out ... it's a little too complicated # at the moment!!! query = "MMS/product_type|id|product_name" depend_col = "discipline_id" depend_element = 'discipline' top = DivWdg() top.add_class("spt_input_top") top.add_attr("spt_cbjs_get_input_key", "var value=spt.dg_table.get_element_value(cell_to_edit, '%s');return value" % depend_element) top.add_style("background: black") # get all of the sobjects search_type, value_col, label_col = query.split("|") search = Search(search_type) sobjects = search.get_sobjects() # arrange the sobjects according to keys selections = {} for sobject in sobjects: depend_value = sobject.get_value(depend_col) selection_list = selections.get(depend_value) if not selection_list: selection_list = [] selections[depend_value] = selection_list selection_list.append(sobject) # put in a default default_div = DivWdg() default_div.add_class("spt_input_option") default_div.add_attr("spt_input_key", "default") default_div.add("No options for selected [%s]" % depend_element) top.add(default_div) # add list of possible select statements for key, selection_list in selections.items(): div = DivWdg() div.add_class("spt_input_option") div.add_attr("spt_input_key", key) values = [] labels = [] for sobject in selection_list: values.append(sobject.get_value(value_col)) labels.append(sobject.get_value(label_col)) select = SelectWdg(my.get_input_name()) select.add_empty_option('-- Select --') select.set_option("values", values) select.set_option("labels", labels) div.add(select) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) top.add(div) return top
def get_display(my): if not my.is_preprocess: my.preprocess() widget = DivWdg() widget.add_class('spt_input_top') # add a callback to determine the input key widget.add_attr('spt_cbjs_get_input_key', "return spt.dg_table.get_status_key(cell_to_edit, edit_cell)") # add a data structure mapping, processes to task pipelines #data = { # "model": "task_model", # "texture": "task_texture", # "rig": "task_rig" #} if my.task_mapping: json_str = HtmlElement.get_json_string(my.task_mapping) widget.add_attr('spt_task_pipeline_mapping', json_str) for pipeline in my.task_pipelines: div = DivWdg() widget.add(div) div.add_class("spt_input_option") div.add_attr("spt_input_key", pipeline.get_code()) # if there is not task_pipeline_code, create a virtual one: if not pipeline: process_names = ['Pending', 'In Progress', 'Approved'] else: process_names = pipeline.get_process_names() allowed_processes = [] security = Environment.get_security() cur_value = '' cur_sobject = my.get_current_sobject() if cur_sobject: cur_value = cur_sobject.get_value('status') for process in process_names: # not all statuses can be shown, if there are access rules # TODO: remove this process_select in 4.1 if cur_value == process or security.check_access("process_select", process, access='view', default='deny'): allowed_processes.append(process) continue # use the new access rule process here access_key = [ {'process': '*' ,'pipeline': pipeline.get_code()}, {'process': '*' ,'pipeline': '*'}, {'process': process , 'pipeline': pipeline.get_code()} ] if security.check_access('process', access_key, "view", default="deny"): allowed_processes.append(process) select = SelectWdg(my.get_input_name()) select.add_empty_option('-- Select --') if cur_value in allowed_processes: select.set_value( cur_value ) select.set_option("values", allowed_processes) # only old table layout has behaviors at the widget level if my.behaviors: from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) div.add(select.get_buffer_display()) return widget
def get_display(my): query = my.get_option("query") depend_col = my.get_option("dependency") # for example # FIXME: this has to be fleshed out ... it's a little too complicated # at the moment!!! query = "MMS/product_type|id|product_name" depend_col = "discipline_id" depend_element = 'discipline' top = DivWdg() top.add_class("spt_input_top") top.add_attr( "spt_cbjs_get_input_key", "var value=spt.dg_table.get_element_value(cell_to_edit, '%s');return value" % depend_element) top.add_style("background: black") # get all of the sobjects search_type, value_col, label_col = query.split("|") search = Search(search_type) sobjects = search.get_sobjects() # arrange the sobjects according to keys selections = {} for sobject in sobjects: depend_value = sobject.get_value(depend_col) selection_list = selections.get(depend_value) if not selection_list: selection_list = [] selections[depend_value] = selection_list selection_list.append(sobject) # put in a default default_div = DivWdg() default_div.add_class("spt_input_option") default_div.add_attr("spt_input_key", "default") default_div.add("No options for selected [%s]" % depend_element) top.add(default_div) # add list of possible select statements for key, selection_list in selections.items(): div = DivWdg() div.add_class("spt_input_option") div.add_attr("spt_input_key", key) values = [] labels = [] for sobject in selection_list: values.append(sobject.get_value(value_col)) labels.append(sobject.get_value(label_col)) select = SelectWdg(my.get_input_name()) select.add_empty_option('-- Select --') select.set_option("values", values) select.set_option("labels", labels) div.add(select) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) top.add(div) return top
def get_display(my): if not my.is_preprocess: my.preprocess() widget = DivWdg() widget.add_class('spt_input_top') # add a callback to determine the input key widget.add_attr( 'spt_cbjs_get_input_key', "return spt.dg_table.get_status_key(cell_to_edit, edit_cell)") # add a data structure mapping, processes to task pipelines #data = { # "model": "task_model", # "texture": "task_texture", # "rig": "task_rig" #} if my.task_mapping: json_str = HtmlElement.get_json_string(my.task_mapping) widget.add_attr('spt_task_pipeline_mapping', json_str) for pipeline in my.task_pipelines: div = DivWdg() widget.add(div) div.add_class("spt_input_option") div.add_attr("spt_input_key", pipeline.get_code()) # if there is not task_pipeline_code, create a virtual one: if not pipeline: status_names = ['Pending', 'In Progress', 'Complete'] else: status_names = pipeline.get_process_names() allowed_statuses = [] security = Environment.get_security() cur_value = '' cur_sobject = my.get_current_sobject() if cur_sobject: cur_value = cur_sobject.get_value('status') processes = ['Synopsis', 'First Draft', 'Second Draft', 'Final'] processes = [None] for process in processes: for status in status_names: # not all statuses can be shown, if there are access rules # TODO: remove this status in 4.1 if cur_value == status or security.check_access( "process_select", status, access='view', default='deny'): if process: allowed_statuses.append("%s / %s" % (process, status)) else: allowed_statuses.append(status) continue # use the new access rule process here access_key = [{ 'process': '*', 'pipeline': pipeline.get_code() }, { 'process': '*', 'pipeline': '*' }, { 'process': status, 'pipeline': pipeline.get_code() }] if security.check_access('status', access_key, "view", default="deny"): if process: allowed_statuses.append("%s / %s" % (process, status)) else: allowed_statuses.append(status) if process: allowed_statuses.append("---") select = SelectWdg(my.get_input_name()) select.add_empty_option('-- Select --') if cur_value in allowed_statuses: select.set_value(cur_value) select.set_option("values", allowed_statuses) # only old table layout has behaviors at the widget level if my.behaviors: from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) div.add(select.get_buffer_display()) return widget