def get_display(my): widget = Widget() if not my.select: return widget if not my.schema: Environment.add_warning("No schema defined") widget.add("No schema defined") return widget if not my.search_type: Environment.add_warning("HierarchicalFilterWdg: Cannot find current search_type") widget.add("Cannot find current search_type") return widget span = SpanWdg(css="med") parent_type = my.get_parent_type() if parent_type: parent_type_obj = SearchType.get(parent_type) span.add("%s: " % parent_type_obj.get_value("title")) # assume that there is a code in the parent my.select.add_empty_option("-- Select --") my.select.set_option("query", "%s|code|code" % my.parent_type) span.add(my.select) widget.add(span) return widget
def get_display(my): #my.init() item_table = Table(css='minimal') item_table.add_style('margin-left','30px') for item in my.items: item_table.add_row() space_td = item_table.add_blank_cell() item_td = item_table.add_cell(item.get_description()) item_td.set_attr("nowrap", "1") delete = IconSubmitWdg("Remove from group", \ "stock_stop-16.png",add_hidden=False) delete.add_event("onclick","document.form.remove_cmd.value=\ '%s|%s';document.form.submit();" \ % (my.group.get_primary_key_value(), item.get_primary_key_value()) ) del_span = SpanWdg(css='med') del_span.add(delete) item_table.add_cell(del_span) if not my.items: item_table.add_blank_cell() my.add(item_table) return super(ItemInContainerWdg, my).get_display()
def get_display(self): #self.init() item_table = Table(css='minimal') item_table.add_style('margin-left', '30px') for item in self.items: item_table.add_row() space_td = item_table.add_blank_cell() item_td = item_table.add_cell(item.get_description()) item_td.set_attr("nowrap", "1") delete = IconSubmitWdg("Remove from group", \ "stock_stop-16.png",add_hidden=False) delete.add_event("onclick","document.form.remove_cmd.value=\ '%s|%s';document.form.submit();" \ % (self.group.get_primary_key_value(), item.get_primary_key_value()) ) del_span = SpanWdg(css='med') del_span.add(delete) item_table.add_cell(del_span) if not self.items: item_table.add_blank_cell() self.add(item_table) return super(ItemInContainerWdg, self).get_display()
def get_instantiation_wdg(self): setting = self.get_default_setting() default_instantiation = setting.get('instantiation') div = DivWdg() is_unchecked = True default_cb = None for value in self.get_instantiation_options(): name = self.get_element_name("instantiation") checkbox = CheckboxWdg( name ) if value == default_instantiation: default_cb = checkbox checkbox.set_option("value", value) checkbox.set_persistence() if checkbox.is_checked(): is_unchecked = False checkbox.add_behavior({'type': 'click_up', 'propagate_evt': True, "cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" %name}) span = SpanWdg(checkbox, css='small') span.add(value) div.add(span) if is_unchecked: default_cb.set_checked() return div
def get_frame_rate_section(self): section_span = SpanWdg() section_span.add('Frame Rate: ') frame_rate_select = SelectWdg('frame_rate_select') frame_rate_select.set_id('frame_rate_code') frame_rate_select.add_style('width', '153px') frame_rate_select.add_style('display', 'inline-block') frame_rate_select.add_empty_option() frame_rate_search = Search('twog/frame_rate') frame_rates = frame_rate_search.get_sobjects() for frame_rate in frame_rates: frame_rate_select.append_option(frame_rate.get_value('name'), frame_rate.get_code()) try: frame_rate_select.set_value(self.frame_rate_code) except AttributeError: pass section_span.add(frame_rate_select) return section_span
def _get_target_span(self): # get the target span search = Search(self.container_cls) self._order_search(search) groups = search.get_sobjects() if groups: self.container_sobj = groups[0] target_span = SpanWdg(css='med') group_table = Table(self.GROUP_TABLE_NAME, css='table') group_table.add_style('width', '30em') group_table.add_col(css='small') group_table.add_col(css='small') group_table.add_col() target_span.add(group_table) group_table.add_row_cell(search.get_search_type_obj()\ .get_description(), "heading") checkbox = CheckboxWdg() checkbox.set_option("onclick", \ "a=new Elements('container_ids');a.toggle_all(this);") group_table.add_row() group_table.add_cell(checkbox) col_name = group_table.get_next_col_name() toggle_control = HiddenRowToggleWdg(col_name=col_name, is_control=True, auto_index=True) group_table.add_cell(toggle_control) group_table.add_cell('MASTER CONTROL') remove_cmd = HiddenWdg(SObjectGroupCmd.REMOVE_CMD) self.add(remove_cmd) for group in groups: group_table.add_row() checkbox = CheckboxWdg("container_ids") checkbox.set_option("value", group.get_primary_key_value()) toggle = HiddenRowToggleWdg(col_name, auto_index=True) toggle.store_event() group_details = ItemInContainerWdg(group, self.item_sobj, self.item_cls, self.grouping_cls) # set the target content of the toggle toggle.set_static_content(group_details) group_table.add_cell(checkbox) group_table.add_cell(toggle, add_hidden_wdg=True) group_table.add_cell(group.get_description()) num_items = group_details.get_num_items() if num_items: td = group_table.add_cell("( %s )" % num_items, 'no_wrap') td.add_color(color) else: group_table.add_blank_cell() return target_span
def get_format_section(self): section_span = SpanWdg() section_span.add('Format: ') section_span.add(self.get_format_select_wdg()) return section_span
def get_instantiation_wdg(my): setting = my.get_default_setting() default_instantiation = setting.get('instantiation') div = DivWdg() is_unchecked = True default_cb = None for value in my.get_instantiation_options(): name = my.get_element_name("instantiation") checkbox = CheckboxWdg(name) if value == default_instantiation: default_cb = checkbox checkbox.set_option("value", value) checkbox.set_persistence() if checkbox.is_checked(): is_unchecked = False checkbox.add_behavior({ 'type': 'click_up', 'propagate_evt': True, "cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name }) span = SpanWdg(checkbox, css='small') span.add(value) div.add(span) if is_unchecked: default_cb.set_checked() return div
def get_prefs(my): div = DivWdg('Bar Size: ') my.bar_select = FilterSelectWdg('progress_bar_size') bar_sizes = [x*2 + 1 for x in xrange(6)] my.bar_select.set_option('values', bar_sizes) my.bar_select.set_option('default', '3') div.add(my.bar_select) my.bar_select_value = my.bar_select.get_value() my.label_select = FilterSelectWdg('Label_Format') my.label_select_value = my.label_select.get_value() my.label_select.set_option('values', 'reg|small|abbr') my.label_select.set_option('default', 'reg') span = SpanWdg('Label Format: ', css='small') span.add(my.label_select) div.add(span) my.desc_checkbox = FilterCheckboxWdg("Show Description", \ 'Show Description: ', css='small') my.desc_checkbox_value = my.desc_checkbox.get_value() div.add(my.desc_checkbox) my.include_sub_task = FilterCheckboxWdg("include_sub_task", \ label="include sub tasks", css='small') my.include_sub_task_value = my.include_sub_task.is_checked() div.add(my.include_sub_task) return div
def get_display(my): sobject = my.get_current_sobject() title = sobject.get_value("title") widget = Widget() widget.add(sobject.get_description()) if title == 'Debug': pop = PopupWdg("pref_help_%s" % title) hint = 'If set to [true], you can view the Debug Widget at the bottom left corner of your page.' icon_wdg = IconWdg(hint, IconWdg.HELP) widget.add(SpanWdg(icon_wdg, css='small')) widget.add(pop) elif title == 'Filter': pop = PopupWdg("pref_help_%s" % title) hint = 'If set to [multi], It generally applies to filters in the filter box for Artist Tab.' icon_wdg = IconWdg(hint, IconWdg.HELP) widget.add(SpanWdg(icon_wdg, css='small')) widget.add(pop) elif title == 'Quick Text': pop = PopupWdg("pref_help_%s" % title) hint = 'A list of | separated phrases a user can pick from to enter into the note area of Note Sheet.' icon_wdg = IconWdg(hint, IconWdg.HELP) widget.add(SpanWdg(icon_wdg, css='small')) widget.add(pop) return widget
def get_prefs(self): div = DivWdg('Bar Size: ') self.bar_select = FilterSelectWdg('progress_bar_size') bar_sizes = [x * 2 + 1 for x in xrange(6)] self.bar_select.set_option('values', bar_sizes) self.bar_select.set_option('default', '3') div.add(self.bar_select) self.bar_select_value = self.bar_select.get_value() self.label_select = FilterSelectWdg('Label_Format') self.label_select_value = self.label_select.get_value() self.label_select.set_option('values', 'reg|small|abbr') self.label_select.set_option('default', 'reg') span = SpanWdg('Label Format: ', css='small') span.add(self.label_select) div.add(span) self.desc_checkbox = FilterCheckboxWdg("Show Description", \ 'Show Description: ', css='small') self.desc_checkbox_value = self.desc_checkbox.get_value() div.add(self.desc_checkbox) self.include_sub_task = FilterCheckboxWdg("include_sub_task", \ label="include sub tasks", css='small') self.include_sub_task_value = self.include_sub_task.is_checked() div.add(self.include_sub_task) return div
def _get_target_span(my): # get the target span search = Search(my.container_cls) my._order_search(search) groups = search.get_sobjects() if groups: my.container_sobj = groups[0] target_span = SpanWdg(css='med') group_table = Table(my.GROUP_TABLE_NAME, css='table') group_table.add_style('width','30em') group_table.add_col(css='small') group_table.add_col(css='small') group_table.add_col() target_span.add(group_table) group_table.add_row_cell(search.get_search_type_obj()\ .get_description(), "heading") checkbox = CheckboxWdg() checkbox.set_option("onclick", \ "a=new Elements('container_ids');a.toggle_all(this);") group_table.add_row() group_table.add_cell(checkbox) col_name = group_table.get_next_col_name() toggle_control = HiddenRowToggleWdg(col_name=col_name, is_control=True, auto_index=True) group_table.add_cell(toggle_control) group_table.add_cell('MASTER CONTROL') remove_cmd = HiddenWdg(SObjectGroupCmd.REMOVE_CMD) my.add(remove_cmd) for group in groups: group_table.add_row() checkbox = CheckboxWdg("container_ids") checkbox.set_option("value", group.get_primary_key_value() ) toggle = HiddenRowToggleWdg(col_name, auto_index=True) toggle.store_event() group_details = ItemInContainerWdg( group, my.item_sobj, my.item_cls, my.grouping_cls ) # set the target content of the toggle toggle.set_static_content(group_details) group_table.add_cell( checkbox ) group_table.add_cell( toggle, add_hidden_wdg=True ) group_table.add_cell( group.get_description()) num_items = group_details.get_num_items() if num_items: td = group_table.add_cell( "( %s )" % num_items, 'no_wrap') td.add_color(color) else: group_table.add_blank_cell() return target_span
def get_display(my): div = SpanWdg() div.add(" is ") text = TextWdg("year") value = my.values.get("year") if value: text.set_value(value) div.add(text) return div
def get_display(my): web = WebContainer.get_web() if not my.view: view = web.get_form_value("filter|view") # create popup create_popup = PopupWdg("create_action") create_popup.set_auto_hide(False) create_popup.add("Enter name of view: ") create_popup.add(TextWdg("create_view_name")) # create_popup.add( HtmlElement.br(2) ) # create_popup.add( "Copy from template: " ) # template_select = SelectWdg("copy_from_template") # template_select.add_empty_option("-- None --") # template_select.set_option("values", "list|summary|task") # create_popup.add( template_select ) create_popup.add(HtmlElement.br(2, clear="all")) from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg create_icon = ProdIconButtonWdg("Create") ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.CustomCreateViewCbk") ajax.add_element_name("create_view_name") ajax.add_element_name("auto_create_edit") ajax.set_option("search_type", my.search_type) ajax.set_option("project", Project.get_project_code()) if my.view: ajax.set_option("template_view", my.view) create_icon.add_event( "onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action');setTimeout('document.form.submit()',1000)"), ) cancel_icon = ProdIconButtonWdg("Cancel") cancel_icon.add_event("onclick", "toggle_display('create_action')") span = SpanWdg() span.add(create_icon) span.add(cancel_icon) create_popup.add(span) create_popup.add(HtmlElement.br()) # add the create button create = IconButtonWdg("Create View", IconWdg.SAVE, True) create.add_event("onclick", "%s" % create_popup.get_on_script()) # lay it all out widget = Widget() widget.add(create_popup) # Browser does not have create # widget.add(create) return widget
def init(self): self.layer = LayerWdg(self.xpos, self.ypos, self.display) if not self.width: self.shadowbox = ShadowBoxWdg(self.shad_name) else: self.shadowbox = ShadowBoxWdg(self.shad_name, self.width) # do not enable it for the Login page web = WebContainer.get_web() if self.shad_name and not web.is_IE(): BaseAppServer.add_onload_script("Move.drag('%s','%s')" \ %(self.shadowbox.get_name(), self.iframe_name)) div = DivWdg() from pyasm.widget import IconButtonWdg move_button = IconWdg(name='move me', icon=IconWdg.NAV) move_button.set_id("%s_handle" % (self.shad_name)) move_button.add_class('move') move_button.add_style('float: left') move_button.add_style('padding: 2px 0 0 6px') if not web.is_IE(): div.add(move_button) mbutton = IconButtonWdg(name='close window', icon=IconWdg.KILL) mbutton.set_class("moduleKillBtn") mbutton.add_event("onclick", self.layer.get_off_script()) div.add(mbutton) if self.nav_links: back_link = HtmlElement.href("<<", "javascript:history.back()") back_link.add_style("font-size", "1.4em") for_link = HtmlElement.href(">>", "javascript:history.forward()") for_link.add_style("font-size", "1.4em") div.add(SpanWdg(back_link, css='med')) div.add(SpanWdg(for_link, css='med')) self.shadowbox.set_header(div) # add button and title_wdg to shadow box if self.title_wdg: title_wdg = DivWdg() title_wdg.set_class("moduleTitle") title_wdg.add(self.title_wdg) self.shadowbox.set_title_wdg(title_wdg) self.layer.add(self.shadowbox) self._add_widget(self.layer)
def get_display(my): web = WebContainer.get_web() if not my.view: view = web.get_form_value("filter|view") # create popup create_popup = PopupWdg("create_action") create_popup.set_auto_hide(False) create_popup.add("Enter name of view: ") create_popup.add(TextWdg("create_view_name")) #create_popup.add( HtmlElement.br(2) ) #create_popup.add( "Copy from template: " ) #template_select = SelectWdg("copy_from_template") #template_select.add_empty_option("-- None --") #template_select.set_option("values", "list|summary|task") #create_popup.add( template_select ) create_popup.add(HtmlElement.br(2, clear="all")) from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg create_icon = ProdIconButtonWdg('Create') ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.CustomCreateViewCbk") ajax.add_element_name("create_view_name") ajax.add_element_name("auto_create_edit") ajax.set_option("search_type", my.search_type) ajax.set_option("project", Project.get_project_code()) if my.view: ajax.set_option("template_view", my.view) create_icon.add_event( "onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action');setTimeout('document.form.submit()',1000)" )) cancel_icon = ProdIconButtonWdg('Cancel') cancel_icon.add_event("onclick", "toggle_display('create_action')") span = SpanWdg() span.add(create_icon) span.add(cancel_icon) create_popup.add(span) create_popup.add(HtmlElement.br()) # add the create button create = IconButtonWdg("Create View", IconWdg.SAVE, True) create.add_event("onclick", "%s" % create_popup.get_on_script()) # lay it all out widget = Widget() widget.add(create_popup) # Browser does not have create #widget.add(create) return widget
def get_export_to_pdf_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') export_to_pdf_button = ButtonNewWdg(title='Export to PDF', icon='ARROW_DOWN') export_to_pdf_button.add_class('export_to_pdf_button') export_to_pdf_button.add_behavior(self.get_export_to_pdf_behavior(self.metadata_report_sobject.get_code())) section_span.add(export_to_pdf_button) return section_span
def get_add_row_button(self): span_wdg = SpanWdg() add_row_button = ButtonNewWdg(title='Add Row', icon='ADD') add_row_button.add_class('add_row_button') add_row_button.add_style('display', 'inline-block') add_row_button.add_behavior(self.get_add_row_behavior()) span_wdg.add(add_row_button) return span_wdg
def get_save_new_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') save_new_button = ButtonNewWdg(title='Save', icon='NEW') save_new_button.add_class('save_due_date') save_new_button.add_behavior(self.get_save_new_behavior()) section_span.add(save_new_button) return section_span
def get_row_checked_button(self, row_code): span_wdg = SpanWdg() checked_row_button = ButtonNewWdg(title='Checked Row', icon='CHECK') checked_row_button.add_style('display', 'inline-block') checked_row_button.add_behavior( self.get_checked_row_behavior(row_code)) span_wdg.add(checked_row_button) return span_wdg
def get_add_multiple_rows_button(self): span_wdg = SpanWdg() add_rows_button = ButtonNewWdg(title='Add Multiple Row', icon='PLUS_ADD') add_rows_button.add_class('add_rows_button') add_rows_button.add_style('display', 'inline-block') add_rows_button.add_behavior(self.get_add_multiple_rows_behavior()) span_wdg.add(add_rows_button) return span_wdg
def get_save_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') save_button = ButtonNewWdg(title='Save', icon='SAVE') save_button.add_class('save_button') save_button.add_behavior(self.get_save_behavior(self.metadata_report_sobject.get_code())) section_span.add(save_button) return section_span
def get_add_row_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') add_row_button = ButtonNewWdg(title='Add Row', icon='ADD') add_row_button.add_class('add_row_button') add_row_button.add_behavior(get_add_audio_configuration_line_behavior(self.element_evaluation_code)) section_span.add(add_row_button) return section_span
def get_save_as_new_version_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') save_as_new_version_button = ButtonNewWdg(title='Save As New Version', icon='INSERT') save_as_new_version_button.add_class('save_as_new_version_button') save_as_new_version_button.add_behavior(self.get_save_as_new_version_behavior()) section_span.add(save_as_new_version_button) return section_span
def get_remove_row_button(self, row_code): span_wdg = SpanWdg() remove_row_button = ButtonNewWdg(title='Remove Row', icon='DELETE') remove_row_button.add_class('subtract_row_button') remove_row_button.add_style('display', 'inline-block') remove_row_button.add_behavior(self.get_remove_row_behavior(row_code)) span_wdg.add(remove_row_button) return span_wdg
def get_remove_row_button(self, line_code): section_span = SpanWdg() section_span.add_style('display', 'inline-block') remove_row_button = ButtonNewWdg(title='Remove Row', icon='DELETE') remove_row_button.add_class('remove_row_button') remove_row_button.add_behavior(get_remove_audio_configuration_line_behavior(self.element_evaluation_code, line_code)) section_span.add(remove_row_button) return section_span
def get_create_view_wdg(my, search_type): # create popup create_popup = PopupWdg("create_action") create_popup.set_auto_hide(False) create_popup.add("Enter name of view: ") create_popup.add(TextWdg("create_view_name")) #create_popup.add( HtmlElement.br(2) ) #create_popup.add( "Copy from template: " ) #template_select = SelectWdg("copy_from_template") #template_select.add_empty_option("-- None --") #template_select.set_option("values", "list|summary|task") #create_popup.add( template_select ) create_popup.add(HtmlElement.br(2)) create_popup.add( CheckboxWdg('auto_create_edit', label='Auto Create Edit View')) create_popup.add(HtmlElement.br(2, clear="all")) from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg create_icon = ProdIconButtonWdg('Create') ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.CustomCreateViewCbk") ajax.add_element_name("create_view_name") ajax.add_element_name("auto_create_edit") ajax.set_option("search_type", search_type) ajax.set_option("project", Project.get_project_code()) div = ajax.generate_div() div.set_post_ajax_script('document.form.submit()') create_icon.add_event( "onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action')")) cancel_icon = ProdIconButtonWdg('Cancel') cancel_icon.add_event("onclick", "toggle_display('create_action')") span = SpanWdg() span.add(create_icon) span.add(cancel_icon) create_popup.add(span) create_popup.add(HtmlElement.br()) # add the create button create = IconButtonWdg("Create View", IconWdg.SAVE, True) create.add_event("onclick", "%s" % create_popup.get_on_script()) # lay it all out widget = Widget() widget.add(create_popup) widget.add(create) widget.add(div) return widget
def get_add_multiple_rows_button(self): span_wdg = SpanWdg() # TODO: Find a better icon for this add_row_button = ButtonNewWdg(title='Add Multiple Row', icon='PLUS_ADD') add_row_button.add_class('add_row_button') add_row_button.add_style('display', 'inline-block') add_row_button.add_behavior(self.get_add_multiple_rows_behavior()) span_wdg.add(add_row_button) return span_wdg
def get_display(my): div = DivWdg(css='left_content') div.set_style("margin-top: 10px; margin-bottom: 20px;") # add some spacing span = SpanWdg() span.set_class('tab_front') div.add(span) # figure out which is the selected one selected_index = 0 for i in range(0, len(my.tab_names)): tab_name = my.tab_names[i] if tab_name == my.tab_value: selected_index = i break for i in range(0, len(my.tab_names)): tab_name = my.tab_names[i] widget = my.get_widget(tab_name) tab = HtmlElement.span() tab.set_attr('name', my.tab_group_name) # required by IE tab.set_id(my.tab_group_name) tab.set_attr('tab', tab_name) if i == selected_index: # selected tab tab.set_class("%s_selected" %my.get_style_prefix()) my.content_div.add(widget) else: # unselected tab tab.set_class("%s_unselected" %my.get_style_prefix()) tab.add( my.get_header(tab_name) ) div.add(tab) # display the content my.content_div.set_id(my.content_div_id) my.content_div.set_class("%s_content" %my.get_style_prefix()) my.content_div.add_style("display: block") div.add(my.content_div) return div
def get_license_info_wdg(my): div = DivWdg() license = Environment.get_security().get_license() if my.first_error: return div #if not license.is_licensed(): # return div msg = DivWdg() div.add(msg) msg.add("The following describes the details of the installed license:<br/><br/>") info_wdg = DivWdg() div.add(info_wdg) info_wdg.add_style("margin: 10px 30px") info_wdg.add_style("font-size: 12px") version = license.get_data("tactic_version") if version: info_wdg.add("TACTIC Version: ") if version == "ALL": version = "ALL (Open Source)" info_wdg.add(version) info_wdg.add(HtmlElement.br(2)) company = license.get_data("company") info_wdg.add("Licensed To: ") if company.find("Southpaw EPL") != -1: company = SpanWdg("<a name='license'>Eclipse Public License v1.0</a> ") icon = IconWdg("EPL v1.0", IconWdg.ZOOM) company.add(icon) company.add_class("hand") company.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.help.load_alias("license") ''' } ) info_wdg.add(company) info_wdg.add(HtmlElement.br(2)) info_wdg.add("Max Users: ") info_wdg.add(license.get_data("max_users") ) info_wdg.add(HtmlElement.br(2)) info_wdg.add("Current Users: ") info_wdg.add(license.get_current_users() ) info_wdg.add(HtmlElement.br(2)) info_wdg.add("Expiry Date: ") expiry_date = license.get_data("expiry_date") if not expiry_date: expiry_date = "Permanent" info_wdg.add(expiry_date) info_wdg.add(HtmlElement.br(2)) return div
def get_create_view_wdg(my, search_type): # create popup create_popup = PopupWdg("create_action") create_popup.set_auto_hide(False) create_popup.add("Enter name of view: ") create_popup.add(TextWdg("create_view_name")) # create_popup.add( HtmlElement.br(2) ) # create_popup.add( "Copy from template: " ) # template_select = SelectWdg("copy_from_template") # template_select.add_empty_option("-- None --") # template_select.set_option("values", "list|summary|task") # create_popup.add( template_select ) create_popup.add(HtmlElement.br(2)) create_popup.add(CheckboxWdg("auto_create_edit", label="Auto Create Edit View")) create_popup.add(HtmlElement.br(2, clear="all")) from pyasm.prod.web import ProdIconButtonWdg, ProdIconSubmitWdg create_icon = ProdIconButtonWdg("Create") ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.CustomCreateViewCbk") ajax.add_element_name("create_view_name") ajax.add_element_name("auto_create_edit") ajax.set_option("search_type", search_type) ajax.set_option("project", Project.get_project_code()) div = ajax.generate_div() div.set_post_ajax_script("document.form.submit()") create_icon.add_event("onclick", "%s;%s" % (ajax.get_on_script(), "toggle_display('create_action')")) cancel_icon = ProdIconButtonWdg("Cancel") cancel_icon.add_event("onclick", "toggle_display('create_action')") span = SpanWdg() span.add(create_icon) span.add(cancel_icon) create_popup.add(span) create_popup.add(HtmlElement.br()) # add the create button create = IconButtonWdg("Create View", IconWdg.SAVE, True) create.add_event("onclick", "%s" % create_popup.get_on_script()) # lay it all out widget = Widget() widget.add(create_popup) widget.add(create) widget.add(div) return widget
def get_title(my): mode = my.get_option("mode") title = SpanWdg() #loader = LoaderButtonWdg() #loader.set_load_script( my.get_load_script() ) #return loader search_type = my.get_search_type() cb_name = '%s_%s' % (search_type, my.CB_NAME) master_cb = CheckboxWdg('master_control') master_cb.add_behavior({ 'type': 'click_up', 'propagate_evt': True, 'cbjs_action': ''' var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_table'),'%s','.spt_latest_%s'); for (var i = 0; i < inputs.length; i++) inputs[i].checked = bvr.src_el.checked; ''' % (cb_name, mode) }) title.add(master_cb) if mode == "input": title.add("Receive") else: title.add("Deliver") return title
def get_display(my): if not my.columns: print my.options search_type = my.options.get("search_type") if search_type: my.set_columns_from_search_type(search_type) if not my.columns: my.columns = [] span = SpanWdg() my.column_select.set_option("values", my.columns) my.column_select.set_persist_on_submit() span.add(my.column_select) relations = [ "is", "is not", "contains", "does not contain", "is empty" ] my.relation_select.set_option("values", relations) my.relation_select.set_persist_on_submit() span.add(my.relation_select) my.value_text.set_persist_on_submit() span.add(my.value_text) return span
def get_notes_wdg(my): widget = Widget() div = DivWdg(css="filter_box") columns = ['code', 'description'] search_filter = SearchFilterWdg("note_search", columns=columns,\ has_persistence=False) div.add(search_filter) sequence_filter = SequenceFilterWdg() div.add(sequence_filter) context_select = FilterSelectWdg("discussion_context") context_select.set_option("setting", "notes_preprod_context") context_select.add_empty_option("-- Any Context --") span = SpanWdg(css="med") span.add("Notes Context: ") span.add(context_select) hint = HintWdg('Submission notes for each shot are also included here') span.add(hint) div.add(span) widget.add(div) # create a search search = Search("prod/shot") sequence_filter.alter_search(search) search_filter.alter_search(search) table = TableWdg("prod/shot", "preprod_notes") table.set_search(search) widget.add(table) return widget
def get_display(self): if not self.columns: print self.options search_type = self.options.get("search_type") if search_type: self.set_columns_from_search_type(search_type) if not self.columns: self.columns = [] span = SpanWdg() self.column_select.set_option("values", self.columns) self.column_select.set_persist_on_submit() span.add(self.column_select) relations = ["is", "is not", "contains", "does not contain", "is empty"] self.relation_select.set_option("values", relations) self.relation_select.set_persist_on_submit() span.add(self.relation_select) self.value_text.set_persist_on_submit() span.add(self.value_text) return span
def add_file_behaviors(my, item_div, dirname, basename): item_div.add_class("spt_script_item") if not dirname: path = "///%s" % (basename) else: path = "%s/%s" % (dirname, basename) scripts = my.kwargs.get("scripts") script = scripts.get(path) if not script: item_div.add_style("background-color", "red") item_div.add_behavior({"type": "click_up", "cbjs_action" : '''spt.alert("Please remove leading / in this script path's Title attribute by using the Manage button.")'''}) item_div.add_attr("title", "Please remove special characters like / in this script path") return script_code = script.get("code") language = script.get("language") item_div.add_attr("spt_script_code", script_code) item_div.add_style("background", "transparent") if language: span = SpanWdg() span.add_style("font-size: 9px") span.add_style("opacity: 0.2") span.add(" <i>(%s)</i>" % language) item_div.add(span)
def get_display(my): widget = Widget() div = DivWdg(css="filter_box") show_span = SpanWdg(css="med") show_span.add("Show All Types: ") checkbox = FilterCheckboxWdg("show_all_types") checkbox.set_persistence() show_span.add(checkbox) show_all_types = checkbox.get_value() div.add(show_span) span = SpanWdg(css="med") span.add("Search Type: ") select = SelectWdg("filter|search_type") select.add_empty_option("-- Select --") project = Project.get() project_type = project.get_base_type() search = Search("sthpw/search_object") if show_all_types: search.add_where( """ namespace = '%s' or namespace = '%s' or search_type in ('sthpw/task') """ % (project_type, project.get_code()) ) else: # show only the custom ones search.add_filter("namespace", project.get_code()) search.add_order_by("title") sobjects = search.get_sobjects() select.set_sobjects_for_options(sobjects, "search_type", "title") # select.set_option("query", "sthpw/search_object|search_type|title") select.set_persistence() select.add_event("onchange", "document.form.submit()") search_type = select.get_value() span.add(select) div.add(span) # make sure the current selection exists try: SearchType.get(search_type) except SearchException, e: return div
def get_link_wdg(self, element_name, config, options): attributes = config.get_element_attributes(element_name) title = self._get_title(config, element_name) default_access = "view" path = options.get('path') security = Environment.get_security() if not security.check_access( "side_bar", element_name, "view", default=default_access): return # backwards compatibility?? #if not security.check_access("url", path, "view"): # return link_wdg = DivWdg(css="hand") link_wdg.add_style("padding-top: 4px") link_wdg.add_attr("spt_title", title) link_wdg.add_attr("spt_icon", attributes.get("icon")) link_wdg.add_class("spt_side_bar_link") link_wdg.add_attr("spt_view", config.get_view()) link_wdg.add_attr("spt_element_name", element_name) link_wdg.add_attr("spt_path", options['path']) # add the mouseover color change link_wdg.add_style("color: #292929") link_wdg.add_class("SPT_DTS") hover = link_wdg.get_color("background3", -10) link_wdg.add_event("onmouseover", "this.style.background='%s'" % hover) link_wdg.add_event("onmouseout", "this.style.background=''") link_wdg.add_class("spt_side_bar_element") link_wdg.add_looks("fnt_text") link_wdg.add_attr("spt_view", config.get_view()) # add an invisible drop widget drop_wdg = self.get_drop_wdg() drop_wdg.add_style("margin-top: -3px") link_wdg.add(drop_wdg) span = SpanWdg() span.add_class("spt_side_bar_title") # add an icon icon = attributes.get("icon") if icon: icon = icon.upper() from pyasm.widget import IconWdg try: span.add(IconWdg(title, eval("IconWdg.%s" % icon))) except: pass span.add(title) link_wdg.add(span) return link_wdg
def get_po_number_section(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') section_span.add('PO #: ') section_span.add(self.get_text_input_wdg('po_number', 100)) return section_span
def get_episode_input_wdg(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') section_span.add('Episode: ') section_span.add(self.get_text_input_wdg('episode', 400)) return section_span
def get_version_input_wdg(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') section_span.add('Version: ') section_span.add(self.get_text_input_wdg('version', 400)) return section_span
def set_text_link(self, widget, div, image_link): '''override how the text link is drawn''' div.add_style('float', 'left') div.add_style('margin-left', '10px') filename = os.path.basename(image_link) if len(filename) > 40: filename = "%s..." % (filename[0:40]) span = SpanWdg(css='med') #href = HtmlElement.href(filename, image_link) href = SpanWdg(filename) href.add_color("color", "color") span.add(href) widget.add(span) span.add_tip('Right-click and choose [Save Link As..] to save to disk.')
def get_video_aspect_ratio_section(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') section_span.add('Video Aspect Ratio: ') section_span.add(self.get_video_aspect_ratio_select_wdg()) return section_span
def get_display(my): div = DivWdg(css='left_content') div.set_style("margin-top: 10px; margin-bottom: 20px;") # add some spacing span = SpanWdg() span.set_class('tab_front') div.add(span) # figure out which is the selected one selected_index = 0 for i in range(0, len(my.tab_names)): tab_name = my.tab_names[i] if tab_name == my.tab_value: selected_index = i break for i in range(0, len(my.tab_names)): tab_name = my.tab_names[i] widget = my.get_widget(tab_name) tab = HtmlElement.span() tab.set_attr('name', my.tab_group_name) # required by IE tab.set_id(my.tab_group_name) tab.set_attr('tab', tab_name) if i == selected_index: # selected tab tab.set_class("%s_selected" % my.get_style_prefix()) my.content_div.add(widget) else: # unselected tab tab.set_class("%s_unselected" % my.get_style_prefix()) tab.add(my.get_header(tab_name)) div.add(tab) # display the content my.content_div.set_id(my.content_div_id) my.content_div.set_class("%s_content" % my.get_style_prefix()) my.content_div.add_style("display: block") div.add(my.content_div) return div
def get_config_wdg(my): widget = Widget() search = Search("sthpw/widget_config") div = DivWdg(css="filter_box") span = SpanWdg(css="med") span.add("Search Type: ") select = FilterSelectWdg("config_search_type") select.add_empty_option("-- Select --") search_type_search = Search("sthpw/search_object") search_type_search.add_order_by("search_type") span.add(select) project = Project.get() project_type = project.get_base_type() filter = search.get_regex_filter("search_type", "login|task|note|timecard", "EQ") search_type_search.add_where( """ namespace = '%s' or namespace = '%s' or %s """ % (project_type, project.get_code(), filter) ) select.set_search_for_options(search_type_search, value_column="search_type") div.add(span) search_type_value = select.get_value() span = SpanWdg() view_text = TextWdg("view") view_text.set_persist_on_submit() span.add("View: ") span.add(view_text) div.add(span) widget.add(div) view = view_text.get_value() if view: search.add_filter("view", view) if search_type_value: search.add_filter("search_type", search_type_value) table = TableWdg("sthpw/widget_config") table.set_search(search) widget.add(table) return widget
def get_input_widget_with_label(self, label, id, width): section_span = SpanWdg() section_span.add_style('display', 'inline-block') section_span.add(label) section_span.add(get_text_input_wdg(id, get_attribute_or_none(self, id), width)) return section_span
def get_open_wdg( sobject, file_type=None): ''' given a snapshot. open the sandbox in explorer ''' span = SpanWdg() # explore button dir = sobject.get_client_lib_dir(file_type=file_type) open_button = IconButtonWdg( "Explore: %s" % dir, IconWdg.LOAD, False) open_button.add_event("onclick", "Applet.open_explorer('%s')" % dir) open_button.add_class('small') span.add(open_button) #dir = sobject.get_sandbox_dir() #copy_button = IconButtonWdg( "Copy to sandbox: %s" % dir, IconWdg.DOWNLOAD, False) #span.add(copy_button) return span
def get_open_wdg(sobject, file_type=None): ''' given a snapshot. open the sandbox in explorer ''' span = SpanWdg() # explore button dir = sobject.get_client_lib_dir(file_type=file_type) open_button = IconButtonWdg("Explore: %s" % dir, IconWdg.LOAD, False) open_button.add_event("onclick", "Applet.open_explorer('%s')" % dir) open_button.add_class('small') span.add(open_button) #dir = sobject.get_sandbox_dir() #copy_button = IconButtonWdg( "Copy to sandbox: %s" % dir, IconWdg.DOWNLOAD, False) #span.add(copy_button) return span
def get_display(my): span = SpanWdg() if len(my.text) > my.length: content = my.text[0:my.length] span.add('%s...' % content) span.add_tip(my.text, my.text) else: span.add(my.text) return span
def get_display(self): span = SpanWdg() if len(self.text) > self.length: content = self.text[0:self.length] span.add('%s...' % content) span.add_tip(self.text, self.text) else: span.add(self.text) return span
def get_display(my): if not my.columns: print my.options search_type = my.options.get("search_type") if search_type: my.set_columns_from_search_type(search_type) if not my.columns: my.columns = [] span = SpanWdg() my.column_select.set_option("values", my.columns) my.column_select.set_persist_on_submit() span.add(my.column_select) relations = ["is", "is not", "contains", "does not contain", "is empty"] my.relation_select.set_option("values", relations) my.relation_select.set_persist_on_submit() span.add(my.relation_select) my.value_text.set_persist_on_submit() span.add(my.value_text) return span
def get_license_info_wdg(self): div = DivWdg() license = Environment.get_security().get_license() if self.first_error: return div #if not license.is_licensed(): # return div msg = DivWdg() div.add(msg) msg.add("The following describes the details of the installed license:<br/><br/>") info_wdg = DivWdg() div.add(info_wdg) info_wdg.add_style("margin: 10px 30px") info_wdg.add_style("font-size: 12px") version = license.get_data("tactic_version") if version: info_wdg.add("TACTIC Version: ") if version == "ALL": version = "ALL (Open Source)" info_wdg.add(version) info_wdg.add(HtmlElement.br(2)) company = license.get_data("company") info_wdg.add("Licensed To: ") if company.find("Southpaw EPL") != -1: company = SpanWdg("<a name='license'>Eclipse Public License v1.0</a> ") icon = IconWdg("EPL v1.0", IconWdg.ZOOM) company.add(icon) company.add_class("hand") company.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.help.load_alias("license") ''' } ) info_wdg.add(company) info_wdg.add(HtmlElement.br(2)) info_wdg.add("Max Users: ") info_wdg.add(license.get_data("max_users") ) info_wdg.add(HtmlElement.br(2)) info_wdg.add("Current Users: ") info_wdg.add(license.get_current_users() ) info_wdg.add(HtmlElement.br(2)) info_wdg.add("Expiry Date: ") expiry_date = license.get_data("expiry_date") if not expiry_date: expiry_date = "Permanent" info_wdg.add(expiry_date) info_wdg.add(HtmlElement.br(2)) return div
def get_button_wdg(self, script_name): func_name = script_name custom_script = self.get_custom_script(script_name) script = HtmlElement.script(''' %s = function() { %s } ''' % (func_name, custom_script)) button = SpanWdg() button.add_class("hand") button.add(script) button.add("[%s]" % script_name) button.add_event("onclick", "%s()" % func_name) return button
def get_extend_wdg(self): widget = Widget() search = Search("sthpw/widget_extend") div = DivWdg(css="filter_box") # add key filter span = SpanWdg(css="med") key_select = FilterSelectWdg("key") key_select.add_empty_option("-- Any Key --") key_select.set_option("query", "sthpw/widget_extend|key|key") span.add("Key: ") span.add(key_select) div.add(span) # add type filter span = SpanWdg(css="med") select = FilterSelectWdg("extend_type") select.add_empty_option("-- Any Type --") select.set_option("values", "TabWdg|TableWdg") span.add("Widget Extend Type: ") span.add(select) div.add(span) widget.add(div) extend_type = select.get_value() if extend_type: search.add_filter("type", extend_type) key = key_select.get_value() if key: search.add_filter("key", key) # add project filter #search.add_where( Project.get_project_filter() ) table = TableWdg("sthpw/widget_extend") table.set_search( search ) widget.add(table) return widget
def get_display(my): box = DivWdg(css="login") box.add_style("margin-top: auto") box.add_style("margin-bottom: auto") box.add_style("text-align: center") script = HtmlElement.script( """function login(e) { if (!e) var e = window.event; if (e.keyCode == 13) { submit_icon_button('Submit'); }} """ ) div = DivWdg() div.add_style("margin: 0px 0px") div.add_class("centered") div.add(HtmlElement.br(6)) sthpw = SpanWdg("SOUTHPAW TECHNOLOGY INC", css="login_sthpw") sthpw.add_style("color: #333") div.add(sthpw) div.add(HtmlElement.br(2)) div.add(my.get_error_wdg()) box.add(div) widget = Widget() # widget.add( HtmlElement.br(3) ) table = Table() table.add_style("width: 100%") table.add_style("height: 85%") table.add_row() td = table.add_cell() td.add_style("vertical-align: middle") td.add_style("text-align: center") td.add_style("background: transparent") td.add(box) widget.add(table) return widget
def get_add_tab_wdg(my): span = SpanWdg(css="hand") span.add("+Add+") from web_wdg import EditLinkWdg link = EditLinkWdg(search_type="sthpw/widget_extend", search_id=-1, text="Create New Tab", config_base="tab_extend", action='CreateTabCmd') link.set_refresh_mode("page") span.add(link) popup = PopupMenuWdg("add_tab"); popup.add("Add New Tab") span.add(popup) span.add_event("onclick", "toggle_display('add_tab')") return span
def get_title(my): widget = Widget() """ search_key_wdg = HiddenWdg('search_key') search_key_wdg.get_value() widget.add(search_key_wdg) """ WebContainer.register_cmd("pyasm.flash.widget.RenderCbk") if not my.get_option("no_button"): render_button = IconSubmitWdg("Render", IconWdg.RENDER, True, add_hidden=True) widget.add(render_button) else: widget.add("Frame Info") float_button = IconSubmitWdg("Render", IconWdg.RENDER, add_hidden=False) span = SpanWdg(float_button, css="med") span.add_style("border-left", "1px solid #777") WebContainer.get_float_menu().add(span) return widget