def get_viewer(my): top = DivWdg(css='spt_note_viewer_top') # draw checkbox options swap = SwapDisplayWdg() title = SpanWdg('main context') split_div = FloatDivWdg(css='spt_split_cb') div = DivWdg(css='spt_main_context_cb') content_div = DivWdg() content_div.add_color('color', 'color') content_div.add_style('padding: 10px') SwapDisplayWdg.create_swap_title(title, swap, content_div, is_open=False) div.add(swap) div.add(title) checkbox_name = 'split_screen' split_cb = CheckboxWdg(checkbox_name, label='Split View') split_cb.persistence = True split_cb.persistence_obj = split_cb key = split_cb.get_key() #cb.add_style('float: left') split_cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_viewer_top"); var table_top = top.getElement(".spt_note_viewer_table"); var cbs = top.getElement('.spt_main_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.note_context_cb; var kwargs = { process_names: processes}; if (bvr.src_el.checked) { kwargs.split_view = 'true'; kwargs.show_context = 'true'; kwargs.left_process_names = processes; kwargs.right_process_names = processes; } spt.input.save_selected(bvr, '%s','%s'); spt.app_busy.show("Note Viewer", 'Loading') ; setTimeout(function(){ spt.panel.refresh(table_top, kwargs, false); if (bvr.src_el.checked) spt.hide(cbs); else spt.show(cbs); spt.app_busy.hide(); }, 50 ); ''' % (checkbox_name, key) }) split_div.add(split_cb) top.add(split_div) top.add(div) div.add(content_div) top.add(HtmlElement.br()) checkbox_name = 'note_main_context_cb' cb = CheckboxWdg(checkbox_name) cb.persistence = True cb.persistence_obj = cb my.checked_process_names = cb.get_values() for value in my.process_names: #my.checked_process_names = web.get_form_values('process_names') cb = CheckboxWdg(checkbox_name, label=value) if value in my.checked_process_names: my.checked_processes.append(value) # FIXME: this is very tenous. Accessing private members to # override behavior cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_viewer_top") var table_top = top.getElement('.spt_note_viewer_table'); var cbs = top.getElement('.spt_main_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.note_main_context_cb; var kwargs = { process_names: processes}; spt.input.save_selected(bvr, '%s','%s'); spt.panel.refresh(table_top, kwargs, false); ''' % (checkbox_name, key) }) content_div.add(cb) table_top = DivWdg(css='spt_note_viewer_table') expression = "@SOBJECT(sthpw/note['context','in','%s'])" % '|'.join( my.checked_processes) if split_cb.is_checked(): table = my.get_split_viewer() else: table_id = 'main_table1' table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=my.view,\ show_row_select=True, show_insert=False, state={'parent_key': my.parent_key}, inline_search=False, show_refresh=True, expression=expression ) my.set_as_panel(table_top) table_top.add_style('float: left') top.add(table_top) table_top.add(table) return top
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_viewer(my): top = DivWdg(css='spt_single_note_viewer_top') # draw checkbox options swap = SwapDisplayWdg() title = SpanWdg('context') title.add_color('color', 'color') div = DivWdg(css='spt_context_cb') div.add_color('color', 'color') SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False) checkbox_name = 'split_screen' checked_process_names = [] if my.show_context: top.add(swap) top.add(title) top.add(div) #checkbox_name = 'note_context_cb' checkbox_name = my.checkbox_name cb = CheckboxWdg(checkbox_name) cb.persistence = True cb.persistence_obj = cb checked_process_names = cb.get_values() for value in my.process_names: #my.checked_process_names = web.get_form_values('process_names') cb = CheckboxWdg(checkbox_name, label=value) if value in checked_process_names: my.checked_processes.append(value) # FIXME: this is very tenous. Accessing private members to # override behavior cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_single_note_viewer_top") var table_top = top.getElement('.spt_note_viewer_table'); var cbs = top.getElement('.spt_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.%s; var kwargs = { process_names: processes}; spt.input.save_selected(bvr, '%s','%s'); spt.panel.refresh(table_top, kwargs, false); ''' % (checkbox_name, checkbox_name, key) }) div.add(cb) else: web = WebContainer.get_web() checked_process_names = web.get_form_values('process_names') table_top = DivWdg(css='spt_note_viewer_table') expression = "@SOBJECT(sthpw/note['context','in','%s'])" % '|'.join( checked_process_names) table_id = 'main_table1' table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=my.view,\ show_row_select=True, show_insert=False, state={'parent_key': my.parent_key}, inline_search=False, show_refresh=True, expression=expression ) if my.resize: from tactic.ui.container import ResizeScrollWdg inner_wdg = ResizeScrollWdg(width='500px', height='500px', scroll_bar_size_str='thick', scroll_expansion='inside') inner_wdg.add(table) table_top.add(inner_wdg) else: table_top.add(table) my.set_as_panel(table_top) top.add(table_top) return top
def get_viewer(self): top = DivWdg(css='spt_note_viewer_top') # draw checkbox options swap = SwapDisplayWdg() title = SpanWdg('main context') split_div = FloatDivWdg(css='spt_split_cb') div = DivWdg(css='spt_main_context_cb') content_div = DivWdg() content_div.add_color('color','color') content_div.add_style('padding: 10px') SwapDisplayWdg.create_swap_title(title, swap, content_div, is_open=False) div.add(swap) div.add(title) checkbox_name = 'split_screen' split_cb = CheckboxWdg(checkbox_name, label='Split View') split_cb.persistence = True split_cb.persistence_obj = split_cb key = split_cb.get_key() #cb.add_style('float: left') split_cb.add_behavior({'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_viewer_top"); var table_top = top.getElement(".spt_note_viewer_table"); var cbs = top.getElement('.spt_main_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.note_context_cb; var kwargs = { process_names: processes}; if (bvr.src_el.checked) { kwargs.split_view = 'true'; kwargs.show_context = 'true'; kwargs.left_process_names = processes; kwargs.right_process_names = processes; } spt.input.save_selected(bvr, '%s','%s'); spt.app_busy.show("Note Viewer", 'Loading') ; setTimeout(function(){ spt.panel.refresh(table_top, kwargs, false); if (bvr.src_el.checked) spt.hide(cbs); else spt.show(cbs); spt.app_busy.hide(); }, 50 ); ''' % ( checkbox_name, key) }) split_div.add(split_cb) top.add(split_div) top.add(div) div.add(content_div) top.add(HtmlElement.br()) checkbox_name = 'note_main_context_cb' cb = CheckboxWdg(checkbox_name) cb.persistence = True cb.persistence_obj = cb self.checked_process_names = cb.get_values() for value in self.process_names: #self.checked_process_names = web.get_form_values('process_names') cb = CheckboxWdg(checkbox_name, label=value) if value in self.checked_process_names: self.checked_processes.append(value) # FIXME: this is very tenous. Accessing private members to # override behavior cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_note_viewer_top") var table_top = top.getElement('.spt_note_viewer_table'); var cbs = top.getElement('.spt_main_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.note_main_context_cb; var kwargs = { process_names: processes}; spt.input.save_selected(bvr, '%s','%s'); spt.panel.refresh(table_top, kwargs, false); ''' % (checkbox_name, key) }) content_div.add(cb) table_top = DivWdg(css='spt_note_viewer_table') expression = "@SOBJECT(sthpw/note['context','in','%s'])" %'|'.join(self.checked_processes) if split_cb.is_checked(): table = self.get_split_viewer() else: table_id = 'main_table1' table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=self.view,\ show_row_select=True, show_insert=False, state={'parent_key': self.parent_key}, inline_search=False, show_refresh=True, expression=expression ) self.set_as_panel(table_top) table_top.add_style('float: left') top.add(table_top) table_top.add(table) return top
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_viewer(self): top = DivWdg(css='spt_single_note_viewer_top') # draw checkbox options swap = SwapDisplayWdg() title = SpanWdg('context') title.add_color('color','color') div = DivWdg(css='spt_context_cb') div.add_color('color','color') SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False) checkbox_name = 'split_screen' checked_process_names = [] if self.show_context: top.add(swap) top.add(title) top.add(div) #checkbox_name = 'note_context_cb' checkbox_name = self.checkbox_name cb = CheckboxWdg(checkbox_name) cb.persistence = True cb.persistence_obj = cb checked_process_names = cb.get_values() for value in self.process_names: #self.checked_process_names = web.get_form_values('process_names') cb = CheckboxWdg(checkbox_name, label=value) if value in checked_process_names: self.checked_processes.append(value) # FIXME: this is very tenous. Accessing private members to # override behavior cb.persistence = True cb.persistence_obj = cb key = cb.get_key() cb.set_option('value', value) cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_single_note_viewer_top") var table_top = top.getElement('.spt_note_viewer_table'); var cbs = top.getElement('.spt_context_cb'); var values = spt.api.Utility.get_input_values(cbs); var processes = values.%s; var kwargs = { process_names: processes}; spt.input.save_selected(bvr, '%s','%s'); spt.panel.refresh(table_top, kwargs, false); ''' % (checkbox_name, checkbox_name, key) }) div.add(cb) else: web = WebContainer.get_web() checked_process_names = web.get_form_values('process_names') table_top = DivWdg(css='spt_note_viewer_table') expression = "@SOBJECT(sthpw/note['context','in','%s'])" %'|'.join(checked_process_names) table_id = 'main_table1' table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=self.view,\ show_row_select=True, show_insert=False, state={'parent_key': self.parent_key}, inline_search=False, show_refresh=True, expression=expression ) if self.resize: from tactic.ui.container import ResizeScrollWdg inner_wdg = ResizeScrollWdg( width='500px', height='500px', scroll_bar_size_str='thick', scroll_expansion='inside' ) inner_wdg.add(table) table_top.add(inner_wdg) else: table_top.add(table) self.set_as_panel(table_top) top.add(table_top) return top