本文整理汇总了Python中pyasm.widget.SelectWdg.set_persist_on_submit方法的典型用法代码示例。如果您正苦于以下问题:Python SelectWdg.set_persist_on_submit方法的具体用法?Python SelectWdg.set_persist_on_submit怎么用?Python SelectWdg.set_persist_on_submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.widget.SelectWdg
的用法示例。
在下文中一共展示了SelectWdg.set_persist_on_submit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import set_persist_on_submit [as 别名]
def get_display(my):
search_type = "prod/asset"
web = WebContainer.get_web()
related_asset = web.get_form_value("edit|related")
search = Search(search_type)
search.add_filter("code", related_asset)
sobjects = search.get_sobjects()
labels = "|".join( ["%s - %s" % (x.get_code(), x.get_value("name") ) for x in sobjects ] )
values = "|".join( [x.get_code() for x in sobjects ] )
select = SelectWdg( my.get_input_name() )
select.set_persist_on_submit()
select.set_option("values", values)
select.set_option("labels", labels)
select.set_option("web_state","true")
return select
示例2: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import set_persist_on_submit [as 别名]
def get_display(self):
type = self.kwargs.get("type")
if type not in ['string', 'varchar', 'float', 'integer', 'timestamp', 'login']:
print("WARNING: FilterWdg: type [%s] not supported, using 'string'" % type)
type = 'string'
filter_span = SpanWdg()
web = WebContainer.get_web()
if type in ["string", "varchar"]:
relations = ["is", "is not", "contains", "does not contain", "is empty", "starts with", "ends with"]
relation_select = SelectWdg("%s_relation" % self.prefix)
relation_select.set_option("values", relations)
relation_select.set_persist_on_submit()
self.set_filter_value(relation_select)
filter_span.add(relation_select)
value_text = TextWdg("%s_value" % self.prefix)
value_text.set_persist_on_submit()
self.set_filter_value(value_text)
filter_span.add(value_text)
elif type in ['integer', 'float', 'currency']:
relations = ["is equal to", "is greater than", "is less than"]
relation_select = SelectWdg("%s_relation" % self.prefix)
relation_select.set_option("values", relations)
relation_select.set_persist_on_submit()
self.set_filter_value(relation_select)
filter_span.add(relation_select)
value_text = TextWdg("%s_value" % self.prefix)
value_text.set_persist_on_submit()
self.set_filter_value(value_text)
filter_span.add(value_text)
elif type == 'timestamp':
relations = ["is newer than", "is older than"]
relation_select = SelectWdg("%s_relation" % self.prefix)
relation_select.set_option("values", relations)
relation_select.set_persist_on_submit()
self.set_filter_value(relation_select)
filter_span.add(relation_select)
options = ["1 day", '2 days', '1 week', '1 month']
another_select = SelectWdg("%s_select" % self.prefix)
another_select.add_empty_option("-- Select --")
another_select.set_option("values", options)
another_select.set_persist_on_submit()
self.set_filter_value(another_select)
filter_span.add(another_select)
filter_span.add(" or ")
value_text = TextWdg("%s_value" % self.prefix)
value_text.set_persist_on_submit()
self.set_filter_value(value_text)
filter_span.add(value_text)
elif type in ['login']:
relations = ["is", "is not", "contains", "does not contain", "is empty", "starts with", "ends with"]
relation_select = SelectWdg("%s_relation" % self.prefix)
relation_select.set_option("values", relations)
relation_select.set_persist_on_submit()
self.set_filter_value(relation_select)
filter_span.add(relation_select)
value_text = CheckboxWdg("%s_user" % self.prefix)
value_text.set_persist_on_submit()
self.set_filter_value(value_text)
filter_span.add(value_text)
filter_span.add("{user}")
filter_span.add(" or ")
value_text = TextWdg("%s_value" % self.prefix)
value_text.set_persist_on_submit()
self.set_filter_value(value_text)
filter_span.add(value_text)
return filter_span
示例3: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import set_persist_on_submit [as 别名]
def get_display(my):
web = WebContainer.get_web()
naming_util = NamingUtil()
if not my.widget_name:
my.widget_name = my.get_name()
# get the sobject required by this input
sobject = my.get_current_sobject()
if not sobject:
sobject = Search.get_by_id(my.search_type, my.search_id)
if my.new_sample_name:
my.new_sample_name.replace("//", "/")
else:
my.new_sample_name = sobject.get_value(my.widget_name)
widget = DivWdg()
widget.set_id("naming")
widget.add_style("display: block")
# set the sample text
div = DivWdg()
div.add("Sample name: <i>%s</i>" % my.new_sample_name)
div.add(HtmlElement.br(2))
new_sample_wdg = ProdIconButtonWdg("Set New Sample")
new_sample_wdg.add_event("onclick", "toggle_display('generate')")
div.add(new_sample_wdg)
generate = DivWdg()
generate.add(HtmlElement.br())
generate.set_id("generate")
generate.add_style("display: none")
sample_text = TextWdg("new_sample_name")
sample_text.set_option("size", "30")
# sample_text.set_persist_on_submit()
# if my.new_sample_name:
# sample_text.set_value(my.new_sample_name)
generate.add(sample_text)
button = IconButtonWdg("Generate", IconWdg.REFRESH, long=True)
on_script = my.setup_ajax("naming")
button.add_event("onclick", on_script)
generate.add(button)
generate.add(HtmlElement.br(2))
div.add(generate)
widget.add(div)
hidden = TextWdg(my.widget_name)
value = my.naming
hidden.set_value(my.new_sample_name)
widget.add(my.widget_name)
widget.add(hidden)
# get all of the parts
# TODO: not sure if this should be dictated by the sample name
# break up the name into parts
import re
if my.new_sample_name:
tmp = my.new_sample_name.strip("/")
parts = re.split("[\\/._]", tmp)
print "parts: ", parts
else:
return widget
# if there is a naming, then populate that
if my.edit_search_type:
options = naming_util.get_options(my.edit_search_type)
else:
options = naming_util.get_options(sobject.get_value("search_type"))
table = Table()
type_values = []
padding_values = []
for idx, part in enumerate(parts):
table.add_row()
table.add_cell(part)
type_select = SelectWdg("type_%s" % idx)
type_select.add_empty_option("-- Explicit --")
type_select.set_persist_on_submit()
type_select.set_option("values", "|".join(options))
type_values.append(type_select.get_value())
td = table.add_cell(type_select)
widget.add(table)
return widget
示例4: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import set_persist_on_submit [as 别名]
def get_display(my):
# if no filters are defined, then display nothing
if not my.filters:
return Widget()
#filter_top = DivWdg(css="maq_search_bar")
filter_top = DivWdg()
filter_top.add_color("color", "color")
filter_top.add_color("background", "background", -5)
filter_top.add_style("padding: 5px")
filter_top.add_style("min-width: 700px")
filter_top.add_border()
my.set_as_panel(filter_top)
# TEST link to help for search widget
help_button = ActionButtonWdg(title="?", tip="Search Documentation", size='small')
filter_top.add(help_button)
help_button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.help.set_top();
spt.help.load_alias("search-quickstart|what-is-searching|search-interface|search-compound|search-expressions");
'''
} )
help_button.add_style("float: right")
# this id should be removed
filter_top.set_id("%s_search" % my.prefix)
filter_top.add_class("spt_search")
for name, value in my.kwargs.items():
filter_top.set_attr("spt_%s" % name, value)
#filter_top.add(my.statement)
popup = my.get_retrieve_wdg()
filter_top.add(popup)
popup = my.get_save_wdg()
filter_top.add(popup)
display = my.kwargs.get('display')
# Add a number of filters indicator
div = DivWdg()
div.add_class("spt_search_num_filters")
div.add_style("float: right")
div.add_style("font-size: 0.9em")
div.add_style("margin: 0 10 0 10")
#search_summary.add(div)
filter_top.add(div)
if my.num_filters_enabled:
msg = "[%s] filter/s" % my.num_filters_enabled
icon = IconWdg(msg, IconWdg.DOT_GREEN)
div.add(icon)
div.add("%s" % msg)
filter_div = DivWdg()
filter_div.set_id("search_filters")
filter_div.add_class("spt_search_filters")
# TODO: disabling for now
# add the action buttons
#action_wdg = my.get_action_wdg()
#action_wdg.add_style("text-align: right")
#filter_div.add( action_wdg )
# add the top
display_str = 'block'
if not display:
display_str = 'none'
filter_div.add_style("display: %s" % display_str)
search_wdg = my.get_search_wdg()
prefix = "filter_mode"
if my.prefix_namespace:
prefix = '%s_%s' %(my.prefix_namespace, prefix)
hidden = HiddenWdg("prefix", prefix)
match_div = DivWdg()
match_div.add(hidden)
match_div.add_class('spt_search_filter')
palette = match_div.get_palette()
bg_color = palette.color('background')
light_bg_color = palette.color('background', modifier=+10)
select = SelectWdg("filter_mode")
select.add_class("spt_search_filter_mode")
select.set_persist_on_submit(prefix)
select.remove_empty_option()
# for Local search, leave out compound search for now
if my.kwargs.get('prefix_namespace'):
select.set_option("labels", "Match all|Match any")
#.........这里部分代码省略.........
示例5: SelectWdg
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import set_persist_on_submit [as 别名]
span.add(select)
div.add(span)
# make sure the current selection exists
try:
SearchType.get(search_type)
except SearchException, e:
return div
except SqlException, 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(my.get_create_view_wdg(search_type))
div.add(HtmlElement.br(2))
div.add(my.get_new_tab_wdg())
widget.add(div)
search = Search("sthpw/widget_config")
示例6: get_first_row_wdg
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import set_persist_on_submit [as 别名]
#.........这里部分代码省略.........
data_row = data_row_text.get_value()
if not data_row:
data_row = 0
else:
try:
data_row = int(data_row)
except ValueError:
data_row = 0
if data_row >= len(csv_data):
data_row = len(csv_data)-1
data_row_text.set_value(data_row)
table = Table()
table.set_attr("cellpadding", "10")
table.add_row()
table.add_header("CSV Column Value")
table.add_header("TACTIC Column")
table.add_header("Create New Column")
columns = my.search_type_obj.get_columns()
search_type = my.search_type_obj.get_base_search_type()
sobj = SObjectFactory.create(search_type)
required_columns = sobj.get_required_columns()
row = csv_data[data_row]
labels = []
for column in columns:
if column in required_columns:
label = '%s**'%column
else:
label = column
labels.append(label)
for j, cell in enumerate(row):
table.add_row()
table.add_cell(cell)
column_select = SelectWdg("column_%s" % j)
column_select.add_event("onchange", "if (this.value!='') {set_display_off('new_column_div_%s')} else {set_display_on('new_column_div_%s')}" % (j,j))
column_select.add_empty_option("-- Select --")
column_select.set_option("values", columns)
column_select.set_option("labels", labels)
# only set the value if it is actually in there
if csv_titles[j] in columns:
column_select.set_option("default", csv_titles[j])
column_select.set_persist_on_submit()
column_select_value = column_select.get_value()
display = column_select.get_buffer_display()
td = table.add_cell( display )
if csv_titles[j] not in columns:
td.add(" <b style='color: red'>*</b>")
# new property
new_column_div = DivWdg()
if column_select_value:
new_column_div.add_style("display", "none")
else:
new_column_div.add_style("display", "block")
new_column_div.set_id("new_column_div_%s" % j)
td = table.add_cell( new_column_div )
text = TextWdg("new_column_%s" % j)
text.set_persist_on_submit()
if my.has_title:
text.set_value(csv_titles[j])
new_column_div.add( " ... or ..." )
new_column_div.add( text )
my.num_columns = len(row)
hidden = HiddenWdg("num_columns", my.num_columns)
# need to somehow specify defaults for columns
div.add(table)
div.add("<br/><br/>")
div.add(my.get_preview_wdg())
return div
示例7: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import set_persist_on_submit [as 别名]
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
#.........这里部分代码省略.........