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_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_display(self): 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 as e: return div except SqlException as e: return div # add the view selector view_select = SelectWdg("view") view_select.add_empty_option("-- View --") view_select.add_event("onchange", "document.form.submit()") view_select.set_persist_on_submit() #view_select.set_persistence() span = SpanWdg(css="med") span.add("Defined Views: ") span.add(view_select) div.add(span) div.add( self.get_create_view_wdg(search_type)) div.add( HtmlElement.br(2) ) div.add( self.get_new_tab_wdg() ) widget.add(div) search = Search("sthpw/widget_config") #search.add_user_filter() search.add_filter("search_type", search_type) search.add_where("view != 'definition' and view != 'custom'") #search.add_column("view") widget_configs = search.get_sobjects() if widget_configs: view_select.set_sobjects_for_options(widget_configs,"view","view") view = view_select.get_value() if not view: view = "custom" #return widget # get the selected widget config for widget_config in widget_configs: if widget_config.get_value("view") == view: break else: return widget # get the handler: a little HACKY. config_xml = widget_config.get_xml_value("config") handler = config_xml.get_value("config/%s/@handler" % view) if not search_type: return widget widget.add(HtmlElement.br()) span = SpanWdg() custom_view = CustomViewWdg(search_type) span.add(custom_view) span.add_style("float: right") widget.add(span) widget.add( HtmlElement.br() ) widget.add("<h3>Example View [%s]</h3>" % view) # add a general filter filter_div = DivWdg() for i in range(0,1): filter = GeneralFilterWdg() filter.set_columns_from_search_type(search_type) filter_div.add("Filter: ") filter_div.add(filter) #filter_div.add(IconWdg("Remove Filter", IconWdg.RETIRE)) filter_div.add( HtmlElement.br(2) ) widget.add(filter_div) search = Search(search_type) search.set_limit(5) filter.alter_search(search) if not handler: if view in ["edit","insert"]: table = EditWdg(search_type, view) else: table = TableWdg(search_type, view) else: table = eval("%s(search_type,view)" % handler) #table.alter_search(search) sobjects = search.get_sobjects() if not sobjects and view in ["edit","insert"]: sobjects = [SObjectFactory.create(search_type)] table.set_sobjects(sobjects) widget.add(table) # show the custom properties widget.add("<h3>Custom Properties [%s]</h3>" % search_type) search = Search("prod/custom_property") search.add_filter("search_type", search_type) # This is actually reading the sthpw/custom_property conf file, weird table = TableWdg("prod/custom_property") table.set_search_limit(5) table.set_sobjects(search.get_sobjects() ) widget.add(table) return widget
def get_display(self): 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 as e: return div except SqlException as e: return div # add the view selector view_select = SelectWdg("view") view_select.add_empty_option("-- View --") view_select.add_event("onchange", "document.form.submit()") view_select.set_persist_on_submit() #view_select.set_persistence() span = SpanWdg(css="med") span.add("Defined Views: ") span.add(view_select) div.add(span) div.add(self.get_create_view_wdg(search_type)) div.add(HtmlElement.br(2)) div.add(self.get_new_tab_wdg()) widget.add(div) search = Search("sthpw/widget_config") #search.add_user_filter() search.add_filter("search_type", search_type) search.add_where("view != 'definition' and view != 'custom'") #search.add_column("view") widget_configs = search.get_sobjects() if widget_configs: view_select.set_sobjects_for_options(widget_configs, "view", "view") view = view_select.get_value() if not view: view = "custom" #return widget # get the selected widget config for widget_config in widget_configs: if widget_config.get_value("view") == view: break else: return widget # get the handler: a little HACKY. config_xml = widget_config.get_xml_value("config") handler = config_xml.get_value("config/%s/@handler" % view) if not search_type: return widget widget.add(HtmlElement.br()) span = SpanWdg() custom_view = CustomViewWdg(search_type) span.add(custom_view) span.add_style("float: right") widget.add(span) widget.add(HtmlElement.br()) widget.add("<h3>Example View [%s]</h3>" % view) # add a general filter filter_div = DivWdg() for i in range(0, 1): filter = GeneralFilterWdg() filter.set_columns_from_search_type(search_type) filter_div.add("Filter: ") filter_div.add(filter) #filter_div.add(IconWdg("Remove Filter", IconWdg.RETIRE)) filter_div.add(HtmlElement.br(2)) widget.add(filter_div) search = Search(search_type) search.set_limit(5) filter.alter_search(search) if not handler: if view in ["edit", "insert"]: table = EditWdg(search_type, view) else: table = TableWdg(search_type, view) else: table = eval("%s(search_type,view)" % handler) #table.alter_search(search) sobjects = search.get_sobjects() if not sobjects and view in ["edit", "insert"]: sobjects = [SObjectFactory.create(search_type)] table.set_sobjects(sobjects) widget.add(table) # show the custom properties widget.add("<h3>Custom Properties [%s]</h3>" % search_type) search = Search("prod/custom_property") search.add_filter("search_type", search_type) # This is actually reading the sthpw/custom_property conf file, weird table = TableWdg("prod/custom_property") table.set_search_limit(5) table.set_sobjects(search.get_sobjects()) widget.add(table) return widget