def get_display(self): # set up the self refresh event for other widgets or callbacks to call event_container = WebContainer.get_event_container() script = ClipboardWdg.get_self_refresh_script(show_progress=False) event_container.add_listener(self.EVENT_ID, script, replace=True ) if self.is_from_ajax(): div = Widget() else: div = DivWdg() div.set_id(self.ID) div.add_style("display: block") div.add_class("background_box") div.add_style("padding-left: 3px") div.add_style("padding-right: 3px") div.add_style("height: 1.5em") div.add_style("width: 150px") # handle the ajax self.set_ajax_top_id(self.ID) self.register_cmd(ClipboardClearCbk) refresh_script = self.get_refresh_script() search = Search("sthpw/clipboard") search.add_user_filter() search.add_filter("category", "select") count = search.get_count() div.add("Clipboard: %s items: " % count) web = WebContainer.get_web() url = WebContainer.get_web().get_widget_url() url.set_option("widget", "pyasm.widget.ClipboardListWdg") ref = url.to_string() iframe = WebContainer.get_iframe() iframe.set_width(64) action = iframe.get_on_script(ref) button = IconButtonWdg("View Clipboard", IconWdg.LOAD) button.add_event("onclick", action) div.add(button) # add the clear clipboard icon clear_icon = IconButtonWdg("Clear Clipboard", IconWdg.CLEAR) clear_icon.add_event("onclick", refresh_script) div.add(clear_icon) return div
def get_display(self): # set up the self refresh event for other widgets or callbacks to call event_container = WebContainer.get_event_container() script = ClipboardWdg.get_self_refresh_script(show_progress=False) event_container.add_listener(self.EVENT_ID, script, replace=True) if self.is_from_ajax(): div = Widget() else: div = DivWdg() div.set_id(self.ID) div.add_style("display: block") div.add_class("background_box") div.add_style("padding-left: 3px") div.add_style("padding-right: 3px") div.add_style("height: 1.5em") div.add_style("width: 150px") # handle the ajax self.set_ajax_top_id(self.ID) self.register_cmd(ClipboardClearCbk) refresh_script = self.get_refresh_script() search = Search("sthpw/clipboard") search.add_user_filter() search.add_filter("category", "select") count = search.get_count() div.add("Clipboard: %s items: " % count) web = WebContainer.get_web() url = WebContainer.get_web().get_widget_url() url.set_option("widget", "pyasm.widget.ClipboardListWdg") ref = url.to_string() iframe = WebContainer.get_iframe() iframe.set_width(64) action = iframe.get_on_script(ref) button = IconButtonWdg("View Clipboard", IconWdg.LOAD) button.add_event("onclick", action) div.add(button) # add the clear clipboard icon clear_icon = IconButtonWdg("Clear Clipboard", IconWdg.CLEAR) clear_icon.add_event("onclick", refresh_script) div.add(clear_icon) 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(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(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()