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_display(my): expr_filter = "sthpw/login['login','not in','admin|guest']['begin']['license_type','user']['license_type','is','NULL']['or']" current_users = Search.eval("@COUNT(%s)" %expr_filter) top = my.top top.add_class("spt_panel_user_top") top.add_style("min-width: 400px") tool_div = DivWdg() # tool_div.add_style('margin-bottom','8px') tool_div.add_style('display','inline-flex') tool_div.add_style('width','50%') tool_div.add_style('margin-bottom','-4px') button = ActionButtonWdg(title="Add", tip="Add New User") button.add_style('align-self: flex-end') tool_div.add(button) button.add_style("float: left") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: "sthpw/login", view: "insert", show_header: false, } var popup = spt.panel.load_popup("Create New User", class_name, kwargs); var top = bvr.src_el.getParent(".spt_panel_user_top"); popup.on_save_cbk = function() { spt.panel.refresh(top); } ''' } ) security = Environment.get_security() license = security.get_license() num_left = license.get_num_licenses_left() current_users = license.get_current_users() #max_users = license.get_max_users() div = DivWdg('Users') div.add_style('align-self: flex-end') div.add_styles("margin: 0 0 6px 20px") badge_span = SpanWdg(css='badge') badge_span.add_style('margin-left','6px') badge_span.add(current_users) div.add(badge_span) tool_div.add(div) tool_div2 = DivWdg() # tool_div.add_style('margin-bottom','8px') tool_div2.add_style('display','inline-flex') tool_div2.add_style('justify-content','flex-end') tool_div2.add_style('width','50%') top.add(tool_div) top.add(tool_div2) if num_left < 1000: div = DivWdg('Users Left') div.add_style('align-self: flex-end') div.add_styles("margin: 0 0 6px 20px") badge_span = SpanWdg(css='badge') badge_span.add_style('margin-left','6px') badge_span.add(num_left) div.add(badge_span) tool_div.add(div) top.add(tool_div) show_security = my.kwargs.get("show_security") if show_security not in ['false', False]: button = ActionButtonWdg(title="Security") button.add_style('align-self: flex-end') #button.add_styles("position: absolute; right: 10px;") tool_div2.add(button) #button.add_style("margin-top: -8px") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.SecurityWdg'; spt.tab.set_main_body_tab() spt.tab.add_new("Security", "Security", class_name) ''' } ) br = HtmlElement.br(clear=True) top.add(br) if not current_users: div = DivWdg() top.add(div) div.add_style("text-align: center") div.add_border() div.add_style("min-height: 150px") div.add_style("margin: 15px 30px 30px 30px") div.add_style("padding: 30px 20px 0px 20px") div.add_color("background", "background3") icon = IconWdg( "WARNING", IconWdg.WARNING ) div.add(icon) div.add("<b>No users have been added</b>") div.add("<br/><br/>") div.add("For more information, read the help docs: ") from tactic.ui.app import HelpButtonWdg help = HelpButtonWdg(alias=my.get_help_alias()) div.add(help) div.add("<br/>") div.add("Click on the 'Add' button above to start adding new users.") return top div = DivWdg() top.add(div) #div.add_style("max-height: 300px") #div.add_style("overflow-y: auto") expr = "@SEARCH(%s)" %expr_filter panel = ViewPanelWdg(search_type='sthpw/login',view='manage_user',show_insert='false',\ show_gear='false', show_select='false', height='700', expression=expr,\ simple_search_view='simple_manage_filter', show_column_manager='false',\ show_layout_switcher='false', show_expand='false') div.add(panel) div.add_style('margin-top', '4px') return top """
def get_display(my): web = WebContainer.get_web() show_multi_project = web.get_form_value('show_multi_project') project = Project.get() search_type_objs = project.get_search_types(include_multi_project=show_multi_project) top = my.top top.add_class("spt_panel_stype_list_top") #top.add_style("min-width: 400px") #top.add_style("max-width: 1000px") #top.add_style("width: 100%") top.center() button = SingleButtonWdg(title="Advanced Setup", icon=IconWdg.ADVANCED) top.add(button) button.add_style("float: right") button.add_style("margin-top: -8px") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.ProjectStartWdg'; spt.tab.set_main_body_tab() spt.tab.add_new("project_setup", "Project Setup", class_name) ''' } ) button = SingleButtonWdg(title="Add", tip="Add New Searchable Type (sType)", icon=IconWdg.ADD) top.add(button) button.add_style("float: left") button.add_style("margin-top: -8px") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.SearchTypeCreatorWdg'; var kwargs = { }; var popup = spt.panel.load_popup("Create New Searchable Type", class_name, kwargs); var top = bvr.src_el.getParent(".spt_panel_stype_list_top"); popup.on_register_cbk = function() { spt.panel.refresh(top); } ''' } ) cb = CheckboxWdg('show_multi_project', label=' show multi-project') if show_multi_project: cb.set_checked() cb.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var panel = bvr.src_el.getParent('.spt_panel_stype_list_top') spt.panel.refresh(panel, {show_multi_project: bvr.src_el.checked}); ''' }) span = SpanWdg(css='small') top.add(span) top.add(cb) top.add("<br clear='all'/>") #search_type_objs = [] if not search_type_objs: arrow_div = DivWdg() top.add(arrow_div) icon = IconWdg("Click to Add", IconWdg.ARROW_UP_LEFT_32) icon.add_style("margin-top: -20") icon.add_style("margin-left: -15") icon.add_style("position: absolute") arrow_div.add(icon) arrow_div.add(" "*5) arrow_div.add("<b>Click to Add</b>") arrow_div.add_style("position: relative") arrow_div.add_style("margin-top: 5px") arrow_div.add_style("margin-left: 20px") arrow_div.add_style("float: left") arrow_div.add_style("padding: 25px") arrow_div.set_box_shadow("0px 5px 20px") arrow_div.set_round_corners(30) arrow_div.add_color("background", "background") div = DivWdg() top.add(div) div.add_border() div.add_style("min-height: 180px") div.add_style("width: 600px") div.add_style("margin: 30px auto") div.add_style("padding: 20px") div.add_color("background", "background3") icon = IconWdg( "WARNING", IconWdg.WARNING ) div.add(icon) div.add("<b>No Searchable Types have been created</b>") div.add("<br/><br/>") div.add("Searchables Types contain lists of items that are managed in this project. Each item will automatically have the ability to have files checked into it, track tasks and status and record work hours.") div.add("<br/>"*2) div.add("For more information, read the help docs: ") from tactic.ui.app import HelpButtonWdg help = HelpButtonWdg(alias="main") div.add(help) div.add("<br/>") div.add("Click on the 'Add' button above to start adding new types.") return top div = DivWdg() top.add(div) #div.add_style("max-height: 300px") #div.add_style("overflow-y: auto") table = Table() div.add(table) table.add_style("margin-top: 10px") table.set_max_width() # group mouse over table.add_relay_behavior( { 'type': "mouseover", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})" } ) table.add_relay_behavior( { 'type': "mouseout", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})" } ) tr = table.add_row() tr.add_color("color", "color") tr.add_gradient("background", "background", -10) th = table.add_header("") th.add_style("text-align: left") th = table.add_header("Title") th.add_style("text-align: left") th = table.add_header("# Items") th.add_style("text-align: left") th = table.add_header("View") th.add_style("text-align: left") th = table.add_header("Add") th.add_style("text-align: left") th = table.add_header("Import") th.add_style("text-align: left") th = table.add_header("Custom Columns") th.add_style("text-align: left") th = table.add_header("Workflow") th.add_style("text-align: left") th = table.add_header("Notifications") th.add_style("text-align: left") th = table.add_header("Triggers") th.add_style("text-align: left") th = table.add_header("Edit") th.add_style("text-align: left") #th = table.add_header("Security") #th.add_style("text-align: left") for i, search_type_obj in enumerate(search_type_objs): tr = table.add_row() tr.add_class("spt_row") if not i or not i%2: tr.add_color("background", "background3") else: tr.add_color("background", "background", -2 ) thumb = ThumbWdg() thumb.set_sobject(search_type_obj) thumb.set_icon_size(30) td = table.add_cell(thumb) search_type = search_type_obj.get_value("search_type") title = search_type_obj.get_title() table.add_cell(title) try: search = Search(search_type) count = search.get_count() if count: table.add_cell("%s item/s" % count) else: table.add_cell(" ") except: td = table.add_cell("< No table >") td.add_style("font-style: italic") td.add_style("color: #F00") continue #search = Search(search_type) #search.add_interval_filter("timestamp", "today") #created_today = search.get_count() #table.add_cell(created_today) td = table.add_cell() button = IconButtonWdg(title="View", icon=IconWdg.ZOOM) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'title': title, 'cbjs_action': ''' var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'table', 'simple_search_view': 'simple_search' }; // use tab var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); //spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) button.add_style("float: left") arrow_button = IconButtonWdg(tip="More Views", icon=IconWdg.ARROWHEAD_DARK_DOWN) arrow_button.add_style("margin-left: 20px") td.add(arrow_button) cbk = ''' var activator = spt.smenu.get_activator(bvr); var class_name = bvr.class_name; var layout = bvr.layout; var kwargs = { search_type: bvr.search_type, layout: layout, view: bvr.view, simple_search_view: 'simple_search', element_names: bvr.element_names, }; // use tab var top = activator.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new('%s', '%s', class_name, kwargs); ''' % (title, title) from tactic.ui.panel import SwitchLayoutMenu SwitchLayoutMenu(search_type=search_type, activator=arrow_button, cbk=cbk, is_refresh=False) td = table.add_cell() button = IconButtonWdg(title="Add", icon=IconWdg.ADD) td.add(button) button.add_behavior( { 'type': 'listen', 'search_type': search_type, 'event_name': 'startup_save:' + search_type_obj.get_title(), 'title': search_type_obj.get_title(), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'table', 'simple_search_view': 'simple_search' }; spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); ''' } ) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'title': search_type_obj.get_title(), 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: bvr.search_type, view: "insert", save_event: "startup_save:" + bvr.title } spt.panel.load_popup("Add New Items ("+bvr.title+")", class_name, kwargs); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'table', 'simple_search_view': 'simple_search' }; spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); ''' } ) """ td = table.add_cell() button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'title': title, 'cbjs_action': ''' var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { search_type: bvr.search_type, view: 'checkin', element_names: ['preview','code','name','description','history','general_checkin','notes'] }; // use tab var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs); //spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) """ td = table.add_cell() button = IconButtonWdg(title="Import", icon=IconWdg.IMPORT) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'title': "Import Data", 'cbjs_action': ''' var class_name = 'tactic.ui.widget.CsvImportWdg'; var kwargs = { search_type: bvr.search_type, }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Custom Columns", icon=IconWdg.COLUMNS) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_type': search_type, 'title': "Add Custom Columns", 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ColumnEditWdg'; var kwargs = { search_type: bvr.search_type, }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Workflow", icon=IconWdg.PIPELINE) button.add_style("float: left") td.add(button) search = Search("sthpw/pipeline") search.add_filter("search_type", search_type) count = search.get_count() if count: check = IconWdg( "Has Items", IconWdg.CHECK, width=8 ) td.add(check) #check.add_style("margin-left: 0px") check.add_style("margin-top: 4px") button.add_behavior( { 'type': 'click_up', 'title': 'Workflow', 'search_type': search_type, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.PipelineEditWdg'; var kwargs = { search_type: bvr.search_type }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Notifications", icon=IconWdg.MAIL) button.add_style("float: left") td.add(button) search = Search("sthpw/notification") search.add_filter("search_type", search_type) count = search.get_count() if count: check = IconWdg( "Has Items", IconWdg.CHECK, width=8 ) td.add(check) #check.add_style("margin-left: 0px") check.add_style("margin-top: 4px") button.add_behavior( { 'type': 'click_up', 'title': 'Trigger', 'search_type': search_type, 'cbjs_action': ''' var class_name = 'tactic.ui.tools.TriggerToolWdg'; var kwargs = { mode: "search_type", search_type: bvr.search_type }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Triggers", icon=IconWdg.ARROW_OUT) td.add(button) button.add_style("float: left") search = Search("config/trigger") search.add_filter("search_type", search_type) count = search.get_count() if count: check = IconWdg( "Has Items", IconWdg.CHECK, width=8 ) td.add(check) #check.add_style("margin-left: 0px") check.add_style("margin-top: 4px") button.add_behavior( { 'type': 'click_up', 'title': 'Trigger', 'search_type': search_type, 'cbjs_action': ''' var class_name = 'tactic.ui.tools.TriggerToolWdg'; var kwargs = { mode: "search_type", search_type: bvr.search_type }; spt.panel.load_popup(bvr.title, class_name, kwargs); ''' } ) td = table.add_cell() button = IconButtonWdg(title="Edit Searchable Type", icon=IconWdg.EDIT) td.add(button) button.add_behavior( { 'type': 'click_up', 'search_key': search_type_obj.get_search_key(), 'cbjs_action': ''' var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: "sthpw/sobject", view: "edit_startup", search_key: bvr.search_key } spt.panel.load_popup("Edit Searchable Type", class_name, kwargs); ''' } ) """ td = table.add_cell() button = IconButtonWdg(title="Security", icon=IconWdg.LOCK) td.add(button) button.add_behavior( { 'type': 'click_up', 'title': 'Trigger', 'search_type': search_type, 'cbjs_action': ''' alert("security"); ''' } ) """ columns_wdg = DivWdg() top.add(columns_wdg) 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): search = Search("sthpw/login") logins = search.get_sobjects() top = my.top top.add_class("spt_panel_user_top") top.add_style("min-width: 400px") button = SingleButtonWdg(title="Advanced Security", icon=IconWdg.LOCK) top.add(button) button.add_style("float: right") button.add_style("margin-top: -8px") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.SecurityWdg'; spt.tab.set_main_body_tab() spt.tab.add_new("Security", "Security", class_name) ''' }) button = SingleButtonWdg(title="Add", tip="Add New User", icon=IconWdg.ADD) top.add(button) button.add_style("float: left") button.add_style("margin-top: -8px") top.add("<br clear='all'/>") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: "sthpw/login", view: "edit", } var popup = spt.panel.load_popup("Create New User", class_name, kwargs); var top = bvr.src_el.getParent(".spt_panel_user_top"); popup.on_save_cbk = function() { spt.panel.refresh(top); } ''' }) #logins = [] if not logins: arrow_div = DivWdg() top.add(arrow_div) arrow_div.add("<b><<< Click to Add</b>") arrow_div.add_style("position: relative") arrow_div.add_style("margin-top: -35px") arrow_div.add_style("margin-left: 35px") arrow_div.add_style("float: left") arrow_div.add_style("padding: 5px") arrow_div.set_box_shadow("1px 1px 2px 2px") arrow_div.set_round_corners(10, corners=['TL', 'BL']) div = DivWdg() top.add(div) div.add_border() div.add_style("min-height: 180px") div.add_style("margin: 15px 30px 30px 30px") div.add_style("padding: 20px") div.add_color("background", "background3") icon = IconWdg("WARNING", IconWdg.WARNING) div.add(icon) div.add("<b>No users have been added</b>") div.add("<br/><br/>") div.add("For more information, read the help docs: ") from tactic.ui.app import HelpButtonWdg help = HelpButtonWdg(alias=my.get_help_alias()) div.add(help) div.add("<br/>") div.add( "Click on the 'Add' button above to start adding new users.") return top div = DivWdg() top.add(div) #div.add_style("max-height: 300px") #div.add_style("overflow-y: auto") table = Table() table.set_max_width() table.add_style("margin-top: 10px") div.add(table) # group mouse over table.add_relay_behavior({ 'type': "mouseover", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})" }) table.add_relay_behavior({ 'type': "mouseout", 'bvr_match_class': 'spt_row', 'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})" }) tr = table.add_row() tr.add_color("color", "color") tr.add_gradient("background", "background", -10) th = table.add_header(" ") th.add_style("text-align: left") th = table.add_header("Login") th.add_style("text-align: left") th = table.add_header("First Name") th.add_style("text-align: left") th = table.add_header("Last Name") th.add_style("text-align: left") th = table.add_header("Display Name") th.add_style("text-align: left") th = table.add_header("Activity") th.add_style("text-align: left") th = table.add_header("Groups") th.add_style("text-align: left") th = table.add_header("Security") th.add_style("text-align: left") th = table.add_header("Edit") th.add_style("text-align: left") for i, login in enumerate(logins): tr = table.add_row() tr.add_class("spt_row") if not i or not i % 2: tr.add_color("background", "background3") else: tr.add_color("background", "background", -2) thumb = ThumbWdg() thumb.set_sobject(login) thumb.set_icon_size(30) td = table.add_cell(thumb) td = table.add_cell(login.get_value("login")) td.add_style("padding: 3px") td = table.add_cell(login.get_value("first_name")) td.add_style("padding: 3px") td = table.add_cell(login.get_value("last_name")) td.add_style("padding: 3px") td = table.add_cell(login.get_value("display_name")) td.add_style("padding: 3px") search_key = login.get_search_key() login_code = login.get_code() full_name = login.get_full_name() td = table.add_cell() button = IconButtonWdg(tip="Activity", icon=IconWdg.CALENDAR) td.add(button) button.add_behavior({ 'type': 'click_up', 'login_code': login_code, 'full_name': full_name, 'cbjs_action': ''' var class_name = 'tactic.ui.tools.ScheduleUserToolWdg'; var kwargs = { login: bvr.login_code } var title = bvr.full_name + ' Schedule'; var top = bvr.src_el.getParent(".spt_dashboard_top"); spt.tab.set_tab_top(top); spt.tab.add_new("user_schedule", title, class_name, kwargs); //spt.panel.load_popup("Activty", class_name, kwargs); ''' }) td = table.add_cell() button = IconButtonWdg(title="Groups", icon=IconWdg.GROUP_LINK) td.add(button) button.add_behavior({ 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.GroupAssignWdg'; var kwargs = { search_key: bvr.search_key }; var popup = spt.panel.load_popup("Group Assignment", class_name, kwargs); ''' }) td = table.add_cell() button = IconButtonWdg(title="Security", icon=IconWdg.LOCK) td.add(button) button.add_behavior({ 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' var class_name = 'tactic.ui.startup.GroupSummaryWdg'; var kwargs = { search_key: bvr.search_key }; var popup = spt.panel.load_popup("Security Summary", class_name, kwargs); ''' }) td = table.add_cell() button = IconButtonWdg(title="Edit User", icon=IconWdg.EDIT) td.add(button) button.add_behavior({ 'type': 'click_up', 'search_key': search_key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_panel_user_top"); var class_name = 'tactic.ui.panel.EditWdg'; var kwargs = { search_type: "sthpw/login", view: "edit", search_key: bvr.search_key } var popup = spt.panel.load_popup("Create New User", class_name, kwargs); popup.on_save_cbk = function() { spt.panel.refresh(top); } ''' }) return top
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