本文整理汇总了Python中pyasm.widget.SelectWdg.add_behavior方法的典型用法代码示例。如果您正苦于以下问题:Python SelectWdg.add_behavior方法的具体用法?Python SelectWdg.add_behavior怎么用?Python SelectWdg.add_behavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.widget.SelectWdg
的用法示例。
在下文中一共展示了SelectWdg.add_behavior方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_sync_mode_wdg
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_sync_mode_wdg(self):
div = DivWdg()
div.add_class("spt_sync_mode")
div.add("Share Mode: ")
select = SelectWdg("sync_mode")
div.add(select)
select.set_option("values", "file|xmlrpc")
select.add_behavior( {
'type': 'change',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_sync_mode");
var value = bvr.src_el.value;
var xmlrpc_el = top.getElement(".spt_xmlrpc_mode");
var file_el = top.getElement(".spt_file_mode");
if (value == 'xmlrpc') {
spt.show(xmlrpc_el);
spt.hide(file_el);
}
else {
spt.hide(xmlrpc_el);
spt.show(file_el);
}
'''
} )
div.add( self.get_xmlrpc_mode_wdg() )
div.add( self.get_file_mode_wdg() )
return div
示例2: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_display(my):
sobject = my.get_current_sobject()
key = sobject.get_value("key")
options = sobject.get_value("options")
type = sobject.get_value("type")
# get the value of the users preferences
search = Search("sthpw/pref_setting")
search.add_user_filter()
search.add_filter("key", key)
pref_setting = search.get_sobject()
if pref_setting:
value = pref_setting.get_value("value")
else:
value = ""
div = DivWdg()
element_name = "%s_%s" % (my.get_name(), sobject.get_id() )
script = '''var server = TacticServerStub.get();
var value = bvr.src_el.value;
if (!value) return;
spt.app_busy.show("Saving", "Saving Preference for [%s]");
setTimeout( function() {
try{
server.execute_cmd('tactic.ui.table.SetPreferenceCmd', {key: '%s', value: value});
}catch(e){
spt.alert(spt.exception.handler(e));
}
spt.app_busy.hide()
}, 200);'''%(key, key)
if key in ['skin', 'palette', 'js_logging_level']:
script = '''%s; spt.app_busy.show('Reloading Page ...'); setTimeout('spt.refresh_page()', 200);'''%script
if type == "sequence":
from pyasm.prod.web import SelectWdg
select = SelectWdg(element_name)
select.add_behavior({'type': "change",
'cbjs_action': script})
select.set_option("values",options)
if value:
select.set_value(value)
div.add(select)
else:
text = TextWdg(element_name)
text.add_behavior({'type': "blur",
'cbjs_action': script})
if value:
text.set_value(value)
div.add(text)
return div
示例3: get_example_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_example_display(self):
div = DivWdg()
div.add_styles("background: grey; padding: 10px; width: 450px;")
div.add( "<br/><br/>" )
from tactic.ui.container import RoundedCornerDivWdg
rc_wdg = RoundedCornerDivWdg(corner_size=10)
# rc_wdg.set_dimensions(width_str="100%", content_height_str='100%', height_str="100%")
rs0_wdg = ResizeScrollWdg( width=300, height=200, scroll_bar_size_str='thin', scroll_expansion='inside',
# max_content_w=500, max_content_h=400,
set_max_to_content_size=True,
min_content_w=100, min_content_h=50 )
rs0_wdg.add( self.get_popwin_oversize_content() )
rc_wdg.add( rs0_wdg )
div.add( rc_wdg )
div.add( "<br/><br/>" )
div.add( "<p style='color: black;'>Resize/Scroll Widget example ...</p>" )
rs_wdg = ResizeScrollWdg( width=300, height=200, scroll_bar_size_str='thin', scroll_expansion='inside' )
rs_wdg.add( self.get_popwin_oversize_content() )
div.add( rs_wdg )
div.add( "<br/><br/>" )
div.add( "<p style='color: black;'>Resize/Scroll Widget example WITH NO RESIZE CAPABILITY" \
" (just scroll bars) ...</p>" )
rs2_wdg = ResizeScrollWdg( width=300, height=200, scroll_bar_size_str='thin', scroll_expansion='inside',
no_resize=True )
rs2_wdg.add( self.get_popwin_oversize_content() )
div.add( rs2_wdg )
div.add( "<br/><br/>" )
popwin_id = "NewPopupWindowTest"
popwin_title = "New Popup Window Widget Test"
popwin = PopWindowWdg(top_id=popwin_id, title=popwin_title, width=150, height=150)
popwin.add( self.get_popwin_oversize_content() )
div.add( popwin )
pwin_launch = DivWdg()
pwin_launch.add_styles("cursor: pointer; background-color: red; color: black; border: 1px solid black; width: 100px; height: 50px;")
pwin_launch.add_behavior( {'type': 'click_up', 'cbjs_action': 'spt.popup.open("' + popwin_id + '");'} )
pwin_launch.add("Click to launch New Popup Window")
div.add( pwin_launch )
div.add( "<br/><br/>" )
test_div = DivWdg()
test_div.add_styles("background: black; padding: 10px; width: 350px; text-align: center;")
test_div.add( SpanWdg("This black DIV has<br/>text-align set to center") )
my_table = Table()
my_table.add_row()
my_table.add_cell("This").add_styles("border: 1px solid white; padding: 4px;")
my_table.add_cell("that").add_styles("border: 1px solid white; padding: 4px;")
my_table.add_cell("and").add_styles("border: 1px solid white; padding: 4px;")
my_table.add_cell("The").add_styles("border: 1px solid white; padding: 4px;")
my_table.add_cell("other").add_styles("border: 1px solid white; padding: 4px;")
test_div.add( "<br/><br/>" )
test_div.add( my_table )
test_div.add( "<br/><br/>" )
tmp_div = DivWdg()
tmp_div.add_styles("width: 200px; background-color: green; color: black; padding: 10px;")
tmp_div.add("I am a DIV without self margins set")
test_div.add(tmp_div)
test_div.add( "<br/><br/>" )
tmp_div = DivWdg()
tmp_div.add_styles("width: 200px; background-color: green; color: black; padding: 10px;")
tmp_div.center()
tmp_div.add("I am a DIV with self margins<br/>set using HtmlElement.center()")
test_div.add(tmp_div)
test_div.add( "<br/><br/>" )
buttons_list = [
{
'label': "Insert",
'tip': "This is an insert",
'bvr': {'cbjs_action': 'alert("Insert!");'}
},
{
'label': 'Cancel',
'tip': 'Cancel',
'bvr': {'cbjs_action': 'alert("Cancel!");'}
}
]
buttons = TextBtnSetWdg( float="", align="center", buttons=buttons_list, spacing=6,
size='medium', side_padding=4 )
test_div.add( buttons )
div.add(test_div)
#.........这里部分代码省略.........
示例4: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
#.........这里部分代码省略.........
item_login = item.get_value("login")
if logins_dict.get(item_login) == None:
continue
item_group = item.get_value("login_group")
group_list = group_dict.get(item_group)
if group_list == None:
group_list = []
group_dict[item_group] = group_list
group_list.append(item_login)
top = DivWdg()
top.add_class("spt_input_top")
# HACK! This isn't very well constructed
### Tore: Not my code! Copied from ProcessContextInputWdg. Seems to work though.
top.add_attr("spt_cbjs_get_input_key", "return cell_to_edit.getAttribute('spt_pipeline_code');")
# Adding an "all users" select option in case it can't find a useful select widget.
div = DivWdg()
div.add_class("spt_input_option")
#div.add_attr("spt_input_key", '__all__') #Not needed, since it defaults to the first one anyway.
select = SelectWdg(my.get_name())
select.add_empty_option("-- Select a User --")
values = []
labels = []
labels_dict = {}
for user in all_users:
user_name = user.get_value('login')
values.append(user_name)
label = user_name
if my.labels_attr:
user_labels = [user.get_value(x) for x in my.labels_attr]
label = ' '.join(user_labels)
labels_dict[user_name] = label
labels.append('%s'%label)
#print "select ", user_name
# -- NOTE: leaving this commented out code here for reference. Not sure why this is the case but when
# -- this click behavior is used instead of a 'change' behavior that forces a blur on select,
# -- click selection only works for this widget in Firefox and does NOT work in IE
#
# select.add_behavior( { 'type': 'click',
# 'cbjs_action': 'spt.dg_table.select_wdg_clicked( evt, bvr.src_el );' } )
# -- Replace previous 'click' behavior with a 'change' behavior to force blur() of select element ...
# -- this works for both Firefox and IE
#
select.add_behavior( { 'type': 'change',
'cbjs_action': 'bvr.src_el.blur();' } )
#behavior = {
# 'type': 'keyboard',
# 'kbd_handler_name': 'DgTableSelectWidgetKeyInput',
#}
#select.add_behavior( behavior )
select.set_option("values", values)
select.set_option("labels", labels)
div.add(select)
top.add(div)
#Building each of the select widgets per group here.
for group in group_dict.keys():
div = DivWdg()
div.add_class("spt_input_option")
div.add_attr("spt_input_key", group)
select = SelectWdg(my.get_name())
select.add_empty_option("-- Select a User --")
values = ['']
labels = ['<< %s >>'%group]
for user in group_dict[group]:
values.append(user)
label = labels_dict.get(user)
labels.append(' %s'%label)
select.add_behavior( { 'type': 'click',
'cbjs_action': 'spt.dg_table.select_wdg_clicked( evt, bvr.src_el );' } )
#behavior = {
# 'type': 'keyboard',
# 'kbd_handler_name': 'DgTableSelectWidgetKeyInput',
#}
#select.add_behavior( behavior )
select.set_option("values", values)
select.set_option("labels", labels)
div.add(select)
top.add(div)
return top
示例5: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_display(self):
self.doc_mode = self.kwargs.get("doc_mode")
path = self.kwargs.get("path")
self.search_type = self.kwargs.get("search_type")
self.last_path = None
doc_key = self.kwargs.get("doc_key")
if doc_key:
self.doc = Search.get_by_search_key(doc_key)
snapshot = Snapshot.get_latest_by_sobject(self.doc)
if snapshot:
self.last_path = snapshot.get_lib_path_by_type('main')
path = self.doc.get_value("link")
# TEST TEST TEST
if not path:
#path = "/home/apache/pdf/mongodb.txt"
#path = "/home/apache/assets/google_docs.html"
#path = "/home/apache/pdf/star_wars.txt"
path = "https://docs.google.com/document/d/1AC_YR8X8wbKsshkJ1h8EjZuFIr41guvqXq3_PXgaqJ0/pub?embedded=true"
path = "https://docs.google.com/document/d/1WPUmXYoSkR2cz0NcyM2vqQYO6OGZW8BAiDL31YEj--M/pub"
#path = "https://docs.google.com/spreadsheet/pub?key=0Al0xl-XktnaNdExraEE4QkxVQXhaOFh1SHIxZmZMQ0E&single=true&gid=0&output=html"
path = "/home/apache/tactic/doc/alias.json"
if not self.search_type:
self.search_type = "test3/shot"
self.column = "description"
top = self.top
top.add_class("spt_document_top")
self.set_as_panel(top)
#table = Table()
table = ResizableTableWdg()
top.add(table)
table.add_row()
table.set_max_width()
left_td = table.add_cell()
left_td.add_style("vertical-align: top")
title = DivWdg()
left_td.add(title)
title.add_style("padding: 10px")
title.add_color("background", "background3")
button = IconButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
title.add(button)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
spt.app_busy.show("Reloading Document");
var top = bvr.src_el.getParent(".spt_document_top");
spt.panel.refresh(top);
spt.app_busy.hide();
'''
} )
button.add_style("float: left")
button = IconButtonWdg(title="Save", icon=IconWdg.SAVE)
title.add(button)
button.add_behavior( {
'type': 'click_up',
'cbjs_action': '''
'''
} )
button.add_style("float: left")
if not self.doc_mode:
self.doc_mode = "text"
select = SelectWdg("doc_mode")
select.set_option("values", "text|formatted")
title.add(select)
select.set_value(self.doc_mode)
select.add_behavior( {
'type': 'change',
'cbjs_action': '''
spt.app_busy.show("Reloading Document");
var top = bvr.src_el.getParent(".spt_document_top");
var value = bvr.src_el.value;
top.setAttribute("spt_doc_mode", value);
spt.panel.refresh(top);
spt.app_busy.hide();
'''
} )
title.add("<br clear='all'/>")
#.........这里部分代码省略.........
示例6: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_display(self):
top = self.top
self.set_as_panel(top)
top.add_class("spt_ingestion_top")
top.add_color("background", "background", -5)
self.data = {}
rules_div = DivWdg()
top.add(rules_div)
rules_div.add_style("padding: 10px")
rules_div.add("Rules: ")
rules_select = SelectWdg("rule_code")
rule_code = self.get_value('rule_code')
if rule_code:
rules_select.set_value(rule_code)
rules_select.set_option("query", "config/ingest_rule|code|title")
rules_select.add_empty_option("-- New --")
rules_div.add(rules_select)
rules_select.add_behavior( {
'type': 'change',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_ingestion_top");
value = bvr.src_el.value;
var class_name = 'tactic.ui.tools.IngestionToolWdg';
spt.panel.load(top, class_name, {rule_code: value} );
'''
} )
rules_div.add("<hr/>")
# read from the database
if rule_code:
search = Search("config/ingest_rule")
search.add_filter("code", rule_code)
sobject = search.get_sobject()
else:
sobject = None
if sobject:
self.data = sobject.get_value("data")
if self.data:
self.data = jsonloads(self.data)
session_code = self.kwargs.get("session_code")
if session_code:
session = Search.get_by_code("config/ingest_session", session_code)
else:
if sobject:
session = sobject.get_related_sobject("config/ingest_session")
print("sobject: ", sobject.get_code(), sobject.get_value("spt_ingest_session_code"))
print("parent: ", session)
else:
session = None
if not session:
#session = SearchType.create("config/ingest_session")
#session.set_value("code", "session101")
#session.set_value("location", "local")
##session.set_value("base_dir", "C:")
top.add("No session defined!!!")
return top
rule = ""
filter = ""
ignore = ""
# get the base path
if sobject:
base_dir = sobject.get_value("base_dir")
else:
base_dir = ''
#else:
# base_dir = self.get_value("base_dir")
#if not base_dir:
# base_dir = ''
if sobject:
title = sobject.get_value("title")
else:
title = ''
if sobject:
code = sobject.get_value("code")
else:
code = ''
file_list = self.get_value("file_list")
scan_type = self.get_value("scan_type")
action_type = self.get_value("action_type")
rule = self.get_value("rule")
if not rule:
#.........这里部分代码省略.........
示例7: get_new_custom_widget
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_new_custom_widget(my, search_type, view):
div = DivWdg()
div.add_style('width: 500px')
mode_select = SelectWdg("custom_mode")
mode_select.add_class("spt_custom_mode")
mode_select.set_option("values", "simple|xml")
mode_select.set_option("labels", "Simple|XML")
mode_select.add_class("spt_input")
behavior = {
'type': 'change',
'cbfn_action': 'spt.custom_property_adder.switch_property_mode'
}
mode_select.add_behavior(behavior)
div.add("Mode: ")
div.add(mode_select)
div.add("<br/><br/>")
custom_table = Table()
custom_table.add_color("color", "color")
custom_table.set_max_width()
mode = "simple"
my.handle_simple_mode(custom_table, mode)
#my.handle_widget_mode(custom_table, mode)
my.handle_xml_mode(custom_table, mode)
div.add(custom_table)
div.add("<br/>")
custom_table = Table()
custom_table.center()
custom_table.add_row()
from tactic.ui.widget import ActionButtonWdg
submit = ActionButtonWdg(title="Add/Next")
behavior = {
'type': 'click',
'mouse_btn': 'LMB',
'cbfn_action': 'spt.custom_property_adder.add_property_cbk',
'search_type': my.search_type,
'view': view
}
submit.add_behavior(behavior)
td = custom_table.add_cell(submit)
behavior['exit'] = 'true'
submit_exit = ActionButtonWdg(title="Add/Exit")
submit_exit.add_behavior(behavior)
custom_table.add_cell(submit_exit)
cancel = ActionButtonWdg(title="Cancel")
behavior = {
'type': 'click_up',
'cbjs_action': "spt.popup.close('New Table Column')"
}
cancel.add_behavior(behavior)
custom_table.add_cell(cancel)
div.add(custom_table)
return div
示例8: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_display(my):
top = my.top
my.set_as_panel(top)
top.add_behavior( {
'type': 'load',
'cbjs_action': '''
spt.named_events.fire_event("side_bar|hide")
'''
} )
top.add_style("width: 100%")
top.add_color("background", "background", -10)
top.add_style("padding-top: 10px")
top.add_style("padding-bottom: 50px")
top.add_class("spt_project_top")
inner = DivWdg()
top.add(inner)
inner.add_style("width: 700px")
inner.add_style("float: center")
inner.add_border()
inner.center()
inner.add_style("padding: 30px")
inner.add_color("background", "background")
from tactic.ui.container import WizardWdg
title = DivWdg()
title.add("Create A New Project")
wizard = WizardWdg(title=title, width="100%")
inner.add(wizard)
help_button = ActionButtonWdg(title="?", tip="Create Project Help", size='s')
title.add(help_button)
help_button.add_style("float: right")
help_button.add_style("margin-top: -20px")
help_button.add_style("margin-right: -10px")
help_button.add_behavior({
'type': 'click_up',
'cbjs_action': '''
spt.help.set_top();
spt.help.load_alias("create-new-project");
'''
})
info_page = DivWdg()
wizard.add(info_page, 'Info')
info_page.add_class("spt_project_top")
info_page.add_style("font-size: 12px")
info_page.add_color("background", "background")
info_page.add_color("color", "color")
info_page.add_style("padding: 20px")
from tactic.ui.input import TextInputWdg
info_page.add("<b>Project Title:</b> ")
text = TextWdg("project_title")
text.add_behavior( {
'type': 'blur',
'cbjs_action': '''
if (bvr.src_el.value == '') {
spt.alert("You must enter a project title");
return;
}
'''})
#text = TextInputWdg(title="project_title")
info_page.add(text)
text.add_style("width: 250px")
info_page.add(HtmlElement.br(3))
span = DivWdg()
info_page.add(span)
span.add_style("padding: 20px 20px 20px 20px")
span.add(IconWdg("INFO", IconWdg.CREATE))
span.add_color("background", "background3")
span.add("The project title can be descriptive and contain spaces and special characters.")
info_page.add("<br/><br/><hr/><br/><br/>")
text.add_behavior( {
'type': 'change',
'cbjs_action': '''
var title = bvr.src_el.value;
if (title.length > 100) {
spt.alert("Title cannot exceed 100 characters.");
return;
}
var code = spt.convert_to_alpha_numeric(title);
code = code.substring(0,30);
var top = bvr.src_el.getParent(".spt_project_top");
var code_el = top.getElement(".spt_project_code");
code_el.value = code;
'''
#.........这里部分代码省略.........
示例9: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_display(self):
self.check()
if self.is_refresh:
div = Widget()
else:
div = DivWdg()
self.set_as_panel(div)
div.add_style('padding','6px')
min_width = '400px'
div.add_style('min-width', min_width)
div.add_color('background','background')
div.add_class('spt_add_task_panel')
div.add_style("padding: 20px")
from tactic.ui.app import HelpButtonWdg
help_button = HelpButtonWdg(alias="creating-tasks")
div.add(help_button)
help_button.add_style("float: right")
help_button.add_style("margin-top: -5px")
if not self.search_key_list:
msg_div = DivWdg()
msg_table = Table()
msg_div.add(msg_table)
msg_table.add_row()
msg_table.add_cell( IconWdg("No items selected", IconWdg.WARNING) )
msg_table.add_cell('Please select at least 1 item to add tasks to.')
msg_div.add_style('margin: 10px')
msg_table.add_style("font-weight: bold")
div.add(msg_div)
return div
msg_div = DivWdg()
msg_div.add_style('margin-left: 4px')
div.add(msg_div, 'info')
msg_div.add('Total: %s item/s to add tasks to' %len(self.search_key_list))
div.add(HtmlElement.br())
hint = HintWdg('Tasks are added according to the assigned pipeline.')
msg_div.add(" ")
msg_div.add(hint)
msg_div.add(HtmlElement.br())
option_div = DivWdg(css='spt_ui_options')
#option_div.add_style('margin-left: 12px')
sel = SelectWdg('pipeline_mode', label='Create tasks by: ')
sel.set_option('values', ['simple process','context', 'standard'])
sel.set_option('labels', ['process','context', 'all contexts in process'])
sel.set_persistence()
sel.add_behavior({'type':'change',
'cbjs_action': 'spt.panel.refresh(bvr.src_el)'})
option_div.add(sel)
value = sel.get_value()
# default to simple process
if not value:
value = 'simple process'
msg = ''
if value not in ['simple process','context','standard']:
value = 'simple process'
if value == 'context':
msg = 'In context mode, a single task will be created for each selected context.'
elif value == 'simple process':
msg = 'In process mode, a single task will be created for each selected process.'
elif value == 'standard':
msg = 'In this mode, a task will be created for all contexts of each selected process.'
option_div.add(HintWdg(msg))
div.add(option_div)
div.add(HtmlElement.br())
title = DivWdg('Assigned Pipelines')
title.add_style('padding: 6px')
title.add_color('background','background2')
title.add_color('color','color', +120)
div.add(title)
content_div = DivWdg()
content_div.add_style('min-height', '150px')
div.add(content_div)
content_div.add_border()
filtered_search_key_list = []
for sk in self.search_key_list:
id = SearchKey.extract_id(sk)
if id=='-1':
continue
filtered_search_key_list.append(sk)
sobjects = SearchKey.get_by_search_keys(filtered_search_key_list)
skipped = []
pipeline_codes = []
for sobject in sobjects:
if isinstance(sobject, Task):
#.........这里部分代码省略.........
示例10: get_new_definition_wdg
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_new_definition_wdg(my):
detail_wdg = DivWdg()
detail_wdg.add_style("color: black")
detail_wdg.add_style("width: 350px")
detail_wdg.add_style("margin-top: 10px")
detail_wdg.add_style("padding: 10px")
detail_wdg.add_border()
title = DivWdg()
title.add_style("color: black")
title.add("Column Definition")
title.add_style("margin-top: -22px")
detail_wdg.add(title)
# add a name entry
title = SpanWdg()
detail_wdg.add("Name: ")
detail_wdg.add(title)
input = SpanWdg()
input.add_style("padding-top: 6px")
input.set_id("config_element_name")
text = TextWdg("column_name")
text.set_value(my.name_string)
input.add(text)
detail_wdg.add(input)
hidden = HiddenWdg("target_search_type", my.search_type)
detail_wdg.add(hidden)
detail_wdg.add(HtmlElement.br(2))
# add data_type entry
data_type = SpanWdg()
default_data_types = [
"varchar(256)",
"varchar",
"character",
"text",
"integer",
"float",
"boolean",
"timestamp",
"Other...",
]
select = SelectWdg("config_data_type", label="Data Type: ")
# detail_wdg.add(": ")
select.set_option("values", default_data_types)
select.set_value(my.data_type_string)
select.add_behavior(
{
"type": "change",
"cbjs_action": "if (bvr.src_el.value=='Other...') {spt.show('config_data_type_custom');}\
else {spt.hide('config_data_type_custom');}",
}
)
data_type.add(select)
text = TextWdg("config_data_type_custom")
span = SpanWdg("Other: ", css="med")
span.add(text)
span.set_id("config_data_type_custom")
span.add_style("display", "none")
text.set_value(my.data_type_string)
data_type.add("<br/>")
data_type.add(span)
detail_wdg.add(data_type)
detail_wdg.add("<br/>")
# add a nullable entry
nullable = DivWdg()
checkbox = CheckboxWdg("config_nullable", label="Allow null(empty) value: ")
nullable.add(checkbox)
if my.nullable_string in ["True", "true"]:
checkbox.set_checked()
detail_wdg.add(nullable)
return detail_wdg
示例11: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_display(my):
top = DivWdg()
top.add_class("spt_element_top")
prefix = my.kwargs.get('prefix')
# this should be name to be consistent with the BaseInputWdg interface
widget_name = my.kwargs.get('name')
if not widget_name:
widget_name = 'data_type'
display_options = my.kwargs.get('display_options')
if not display_options:
display_options = {}
option = my.kwargs.get('option')
if not option:
option = {}
# get the current value
option_name = option.get('name')
widget_type = display_options.get(option_name)
select = SelectWdg(widget_name)
top.add(select)
default = option.get('default')
if default:
select.set_value(default)
else:
select.add_empty_option('-- Select --')
values = option.get('values')
if not values:
values = 'integer|float|percent|currency|date|time|scientific|boolean|text|timecode',
select.set_option('values', values)
if widget_type:
select.set_value(widget_type)
select.add_behavior( {
'type': 'change',
'cbjs_action': '''
var value = bvr.src_el.value;
var top = bvr.src_el.getParent(".spt_element_top");
var selects = top.getElements(".spt_format");
for (var i = 0; i < selects.length; i++) {
var type = selects[i].getAttribute("spt_type");
if (value == type) {
selects[i].setStyle("display", "");
selects[i].removeAttribute("disabled");
}
else {
selects[i].setStyle("display", "none");
selects[i].setAttribute("disabled", "disabled");
selects[i].value = '';
}
}
'''
} )
selects_values = {
'': [],
'integer': ['-1234',
'-1,234'],
'float': ['-1234.12',
'-1,234.12'],
'percent': ['-13%',
'-12.95%'],
'currency': ['-$1,234',
'-$1,234.00',
'-$1,234.--',
'-1,234.00 CAD',
'($1,234.00)',
],
'date': ['31/12/99',
'December 31, 1999',
'31/12/1999',
'Dec 31, 99',
'Dec 31, 1999',
'31 Dec, 1999',
'31 December 1999',
'Fri, Dec 31, 99',
'Fri 31/Dec 99',
'Fri, December 31, 1999',
'Friday, December 31, 1999',
'12-31',
'99-12-31',
'1999-12-31',
'12-31-1999',
'12/99',
'31/Dec',
'December',
#.........这里部分代码省略.........
示例12: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_display(self):
top = self.top
self.set_as_panel(top)
is_refresh = self.kwargs.get("is_refresh")
inner = DivWdg()
top.add(inner)
title = DivWdg()
inner.add(title)
inner.add_class("spt_sync_settings_top")
inner.add_style("padding: 20px")
inner.add_color("background", "background")
server_code = self.get_value("server")
# get all of the defined servers
search = Search("sthpw/sync_server")
servers = search.get_sobjects()
server_codes = [x.get_code() for x in servers]
if not server_codes and not server_code:
msg_div = DivWdg()
msg_div.add("No servers defined. Please add a server")
inner.add(msg_div)
return top
if len(server_codes) == 1 or not server_code:
server_code = server_codes[0]
select = SelectWdg("server")
inner.add("Server: ")
inner.add(select)
select.set_option("values", server_codes)
if server_code:
select.set_value(server_code)
else:
return top
select.add_behavior( {
'type': 'change',
'cbjs_action': '''
var top = bvr.src_el.getParent(".spt_sync_settings_top");
spt.panel.refresh(top);
'''
} )
project = Project.get()
project_code = project.get_code()
if project_code == "admin":
project_code = ""
inner.add( self.get_install_wdg(server_code, project_code) )
inner.add( self.get_dump_wdg(server_code, project_code) )
if is_refresh:
return inner
else:
return top
示例13: get_display
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_display(my):
person_code = ''
person = None
person_exists = False
has_login = 'false'
is_disabled = 'false'
is_employee = 'false'
login_obj = None
password = ''
existing_login_name = ''
if 'person_code' in my.kwargs.keys():
person_code = my.kwargs.get('person_code')
person_s = Search("twog/person")
person_s.add_filter('code',person_code)
person = person_s.get_sobject()
if person:
person_exists = True
login_name = person.get_value('login_name')
if login_name not in [None,'']:
login_s = Search("sthpw/login")
login_s.add_filter('login',login_name)
login_obj = login_s.get_sobject()
if login_obj:
has_login = 'true'
license_type = login_obj.get_value('license_type')
password = login_obj.get_value('password')
existing_login_name = login_obj.get_value('login')
if license_type == 'disabled':
is_disabled = 'true'
if login_obj.get_value('location') == 'internal':
is_employee = 'true'
first_name = ''
last_name = ''
company_code = ''
title = ''
email = ''
alternate_email = ''
main_phone = ''
work_phone = ''
cell_phone = ''
home_phone = ''
fax = ''
country = ''
state = ''
city = ''
zip = ''
street_address = ''
suite = ''
if person_exists:
first_name = person.get_value('first_name')
last_name = person.get_value('last_name')
company_code = person.get_value('company_code')
title = person.get_value('title')
email = person.get_value('email')
alternate_email = person.get_value('alternate_email')
main_phone = person.get_value('main_phone')
work_phone = person.get_value('work_phone')
cell_phone = person.get_value('cell_phone')
home_phone = person.get_value('home_phone')
fax = person.get_value('fax')
country = person.get_value('country')
state = person.get_value('state')
city = person.get_value('city')
zip = person.get_value('zip')
street_address = person.get_value('street_address')
suite = person.get_value('suite')
people_s = Search("twog/person")
people_s.add_order_by('last_name')
people_s.add_order_by('first_name')
people = people_s.get_sobjects()
peep_sel = SelectWdg("person_selector")
peep_sel.add_attr('id','person_selector')
peep_sel.append_option('--Create New Login--','NEW')
for peep in people:
peep_sel.append_option('%s, %s' % (peep.get_value('last_name'), peep.get_value('first_name')), peep.get_code())
if person_exists:
peep_sel.set_value(person_code)
peep_sel.add_behavior(my.switch_person())
company_s = Search("twog/company")
company_s.add_order_by('name')
companies = company_s.get_sobjects()
comp_sel = SelectWdg('company_code')
comp_sel.add_attr('id','company_code')
comp_sel.append_option('--Select--','')
for company in companies:
comp_sel.append_option(company.get_value('name'), company.get_code())
if person_exists:
comp_sel.set_value(company_code)
country_sel = SelectWdg('country')
country_sel.add_attr('id','country')
country_sel.append_option('--Select--','')
for country in my.countries:
country_sel.append_option(country,country)
if person_exists:
my_country = person.get_value('country')
if my_country in [None,'']:
my_country = ''
#.........这里部分代码省略.........
示例14: get_action_wdg
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_action_wdg(self, name):
'''get the action widget for ui option of note entry'''
note_wdg = DivWdg()
note_wdg.add_style("padding-top: 3px")
# note options
option = DivWdg(css='spt_uber_note_option')
cb = CheckboxWdg('is_private')
#cb.set_default_checked()
checkbox_name = 'note_master_private_cb'
master_cb = CheckboxWdg(checkbox_name)
if master_cb.is_checked():
cb.set_default_checked()
option.add_style('margin-right','5px')
option.add_style('float','right')
option.add(cb)
option.add('private')
#commit = TextBtnWdg(label='save', size='small')
commit = ActionButtonWdg(title='save', tip="Save Changes")
commit.add_style('margin-top: -5px')
commit.add_style('margin-bottom: 5px')
commit.add_style('float: right')
commit.add_behavior({
'type': 'click_up',
'cbjs_action': '''
var td = bvr.src_el.getParent(".spt_table_td");
var text = td.getElement(".spt_note_text");
text.blur();
spt.dg_table.update_row(evt, bvr);
td.setStyle('background-color','');
''',
'cell_only': True
})
#commit.set_scale("0.75")
# do some gynastics to handle a refresh.
if self.parent_wdg:
info = self.parent_wdg.get_aux_info()
sobject_dict = info.get('sobjects')
sobject = sobject_dict.get(self.get_name())
parent = info.get('parent')
else:
sobject = None
parent = None
if not sobject:
if self.parent_key:
parent = SearchKey.get_by_search_key(self.parent_key)
# get the latest note
#search_key = self.kwargs.get("search_key")
#if search_key:
# sobject = SearchKey.get_by_search_key(search_key)
search = Search('sthpw/note')
search.add_parent_filter(parent)
search.add_filter('context', name)
# Make the assumption that the last one entered is by timestamp
search.add_order_by('timestamp desc')
sobject = search.get_sobject()
# Show a history of notes
if sobject:
history = ActionButtonWdg(title='history', tip="Show note history")
#history = TextBtnWdg(label='history', size='small')
#history.get_top_el().add_style("margin-left: 4px")
#history.get_top_el().add_style('float: left')
history.add_style("float: left")
history.add_style("margin-top: -5px")
history.add_style("margin-bottom: 5px")
note_wdg.add(history)
self.parent_key = SearchKey.get_by_sobject(parent)
context = name
filter = '[{"prefix":"main_body","main_body_enabled":"on","main_body_column":"context","main_body_relation":"is","main_body_value":"%s"}]' % context
history.add_behavior( {
'type': 'click_up',
'cbjs_action': "spt.popup.get_widget(evt, bvr)",
'options': {
'class_name': 'tactic.ui.panel.ViewPanelWdg',
'title': 'Notes History',
'popup_id': 'Notes_History_%s'%context
},
'args': {
'search_type': 'sthpw/note',
'view': 'summary',
'parent_key': self.parent_key,
'filter': filter,
#.........这里部分代码省略.........
示例15: get_filter_wdg
# 需要导入模块: from pyasm.widget import SelectWdg [as 别名]
# 或者: from pyasm.widget.SelectWdg import add_behavior [as 别名]
def get_filter_wdg(my):
div = DivWdg()
div.add_style("margin: 10px")
div.add_class("spt_view_manager_filter")
div.add('Search Type: ')
security = Environment.get_security()
if security.check_access("builtin", "view_site_admin", "allow"):
select_mode = SearchTypeSelectWdg.ALL
else:
select_mode = SearchTypeSelectWdg.ALL_BUT_STHPW
select = SearchTypeSelectWdg(name='search_type', \
mode=select_mode)
behavior = {'type': 'change', 'cbjs_action': '''
var filter_top = bvr.src_el.getParent(".spt_view_manager_filter");
var table_top = bvr.src_el.getParent(".spt_table_view_manager_top");
var manager_top = table_top.getElement(".spt_view_manager_top");
var input = spt.api.Utility.get_input(filter_top, 'search_type');
var view_input = spt.api.Utility.get_input(filter_top, 'view');
var view_input_value = '';
if (view_input != null) {
view_input_value = view_input.value;
}
var values = {'search_type': input.value, 'view': view_input_value, 'is_refresh': 'true'};
spt.panel.refresh(table_top, values);'''
#//spt.panel.refresh(manager_top, values);'''
}
select.add_behavior(behavior)
select.set_value(my.search_type)
div.add(select)
if not my.search_type:
return div
div.add('View: ')
view_wdg = SelectWdg("view")
view_wdg.set_value(my.view)
view_wdg.add_empty_option("-- Select --")
view_wdg.add_behavior(behavior)
div.add(view_wdg)
search = Search("config/widget_config")
search.add_filter("search_type", my.search_type)
db_configs = search.get_sobjects()
views = set()
for db_config in db_configs:
view = db_config.get_value("view")
views.update([view])
if my.search_type and my.view:
config_view = WidgetConfigView.get_by_search_type(my.search_type, my.view)
configs = config_view.get_configs()
for x in configs:
view = x.get_view()
file_path = x.get_file_path()
if view != my.view:
continue
if file_path and file_path.endswith("DEFAULT-conf.xml"):
continue
config_views = x.get_all_views()
views.update(config_views)
views_list = list(views)
views_list.sort()
view_wdg.set_option("values", views_list)
return div