def get_panel_wdg(my, td, panel): title = panel.get("title") widget = panel.get("widget") width = panel.get("width") #height = panel.get("height") #if not height: # height = "250px" #td.add_style("height: %s" % height) if width: td.add_style("width: %s" % width) td.add_border() div = DivWdg() div.add_style("padding: 5px") #div.add_style("padding: 10px") title_wdg = DivWdg() div.add(title_wdg) title_wdg.add_style("padding: 5px") #title_wdg.add_style("margin: -12px -12px 10px -12px") title_wdg.add_style("margin: -6px -7px 5px -7px") title_wdg.add_style("font-weight: bold") title_wdg.add_style("font-size: 14px") if title: title_wdg.add_color("background", "background", -5) title_wdg.add_color("color", "color", -10) title_wdg.add_border() title_wdg.add(title) from tactic.ui.app import HelpButtonWdg help_wdg = HelpButtonWdg(alias=my.get_help_alias()) help_wdg.add_style("float: right") help_wdg.add_style("margin-top: -5px") title_wdg.add(help_wdg) else: title_wdg.add_style("height: 10px") if widget: div.add(widget) return div
def get_display(my): title = DivWdg() title.add(my.name_of_title) title.add_style("padding: 5px") title.add_style("margin: -10px -10px 10px -10px") title.add_style("font-weight: bold") title.add_style("font-size: 14px") title.add_gradient("background", "background", -10) title.add_color("color", "color", -10) title.add_border() from tactic.ui.app import HelpButtonWdg help_wdg = HelpButtonWdg(alias=my.help_alias) help_wdg.add_style("float: right") help_wdg.add_style("margin-top: -5px") title.add(help_wdg) return title
def get_filter_wdg(my): div = DivWdg() div.add_style("padding: 10px") div.add_style("margin: -10 -10 10 -10") div.add_style("min-width: 600px") div.add_class("spt_view_manager_filter") from tactic.ui.app import HelpButtonWdg help_wdg = HelpButtonWdg(alias="view-manager|what-are-views") div.add(help_wdg) help_wdg.add_style("float: right") div.add("<b>Search Type:</b> ") div.add_gradient("background", "background", -10) security = Environment.get_security() project = Project.get() if security.check_access("builtin", "view_site_admin", "allow"): search_type_objs = project.get_search_types(include_sthpw=True, include_config=True) else: search_type_objs = project.get_search_types() search_types = [x.get_value("search_type") for x in search_type_objs] titles = ["%s (%s)" % (x.get_value("search_type"), x.get_value("title")) for x in search_type_objs] select = SelectWdg(name="search_type") select.set_option("values", search_types) select.set_option("labels", titles) select.add_empty_option("-- Select --") select.set_persistence() # select.set_persist_on_submit() # security = Environment.get_security() # if security.check_access("builtin", "view_site_admin", "allow"): # select_mode = SearchTypeSelectWdg.ALL # else: # select_mode = SearchTypeSelectWdg.ALL_BUT_STHPW # select = SearchTypeSelectWdg(name='search_type', \ # mode=select_mode) behavior = { "type": "change", "cbjs_action": """ var manager_top = bvr.src_el.getParent(".spt_view_manager_top"); var input = spt.api.Utility.get_input(manager_top, 'search_type'); var view_input = spt.api.Utility.get_input(manager_top, 'view'); var view_input_value = ''; if (view_input != null) { view_input_value = view_input.value; } var values = {'search_type': input.value, 'view': view_input_value, 'is_refresh': 'true'}; spt.panel.refresh(manager_top, values);""" # //spt.panel.refresh(manager_top, values);''' } select.add_behavior(behavior) select.set_value(my.search_type) div.add(select) if not my.search_type: content = DivWdg() content.add_style("width: 400px") content.add_style("height: 400px") div.add(content) content.add_style("padding: 20px") content.add(IconWdg("WARNING", IconWdg.WARNING)) content.add("No Search Type Selected") content.add_border() content.add_style("margin-top: 20px") content.add_color("background", "background") content.add_style("font-weight: bold") return div div.add(" ") div.add("<b>View: </b>") view_wdg = SelectWdg("view") view_wdg.set_value(my.view) view_wdg.add_empty_option("-- Select --") view_wdg.add_behavior(behavior) div.add(view_wdg) search = Search("config/widget_config") search.add_filter("search_type", my.search_type) db_configs = search.get_sobjects() views = set() for db_config in db_configs: view = db_config.get_value("view") if view.startswith("link_search:"): continue views.update([view]) # print "search_type: ", my.search_type # print "view: ", views, my.view if my.search_type and my.view: config_view = WidgetConfigView.get_by_search_type(my.search_type, my.view) configs = config_view.get_configs() for x in configs: view = x.get_view() file_path = x.get_file_path() if view != my.view: continue if file_path and file_path.endswith("DEFAULT-conf.xml"): continue config_views = x.get_all_views() views.update(config_views) views_list = list(views) views_list.sort() view_wdg.set_option("values", views_list) return div
def get_display(my): if my.is_refresh: top = Widget() my.add(top) else: container = DivWdg() my.add(container) #parent = SearchKey.get_by_search_key(my.search_key) top = DivWdg() container.add(top) my.set_as_panel(top) top.add_style("margin-top: -2px") top.add_class("spt_uber_notes_top") from tactic.ui.app import HelpButtonWdg help_button = HelpButtonWdg(alias="note-sheet-widget") top.add(help_button) help_button.add_style("float: right") table_id = 'sub_table' view = 'table' span = DivWdg(css='spt_input_group') top.add(span) span.add_border() span.add_style("height: 27px") span.add_style("padding: 5px") button_div = DivWdg() span.add(button_div) button_div.add_style("float: left") button_div.add_style("margin-right: 10px") table = Table() button_div.add(table) table.add_row() from tactic.ui.widget import SingleButtonWdg refresh = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH) table.add_cell(refresh) refresh.add_style("float: left") refresh.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var tbody = top.getElements('.spt_table_tbody')[2]; var values = spt.api.Utility.get_input_values(tbody); spt.panel.refresh(top, values, false); ''' }) save = SingleButtonWdg(title="Save", icon=IconWdg.SAVE) table.add_cell(save) save.add_style("float: left") save.add_behavior({ 'type': 'click_up', 'update_current_only': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var table = top.getElement(".spt_table"); bvr.src_el = table; spt.dg_table.update_row(evt, bvr) ''' }) process = SingleButtonWdg(title="Show Processes", icon=IconWdg.PROCESS, show_arrow=True) table.add_cell(process) from tactic.ui.container import DialogWdg process_dialog = DialogWdg(display=False) span.add(process_dialog) process_dialog.set_as_activator(process) process_dialog.add_title("Processes") process_div = DivWdg() process_dialog.add(process_div) #process_div.add_style("padding: 5px") process_div.add_color("background", "background") process_div.add_color("color", "color") process_div.add_border() refresh = ActionButtonWdg(title="Refresh") refresh.add_style('margin: 0 auto 10px auto') process_div.add(refresh) refresh.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var tbody = top.getElements('.spt_table_tbody')[2]; var values = spt.api.Utility.get_input_values(tbody); spt.panel.refresh(top, values, false); ''' }) process_div.add("<hr/>") selected_process_names = [] step = 0 for idx, value in enumerate(my.process_names): checkbox_name = 'note_process_cb' if my.child_mode: selected_process_names.append(value) #break cb = CheckboxWdg(checkbox_name, label=value) cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) #cb.set_persistence() cb.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.input.save_selected(bvr, '%s','%s'); ''' % (checkbox_name, key) }) # only 1 is selected in child_mode if cb.is_checked(): selected_process_names.append(value) if idx == 0 or idx == 10 * step: # add a new inner div inner_div = my._get_inner_div() process_div.add(inner_div, 'inner%s' % step) step += 1 inner_div.add(cb) inner_div.add("<br/>") # if less than 10, make it wider if len(my.process_names) < 10: inner_div.add_style('width: 100px') # add a master private checkbox if not my.child_mode: checkbox_name = 'note_master_private_cb' cb = CheckboxWdg(checkbox_name, label='make notes private') cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var tbody = top.getElements('.spt_table_tbody')[2]; var inputs = spt.api.Utility.get_inputs(tbody,'is_private'); for (var i = 0; i < inputs.length; i++) inputs[i].checked = bvr.src_el.checked; spt.input.save_selected(bvr, '%s','%s'); ''' % (checkbox_name, key) }) cb_span = DivWdg(cb, css='small') cb_span.add_styles( 'border-left: 1px dotted #bbb; margin-left: 10px') span.add(cb_span) main_config_view = my._get_main_config(view, selected_process_names) sobject_dict = {} # TODO: do a union all search or by order number = 1 for value in selected_process_names: search = Search('sthpw/note') search.add_filter('project_code', Project.get_project_code()) search.add_filter('context', value) search.add_filter('search_type', my.parent_search_type) search.add_filter('search_id', my.parent_search_id) search.add_order_by('timestamp desc') search.add_limit(1) sobject = search.get_sobject() if sobject: sobject_dict[value] = sobject #sobjects = search.get_sobjects() # virtual sobject for placeholder, we can put more than 1 maybe? sobject = SearchType.create('sthpw/note') edit_config = my._get_edit_config('edit', selected_process_names) edit_configs = {'sthpw/note': edit_config} Container.put("CellEditWdg:configs", edit_configs) table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view='table', config=main_config_view, aux_info={ 'sobjects': sobject_dict, 'parent': my.parent }, mode="simple", show_row_select=False, show_insert=False, show_commit_all=True, show_refresh='false', state={'parent_key': my.search_key}) table.set_sobject(sobject) top.add(table) return super(NoteSheetWdg, my).get_display()
def get_display(self): self.check() if self.is_refresh: div = Widget() else: div = DivWdg() self.set_as_panel(div) div.add_style('padding', '6px') min_width = '400px' div.add_style('min-width', min_width) div.add_color('background', 'background') div.add_class('spt_add_task_panel') div.add_style("padding: 20px") from tactic.ui.app import HelpButtonWdg help_button = HelpButtonWdg(alias="creating-tasks") div.add(help_button) help_button.add_style("float: right") help_button.add_style("margin-top: -5px") if not self.search_key_list: msg_div = DivWdg() msg_table = Table() msg_div.add(msg_table) msg_table.add_row() msg_table.add_cell(IconWdg("No items selected", IconWdg.WARNING)) msg_table.add_cell( 'Please select at least 1 item to add tasks to.') msg_div.add_style('margin: 10px') msg_table.add_style("font-weight: bold") div.add(msg_div) return div msg_div = DivWdg() msg_div.add_style('margin-left: 4px') div.add(msg_div, 'info') msg_div.add('Total: %s item/s to add tasks to' % len(self.search_key_list)) div.add(HtmlElement.br()) hint = HintWdg('Tasks are added according to the assigned pipeline.') msg_div.add(" ") msg_div.add(hint) msg_div.add(HtmlElement.br()) option_div = DivWdg(css='spt_ui_options') #option_div.add_style('margin-left: 12px') sel = SelectWdg('pipeline_mode', label='Create tasks by: ') sel.set_option('values', ['simple process', 'context', 'standard']) sel.set_option('labels', ['process', 'context', 'all contexts in process']) sel.set_persistence() sel.add_behavior({ 'type': 'change', 'cbjs_action': 'spt.panel.refresh(bvr.src_el)' }) option_div.add(sel) value = sel.get_value() # default to simple process if not value: value = 'simple process' msg = '' if value not in ['simple process', 'context', 'standard']: value = 'simple process' if value == 'context': msg = 'In context mode, a single task will be created for each selected context.' elif value == 'simple process': msg = 'In process mode, a single task will be created for each selected process.' elif value == 'standard': msg = 'In this mode, a task will be created for all contexts of each selected process.' option_div.add(HintWdg(msg)) div.add(option_div) div.add(HtmlElement.br()) title = DivWdg('Assigned Pipelines') title.add_style('padding: 6px') title.add_color('background', 'background2') title.add_color('color', 'color', +120) div.add(title) content_div = DivWdg() content_div.add_style('min-height', '150px') div.add(content_div) content_div.add_border() filtered_search_key_list = [] for sk in self.search_key_list: id = SearchKey.extract_id(sk) if id == '-1': continue filtered_search_key_list.append(sk) sobjects = SearchKey.get_by_search_keys(filtered_search_key_list) skipped = [] pipeline_codes = [] for sobject in sobjects: if isinstance(sobject, Task): msg_div = DivWdg( 'WARNING: Creation of task for [Task] is not allowed.') msg_div.add_style('margin-left: 10px') div.add(msg_div, 'info') return div pipeline_code = sobject.get_value('pipeline_code', no_exception=True) if not pipeline_code: skipped.append(sobject) if pipeline_code not in pipeline_codes: pipeline_codes.append(pipeline_code) pipelines = Search.get_by_code('sthpw/pipeline', pipeline_codes) if pipelines == None: pipelines = [] #if not pipelines: # msg_div = DivWdg('WARNING: No Pipelines found for selected.') # msg_div.add_style('margin-left: 10px') # div.add(msg_div, 'info') # return div # expand the width according to num of pipelines content_div.add_style('min-width', len(pipelines) * 250) mode_cb = SelectWdg('pipeline_mode') mode_cb.set_persistence() mode = mode_cb.get_value() if 'context' == mode: mode = 'context' else: mode = 'process' show_subpipeline = True min_height = '150px' # create a temp default pipeline if not pipelines: pipeline = SearchType.create("sthpw/pipeline") pipeline.set_value("code", "__default__") pipeline.set_value( "pipeline", ''' <pipeline> <process name='publish'/> </pipeline> ''') # FIXME: HACK to initialize virtual pipeline pipeline.set_pipeline(pipeline.get_value("pipeline")) pipelines = [pipeline] for pipeline in pipelines: name = pipeline.get_value("name") if not name: name = pipeline.get_code() span = SpanWdg("Pipeline: %s" % name) span.add_style('font-weight: bold') v_div = FloatDivWdg(span) v_div.add_style('margin: 20px') v_div.add_style('min-height', min_height) v_div.add(HtmlElement.br(2)) content_div.add(v_div) processes = pipeline.get_processes(recurse=show_subpipeline, type=['manual', 'approval']) cb_name = '%s|task_process' % pipeline.get_code() master_cb = CheckboxWdg('master_control') master_cb.set_checked() master_cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_add_task_panel'),'%s'); for (var i = 0; i < inputs.length; i++) inputs[i].checked = bvr.src_el.checked; ''' % cb_name }) toggle_div = DivWdg() toggle_div.add(SpanWdg(master_cb, css='small')) label = HtmlElement.i('toggle all') label.add_style('color: #888') toggle_div.add_styles( 'border-bottom: 1px solid #888; width: 170px') toggle_div.add(label) v_div.add(toggle_div) process_names = [] for process in processes: process_labels = [] if process.is_from_sub_pipeline(): process_name = process.get_full_name() else: process_name = process.get_name() process_label = process.get_label() if not process_label: process_label = '' if mode == 'context': contexts = pipeline.get_output_contexts(process.get_name()) labels = contexts if process.is_from_sub_pipeline(): labels = [ '%s/%s' % (process.parent_pipeline_code, x) for x in contexts ] for x in labels: process_labels.append(process_label) # prepend process to contexts in this mode to ensure uniqueness contexts = ['%s:%s' % (process_name, x) for x in contexts] else: contexts = [process_name] labels = contexts process_labels.append(process_label) for idx, context in enumerate(contexts): cb = CheckboxWdg(cb_name) cb.set_checked() cb.set_option('value', context) v_div.add(SpanWdg(cb, css='small')) if mode == 'context': span = SpanWdg(process_name, css='med') #span.add_color('color','color') v_div.add(span) v_div.add(SpanWdg(labels[idx])) process_label = process_labels[idx] if process_label: v_div.add(SpanWdg("(%s)" % process_label, css='small')) v_div.add(HtmlElement.br()) content_div.add("<br clear='all'/>") skipped = [] if True: div.add("<br/>") btn = ActionButtonWdg(title='Add Tasks') btn.add_behavior({ 'type': 'click_up', 'post_event': 'search_table_%s' % self.table_id, 'cbjs_action': ''' spt.dg_table.add_task_selected(bvr); ''', 'search_key_list': self.search_key_list }) cb = CheckboxWdg('skip_duplicated', label='Skip Duplicates') cb.set_checked() option_div = DivWdg(cb) option_div.add_style('width', '130px') option_div.add_style('align: left') div.add(option_div) div.add(HtmlElement.br()) btn.add_style("float: right") div.add(btn) div.add(HtmlElement.br(clear="all")) if skipped: content_div.add(HtmlElement.br()) skip_div = DivWdg('Missing pipeline code (Skipped)') skip_div.add_style('text-decoration: underline') content_div.add(skip_div) content_div.add(HtmlElement.br()) item_div = DivWdg() item_div.add_style('margin-left: 10px') content_div.add(item_div) for skip in skipped: item_div.add(skip.get_code()) item_div.add(HtmlElement.br()) return div
def get_display(my): data = my.kwargs.get('kwargs') if data: data = jsonloads(data) my.kwargs.update(data) my.search_type = my.kwargs.get("search_type") my.x_axis = my.kwargs.get("x_axis") if not my.x_axis: my.x_axis = 'code' my.y_axis = my.kwargs.get("y_axis") if type(my.y_axis) == types.ListType: my.y_axis = "|".join( my.y_axis ) my.chart_type = my.kwargs.get("chart_type") if not my.chart_type: my.chart_type = 'bar' # get any search keys if any are passed in my.search_keys = my.kwargs.get("search_keys") top = DivWdg() top.add_class("spt_chart_builder") top.add_color("background", "background") top.add_border() from tactic.ui.app import HelpButtonWdg help_button = HelpButtonWdg(alias='charting') top.add( help_button ) help_button.add_style("float: right") project = Project.get() search_types = project.get_search_types(include_sthpw=True) search_types = [x.get_value("search_type") for x in search_types] build_div = DivWdg() from pyasm.widget import SwapDisplayWdg swap_wdg = SwapDisplayWdg.get_triangle_wdg() swap_script = swap_wdg.get_swap_script() build_div.add(swap_wdg) build_div.add("<b>Chart Specifications</b>") build_div.add_style("margin-bottom: 5px") build_div.add_style("height: 25px") build_div.add_style("padding-top: 5px") build_div.add_gradient("background", "background", -10) build_div.add_color("color", "color") build_div.add_class("hand") build_div.add_class("SPT_DTS") top.add(build_div) build_div.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var spec = top.getElement(".spt_chart_spec"); //spt.api.toggle_show_hide(spec); spt.toggle_show_hide(spec); %s; ''' % swap_script } ) spec_div = DivWdg() spec_div.add_color("color", "color3") spec_div.add_color("background", "background3") spec_div.add_class("spt_chart_spec") spec_div.add_border() spec_div.add_style("padding: 10px") spec_div.add_style("margin: 5px") spec_div.add_style("display: none") top.add(spec_div) table = Table() table.add_color("color", "color3") spec_div.add(table) # add the search type selector table.add_row() table.add_cell("Search Type: ") search_type_div = DivWdg() search_type_select = TextWdg("search_type") search_type_select.set_value(my.search_type) #search_type_select.set_option("values", search_types) search_type_div.add(search_type_select) table.add_cell(search_type_div) # add the chart type selector table.add_row() table.add_cell("Chart Type: ") type_div = DivWdg() #type_div.add_style("padding: 3px") type_select = SelectWdg("chart_type") type_select.set_option("values", "line|bar|area") if my.chart_type: type_select.set_value(my.chart_type) type_div.add(type_select) table.add_cell(type_div) # add the chart type selector table.add_row() table.add_cell("X-Axis: ") # need to find all expression widgets or use get_text_value()? x_axis_div = DivWdg() x_axis_text = TextWdg("x_axis") x_axis_text.set_value("code") x_axis_div.add(x_axis_text) table.add_cell(x_axis_div) # add the chart type selector table.add_row() td = table.add_cell("Y-Axis: ") td.add_style("vertical-align: top") y_axis_div = DivWdg() #y_axis_text = TextWdg("y_axis") #if my.y_axis: # y_axis_text.set_value(my.y_axis) #y_axis_div.add(y_axis_text) td = table.add_cell(y_axis_div) # add in a list of entries from tactic.ui.container import DynamicListWdg list_wdg = DynamicListWdg() for value in my.y_axis.split("|"): item = TextWdg("y_axis") item.set_value(value, set_form_value=False) list_wdg.add_item(item) y_axis_div.add(list_wdg) spec_div.add("<br/>") from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Refresh") spec_div.add(button) spec_div.add(HtmlElement.br(2)) button.add_style("float: left") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var chart = top.getElement(".spt_chart"); var values = spt.api.get_input_values(top); //var values = spt.api.Utility.get_input_values(top); spt.panel.refresh(chart, values); ''' } ) #TODO: provide a field for user to type in the chart name """ button = ActionButtonWdg(title="Save") spec_div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var chart = top.getElement(".spt_chart"); var values = spt.api.get_input_values(top); var login = '******'; var search_type = 'SideBarWdg'; var side_bar_view = 'project_view'; var unique_el_name = 'chart_test' var kwargs = {}; kwargs['login'] = null; //if (save_as_personal) // kwargs['login'] = login; kwargs['class_name'] = 'tactic.ui.chart.ChartBuilderWdg'; var display_options = {}; display_options['search_type'] = 'prod/asset' kwargs['display_options'] = display_options; kwargs['unique'] = true; //if (new_title) // kwargs['element_attrs'] = {'title': new_title}; var server = TacticServerStub.get() server.add_config_element(search_type, side_bar_view, unique_el_name, kwargs); spt.panel.refresh("side_bar"); ''' } ) """ width = '600px' kwargs = { 'y_axis': my.y_axis, 'chart_type': my.chart_type, 'search_type': my.search_type, 'width': width, 'search_keys': my.search_keys } chart_div = DivWdg() chart = BarChartWdg(**kwargs) chart_div.add(chart) top.add(chart_div) #from chart2_wdg import SampleSObjectChartWdg #chart = SampleSObjectChartWdg(**kwargs) #chart_div.add(chart) return top
def get_display(self): self.check() if self.is_refresh: div = Widget() else: div = DivWdg() self.set_as_panel(div) div.add_style('padding','6px') min_width = '400px' div.add_style('min-width', min_width) div.add_color('background','background') div.add_class('spt_add_task_panel') div.add_style("padding: 20px") from tactic.ui.app import HelpButtonWdg help_button = HelpButtonWdg(alias="creating-tasks") div.add(help_button) help_button.add_style("float: right") help_button.add_style("margin-top: -5px") if not self.search_key_list: msg_div = DivWdg() msg_table = Table() msg_div.add(msg_table) msg_table.add_row() msg_table.add_cell( IconWdg("No items selected", IconWdg.WARNING) ) msg_table.add_cell('Please select at least 1 item to add tasks to.') msg_div.add_style('margin: 10px') msg_table.add_style("font-weight: bold") div.add(msg_div) return div msg_div = DivWdg() msg_div.add_style('margin-left: 4px') div.add(msg_div, 'info') msg_div.add('Total: %s item/s to add tasks to' %len(self.search_key_list)) div.add(HtmlElement.br()) hint = HintWdg('Tasks are added according to the assigned pipeline.') msg_div.add(" ") msg_div.add(hint) msg_div.add(HtmlElement.br()) option_div = DivWdg(css='spt_ui_options') #option_div.add_style('margin-left: 12px') sel = SelectWdg('pipeline_mode', label='Create tasks by: ') sel.set_option('values', ['simple process','context', 'standard']) sel.set_option('labels', ['process','context', 'all contexts in process']) sel.set_persistence() sel.add_behavior({'type':'change', 'cbjs_action': 'spt.panel.refresh(bvr.src_el)'}) option_div.add(sel) value = sel.get_value() # default to simple process if not value: value = 'simple process' msg = '' if value not in ['simple process','context','standard']: value = 'simple process' if value == 'context': msg = 'In context mode, a single task will be created for each selected context.' elif value == 'simple process': msg = 'In process mode, a single task will be created for each selected process.' elif value == 'standard': msg = 'In this mode, a task will be created for all contexts of each selected process.' option_div.add(HintWdg(msg)) div.add(option_div) div.add(HtmlElement.br()) title = DivWdg('Assigned Pipelines') title.add_style('padding: 6px') title.add_color('background','background2') title.add_color('color','color', +120) div.add(title) content_div = DivWdg() content_div.add_style('min-height', '150px') div.add(content_div) content_div.add_border() filtered_search_key_list = [] for sk in self.search_key_list: id = SearchKey.extract_id(sk) if id=='-1': continue filtered_search_key_list.append(sk) sobjects = SearchKey.get_by_search_keys(filtered_search_key_list) skipped = [] pipeline_codes = [] for sobject in sobjects: if isinstance(sobject, Task): msg_div = DivWdg('WARNING: Creation of task for [Task] is not allowed.') msg_div.add_style('margin-left: 10px') div.add(msg_div, 'info') return div pipeline_code = sobject.get_value('pipeline_code', no_exception=True) if not pipeline_code: skipped.append(sobject) if pipeline_code not in pipeline_codes: pipeline_codes.append(pipeline_code) pipelines = Search.get_by_code('sthpw/pipeline', pipeline_codes) if pipelines == None: pipelines = [] #if not pipelines: # msg_div = DivWdg('WARNING: No Pipelines found for selected.') # msg_div.add_style('margin-left: 10px') # div.add(msg_div, 'info') # return div # expand the width according to num of pipelines content_div.add_style('min-width', len(pipelines)*250) mode_cb = SelectWdg('pipeline_mode') mode_cb.set_persistence() mode = mode_cb.get_value() if 'context' == mode: mode = 'context' else: mode = 'process' show_subpipeline = True min_height = '150px' # create a temp default pipeline if not pipelines: pipeline = SearchType.create("sthpw/pipeline") pipeline.set_value("code", "__default__") pipeline.set_value("pipeline", ''' <pipeline> <process name='publish'/> </pipeline> ''') # FIXME: HACK to initialize virtual pipeline pipeline.set_pipeline(pipeline.get_value("pipeline")) pipelines = [pipeline] for pipeline in pipelines: name = pipeline.get_value("name") if not name: name = pipeline.get_code() span = SpanWdg("Pipeline: %s" % name) span.add_style('font-weight: bold') v_div = FloatDivWdg(span) v_div.add_style('margin: 20px') v_div.add_style('min-height', min_height) v_div.add(HtmlElement.br(2)) content_div.add(v_div) processes = pipeline.get_processes(recurse=show_subpipeline, type=['manual','approval']) cb_name = '%s|task_process' %pipeline.get_code() master_cb = CheckboxWdg('master_control') master_cb.set_checked() master_cb.add_behavior({'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_add_task_panel'),'%s'); for (var i = 0; i < inputs.length; i++) inputs[i].checked = bvr.src_el.checked; ''' %cb_name}) toggle_div = DivWdg() toggle_div.add(SpanWdg(master_cb, css='small')) label = HtmlElement.i('toggle all') label.add_style('color: #888') toggle_div.add_styles('border-bottom: 1px solid #888; width: 170px') toggle_div.add(label) v_div.add(toggle_div) process_names = [] for process in processes: process_labels = [] if process.is_from_sub_pipeline(): process_name = process.get_full_name() else: process_name = process.get_name() process_label = process.get_label() if not process_label: process_label = '' if mode =='context': contexts = pipeline.get_output_contexts(process.get_name()) labels = contexts if process.is_from_sub_pipeline(): labels = ['%s/%s'%(process.parent_pipeline_code, x) for x in contexts] for x in labels: process_labels.append(process_label) # prepend process to contexts in this mode to ensure uniqueness contexts = ['%s:%s' %(process_name, x) for x in contexts] else: contexts = [process_name] labels = contexts process_labels.append(process_label) for idx, context in enumerate(contexts): cb = CheckboxWdg(cb_name) cb.set_checked() cb.set_option('value', context) v_div.add(SpanWdg(cb, css='small')) if mode == 'context': span = SpanWdg(process_name, css='med') #span.add_color('color','color') v_div.add(span) v_div.add(SpanWdg(labels[idx])) process_label = process_labels[idx] if process_label: v_div.add(SpanWdg("(%s)" %process_label, css='small')) v_div.add(HtmlElement.br()) content_div.add("<br clear='all'/>") skipped = [] if True: div.add("<br/>") btn = ActionButtonWdg(title='Add Tasks') btn.add_behavior({'type' : 'click_up', 'post_event': 'search_table_%s'% self.table_id, 'cbjs_action': ''' spt.dg_table.add_task_selected(bvr); ''', 'search_key_list': self.search_key_list }) cb = CheckboxWdg('skip_duplicated', label='Skip Duplicates') cb.set_checked() option_div =DivWdg(cb) option_div.add_style('width', '130px') option_div.add_style('align: left') div.add(option_div) div.add(HtmlElement.br()) btn.add_style("float: right") div.add(btn) div.add(HtmlElement.br(clear="all")) if skipped: content_div.add(HtmlElement.br()) skip_div = DivWdg('Missing pipeline code (Skipped)') skip_div.add_style('text-decoration: underline') content_div.add(skip_div) content_div.add(HtmlElement.br()) item_div = DivWdg() item_div.add_style('margin-left: 10px') content_div.add(item_div) for skip in skipped: item_div.add(skip.get_code()) item_div.add(HtmlElement.br()) return div
def get_display(my): top = my.top top.add_color("background", "background") top.add_color("color", "color") top.add_style("padding: 10px") top.add_style("min-width: 400px") from tactic.ui.app import HelpButtonWdg help_wdg = HelpButtonWdg(alias="exporting-csv-data") top.add(help_wdg) help_wdg.add_style("float: right") help_wdg.add_style("margin-top: -3px") if not my.check(): top.add(DivWdg('Error: %s' %my.error_msg)) top.add(HtmlElement.br(2)) return super(CsvExportWdg, my).get_display() if my.search_type_list and my.search_type_list[0] != my.search_type: st = SearchType.get(my.search_type_list[0]) title_div =DivWdg('Exporting related items [%s]' % st.get_title()) top.add(title_div) top.add(HtmlElement.br()) my.search_type = my.search_type_list[0] my.view = my.related_view if my.mode != 'export_all': num = len(my.selected_search_keys) else: search = Search(my.search_type) num = search.get_count() msg_div = DivWdg('Total: %s items to export'% num) msg_div.add_style("font-size: 12px") msg_div.add_style("font-weight: bold") msg_div.add_style('margin-left: 4px') top.add(msg_div) if num > 300: msg_div.add_behavior({'type':'load', 'cbjs_action': "spt.alert('%s items are about to be exported. It may take a while.')" %num}) top.add(HtmlElement.br()) div = DivWdg(css='spt_csv_export', id='csv_export_action') div.add_color("background", "background", -10) div.add_style("padding: 10px") div.add_style("margin: 5px") div.add_styles('max-height: 350px; overflow: auto') table = Table( css='minimal') table.add_color("color", "color") div.add(table) table.set_id('csv_export_table') table.center() cb_name = 'csv_column_name' master_cb = CheckboxWdg('master_control') master_cb.set_checked() master_cb.add_behavior({'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_csv_export'),'%s'); for (var i = 0; i < inputs.length; i++) inputs[i].checked = !inputs[i].checked; ''' %cb_name}) span = SpanWdg('Select Columns To Export') span.add_style('font-weight','600') table.add_row_cell(span) table.add_row_cell(HtmlElement.br()) tr = table.add_row() tr.add_style('border-bottom: 1px groove #777') td = table.add_cell(master_cb) label = HtmlElement.i('toggle all') label.add_style('color: #888') table.add_cell(label) col1 = table.add_col() col1.add_style('width: 35px') col2 = table.add_col() if not my.search_type or not my.view: return table # use overriding element names and derived titles if available config = WidgetConfigView.get_by_search_type(my.search_type, my.view) if my.element_names and config: filtered_columns = my.element_names titles = [] for name in my.element_names: title = config.get_element_title(name) titles.append(title) else: # excluding FunctionalTableElement filtered_columns = [] titles = [] if not config: columns = search.get_columns() filtered_columns = columns titles = ['n/a'] * len(filtered_columns) else: columns = config.get_element_names() filtered_columns = columns titles = config.get_element_titles() """ # commented out until it is decided 2.5 widgets will # use this class to differentiate between reg and functional element from pyasm.widget import FunctionalTableElement for column in columns: widget = config.get_display_widget(column) if isinstance(widget, FunctionalTableElement): continue filtered_columns.append(column) """ for idx, column in enumerate(filtered_columns): table.add_row() cb = CheckboxWdg(cb_name) cb.set_option('value', column) cb.set_checked() table.add_cell(cb) title = titles[idx] table.add_cell('<b>%s</b> (%s) '%(title, column)) action_div = DivWdg() widget = DivWdg() table.add_row_cell(widget) widget.add_style("margin: 20px 0 10px 0px") cb = CheckboxWdg('include_id', label=" Include ID") cb.set_default_checked() widget.add(cb) hint = HintWdg('To update entries with specific ID later, please check this option. For new inserts in this or other table later on, uncheck this option.') widget.add(hint) label = string.capwords(my.mode.replace('_', ' ')) button = ActionButtonWdg(title=label) is_export_all = my.mode == 'export_all' button.add_behavior({ 'type': "click_up", 'cbfn_action': 'spt.dg_table_action.csv_export', 'element': 'csv_export', 'column_names': 'csv_column_name', 'search_type': my.search_type, 'view': my.view, 'search_keys' : my.selected_search_keys, 'is_export_all' : is_export_all }) my.close_action = "var popup = bvr.src_el.getParent('.spt_popup');spt.popup.close(popup)" if my.close_action: close_button = ActionButtonWdg(title='Close') close_button.add_behavior({ 'type': "click", 'cbjs_action': my.close_action }) table = Table() action_div.add(table) table.center() table.add_row() td = table.add_cell(button) td.add_style("width: 130px") table.add_cell(close_button) action_div.add("<br clear='all'/>") top.add(div) top.add(HtmlElement.br()) top.add(action_div) return top
def get_display(my): data = my.kwargs.get('kwargs') if data: data = jsonloads(data) my.kwargs.update(data) my.search_type = my.kwargs.get("search_type") my.x_axis = my.kwargs.get("x_axis") if not my.x_axis: my.x_axis = 'code' my.y_axis = my.kwargs.get("y_axis") if type(my.y_axis) == types.ListType: my.y_axis = "|".join(my.y_axis) my.chart_type = my.kwargs.get("chart_type") if not my.chart_type: my.chart_type = 'bar' # get any search keys if any are passed in my.search_keys = my.kwargs.get("search_keys") top = DivWdg() top.add_class("spt_chart_builder") top.add_color("background", "background") top.add_border() from tactic.ui.app import HelpButtonWdg help_button = HelpButtonWdg(alias='charting') top.add(help_button) help_button.add_style("float: right") project = Project.get() search_types = project.get_search_types(include_sthpw=True) search_types = [x.get_value("search_type") for x in search_types] build_div = DivWdg() from pyasm.widget import SwapDisplayWdg swap_wdg = SwapDisplayWdg.get_triangle_wdg() swap_script = swap_wdg.get_swap_script() build_div.add(swap_wdg) build_div.add("<b>Chart Specifications</b>") build_div.add_style("margin-bottom: 5px") build_div.add_style("height: 25px") build_div.add_style("padding-top: 5px") build_div.add_gradient("background", "background", -10) build_div.add_color("color", "color") build_div.add_class("hand") build_div.add_class("SPT_DTS") top.add(build_div) build_div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var spec = top.getElement(".spt_chart_spec"); //spt.api.toggle_show_hide(spec); spt.toggle_show_hide(spec); %s; ''' % swap_script }) spec_div = DivWdg() spec_div.add_color("color", "color3") spec_div.add_color("background", "background3") spec_div.add_class("spt_chart_spec") spec_div.add_border() spec_div.add_style("padding: 10px") spec_div.add_style("margin: 5px") spec_div.add_style("display: none") top.add(spec_div) table = Table() table.add_color("color", "color3") spec_div.add(table) # add the search type selector table.add_row() table.add_cell("Search Type: ") search_type_div = DivWdg() search_type_select = TextWdg("search_type") search_type_select.set_value(my.search_type) #search_type_select.set_option("values", search_types) search_type_div.add(search_type_select) table.add_cell(search_type_div) # add the chart type selector table.add_row() table.add_cell("Chart Type: ") type_div = DivWdg() #type_div.add_style("padding: 3px") type_select = SelectWdg("chart_type") type_select.set_option("values", "line|bar|area") if my.chart_type: type_select.set_value(my.chart_type) type_div.add(type_select) table.add_cell(type_div) # add the chart type selector table.add_row() table.add_cell("X-Axis: ") # need to find all expression widgets or use get_text_value()? x_axis_div = DivWdg() x_axis_text = TextWdg("x_axis") x_axis_text.set_value("code") x_axis_div.add(x_axis_text) table.add_cell(x_axis_div) # add the chart type selector table.add_row() td = table.add_cell("Y-Axis: ") td.add_style("vertical-align: top") y_axis_div = DivWdg() #y_axis_text = TextWdg("y_axis") #if my.y_axis: # y_axis_text.set_value(my.y_axis) #y_axis_div.add(y_axis_text) td = table.add_cell(y_axis_div) # add in a list of entries from tactic.ui.container import DynamicListWdg list_wdg = DynamicListWdg() for value in my.y_axis.split("|"): item = TextWdg("y_axis") item.set_value(value, set_form_value=False) list_wdg.add_item(item) y_axis_div.add(list_wdg) spec_div.add("<br/>") from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Refresh") spec_div.add(button) spec_div.add(HtmlElement.br(2)) button.add_style("float: left") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var chart = top.getElement(".spt_chart"); var values = spt.api.get_input_values(top); //var values = spt.api.Utility.get_input_values(top); spt.panel.refresh(chart, values); ''' }) #TODO: provide a field for user to type in the chart name """ button = ActionButtonWdg(title="Save") spec_div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chart_builder"); var chart = top.getElement(".spt_chart"); var values = spt.api.get_input_values(top); var login = '******'; var search_type = 'SideBarWdg'; var side_bar_view = 'project_view'; var unique_el_name = 'chart_test' var kwargs = {}; kwargs['login'] = null; //if (save_as_personal) // kwargs['login'] = login; kwargs['class_name'] = 'tactic.ui.chart.ChartBuilderWdg'; var display_options = {}; display_options['search_type'] = 'prod/asset' kwargs['display_options'] = display_options; kwargs['unique'] = true; //if (new_title) // kwargs['element_attrs'] = {'title': new_title}; var server = TacticServerStub.get() server.add_config_element(search_type, side_bar_view, unique_el_name, kwargs); spt.panel.refresh("side_bar"); ''' } ) """ width = '600px' kwargs = { 'y_axis': my.y_axis, 'chart_type': my.chart_type, 'search_type': my.search_type, 'width': width, 'search_keys': my.search_keys } chart_div = DivWdg() chart = BarChartWdg(**kwargs) chart_div.add(chart) top.add(chart_div) #from chart2_wdg import SampleSObjectChartWdg #chart = SampleSObjectChartWdg(**kwargs) #chart_div.add(chart) return top
def get_filter_wdg(my): div = DivWdg() div.add_style("padding: 10px") div.add_style("margin: -10 -10 10 -10") div.add_style("min-width: 600px") div.add_class("spt_view_manager_filter") from tactic.ui.app import HelpButtonWdg help_wdg = HelpButtonWdg(alias="view-manager|what-are-views") div.add(help_wdg) help_wdg.add_style("float: right") div.add('<b>Search Type:</b> ') div.add_gradient("background", "background", -10) security = Environment.get_security() project = Project.get() if security.check_access("builtin", "view_site_admin", "allow"): search_type_objs = project.get_search_types(include_sthpw=True, include_config=True) else: search_type_objs = project.get_search_types() search_types = [x.get_value("search_type") for x in search_type_objs] titles = ["%s (%s)" % (x.get_value("search_type"), x.get_value("title")) for x in search_type_objs] select = SelectWdg(name='search_type') select.set_option('values', search_types) select.set_option('labels', titles) select.add_empty_option('-- Select --') select.set_persistence() #select.set_persist_on_submit() #security = Environment.get_security() #if security.check_access("builtin", "view_site_admin", "allow"): # select_mode = SearchTypeSelectWdg.ALL #else: # select_mode = SearchTypeSelectWdg.ALL_BUT_STHPW #select = SearchTypeSelectWdg(name='search_type', \ # mode=select_mode) behavior = {'type': 'change', 'cbjs_action': ''' var manager_top = bvr.src_el.getParent(".spt_view_manager_top"); var input = spt.api.Utility.get_input(manager_top, 'search_type'); var view_input = spt.api.Utility.get_input(manager_top, 'view'); var view_input_value = ''; if (view_input != null) { view_input_value = view_input.value; } var values = {'search_type': input.value, 'view': view_input_value, 'is_refresh': 'true'}; spt.panel.refresh(manager_top, values);''' #//spt.panel.refresh(manager_top, values);''' } select.add_behavior(behavior) select.set_value(my.search_type) div.add(select) if not my.search_type: content = DivWdg() content.add_style("width: 400px") content.add_style("height: 400px") div.add(content) content.add_style("padding: 20px") content.add( IconWdg("WARNING", IconWdg.WARNING) ) content.add("No Search Type Selected") content.add_border() content.add_style("margin-top: 20px") content.add_color("background", "background") content.add_style("font-weight: bold") return div div.add(' ') div.add('<b>View: </b>') view_wdg = SelectWdg("view") view_wdg.set_value(my.view) view_wdg.add_empty_option("-- Select --") view_wdg.add_behavior(behavior) div.add(view_wdg) search = Search("config/widget_config") search.add_filter("search_type", my.search_type) db_configs = search.get_sobjects() views = set() for db_config in db_configs: view = db_config.get_value("view") if view.startswith('link_search:'): continue views.update([view]) #print "search_type: ", my.search_type #print "view: ", views, my.view if my.search_type and my.view: config_view = WidgetConfigView.get_by_search_type(my.search_type, my.view) configs = config_view.get_configs() for x in configs: view = x.get_view() file_path = x.get_file_path() if view != my.view: continue if file_path and file_path.endswith("DEFAULT-conf.xml"): continue config_views = x.get_all_views() views.update(config_views) views_list = list(views) views_list.sort() view_wdg.set_option("values", views_list) return div
def get_display(self): if self.is_refresh: top = Widget() self.add(top) else: container = DivWdg() self.add(container) #parent = SearchKey.get_by_search_key(self.search_key) top = DivWdg() container.add(top) self.set_as_panel(top) top.add_style("margin-top: -2px") top.add_class("spt_uber_notes_top") from tactic.ui.app import HelpButtonWdg help_button = HelpButtonWdg(alias="note-sheet-widget") top.add(help_button) help_button.add_style("float: right") table_id = 'sub_table' view = 'table' span = DivWdg(css='spt_input_group') top.add(span) span.add_border() span.add_style("height: 27px") span.add_style("padding: 5px") button_div = DivWdg() span.add(button_div) button_div.add_style("float: left") button_div.add_style("margin-right: 10px") table = Table() button_div.add(table) table.add_row() from tactic.ui.widget import SingleButtonWdg refresh = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH) table.add_cell(refresh) refresh.add_style("float: left") refresh.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var tbody = top.getElements('.spt_table_tbody')[2]; var values = spt.api.Utility.get_input_values(tbody); spt.panel.refresh(top, values, false); ''' }) save = SingleButtonWdg(title="Save", icon=IconWdg.SAVE) table.add_cell(save) save.add_style("float: left") save.add_behavior( { 'type': 'click_up', 'update_current_only': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var table = top.getElement(".spt_table"); bvr.src_el = table; spt.dg_table.update_row(evt, bvr) ''' }) process = SingleButtonWdg(title="Show Processes", icon=IconWdg.PROCESS, show_arrow=True) table.add_cell(process) from tactic.ui.container import DialogWdg process_dialog = DialogWdg(display=False) span.add(process_dialog) process_dialog.set_as_activator(process) process_dialog.add_title("Processes") process_div = DivWdg() process_dialog.add(process_div) #process_div.add_style("padding: 5px") process_div.add_color("background", "background") process_div.add_color("color", "color") process_div.add_border() refresh = ActionButtonWdg(title="Refresh") refresh.add_style('margin: 0 auto 10px auto') process_div.add(refresh) refresh.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var tbody = top.getElements('.spt_table_tbody')[2]; var values = spt.api.Utility.get_input_values(tbody); spt.panel.refresh(top, values, false); ''' } ) process_div.add("<hr/>") selected_process_names = [] step = 0 for idx, value in enumerate(self.process_names): checkbox_name = 'note_process_cb' if self.child_mode: selected_process_names.append(value) #break cb = CheckboxWdg(checkbox_name, label=value) cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) #cb.set_persistence() cb.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.input.save_selected(bvr, '%s','%s'); ''' % (checkbox_name, key) }) # only 1 is selected in child_mode if cb.is_checked(): selected_process_names.append(value) if idx == 0 or idx == 10 * step: # add a new inner div inner_div = self._get_inner_div() process_div.add(inner_div, 'inner%s'%step) step += 1 inner_div.add(cb) inner_div.add("<br/>") # if less than 10, make it wider if len(self.process_names) < 10: inner_div.add_style('width: 100px') # add a master private checkbox if not self.child_mode: checkbox_name = 'note_master_private_cb' cb = CheckboxWdg(checkbox_name, label='make notes private') cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_uber_notes_top"); var tbody = top.getElements('.spt_table_tbody')[2]; var inputs = spt.api.Utility.get_inputs(tbody,'is_private'); for (var i = 0; i < inputs.length; i++) inputs[i].checked = bvr.src_el.checked; spt.input.save_selected(bvr, '%s','%s'); '''%(checkbox_name, key) }) cb_span = DivWdg(cb, css='small') cb_span.add_styles('border-left: 1px dotted #bbb; margin-left: 10px') span.add(cb_span) main_config_view = self._get_main_config(view, selected_process_names) sobject_dict = {} # TODO: do a union all search or by order number = 1 for value in selected_process_names: search = Search('sthpw/note') search.add_filter('project_code', Project.get_project_code()) search.add_filter('context', value) search.add_filter('search_type',self.parent_search_type) search.add_filter('search_id',self.parent_search_id) search.add_order_by('timestamp desc') search.add_limit(1) sobject = search.get_sobject() if sobject: sobject_dict[value] = sobject #sobjects = search.get_sobjects() # virtual sobject for placeholder, we can put more than 1 maybe? sobject = SearchType.create('sthpw/note') edit_config = self._get_edit_config('edit', selected_process_names) edit_configs = {'sthpw/note': edit_config} Container.put("CellEditWdg:configs", edit_configs) table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view='table', config=main_config_view, aux_info={'sobjects': sobject_dict, 'parent': self.parent}, mode="simple", show_row_select=False, show_insert=False, show_commit_all=True, show_refresh='false', state={'parent_key': self.search_key} ) table.set_sobject(sobject) top.add(table) return super(NoteSheetWdg, self).get_display()
def get_display(my): top = my.top top.add_color("background", "background") top.add_color("color", "color") top.add_style("padding: 10px") top.add_style("min-width: 400px") from tactic.ui.app import HelpButtonWdg help_wdg = HelpButtonWdg(alias="exporting-csv-data") top.add(help_wdg) help_wdg.add_style("float: right") help_wdg.add_style("margin-top: -3px") if not my.check(): top.add(DivWdg('Error: %s' %my.error_msg)) top.add(HtmlElement.br(2)) return super(CsvExportWdg, my).get_display() if my.search_type_list and my.search_type_list[0] != my.search_type: st = SearchType.get(my.search_type_list[0]) title_div =DivWdg('Exporting related items [%s]' % st.get_title()) top.add(title_div) top.add(HtmlElement.br()) my.search_type = my.search_type_list[0] my.view = my.related_view if my.mode != 'export_all': num = len(my.selected_search_keys) else: search = Search(my.search_type) num = search.get_count() msg_div = DivWdg('Total: %s items to export'% num) msg_div.add_style("font-size: 12px") msg_div.add_style("font-weight: bold") msg_div.add_style('margin-left: 4px') top.add(msg_div) if num > 300: msg_div.add_behavior({'type':'load', 'cbjs_action': "spt.alert('%s items are about to be exported. It may take a while.')" %num}) top.add(HtmlElement.br()) div = DivWdg(css='spt_csv_export', id='csv_export_action') div.add_color("background", "background", -10) div.add_style("padding: 10px") div.add_style("margin: 5px") div.add_styles('max-height: 350px; overflow: auto') table = Table( css='minimal') table.add_color("color", "color") div.add(table) table.set_id('csv_export_table') table.center() cb_name = 'csv_column_name' master_cb = CheckboxWdg('master_control') master_cb.set_checked() master_cb.add_behavior({'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_csv_export'),'%s'); for (var i = 0; i < inputs.length; i++) inputs[i].checked = !inputs[i].checked; ''' %cb_name}) span = SpanWdg('Select Columns To Export') span.add_style('font-weight','600') table.add_row_cell(span) table.add_row_cell(HtmlElement.br()) tr = table.add_row() tr.add_style('border-bottom: 1px groove #777') td = table.add_cell(master_cb) label = HtmlElement.i('toggle all') label.add_style('color: #888') table.add_cell(label) col1 = table.add_col() col1.add_style('width: 35px') col2 = table.add_col() if not my.search_type or not my.view: return table # use overriding element names and derived titles if available config = WidgetConfigView.get_by_search_type(my.search_type, my.view) if my.element_names and config: filtered_columns = my.element_names titles = [] for name in my.element_names: title = config.get_element_title(name) titles.append(title) else: # excluding FunctionalTableElement filtered_columns = [] titles = [] if not config: columns = search.get_columns() filtered_columns = columns titles = ['n/a'] * len(filtered_columns) else: columns = config.get_element_names() filtered_columns = columns titles = config.get_element_titles() """ # commented out until it is decided 2.5 widgets will # use this class to differentiate between reg and functional element from pyasm.widget import FunctionalTableElement for column in columns: widget = config.get_display_widget(column) if isinstance(widget, FunctionalTableElement): continue filtered_columns.append(column) """ for idx, column in enumerate(filtered_columns): table.add_row() cb = CheckboxWdg(cb_name) cb.set_option('value', column) cb.set_checked() table.add_cell(cb) title = titles[idx] table.add_cell('<b>%s</b> (%s) '%(title, column)) action_div = DivWdg() widget = DivWdg() table.add_row_cell(widget) widget.add_style("margin: 20px 0 10px 0px") cb = CheckboxWdg('include_id', label=" Include ID") cb.set_default_checked() widget.add(cb) hint = HintWdg('To update entries with specific ID later, please check this option. For new inserts in this or other table later on, uncheck this option.') widget.add(hint) label = string.capwords(my.mode.replace('_', ' ')) button = ActionButtonWdg(title=label, size='l') is_export_all = my.mode == 'export_all' button.add_behavior({ 'type': "click_up", 'cbfn_action': 'spt.dg_table_action.csv_export', 'element': 'csv_export', 'column_names': 'csv_column_name', 'search_type': my.search_type, 'view': my.view, 'search_keys' : my.selected_search_keys, 'is_export_all' : is_export_all }) my.close_action = "var popup = bvr.src_el.getParent('.spt_popup');spt.popup.close(popup)" if my.close_action: close_button = ActionButtonWdg(title='Close') close_button.add_behavior({ 'type': "click", 'cbjs_action': my.close_action }) table = Table() action_div.add(table) table.center() table.add_row() td = table.add_cell(button) td.add_style("width: 130px") table.add_cell(close_button) action_div.add("<br clear='all'/>") top.add(div) top.add(HtmlElement.br()) top.add(action_div) if my.is_test: rtn_data = {'columns': my.element_names, 'count': len(my.selected_search_keys)} if my.mode == 'export_matched': rtn_data['sql'] = my.table.search_wdg.search.get_statement() from pyasm.common import jsondumps rtn_data = jsondumps(rtn_data) return rtn_data return top