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_related_wdg(my, aliases): div = DivWdg() div.add("<b>Related links</b>:  ") div.add_style("margin-top: 5px") div.add_style("margin-bottom: 5px") div.add_style("margin-left: 10px") titles = [Common.get_display_title(x.replace("-"," ")) for x in aliases] for alias, title in zip(aliases, titles): link_div = SpanWdg() div.add(link_div) link_div.add_color("background", "background") link_div.add(title) link_div.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.help.set_top(); spt.help.load_alias("%s"); ''' % alias } ) link_div.add_class("spt_link") link_div.add_class("hand") return div
def get_related_wdg(my, aliases): div = DivWdg() div.add("<b>Related links</b>:  ") div.add_style("margin-top: 5px") div.add_style("margin-bottom: 5px") div.add_style("margin-left: 10px") titles = [ Common.get_display_title(x.replace("-", " ")) for x in aliases ] for alias, title in zip(aliases, titles): link_div = SpanWdg() div.add(link_div) link_div.add_color("background", "background") link_div.add(title) link_div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.help.set_top(); spt.help.load_alias("%s"); ''' % alias }) link_div.add_class("spt_link") link_div.add_class("hand") return div
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_display(self): outer_div = DivWdg() outer_div.set_id('edit_instructions_{0}'.format(self.instructions_sobject.get_code())) # Get a list of the components the instructions are attached to attached_components = get_components_attached_to_instructions(self.instructions_sobject) component_div = DivWdg() title_span = SpanWdg() if attached_components: title_span.add('The following Components are attached to this Instructions Document:') component_div.add(title_span) component_list = HtmlElement.ul() for component in attached_components: li = HtmlElement.li() li.add('{0} ({1})'.format(component.get('name'), component.get_code())) component_list.add(li) component_div.add(component_list) else: title_span.add('Instructions are not currently attached to any Components') component_div.add(title_span) outer_div.add(component_div) outer_div.add(get_instructions_textarea_wdg(self.instructions_sobject)) submit_button = SubmitWdg('Submit Changes') submit_button.add_behavior(self.submit_button_behavior()) submit_button.add_style('display', 'block') outer_div.add(submit_button) return outer_div
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_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(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_format_section(self): section_span = SpanWdg() section_span.add('Format: ') section_span.add(self.get_format_select_wdg()) return section_span
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_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 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_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_display(self): widget = Widget() if not self.select: return widget if not self.schema: Environment.add_warning("No schema defined") widget.add("No schema defined") return widget if not self.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 = self.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 self.select.add_empty_option("-- Select --") self.select.set_option("query", "%s|code|code" % self.parent_type) span.add(self.select) widget.add(span) 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_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_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 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 = 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(self): div = SpanWdg() div.add(" is ") text = TextWdg("year") value = self.values.get("year") if value: text.set_value(value) div.add(text) 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_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_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_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(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): 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_loading_span(self): span = SpanWdg() span.add_style("display", "none") img = HtmlElement.img('/context/icons/common/loading.gif') img.add_style("height", "10px") msg_span = SpanWdg('loading') msg_span.set_class('small') span.add(msg_span) span.add(img) span.set_id(self.img_span_name) return span
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.prequal_eval_sobject.get_code())) section_span.add(save_button) return section_span
def get_export_to_pdf_button(self): section_span = SpanWdg() section_span.add_style('display', 'inline-block') save_as_new_button = ButtonNewWdg(title='Export to PDF', icon='ARROW_DOWN') save_as_new_button.add_class('save_as_new_button') save_as_new_button.add_behavior(self.get_export_to_pdf_behavior(self.prequal_eval_sobject.get_code())) section_span.add(save_as_new_button) return section_span
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_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_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_loading_span(my): span = SpanWdg() span.add_style("display","none") img = HtmlElement.img('/context/icons/common/loading.gif') img.add_style("height","10px") msg_span = SpanWdg('loading') msg_span.set_class('small') span.add(msg_span) span.add(img) span.set_id(my.img_span_name) return 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_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_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_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_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 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_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(self): ajax = AjaxCmd() ajax.register_cmd("pyasm.widget.ClipboardAddCbk") progress = ajax.generate_div() progress.add_style('display', 'inline') search_type = self.sobject.get_search_type() search_id = self.sobject.get_id() ajax.set_option("search_type", search_type) ajax.set_option("search_id", search_id) search_key = self.sobject.get_search_key() span = SpanWdg() span.set_id("clipboard_%s" % search_key) span.add_style("display: none") checkbox = CheckboxWdg() checkbox.add_style("vertical-align: top") checkbox.add_style("width: 7px") checkbox.add_event("onclick", "%s" % ajax.get_on_script(show_progress=False) ) #checkbox.add_event("onmouseover", "this.style.width=15") #checkbox.add_event("onmouseout", "this.style.width=7") # FIXME :DEPRECATED """ event = WebContainer.get_event_container() caller = event.get_event_caller(ClipboardWdg.EVENT_ID) from file_wdg import ThumbWdg post_script = [caller] if self.thumbnail_mode: post_script.append( ThumbWdg.get_refresh_script(\ self.sobject, self.icon_size, show_progress=False) ) progress.set_post_ajax_script(';'.join(post_script)) if Clipboard.is_selected(self.sobject): checkbox.set_option("checked", "1") """ span.add(checkbox) span.add(progress) return span
def get_button_wdg(my, script_name): func_name = script_name custom_script = my.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 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) 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_link_wdg(my, section_id, target_id, title, options): view_link_wdg = SpanWdg(css="hand") view_link_wdg.add_class("SPT_DTS") view_link_wdg.add_style("color: #292929") view_link_wdg.add_event("onmouseover", "this.style.background='#696969'") view_link_wdg.add_event("onmouseout", "this.style.background='#949494'") view_link_wdg.add(title) path = title options['path'] = "/%s" % title if not options.get('class_name'): options['class_name'] = "tactic.ui.panel.ViewPanelWdg" behavior = { 'type': 'click_up', 'cbfn_action': 'spt.side_bar.display_link_cbk', 'target_id': target_id, 'title': title, 'options': options, } view_link_wdg.add_behavior( behavior ) options2 = options.copy() options2['inline_search'] = "true" behavior = { 'type': 'click_up', 'modkeys': 'SHIFT', 'cbfn_action': 'spt.side_bar.display_link_cbk', 'is_popup': 'true', 'target_id': path, 'title': title, 'options': options2, } view_link_wdg.add_behavior( behavior ) return view_link_wdg