本文整理汇总了Python中pyasm.widget.HiddenWdg类的典型用法代码示例。如果您正苦于以下问题:Python HiddenWdg类的具体用法?Python HiddenWdg怎么用?Python HiddenWdg使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HiddenWdg类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_info_wdg
def get_info_wdg(my):
widget = Widget()
context_input = HiddenWdg("%s|context" % my.get_input_name(), my.context)
context_input.add_class('spt_upload_context')
widget.add(context_input)
# override the column
column = my.get_option("column")
if column != "":
column_input = HiddenWdg("%s|column" % my.get_input_name(), column)
widget.add(column_input)
return widget
示例2: get_display
def get_display(self):
self.display_expr = self.kwargs.get('display_expr')
self.values = []
instance_type = self.get_option("instance_type")
accepted_type = self.get_option("accepted_drop_type")
div = DivWdg()
div.add_class("spt_drop_element_top")
div.add_style("width: 100%")
div.add_style("min-height: 70px")
div.add_style("height: auto")
div.add_style("min-width: 100px")
div.add_style("max-height: 300px")
div.add_style("overflow-y: auto")
div.add_style("overflow-x: hidden")
self.value_wdg = HiddenWdg(self.get_name())
self.value_wdg.add_class("spt_drop_element_value")
div.add( self.value_wdg )
version = self.parent_wdg.get_layout_version()
#if version != "2":
self.add_drop_behavior(div, accepted_type)
# add the hidden div which holds containers info for the sobject
template_div = DivWdg()
template_div.add_style("display: none")
template_item = self.get_item_div(None)
# float left for the new icon beside it
item_div = template_item.get_widget('item_div')
#item_div.add_style('float: left')
template_item.add_class("spt_drop_template")
new_icon = IconWdg("New", IconWdg.NEW)
new_icon.add_style('padding-left','3px')
#TODO: insert the new_icon at add(new_icon, index=0) and make sure
# the js-side sobject_drop_action cloning align the template div properly
#template_item.add(new_icon)
template_div.add(template_item)
div.add(template_div)
content_div = DivWdg()
div.add(content_div)
content_div.add_class("spt_drop_content")
if instance_type:
instance_wdg = self.get_instance_wdg(instance_type)
content_div.add(instance_wdg)
return div
示例3: get_display
def get_display(my):
top = DivWdg()
top.add_color("color", "color")
#top.add_color("background", "background")
top.add_class("spt_simple_upload_top")
top.add(my.browse)
hidden = HiddenWdg( "%s|path" % my.get_input_name() )
hidden.add_class("spt_upload_hidden")
top.add(hidden)
# this can be used for some other transaction that picks up this file to checkin
hidden = HiddenWdg( "%s|ticket" % my.get_input_name() )
hidden.add_class("spt_upload_ticket")
top.add(hidden)
# if not specified, get the sobject's icon context
my.context = my.kwargs.get("context")
if not my.context:
current = my.get_current_sobject()
if current:
my.context = current.get_icon_context()
else:
from pyasm.biz import Snapshot
my.context = Snapshot.get_default_context()
top.add_attr("spt_context", my.context)
top.add( my.get_info_wdg() )
files_div = DivWdg()
top.add(files_div)
files_div.add_class("spt_upload_files")
files_div.add_style("font-size: 11px")
files_div.add_style("margin-top: 10px")
my.add_action()
return top
示例4: get_display
#.........这里部分代码省略.........
# extra info for foreign key
custom_table.add_row()
div = DivWdg()
div.add_class("foreign_key_options")
div.add_style("display: none")
div.add_style("margin-top: 10px")
div.add("Options")
div.add(HtmlElement.br())
# extra info for foreign key
custom_table.add_row()
div = DivWdg()
div.add_class("foreign_key_options")
div.add_style("display: none")
div.add_style("margin-top: 10px")
div.add("Options")
div.add(HtmlElement.br())
# TODO: this class should not be in prod!!
from pyasm.prod.web import SearchTypeSelectWdg
div.add("Relate to: ")
search_type_select = SearchTypeSelectWdg("foreign_key_search_select", mode=SearchTypeSelectWdg.CURRENT_PROJECT)
div.add(search_type_select)
td.add(div)
# extra info for list
custom_table.add_row()
div = DivWdg()
div.add_class("list_options")
div.add_style("display: none")
div.add_style("margin-top: 10px")
div.add("Options")
div.add(HtmlElement.br())
# TODO: this class should not be in prod!!
from pyasm.prod.web import SearchTypeSelectWdg
div.add("Values: ")
search_type_text = TextWdg("list_values")
div.add(search_type_text)
td.add(div)
# extra info for button
custom_table.add_row()
div = DivWdg()
div.add_style("color: black")
div.add_class("button_options")
div.add_style("display: none")
div.add_style("margin-top: 10px")
#class_path = "tactic.ui.table.ButtonElementWdg"
class_path = display_handler
button = Common.create_from_class_path(class_path)
args_keys = button.get_args_keys()
div.add("Options")
div.add(HtmlElement.br())
for key in args_keys.keys():
option_name_text = HiddenWdg("option_name")
option_name_text.set_value(key)
div.add(option_name_text)
div.add("%s: " % key)
div.add(" ")
input = button.get_input_by_arg_key(key)
value = display_options.get(key)
if value:
input.set_value(value)
div.add(input)
div.add(HtmlElement.br())
td.add(div)
# is searchable checkbox
#custom_table.add_row()
#current_searchable_wdg = CheckboxWdg("is_searchable")
#current_view_wdg.set_checked()
#custom_table.add_cell("Searchable? ")
#td = custom_table.add_cell(current_searchable_wdg)
custom_table.close_tbody()
return top_wdg
示例5: get_display
#.........这里部分代码省略.........
else:
task_pipeline_code = "task"
task_pipeline = None
process_div = DivWdg()
process_div.add_style("float: left")
process_div.add_class("spt_process_top")
if i == 0:
dyn_list.add_template(process_div)
else:
dyn_list.add_item(process_div)
#process_div.add_style("padding-left: 10px")
#process_div.add_style("margin: 5px")
table = Table()
process_div.add(table)
table.add_row()
text = TextInputWdg(name="process")
process_cell = table.add_cell(text)
text.add_style("width: 95px")
text.add_style("margin: 5px")
text.set_value(process_name)
text.add_class("spt_process")
# the template has a border
if i == 0:
text.add_style("border: solid 1px #AAA")
hidden = HiddenWdg(name='process_type')
hidden.set_value(process_type)
process_cell.add(hidden)
hidden = HiddenWdg(name='process_xpos')
hidden.set_value(process_xpos)
process_cell.add(hidden)
hidden = HiddenWdg(name='process_ypos')
hidden.set_value(process_ypos)
process_cell.add(hidden)
text = TextInputWdg(name="description")
table.add_cell(text)
text.add_style("width: 175px")
text.add_style("margin: 5px")
text.set_value(description)
# the template has a border
if i == 0:
text.add_style("border: solid 1px #AAA")
if process_type in ['manual','approval']:
read_only = False
else:
read_only = True
text = TextInputWdg(name="task_status", read_only=read_only)
table.add_cell(text)
text.add_style("width: 325px")
text.add_style("margin: 5px")
示例6: get_display
def get_display(my):
if not my.preprocessed:
my.preprocess()
if my.is_refresh:
top = Widget()
else:
top = DivWdg()
top.add_class("spt_work_hours_top")
hidden = HiddenWdg('workhour_data')
hidden.add_class('spt_workhour_data')
header_data = {'start_date': str(my.start_date)}
header_data = jsondumps(header_data).replace('"', """)
hidden.set_value(header_data, set_form_value=False )
top.add(hidden)
days = []
for date in my.dates:
days.append( date.strftime("%Y_%m_%d") )
today = my.today.strftime("%Y_%m_%d")
task = my.get_current_sobject()
if not my.is_refresh:
my.set_as_panel(top)
entries = my.entries.get(task.get_code())
if isinstance(task, Task):
parent = task.get_parent()
if not parent:
disabled = True
else:
disabled = False
else:
disabled = False
if not entries:
entries = {}
table = Table()
top.add(table)
if my.use_straight_time:
row_list = [my.ST_ROW]
if my.show_overtime:
row_list.append(my.OT_ROW)
prefix_list = ['','ot']
else:
row_list = [my.STT_ROW, my.ENT_ROW]
prefix_list = ['stt','ent']
text = HiddenWdg(my.get_name() )
text.add_class("spt_data")
table.add_color("color", "color")
table.add_styles("width: %spx; float: left"%my.table_width)
for row_to_draw in row_list:
tr = table.add_row()
tr.add_style('line-height','8px')
td = table.add_blank_cell()
offset_width = my.MONTH_WIDTH + my.LEFT_WIDTH+8
td.add_style("min-width: %spx" % offset_width)
td.add(text)
# go through each day and draw an input for overtime
total_hours_st = 0
total_hours_ot = 0
search_key = task.get_search_key()
# Add a label to indicate if the row is straight time or overtime
time_prefix = ''
if row_to_draw == my.OT_ROW:
time_prefix = 'ot'
div = DivWdg()
div.add("OT")
div.add_styles('text-align: right; margin-right: 4px')
td.add(div)
elif row_to_draw == my.STT_ROW:
time_prefix = 'stt'
div = DivWdg()
div.add("ST")
div.add_styles('text-align: right; margin: 0 4px 4px 0')
td.add(div)
elif row_to_draw == my.ENT_ROW:
time_prefix = 'ent'
div = DivWdg()
div.add("ET")
div.add_styles('text-align: right; margin: 0 4px 4px 0')
td.add(div)
for idx, day in enumerate(days):
day_wdg = DivWdg()
#.........这里部分代码省略.........
示例7: init
def init(self):
self.current_offset = 0
self.count = None
#self.text = TextWdg(self.search_limit_name)
self.text = HiddenWdg(self.search_limit_name)
self.text.add_style("width: 23px")
self.text.add_style("margin-bottom: -1px")
self.text.add_class("spt_search_limit_text")
self.text.set_persist_on_submit(prefix=self.prefix)
behavior = {
'type': 'keydown',
'cbjs_action': '''
if (evt.key=='enter') {
// register this as changed item
var value = bvr.src_el.value;
if (isNaN(value) || value.test(/[\.-]/)) {
spt.error('You have to use an integer.');
}
}
'''}
self.text.add_behavior(behavior)
# get the search limit that is passed in
filter_data = FilterData.get()
values = filter_data.get_values_by_prefix(self.prefix)
if not values:
# check web for embedded table
web = WebContainer.get_web()
values = {}
limit_value = web.get_form_value("search_limit")
label_value = web.get_form_value(self.label)
if limit_value:
values['search_limit'] = limit_value
if label_value:
values[self.label] = label_value
else:
values = values[0]
self.values2 = filter_data.get_values_by_prefix("search_limit_simple")
if not len(self.values2):
self.values2 = {}
elif len(self.values2) == 2:
if self.values2[0]['page']:
self.values2 = self.values2[0]
else:
self.values2 = self.values2[1]
else:
self.values2 = self.values2[0]
self.stated_search_limit = values.get("search_limit")
"""
if not self.stated_search_limit:
self.stated_search_limit = values.get("limit_select")
if not self.stated_search_limit:
self.stated_search_limit = values.get("custom_limit")
"""
if self.stated_search_limit:
self.stated_search_limit = int(self.stated_search_limit)
else:
self.stated_search_limit = 0
# reused for alter_search() later
self.values = values
示例8: get_data_wdg
#.........这里部分代码省略.........
category_div.add(" Categorize files by Day")
category_div.add_style("margin-bottom: 5px")
category_div = DivWdg()
name_div.add(category_div)
checkbox = RadioWdg("category")
checkbox.set_option("value", "by_week")
category_div.add(checkbox)
category_div.add(" Categorize files by Week")
category_div.add_style("margin-bottom: 5px")
category_div = DivWdg()
name_div.add(category_div)
checkbox = RadioWdg("category")
checkbox.set_option("value", "by_year")
category_div.add(checkbox)
category_div.add(" Categorize files by Year")
category_div.add_style("margin-bottom: 5px")
"""
checkbox = RadioWdg("category")
checkbox.set_option("value", "custom")
name_div.add(checkbox)
name_div.add(" Custom")
"""
name_div.add("<br/>")
hidden = HiddenWdg(name="parent_key")
dialog_data_div.add(hidden)
hidden.add_class("spt_parent_key")
parent_key = my.kwargs.get("parent_key") or ""
if parent_key:
hidden.set_value(parent_key)
dialog_data_div.add("Keywords:<br/>")
dialog.add(dialog_data_div)
text = TextAreaWdg(name="keywords")
dialog_data_div.add(text)
text.add_class("spt_keywords")
text.add_style("padding: 1px")
dialog_data_div.add("<br/>"*2)
extra_data = my.kwargs.get("extra_data")
if not isinstance(extra_data, basestring):
extra_data = jsondumps(extra_data)
dialog_data_div.add("Extra Data (JSON):<br/>")
text = TextAreaWdg(name="extra_data")
dialog_data_div.add(text)
if extra_data != "null":
text.set_value(extra_data)
text.add_class("spt_extra_data")
text.add_style("padding: 1px")
示例9: get_display
def get_display(my):
top = my.top
view = my.kwargs.get("view")
top.add_class("spt_help_edit_content")
search = Search("config/widget_config")
search.add_filter("category", "HelpWdg")
search.add_filter("view", view)
sobject = search.get_sobject()
if not sobject:
value = ""
search_key = ""
else:
xml_value = sobject.get_xml_value("config")
value = xml_value.get_value("config/%s/html/div" % (view) )
search_key = sobject.get_search_key()
title_wdg = DivWdg()
top.add(title_wdg)
title_wdg.add("<b>View: %s</b>" % view)
title_wdg.add_style("font-style: bold")
title_wdg.add_style("padding: 5px")
title_wdg.add_gradient("background", "background", 0, -10)
hidden = HiddenWdg("view")
top.add(hidden)
hidden.set_value(view)
text = TextAreaWdg("content")
text_id = text.set_unique_id()
text.set_value(value)
from tactic.ui.widget import ActionButtonWdg
if sobject:
delete_button = ActionButtonWdg(title="Delete")
top.add(delete_button)
delete_button.add_style("float: right")
delete_button.add_style("margin-top: -3px")
delete_button.add_behavior( {
'type': 'click_up',
'search_key': search_key,
'cbjs_action': '''
if (!confirm("Are you sure you wish to delete this help page?")) {
return;
}
var server = TacticServerStub.get();
server.delete_sobject(bvr.search_key);
var top = bvr.src_el.getParent(".spt_help_edit_top");
spt.panel.refresh(top);
'''
})
test_button = ActionButtonWdg(title="Preview")
top.add(test_button)
test_button.add_style("float: right")
test_button.add_style("margin-top: -3px")
test_button.add_behavior( {
'type': 'click_up',
'text_id': text_id,
'cbjs_action': '''
var js_file = "ckeditor/ckeditor.js";
var url = "/context/spt_js/" + js_file;
var js_el = document.createElement("script");
js_el.setAttribute("type", "text/javascript");
js_el.setAttribute("src", url);
var head = document.getElementsByTagName("head")[0];
head.appendChild(js_el);
var cmd = "CKEDITOR.instances." + bvr.text_id + ".getData()";
var text_value = eval( cmd );
bvr.options = {};
bvr.options.html = text_value;
spt.named_events.fire_event("show_help", bvr)
'''
})
save_button = ActionButtonWdg(title="Save")
top.add(save_button)
save_button.add_style("float: right")
save_button.add_style("margin-top: -3px")
top.add("<br/>")
#.........这里部分代码省略.........
示例10: get_display
#.........这里部分代码省略.........
// Do an inplace check-in into TACTIC
var path = action.depotFile;
var parts = path.split("/");
var filename = parts[parts.length-1];
var context = process + "/" + filename;
var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} );
}
}
else {
// check in all of the files
for ( var i = 0; i < paths.length; i++) {
var path = paths[i];
var scm_info = spt.scm.run("commit_file", [path, description, editable]);
// the first item is the changelist number
var action = scm_info[1];
revision = action.rev;
revisions.push(revision);
var parts = path.split("/");
var filename = parts[parts.length-1];
var context = process + "/" + filename;
//path = path.replace(bvr.sandbox_dir, "//"+bvr.depot);
// NOTE: this assumes project == depot
path = path.replace(bvr.sandbox_dir, "//");
// Do an inplace check-in into TACTIC
var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} );
}
}
if (add_note == 'on') {
var note = [];
note.push('CHECK-IN');
for (var i = 0; i < paths.length; i++) {
var parts = paths[i].split("/");
var filename = parts[parts.length-1];
note.push(filename+' (v'+revisions[i]+')');
}
note.push(': ');
note.push(description);
note = note.join(" ");
server.create_note(bvr.search_key, note, {process: process});
}
server.finish({description: "File Check-in ["+paths.length+" file/s]"});
spt.panel.refresh(top);
}
catch(e) {
spt.error("Error detected: " + e.msg)
//console.log(e);
server.abort();
}
spt.app_busy.hide();
'''
} )
else:
button.add_behavior(behavior)
button.add_style("margin-right: auto")
button.add_style("margin-left: auto")
button.add_style("margin-top: 20px")
button.add_style("margin-bottom: 20px")
top.add("<br clear='all'/>")
top.add("<hr/>")
hidden = HiddenWdg("checkin_type")
top.add(hidden)
hidden.add_class("spt_checkin_type")
grey_out_div = DivWdg()
top.add(grey_out_div)
grey_out_div.add_class("spt_publish_disable")
grey_out_div.add_style("position: absolute")
grey_out_div.add_style("left: 0px")
grey_out_div.add_style("top: 10px")
grey_out_div.add_style("opacity: 0.6")
grey_out_div.add_color("background", "background")
grey_out_div.add_style("height: 100%")
grey_out_div.add_style("width: 100%")
#grey_out_div.add_border()
return top
示例11: get_display
#.........这里部分代码省略.........
}
page_el.value = value;
bvr.src_el = bvr.src_el.getParent('.spt_table_top');
//bvr.panel = bvr.src_el.getParent('.spt_view_panel');
spt.dg_table.search_cbk(evt, bvr);
'''
} )
bgcolor = top.get_color("background3")
bgcolor2 = top.get_color("background3", 10)
top.add_relay_behavior( {
'type': 'mouseover',
'bgcolor': bgcolor2,
'bvr_match_class': 'spt_link',
'cbjs_action': '''
bvr.src_el.setStyle("background", bvr.bgcolor);
'''
} )
top.add_relay_behavior( {
'type': 'mouseout',
'bgcolor': bgcolor,
'bvr_match_class': 'spt_link',
'cbjs_action': '''
if (!bvr.src_el.hasClass('spt_current_page'))
bvr.src_el.setStyle("background", bvr.bgcolor);
'''
} )
top.add_class("spt_table_search")
hidden = HiddenWdg("prefix", "search_limit_simple")
top.add(hidden)
hidden = HiddenWdg("page", "")
hidden.add_class("spt_page")
top.add(hidden)
td = table.add_cell()
left = "< Prev"
td.add(left)
if current_page > 1:
td.add_class("spt_link")
else:
td.add_class("spt_no_link")
td.add_attr("spt_page", "prev")
# find the range ... always show 10 pages max
start_page = current_page - 5
if start_page < 1:
start_page = 1
if start_page + 9 <= num_pages:
end_page = start_page + 10 - 1
elif start_page > 5:
end_page = current_page + 5
else:
end_page = num_pages
示例12: handle_dir_or_item
def handle_dir_or_item(my, item_div, dirname, basename):
spath = "%s/%s" % (dirname, basename)
fspath = "%s/%s" % (dirname, File.get_filesystem_name(basename))
md5 = my.md5s.get(fspath)
changed = False
context = None
error_msg = None
snapshot = None
file_obj = my.checked_in_paths.get(fspath)
if not file_obj:
if fspath.startswith(my.base_dir):
rel = fspath.replace("%s/" % my.base_dir, "")
file_obj = my.checked_in_paths.get(rel)
if file_obj != None:
snapshot_code = file_obj.get_value("snapshot_code")
snapshot = my.snapshots_dict.get(snapshot_code)
if not snapshot:
# last resort
snapshot = file_obj.get_parent()
if snapshot:
context = snapshot.get_value("context")
item_div.add_attr("spt_snapshot_code", snapshot.get_code())
snapshot_md5 = file_obj.get_value("md5")
item_div.add_attr("spt_md5", snapshot_md5)
item_div.add_attr("title", "Checked-in as: %s" % file_obj.get_value("file_name"))
if md5 and md5 != snapshot_md5:
item_div.add_class("spt_changed")
changed = True
else:
error_msg = 'snapshot not found'
status = None
if file_obj != None:
if changed:
check = IconWdg( "Checked-In", IconWdg.ERROR, width=12 )
status = "changed"
else:
check = IconWdg( "Checked-In", IconWdg.CHECK, width=12 )
status = "same"
item_div.add_color("color", "color", [0, 0, 50])
else:
check = None
item_div.add_style("opacity: 0.8")
status = "unversioned"
if check:
item_div.add(check)
check.add_style("float: left")
check.add_style("margin-left: -16px")
check.add_style("margin-top: 4px")
# add the file name
filename_div = DivWdg()
item_div.add(filename_div)
filename_div.add(basename)
file_info_div = None
if snapshot and status != 'unversioned':
file_info_div = SpanWdg()
filename_div.add(file_info_div)
if error_msg:
filename_div.add(' (%s)'%error_msg)
filename_div.add_style("float: left")
filename_div.add_style("overflow: hidden")
filename_div.add_style("width: 65%")
# DEPRECATED
from pyasm.widget import CheckboxWdg, TextWdg, SelectWdg, HiddenWdg
checkbox = CheckboxWdg("check")
checkbox.add_style("display: none")
checkbox.add_class("spt_select")
checkbox.add_style("float: right")
checkbox.add_style("margin-top: 1px")
item_div.add(checkbox)
subcontext_val = ''
cat_input = None
is_select = True
if my.context_options:
context_sel = SelectWdg("context")
context_sel.add_attr('title', 'context')
context_sel.set_option("show_missing", False)
context_sel.set_option("values", my.context_options)
#.........这里部分代码省略.........
示例13: get_display
def get_display(my):
widget = Widget()
my.search_type = my.options.get("search_type")
if not my.search_type:
my.search_type = my.kwargs.get("search_type")
assert my.search_type
my.load_options_class = my.kwargs.get('load_options_class')
state = Container.get("global_state")
if state:
my.process = state.get("process")
else:
my.process = None
# the filter for searching assets
div = DivWdg(css='filter_box')
div.add_color("background", "background2", -35)
from app_init_wdg import PyMayaInit, PyXSIInit, PyHoudiniInit
if WebContainer.get_web().get_selected_app() == 'Maya':
app = PyMayaInit()
elif WebContainer.get_web().get_selected_app() == 'XSI':
app = PyXSIInit()
elif WebContainer.get_web().get_selected_app() == 'Houdini':
app = PyHoudiniInit()
div.add(app)
# add the possibility of a custom callback
callback = my.options.get('callback')
if callback:
hidden = HiddenWdg("callback", callback)
div.add(hidden)
# or add the possiblity of a switch mode
pipeline_type = "load"
hidden = HiddenWdg("pipeline_type", pipeline_type)
if my.process:
process_div = DivWdg()
process_div.add_style("margin: 10px")
process_div.add("PROCESS: %s" % my.process)
process_div.add_style("font-size: 20px")
widget.add(process_div)
hidden_wdg = HiddenWdg("process_select_%s" %my.search_type)
hidden_wdg.set_value(my.process)
widget.add(hidden_wdg)
else:
search_type = my.search_type
if search_type =='prod/shot_instance':
search_type = 'prod/shot'
process_filter = ProcessFilterWdg(my.get_context_data(search_type), search_type)
span = SpanWdg(process_filter, css='med')
div.add(span)
widget.add(div)
# load options for diff search type
if my.load_options_class:
load_options = Common.create_from_class_path(my.load_options_class)
elif my.search_type=='prod/asset':
load_options = LoadOptionsWdg()
elif my.search_type == 'prod/shot':
load_options = ShotLoadOptionsWdg()
elif my.search_type == 'prod/shot_instance':
load_options = AnimLoadOptionsWdg()
else:
load_options = LoadOptionsWdg()
load_options.set_prefix(my.search_type)
widget.add(load_options)
return widget
示例14: get_upload_wdg
def get_upload_wdg(my):
'''get search type select and upload wdg'''
key = 'csv_import'
widget = DivWdg(css='spt_import_csv')
widget.add_color('color','color')
widget.add_color('background','background')
widget.add_style('width: 600px')
# get the search type
stype_div = DivWdg()
widget.add(stype_div)
# DEPRECATED
# handle new search_types
"""
new_search_type = CheckboxWdg("new_search_type_checkbox")
new_search_type.add_event("onclick", "toggle_display('new_search_type_div')")
new_search_type_div = DivWdg()
new_search_type_div.set_id("new_search_type_div")
name_input = TextWdg("asset_name")
title = TextWdg("asset_title")
description = TextAreaWdg("asset_description")
table = Table()
table.set_id('csv_main_body')
table.add_style("margin: 10px 10px")
table.add_col().set_attr('width','140')
table.add_col().set_attr('width','400')
table.add_row()
table.add_header("Search Type: ").set_attr('align','left')
table.add_cell(name_input)
table.add_row()
table.add_header("Title: ").set_attr('align','left')
table.add_cell(title)
table.add_row()
table.add_header("Description: ").set_attr('align','left')
table.add_cell(description)
new_search_type_div.add(table)
new_search_type_div.add_style("display: none")
#widget.add(new_search_type_div)
"""
show_stype_select = my.kwargs.get("show_stype_select")
if show_stype_select in ['true',True] or not my.search_type:
title = DivWdg("<b>Select sType to import data into:</b> ")
stype_div.add( title )
title.add_style("float: left")
search_type_select = SearchTypeSelectWdg("search_type_filter", mode=SearchTypeSelectWdg.ALL)
search_type_select.add_empty_option("-- Select --")
if not search_type_select.get_value():
search_type_select.set_value(my.search_type)
search_type_select.set_persist_on_submit()
stype_div.add(search_type_select)
search_type_select.add_behavior( {'type': 'change', \
'cbjs_action': "spt.panel.load('csv_import_main','%s', {}, {\
'search_type_filter': bvr.src_el.value});" %(Common.get_full_class_name(my)) } )
else:
hidden = HiddenWdg("search_type_filter")
stype_div.add(hidden)
hidden.set_value(my.search_type)
if my.search_type:
sobj = None
try:
sobj = SObjectFactory.create(my.search_type)
except ImportError:
widget.add(HtmlElement.br())
widget.add(SpanWdg('WARNING: Import Error encountered. Please choose another search type.', css='warning'))
return widget
required_columns = sobj.get_required_columns()
if required_columns:
widget.add(HtmlElement.br())
req_span = SpanWdg("Required Columns: ", css='med')
req_span.add_color('color','color')
widget.add(req_span)
#required_columns = ['n/a']
req_span.add(', '.join(required_columns))
widget.add( HtmlElement.br() )
if my.file_path:
#.........这里部分代码省略.........
示例15: get_data_wdg
#.........这里部分代码省略.........
checkbox = RadioWdg("category")
checkbox.set_option("value", "by_week")
category_div.add(checkbox)
category_div.add(" Categorize files by Week")
category_div.add_style("margin-bottom: 5px")
category_div = DivWdg()
name_div.add(category_div)
checkbox = RadioWdg("category")
checkbox.set_option("value", "by_year")
category_div.add(checkbox)
category_div.add(" Categorize files by Year")
category_div.add_style("margin-bottom: 5px")
"""
checkbox = RadioWdg("category")
checkbox.set_option("value", "custom")
name_div.add(checkbox)
name_div.add(" Custom")
"""
name_div.add("<br/>")
ingest_data_view = my.kwargs.get('ingest_data_view')
from tactic.ui.panel import EditWdg
sobject = SearchType.create(my.search_type)
edit = EditWdg(search_key =sobject.get_search_key(), mode='view', view=ingest_data_view )
dialog_data_div.add(edit)
hidden = HiddenWdg(name="parent_key")
dialog_data_div.add(hidden)
hidden.add_class("spt_parent_key")
parent_key = my.kwargs.get("parent_key") or ""
if parent_key:
hidden.set_value(parent_key)
extra_data = my.kwargs.get("extra_data")
if not isinstance(extra_data, basestring):
extra_data = jsondumps(extra_data)
if extra_data and extra_data != "null":
# it needs a TextArea instead of Hidden because of JSON data
text = TextAreaWdg(name="extra_data")
text.add_style('display: none')
text.set_value(extra_data)
dialog_data_div.add(text)
"""
dialog_data_div.add("Keywords:<br/>")
dialog.add(dialog_data_div)
text = TextAreaWdg(name="keywords")
dialog_data_div.add(text)
text.add_class("spt_keywords")
text.add_style("padding: 1px")
dialog_data_div.add("<br/>"*2)