def get_save_wdg(my): # add the popup popup = PopupWdg(id="save_search_wdg") popup.add("Save Search", "title") div = DivWdg() div.add("Save current search as: ") text = TextWdg("save_search_text") text.set_id("save_search_text") div.add(text) save_button = ButtonWdg("Save Search") behavior = {"type": "click", "mouse_btn": "LMB", "cbjs_action": "spt.dg_table.save_search_cbk(evt, bvr);"} save_button.add_behavior(behavior) cancel_button = ButtonWdg("Cancel") cancel_button.add_event("onclick", "$('save_search_wdg').style.display = 'none'") div.add(HtmlElement.hr()) button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(save_button) button_div.add(" ") button_div.add(cancel_button) div.add(button_div) popup.add(div, "content") return popup
def get_save_wdg(self): div = DivWdg() div.add("Save current search as: ") text = TextWdg("save_search_text") text.set_id("save_search_text") div.add(text) save_button = ButtonWdg("Save Search") behavior = { 'cbjs_action': 'spt.table.save_search();' } save_button.add_behavior( behavior ) cancel_button = ButtonWdg("Cancel") cancel_button.add_event("onclick", "$('save_search_wdg').style.display = 'none'") div.add(HtmlElement.hr()) button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(save_button) button_div.add(" ") button_div.add(cancel_button) div.add(button_div) return div
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
def get_info_wdg(my): div = DivWdg() div.add("<b>Create a share</b>") div.add("<br/>" * 2) table = Table() div.add(table) table.add_style("margin-left: 15px") table.add_row() td = table.add_cell("Share Code: ") td.add_style("vertical-align: top") text = TextWdg("code") table.add_cell(text) text.add_behavior({ 'type': 'change', 'cbjs_action': ''' var value = bvr.src_el.value; if (!value) { return; } var server = TacticServerStub.get(); var expr = "@SOBJECT(sthpw/sync_server['code','"+value+"'])"; var test = server.eval(expr); if (test.length > 0) { spt.alert("Share ["+value+"] already exists."); bvr.src_el.value = ""; bvr.src_el.focus(); } ''' }) tr, td = table.add_row_cell() msg_div = DivWdg() td.add(msg_div) msg_div.add( "The share code is used as a prefix for all transactions and allows TACTIC to separate transactions from each location. By convention, these codes should be a short initial (ie: ABC)." ) msg_div.add_style("margin: 10px 20px 20px 20px") table.add_row() table.add_row_cell(" ") table.add_row() td = table.add_cell("Description: ") td.add_style("vertical-align: top") text = TextAreaWdg("description") td = table.add_cell(text) #table.add_row() #table.add_cell("Auth Ticket: ") #text = TextWdg("ticket") #table.add_cell(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_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_xmlrpc_mode_wdg(my): div = DivWdg() div.add_style("margin-top: 15px") div.add_style("margin-bottom: 15px") div.add_class("spt_xmlrpc_mode") div.add_style("display: none") div.add("Server: ") text = TextWdg("host") text.add_style("width: 300px") div.add(text) div.add("<br/>" * 2) div.add( "Each server requires an authentication that will be used to enable sending transactions to the remote server. The remote server must have this ticket defined in order to recieve the transaction." ) div.add("<br/>" * 2) div.add("Authentication Ticket: ") text = TextWdg("auth_ticket") text.add_style("width: 300px") div.add(text) return div
def get_display(my): from tactic.ui.widget import SObjectCheckinHistoryWdg my.code = str(my.kwargs.get('source_code')) my.sk = my.server.build_search_key('twog/source',my.code) my.movement_code = str(my.kwargs.get('movement_code')) ms = MovementScripts(movement_code=my.movement_code) clients_expr = "@SOBJECT(twog/client['@ORDER_BY','name desc'])" clients = my.server.eval(clients_expr) client_sel = '<select class="REPLACE_ME"><option value="">--Select--</option>' for client in clients: client_sel = '%s<option value="%s">%s</option>' % (client_sel, client.get('code'), client.get('name')) client_sel = '%s</select>' % client_sel existing_expr = "@SOBJECT(twog/outside_barcode['source_code','%s'])" % my.code existing = my.server.eval(existing_expr) count = 0 table = Table() table.add_attr('class','movement_outside_barcodes') for obc in existing: table.add_row() barcode_text_wdg = TextWdg('outside_barcode_insert_%s' % count) barcode_text_wdg.set_value(obc.get('barcode')) barcode_text_wdg.add_attr('curr_code',obc.get('code')) table.add_cell(barcode_text_wdg) new_sel = client_sel new_sel2 = new_sel.replace('REPLACE_ME','outside_client_%s' % count) found = new_sel2.find('"%s"' % obc.get('client_code')) if found > 0: part1 = new_sel2[:found] part2 = new_sel2[found:] found2 = part2.find('>') if found2 > 0: good2 = part2[found2:] new_sel2 = '%s"%s" selected="selected"%s' % (part1, obc.get('client_code'),good2) table.add_cell(new_sel2) count = count + 1 additional_count = [1, 2, 3, 4, 5] for n in additional_count: table.add_row() barcode_text_wdg = TextWdg('outside_barcode_insert_%s' % count) barcode_text_wdg.add_attr('curr_code','') table.add_cell(barcode_text_wdg) new_sel = client_sel new_sel = new_sel.replace('REPLACE_ME','outside_client_%s' % count) table.add_cell(new_sel) count = count + 1 table.add_row() save_tbl = Table() save_tbl.add_row() s1 = save_tbl.add_cell(' ') s1.add_attr('width','100%s' % '%') save_cell = table.add_cell('<input type="button" value="Save All"/>') save_cell.add_attr('align','center') save_cell.add_behavior(ms.get_save_outside_barcodes_behavior(my.code)) s2 = save_tbl.add_cell(' ') s2.add_attr('width','100%s' % '%') ss = table.add_cell(save_tbl) ss.add_attr('colspan','2') ss.add_attr('align','center') return table
def get_first_page(self): div = DivWdg() div.add("First Page") div.add("<br/>") div.add("<br/>") div.add("Project Name: ") div.add(TextWdg("project_name")) div.add("<br/>") div.add("<br/>") div.add("Project Title: ") div.add(TextWdg("project_title")) div.add("<br/>") return div
def get_second_page(self): div = DivWdg() div.add("Second Page") div.add("<br/>") div.add("<br/>") div.add("Column1: ") div.add(TextWdg("column1")) div.add("<br/>") div.add("<br/>") div.add("Column2: ") div.add(TextWdg("column2")) div.add("<br/>") return div
def get_config_wdg(my): widget = Widget() search = Search("sthpw/widget_config") div = DivWdg(css="filter_box") span = SpanWdg(css="med") span.add("Search Type: ") select = FilterSelectWdg("config_search_type") select.add_empty_option("-- Select --") search_type_search = Search("sthpw/search_object") search_type_search.add_order_by("search_type") span.add(select) project = Project.get() project_type = project.get_base_type() filter = search.get_regex_filter("search_type", "login|task|note|timecard", "EQ") search_type_search.add_where( """ namespace = '%s' or namespace = '%s' or %s """ % (project_type, project.get_code(), filter) ) select.set_search_for_options(search_type_search, value_column="search_type") div.add(span) search_type_value = select.get_value() span = SpanWdg() view_text = TextWdg("view") view_text.set_persist_on_submit() span.add("View: ") span.add(view_text) div.add(span) widget.add(div) view = view_text.get_value() if view: search.add_filter("view", view) if search_type_value: search.add_filter("search_type", search_type_value) table = TableWdg("sthpw/widget_config") table.set_search(search) widget.add(table) return widget
def get_display(self): top = DivWdg() self.set_as_panel(top) top.add("Search Type: ") search_type_text = TextWdg("search_type") top.add(search_type_text) test_button = ProdIconButtonWdg("Test") top.add(test_button) test_button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_panel"); var values = spt.api.get_input_values(top, null, false); var search_type = values['search_type'][0]; cmd = 'tactic.command.NamingMigratorCmd'; server = TacticServerStub.get(); server.execute_cmd(cmd, values) ''' }) return top
def get_display(self): top = DivWdg() top.add_color("color", "color") top.add_color("background", "background") top.add_style("padding: 15px") top.add_border() wizard = WizardWdg(title="Project Creation Wizard") top.add(wizard) page = DivWdg() first = self.get_first_page() first.add_style("width: 500px") first.add_style("height: 300px") page.add(first) wizard.add(page, "Project Title") page = DivWdg() first = self.get_second_page() first.add_style("width: 500px") first.add_style("height: 300px") page.add(first) wizard.add(page, "Foo") page = DivWdg() page.add("Hello world!!!") text = TextWdg("wow") page.add(text) wizard.add(page, "Hello!!") return top
def handle_python_script_test(self, top): top.add(DivWdg('Python Script Test', css='spt_info_title')) table = Table(css='script') table.add_color("color", "color") table.add_style("margin: 10px") table.add_style("width: 100%") top.add(table) table.add_row() td = table.add_cell("Script Path: ") td.add_style("width: 150px") text = TextWdg('script_path') td = table.add_cell(text) button = ActionButtonWdg(title='Run') table.add_cell(button) button.add_style("float: right") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var s = TacticServerStub.get(); try { var path = bvr.src_el.getParent('.script').getElement('.spt_input').value; if (! path) throw('Please enter a valid script path'); s.execute_cmd('tactic.command.PythonCmd', {script_path: path}); } catch(e) { spt.alert(spt.exception.handler(e)); } ''' })
def get_local_wdg(my): div = DivWdg() server = Config.get_value("install", "server") if not server: msg_div = DivWdg() msg_div.add(IconWdg("No local prefix set", IconWdg.WARNING)) msg_div.add( "WARNING: No local server prefix set. This will allow transactions to be merged properly with remote servers. Without a local prefix, it is highly likely that transactions will conflict" ) msg_div.add("<br/>" * 2) text = TextWdg("local_prefix") change_div = DivWdg() msg_div.add(change_div) change_div.add("Set Local Prefix: ") change_div.add(text) else: msg_div = DivWdg() msg_div.add(IconWdg("No local prefix set", IconWdg.CREATE)) msg_div.add("Local server set to [%s]" % server) msg_div.add_style("padding: 30px") msg_div.add_style("width: 80%") msg_div.add_color("background", "background3") msg_div.add_border() msg_div.add_style("text-align: center") div.add(msg_div) return div
def get_config_wdg(self): widget = Widget() search = Search("sthpw/widget_config") div = DivWdg(css="filter_box") span = SpanWdg(css="med") span.add("Search Type: ") select = FilterSelectWdg("config_search_type") select.add_empty_option("-- Select --") search_type_search = Search("sthpw/search_object") search_type_search.add_order_by("search_type") span.add(select) project = Project.get() project_type = project.get_base_type() filter = search.get_regex_filter("search_type", "login|task|note|timecard", "EQ") search_type_search.add_where(''' namespace = '%s' or namespace = '%s' or %s ''' % (project_type, project.get_code(), filter)) select.set_search_for_options(search_type_search, value_column='search_type') div.add(span) search_type_value = select.get_value() span = SpanWdg() view_text = TextWdg("view") view_text.set_persist_on_submit() span.add("View: ") span.add(view_text) div.add(span) widget.add(div) view = view_text.get_value() if view: search.add_filter("view", view) if search_type_value: search.add_filter("search_type", search_type_value) table = TableWdg("sthpw/widget_config") table.set_search(search) widget.add(table) return widget
def get_display(my): widget = DivWdg() table = Table() table.add_attr('class','scraper') table.add_row() tb = TextWdg('title_box') tb.add_attr('id','title_box') multiple_titles = None print "MY.TITLE_OF_SHOW = %s" % my.title_of_show if my.title_of_show not in [None,'']: tb.set_value(my.title_of_show) #poster_url_text = my.get_poster_url(my.title_of_show) #poster_url = poster_url_text.split('=')[1] multiple_titles = my.get_multiple_title_info(my.title_of_show) print "MULTIPLE_TITLES = %s" % multiple_titles tb.add_behavior(my.get_search()) table.add_cell(tb) if multiple_titles not in [None,''] and len(multiple_titles) > 0: for m in multiple_titles: table.add_row() table.add_cell('<img src="%s"/>' % m['TopLevel']['poster']) mkeys = m.keys() for k in mkeys: table.add_row() table.add_cell('<b><u>%s</u></b>' % k) dudes = m[k] dkeys = dudes.keys() for d in dkeys: table.add_row() table.add_cell('%s: %s' % (d, dudes[d])) widget.add(table) return widget
def get_display(my): name = my.get_name() # get the sobject required by this input sobject = my.get_current_sobject() widget = DivWdg() # add an advanced widget text = TextWdg("%s" % name) text.set_attr("size", 90) value = sobject.get_value(name) text.set_value(value) div = DivWdg() # div.add("Advanced: ") div.add(text) widget.add(div) return widget
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_add_chat_wdg(my): div = DivWdg() div.add_border() div.add_style("padding: 20px") div.add_class("spt_add_chat_top") div.add("User: "******"user") div.add(text) text.add_class("spt_add_chat_user") add_button = ActionButtonWdg(title="Start Chat") div.add(add_button) add_button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_add_chat_top"); var el = top.getElement(".spt_add_chat_user"); var user = el.value; if (!user) { alert("Specify a valid user to chat with"); return; } // new chat var server = TacticServerStub.get(); var category = "chat"; var class_name = 'tactic.ui.app.ChatCmd'; var kwargs = { users: [user] } server.execute_cmd(class_name, kwargs); spt.panel.refresh(bvr.src_el); ''' }) return div
def get_display(my): raise Exception("tactic.widget.ColorInputWdg is deprecated") color_div = DivWdg() color_div.add_style("z-index: 1000") # color_div.add_style("float: left") import random number = random.randint(1, 1000) rainbow_id = "rainbow_%s" % number color_div.add( """ <img id="%s" src="/context/spt_js/mooRainbow/rainbow.png" alt="[r]" width="16" height="16" /> """ % rainbow_id ) # <input id="myInput" name="myInput" type="text" size="13" /> text = TextWdg(my.get_name()) text.set_id("myInput") behavior = {"type": "keyboard", "kbd_handler_name": "DgTableMultiLineTextEdit"} text.add_behavior(behavior) color_div.add(text) color_div.add_behavior( { "type": "load", "cbjs_action": """ var r = new MooRainbow('%s', { startColor: [58, 142, 246], imgPath: '/context/spt_js/mooRainbow/images/', onComplete: function(color) { $(myInput).value=color.hex; } }); """ % rainbow_id, } ) return color_div
def get_input_by_arg_key(my, key): if key == 'icon': input = SelectWdg("option_icon_select") input.set_option("values", IconWdg.get_icons_keys()) input.add_empty_option("-- Select --") elif key == 'script': input = SelectWdg("option_script_select") input.set_option("query", "config/custom_script|code|code") input.add_empty_option("-- Select --") else: input = TextWdg("value") return input
def get_add_chat_wdg(my): div = DivWdg() div.add_border() div.add_style("padding: 20px") div.add_class("spt_add_chat_top") div.add("User: "******"user") div.add(text) text.add_class("spt_add_chat_user") add_button = ActionButtonWdg(title="Start Chat") div.add(add_button) add_button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_add_chat_top"); var el = top.getElement(".spt_add_chat_user"); var user = el.value; if (!user) { alert("Specify a valid user to chat with"); return; } // new chat var server = TacticServerStub.get(); var category = "chat"; var class_name = 'tactic.ui.app.ChatCmd'; var kwargs = { users: [user] } server.execute_cmd(class_name, kwargs); spt.panel.refresh(bvr.src_el); ''' } ) return div
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_first_page(my): div = DivWdg() div.add("<br/>") div.add("Project Title: ") text = TextWdg("project_title") div.add(text) div.add("<br/>"*2) div.add("The project title can be more descriptive and contain spaces") div.add("<br/><br/><hr/><br/>") div.add("Project Code: ") text = TextWdg("project_code") div.add(text) div.add("<br/>"*2) div.add('''* Note: the project code must contain only alphanumeric characters [A-Z]/[0-9] and only an '_' as a separator''') return div
def get_display(my): from pyasm.search import Search #from tactic_client_lib import TacticServerStub barcode = '' sources = [] bad_sources = [] if 'barcode' in my.kwargs.keys(): barcode = my.kwargs.get('barcode') tracker_s = Search("twog/location_tracker") tracker_s.add_filter('location_barcode',barcode) trackers = tracker_s.get_sobjects() #print "BARCODE = %s" % barcode #print "LEN TRACKERS = %s" % len(trackers) for t in trackers: tdate = t.get('timestamp') source_barcode = t.get('source_barcode') other_tracks = Search("twog/location_tracker") other_tracks.add_filter('source_barcode',source_barcode) other_tracks.add_filter('timestamp',tdate, op=">") others = other_tracks.get_sobjects() if len(others) == 0: source_s = Search("twog/source") source_s.add_filter('barcode',source_barcode) source = source_s.get_sobject() if source: if source.get_value('in_house') in [True,'true','True',1,'1']: sources.append(source) else: bad_sources.append({'barcode': source_barcode, 'title': 'UNKNOWN SOURCE'}) table = Table() table.add_attr('class','location_inventory_wdg') table.add_row() bc = TextWdg('nextbc') bc.add_attr('id', 'location_inventory_txtbox') bc.add_behavior(my.get_entry_bvr()) bc.set_value(barcode) table.add_cell(bc) #print "LEN SOURCES = %s" % len(sources) if len(sources) > 0: table.add_row() table.add_cell("<b>TOTAL: %s (UNKNOWN: %s)</b>" % (len(sources), len(bad_sources))) for source in sources: table.add_row() table.add_cell('Barcode: %s, Code: %s, Name: %s: %s' % (source.get_value('barcode'), source.get_code(), source.get_value('title'), source.get_value('episode'))) if len(bad_sources) > 0: table.add_row() table.add_cell("<b>UNKNOWN SOURCES</b>") for b in bad_sources: table.add_row() table.add_cell('Barcode: %s, Name: %s' % (b.get('barcode'), b.get('title'))) widget = DivWdg() widget.add(table) return widget
def get_display(my): table = Table() my.movement_code = my.kwargs.get('movement_code') table.add_attr('class', 'movement_add_source') table.add_attr('movement_id','') table.add_attr('movement_sk','') table.add_attr('movement_code','') top_row = table.add_row() top_row.add_style('background-color: #eaeaea;') if my.movement_code not in ['',None]: ms = MovementScripts(movement_code=my.movement_code) barcode_text_wdg = TextWdg('source_barcode_insert') barcode_text_wdg.add_attr('id','source_barcode_insert') barcode_text_wdg.add_behavior(ms.get_barcode_insert_behavior()) table.add_cell('Barcode: ') table.add_cell(barcode_text_wdg) widget = DivWdg() widget.add(table) if my.movement_code not in ['',None]: widget.add_behavior(my.get_on_load_js()) return widget
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
def get_save_wdg(my): # add the popup popup = PopupWdg(id='save_search_wdg') popup.add("Save Search", "title") div = DivWdg() div.add("Save current search as: ") text = TextWdg("save_search_text") text.set_id("save_search_text") div.add(text) save_button = ButtonWdg("Save Search") behavior = { 'type': 'click', 'mouse_btn': 'LMB', 'cbjs_action': 'spt.dg_table.save_search_cbk(evt, bvr);' } save_button.add_behavior(behavior) cancel_button = ButtonWdg("Cancel") cancel_button.add_event("onclick", "$('save_search_wdg').style.display = 'none'") div.add(HtmlElement.hr()) button_div = DivWdg() button_div.add_style("text-align: center") button_div.add(save_button) button_div.add(" ") button_div.add(cancel_button) div.add(button_div) popup.add(div, "content") return popup
def get_display(self): top = DivWdg() top.add_style("width: 200px") top.add_style("height: 200px") top.add_color("background", "background") top.add_color("padding", "10px") top.add_border() template = self.get_option("template") template = "prod/sequence" select = SelectWdg("foo") top.add(select) select.set_option("values", "XG|FF|WOW") text = TextWdg("foo") top.add(text) top.add("!!!!!") return top
def get_display(self): name = self.get_name() # get the sobject required by this input sobject = self.get_current_sobject() widget = DivWdg() # add an advanced widget text = TextWdg("%s" % name) text.set_attr("size", 90) value = sobject.get_value(name) text.set_value(value) div = DivWdg() #div.add("Advanced: ") div.add(text) widget.add(div) return widget
def get_display(self): raise Exception("tactic.widget.ColorInputWdg is deprecated") color_div = DivWdg() color_div.add_style("z-index: 1000") #color_div.add_style("float: left") import random number = random.randint(1, 1000) rainbow_id = "rainbow_%s" % number color_div.add(''' <img id="%s" src="/context/spt_js/mooRainbow/rainbow.png" alt="[r]" width="16" height="16" /> ''' % rainbow_id) #<input id="selfInput" name="selfInput" type="text" size="13" /> text = TextWdg(self.get_name()) text.set_id("selfInput") behavior = { 'type': 'keyboard', 'kbd_handler_name': 'DgTableMultiLineTextEdit' } text.add_behavior(behavior) color_div.add(text) color_div.add_behavior( { "type": "load", "cbjs_action": ''' var r = new MooRainbow('%s', { startColor: [58, 142, 246], imgPath: '/context/spt_js/mooRainbow/images/', onComplete: function(color) { $(myInput).value=color.hex; } }); ''' % rainbow_id } ) return color_div
def get_xmlrpc_mode_wdg(self): div = DivWdg() div.add_style("margin-top: 15px") div.add_style("margin-bottom: 15px") div.add_class("spt_xmlrpc_mode") div.add_style("display: none") div.add("Server: ") text = TextWdg("host") text.add_style("width: 300px") div.add(text) div.add("<br/>"*2) div.add("Each server requires an authentication that will be used to enable sending transactions to the remote server. The remote server must have this ticket defined in order to recieve the transaction.") div.add("<br/>"*2) div.add("Authentication Ticket: ") text = TextWdg("auth_ticket") text.add_style("width: 300px") div.add(text) return div
def get_display(my): my.title_code = str(my.kwargs.get('title_code')) my.title_sk = str(my.kwargs.get('title_sk')) my.order_sk = str(my.kwargs.get('order_sk')) origin_search = Search("twog/title_origin") origin_search.add_filter('title_code',my.title_code) origins = origin_search.get_sobjects() groups_str = '' user_group_names = Environment.get_group_names() for mg in user_group_names: if groups_str == '': groups_str = mg else: groups_str = '%s,%s' % (groups_str, mg) user_is_scheduler = False if 'scheduling' in groups_str: user_is_scheduler = True table = Table() table.add_attr('width','100%s' % '%') table.add_attr('bgcolor','#cbe49e') table.add_style('border-bottom-right-radius', '10px') table.add_style('border-bottom-left-radius', '10px') table.add_style('border-top-right-radius', '10px') table.add_style('border-top-left-radius', '10px') table.add_row() source_limit = 7 count = 0 if len(origins) > 0: table.add_row() mr_title = table.add_cell('<b><u><i>Sources</i></u></b>') mr_title.add_style('font-size: 90%s;' % '%') seen = [] for origin in origins: source_code = origin.get_value('source_code') if source_code not in seen: seen.append(source_code) source_search = Search("twog/source") source_search.add_filter('code',source_code) source = source_search.get_sobject() if count % source_limit == 0: table.add_row() celly = None if not source.get_value('high_security'): celly = table.add_cell('<font color="#3e3e3e"><b><u>(%s): %s</u></b></font>' % (source.get_value('barcode'),source.get_value('title'))) else: celly = table.add_cell('<font color="#ff0000"><b><u>!!!(%s): %s!!!</u></b></font>' % (source.get_value('barcode'),source.get_value('title'))) celly.add_attr('nowrap','nowrap') celly.add_style('cursor: pointer;') celly.add_style('font-size: 80%s;' % '%') celly.add_behavior(get_launch_source_behavior(my.title_code, my.title_sk, source.get_value('code'), source.get_search_key(), my.order_sk)) table.add_cell(' ') count += 1 else: my.server = TacticServerStub.get() my.server.retire_sobject(origin.get_search_key()) table2 = Table() if user_is_scheduler: table2.add_row() barcode_text_wdg = TextWdg('barcode_insert') barcode_text_wdg.add_behavior(my.get_barcode_insert_behavior(my.title_code, my.title_sk, my.order_sk)) bct = table2.add_cell(barcode_text_wdg) bct.add_attr('align','right') bct.add_attr('width','100%s' % '%') two_gether = Table() two_gether.add_row() srcs = two_gether.add_cell(table) srcs.add_attr('width','100%s' % '%') srcs.add_attr('valign','top') if user_is_scheduler: bcentry = two_gether.add_cell(table2) bcentry.add_attr('valign','top') return two_gether
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'/>") #title.add(path) text_wdg = DivWdg() text_wdg.add_class("spt_document_content") left_td.add(text_wdg) #if path.startswith("https://docs.google.com/spreadsheet"): # #path = "http://www.southpawtech.com.com" # text_wdg.add(''' # <iframe class="spt_document_iframe" style="width: 100%%; height: auto; min-height: 600px; font-size: 1.0em" src="%s"></iframe> # ''' % path) # text_wdg.add_style("overflow-x: hidden") if True: if not self.last_path and self.doc: tmp_dir = Environment.get_tmp_dir() tmp_path = '%s/last_path.txt' % tmp_dir f = open(tmp_path, 'w') text = self.get_text(path, highlight=False) f.write(text) f.close() cmd = FileCheckin(self.doc, tmp_path) Command.execute_cmd(cmd) else: save = False if save: # open up the last path f = open(self.last_path, 'r') last_text = f.read() text = self.get_text(path, None, highlight=False) if last_text != text: tmp_dir = Environment.get_tmp_dir() tmp_path = '%s/last_path.txt' % tmp_dir f = open(tmp_path, 'w') f.write(text) f.write(text) f.close() cmd = FileCheckin(self.doc, tmp_path) Command.execute_cmd(cmd) text = self.get_text(path, self.last_path) lines = text.split("\n") if self.doc_mode == "text": num_lines = len(lines) """ line_div = HtmlElement.pre() text_wdg.add(line_div) line_div.add_style("width: 20px") line_div.add_style("float: left") line_div.add_style("text-align: right") line_div.add_style("opacity: 0.3") line_div.add_style("padding-right: 10px") for i in range(0, num_lines*2): line_div.add(i+1) line_div.add("<br/>") """ if self.doc_mode == "text": pre = HtmlElement.pre() pre.add_style("white-space: pre-wrap") else: pre = DivWdg() pre = DivWdg() text_wdg.add(pre) text_wdg.add_style("padding: 10px 5px") text_wdg.add_style("max-height: 600px") text_wdg.add_style("overflow-y: auto") text_wdg.add_style("width: 600px") text_wdg.add_class("spt_resizable") pre.add_style("font-family: courier") if self.doc_mode == "formatted": pre.add(text) else: line_table = Table() pre.add(line_table) line_table.add_style("width: 100%") count = 1 for line in lines: #line = line.replace(" ", " ") tr = line_table.add_row() if count % 2 == 0: tr.add_color("background", "background", -2) td = line_table.add_cell() # FIXME: hacky if line.startswith('''<span style='background: #CFC'>'''): is_new = True else: td.add_style("vertical-align: top") text = TextWdg() text.add_style("border", "none") text.add_style("text-align", "right") text.add_style("width", "25px") text.add_style("margin", "0 10 0 0") text.add_style("opacity", "0.5") text.set_value(count) td.add(text) count += 1 is_new = False td = line_table.add_cell() if not is_new: SmartMenu.assign_as_local_activator( td,'TEXT_CTX' ) tr.add_class("spt_line"); else: SmartMenu.assign_as_local_activator( td,'TEXT_NEW_CTX' ) tr.add_class("spt_new_line"); td.add_class("spt_line_content"); td.add(line) #from tactic.ui.app import AceEditorWdg #editor = AceEditorWdg(code=text, show_options=False, readonly=True, height="600px") #text_wdg.add(editor) # add a click on spt_item text_wdg.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': 'spt_document_item', 'search_type': self.search_type, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_document_top"); var data_el = top.getElement(".spt_document_data"); var search_key = bvr.src_el.getAttribute("spt_search_key"); var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': bvr.search_type, 'search_key': search_key, } spt.panel.load(data_el, class_name, kwargs); ''' } ) # add a double click on spt_item bgcolor = text_wdg.get_color("background", -10) text_wdg.add_relay_behavior( { 'type': 'mouseover', 'bvr_match_class': 'spt_document_item', 'search_type': self.search_type, 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("opacity", "1.0"); //bvr.src_el.setStyle("font-weight", "normal"); bvr.src_el.setStyle("background", bvr.bgcolor); ''' } ) # add a double click on spt_item text_wdg.add_relay_behavior( { 'type': 'mouseout', 'bvr_match_class': 'spt_document_item', 'search_type': self.search_type, 'cbjs_action': ''' bvr.src_el.setStyle("opacity", "1.0"); //bvr.src_el.setStyle("font-weight", "bold"); bvr.src_el.setStyle("background", ""); ''' } ) # add a context menu ctx_menu = self.get_text_context_menu() ctx_new_menu = self.get_text_new_context_menu() menus_in = { 'TEXT_CTX': ctx_menu, 'TEXT_NEW_CTX': ctx_new_menu, } SmartMenu.attach_smart_context_menu( text_wdg, menus_in, False ) panel = ViewPanelWdg( search_type=self.search_type, layout="blah" ) right_td = table.add_cell() right_td.add_style("vertical-align: top") panel_div = DivWdg() panel_div.add_class("spt_document_data") right_td.add(panel_div) panel_div.add(panel) text_wdg.add_behavior( { 'type': 'load', 'cbjs_action': r''' spt.document = {}; spt.document.selected_text = null; spt.document.get_selected_text = function(frame) { var t = ''; if (frame) { var rng = frame.contentWindow.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (window.getSelection) // FF4 with one tab open? { var rng = window.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (document.getSelection) // FF4 with multiple tabs open? { var rng = document.getSelection().getRangeAt(0); spt.document.expandtoword(rng); t = rng.toString(); } else if (document.selection) // IE8 { var rng = document.selection.createRange(); // expand range to enclose any word partially enclosed in it rng.expand("word"); t = rng.text; } // convert newline chars to spaces, collapse whitespace, and trim non-word chars return t.replace(/^\W+|\W+$/g, ''); //return t.replace(/\r?\n/g, " ").replace(/\s+/g, " ").replace(/^\W+|\W+$/g, ''); } // expand FF range to enclose any word partially enclosed in it spt.document.expandtoword = function(range) { if (range.collapsed) { return; } while (range.startOffset > 0 && range.toString()[0].match(/\w/)) { range.setStart(range.startContainer, range.startOffset - 1); } while (range.endOffset < range.endContainer.length && range.toString()[range.toString().length - 1].match(/\w/)) { range.setEnd(range.endContainer, range.endOffset + 1); } } ''' } ) top.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': 'spt_document_content', 'cbjs_action': r''' //spt.ace_editor.set_editor_top(bvr.src_el); //var text = spt.ace_editor.get_selection(); var text = spt.document.get_selected_text(); text = text.replace(/\n\n/mg, "\n"); text = text.replace(/\n\n/mg, "\n"); spt.document.selected_text = text + ""; ''' } ) return top
def get_display(my): my.search_type = my.kwargs.get('search_type') my.element_name = my.kwargs.get('element_name') assert my.search_type assert my.element_name class_name = 'tactic.ui.app.aggregate_wdg.AggregateCmd' interval = 120 priority = None if my.kwargs.get('is_refresh'): user = Environment.get_user_name() # these interval jobs need to have a specific code code = "aggregate|%s|%s" % (my.search_type, my.element_name) # check to see if the job exists #job = Search.get_by_code("sthpw/queue", code) job = None if not job: job = SearchType.create("sthpw/queue") #job.set_value("code", code) job.set_value("project_code", Project.get_project_code() ) job.set_value("class_name", class_name) job.set_value("command", class_name) job.set_value("serialized", str(my.kwargs) ) job.set_value("interval", 120) job.set_value("state", 'pending') job.set_value("queue", 'interval') job.set_value("priority", 9999) job.set_value("login", user) job.commit() my.view = my.kwargs.get('view') if not my.view: my.view = 'definition' top = DivWdg() my.set_as_panel(top) action_div = DivWdg() top.add(action_div) refresh = IconButtonWdg("Refresh", IconWdg.REFRESH) refresh.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_panel"); spt.panel.refresh(top); ''' } ) action_div.add(refresh) register_div = DivWdg() register_div.add_class("spt_queue_register") top.add(register_div) register_div.add_style("border: solid 1px black") register_div.add_style("padding: 20px") register_div.add("Register new interval aggregate") table = Table() table.add_style("margin: 15px") register_div.add(table) table.add_row() table.add_cell("command: ") table.add_cell(class_name) #table.add_row() #table.add_cell("priority: ") #table.add_cell(priority) table.add_row() table.add_cell("interval: ") td = table.add_cell("every ") td.set_attr("title", "Recalculation interval") text = TextWdg("interval") text.add_style("width: 30px") text.set_value(interval) td.add(text) unit_select = SelectWdg("unit") unit_select.set_value(interval) unit_select.set_option("values", "seconds|minutes|hours|days") td.add(" ") td.add(unit_select) table.add_row() table.add_cell("queue: ") table.add_cell("interval") from pyasm.widget import ProdIconButtonWdg button = ProdIconButtonWdg("Register") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_queue_register") var values = spt.api.get_input_values(top); var top = bvr.src_el.getParent(".spt_panel"); spt.panel.refresh(top); ''' } ) register_div.add(button) from pyasm.widget import ProdIconButtonWdg button = ProdIconButtonWdg("Cancel") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' alert('cancel'); ''' } ) register_div.add(button) ''' cmd = AggregateCmd(**my.kwargs) print "registering scheduled task" scheduler = Scheduler.get() scheduler.start_thread() task = AggregateRefreshTask(name="cow", command=cmd) scheduler.add_interval_task(task, 10, mode='forked') scheduler.cancel_task("cow", delay=35) ''' top.add("<br/>") top.add("<b>Current Job Queue</b>") top.add("<br/><br/>") from tactic.ui.panel import TableLayoutWdg table = TableLayoutWdg(search_type='sthpw/queue',view='test') top.add(table) return top
def get_bottom_wdg(my, search_keys=[]): # check if the user has enabled it info = my.check_bottom_wdg() if info.get('check') == False: return None if info.get('mode') != 'total': top = DivWdg() top.add( "Only [total] is supported. Please change it in Edit Column Definition" ) return top my.today = datetime.date.today() if my.is_refresh: top = Widget() else: top = DivWdg() days = [] for date in my.dates: days.append(date.strftime("%Y_%m_%d")) today = my.today.strftime("%Y_%m_%d") table = Table() top.add(table) row_list = [my.ST_ROW] if my.show_overtime: row_list.append(my.OT_ROW) for row_to_draw in row_list: table.add_row() table.add_color("color", "color") table.add_styles("width: %spx; float: left" % my.table_width) td = table.add_blank_cell() td.add_style("min-width: %spx" % (my.MONTH_WIDTH + my.LEFT_WIDTH + 8)) 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; margin-bottom: 6px') 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-right: 4px; margin-bottom: 6px') 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-right: 4px; margin-bottom: 6px') td.add(div) for idx, day in enumerate(days): day_wdg = DivWdg() day_wdg.add(day) td = table.add_cell() td.add_style("width: %spx" % my.day_width) # keep it as text input for consistent alignment text = TextWdg("%sday_%s" % (time_prefix, day)) if row_to_draw == my.OT_ROW: sobj_daily_dict = my.summary_ot[idx] else: sobj_daily_dict = my.summary_st[idx] if search_keys: sobj_daily_sub_dict = Common.subset_dict( sobj_daily_dict, search_keys) else: sobj_daily_sub_dict = sobj_daily_dict daily_total = 0 for value in sobj_daily_sub_dict.values(): if value: daily_total += value text.set_value(daily_total) td.add(text) text.add_class("spt_day%s" % (time_prefix)) text.add_style("width: %spx" % (my.day_width - 2)) #text.add_style("width: 100%") text.add_style("text-align: right") text.add_style("padding-left: 2px") text.add_style('font-weight: 500') text.set_attr("readonly", "readonly") # grey out the text color text.add_color('color', 'color', +40) if day == today: text.add_style("border: solid 1px black") elif idx in [0, 6]: if row_to_draw == my.OT_ROW: # FOOTER: Overtime, weekends text.add_color("background", "background2", modifier=[-15, 0, 5]) else: # FOOTER: Straight time, weekends text.add_color("background", "background2", modifier=[0, 15, 20]) text = TextWdg("total") daily_total = 0 if row_to_draw == my.OT_ROW: sobj_daily_dict = my.summary_ot[7] else: sobj_daily_dict = my.summary_st[7] if search_keys: sobj_daily_sub_dict = Common.subset_dict( sobj_daily_dict, search_keys) else: sobj_daily_sub_dict = sobj_daily_dict for value in sobj_daily_sub_dict.values(): if value: daily_total += value text.set_value(daily_total) td = table.add_cell(text) text.add_class("spt_total%s" % (time_prefix)) # does not look good in FF #td.add_style("border-width: 0 0 0 1") #td.add_style("border-style: solid") td.add_style("width: %spx" % my.day_width) text.add_styles( "font-weight: 500;width: %spx; text-align: right; padding-left: 2px" % (my.day_width)) text.set_attr("readonly", "readonly") text.add_color('color', 'color', +40) if row_to_draw == my.OT_ROW: # FOOTER: Overtime, total. text.add_color("background", "background2", modifier=[5, -15, 0]) else: # FOOTER: Straight time, total text.add_color("background", "background2", modifier=[20, 0, 15]) td = table.add_blank_cell() td.add_style('width', '100%') return top
def get_display(my): from tactic_client_lib import TacticServerStub widget = DivWdg() server = TacticServerStub.get() allowed_groups = ['admin','audio','billing and accounts receivable','compression','compression supervisor','edeliveries','edit','edit supervisor','executives','it','machine room','machine room supervisor','management','media vault','media vault supervisor','office employees','qc','qc supervisor','sales','sales supervisor','scheduling','scheduling supervisor','senior_staff','streamz','technical services'] sobject = None code = None user_name = None do_inserted_msg = False table = Table() table.add_attr('class','source_security_wdg') if 'source_code' in my.kwargs.keys(): code = str(my.kwargs.get('source_code')) if code in [None,'']: if 'code' in my.kwargs.keys(): code = my.kwargs.get('code') if 'user_name' in my.kwargs.keys(): user_name = my.kwargs.get('user_name') else: login = Environment.get_login() user_name = login.get_login() if 'from' in my.kwargs.keys(): if my.kwargs.get('from') == 'insert': do_inserted_msg = True table.add_attr('from','insert') if not do_inserted_msg: table.add_attr('from','i dunno') group = None login_in_groups = server.eval("@SOBJECT(sthpw/login_in_group['login','%s']['login_group','not in','user|client'])" % user_name) for lg in login_in_groups: if not group: group = lg.get('login_group') if 'supervisor' in lg.get('login_group'): group = lg.get('login_group') checks = server.eval("@SOBJECT(twog/source_req['source_code','%s'])" % code) visi = 'display: none;' if len(checks) > 0: visi = 'display: table-row;'; if do_inserted_msg: table.add_row() inserted_row = table.add_cell('<font color="#f0000">!!!Please Enter the High Security Requirements!!!</font>') colspan = 2 if group in allowed_groups: colspan = 3 inserted_row.add_attr('colspan',colspan) top_row = table.add_row() top_row.add_style(visi) if group in allowed_groups: table.add_cell(' ') table.add_cell(' ') table.add_cell('Satisfied?') for check in checks: check_row = table.add_row() check_row.add_attr('class','row_%s' % check.get('__search_key__')) if group in allowed_groups: killer = table.add_cell(my.x_butt) killer.add_style('cursor: pointer;') killer.add_behavior(my.get_killer_behavior(check.get('__search_key__'))) table.add_cell(check.get('requirement')) checkbox = CheckboxWdg('satisfied_%s' % check.get('__search_key__')) #checkbox.set_persistence() if check.get('satisfied'): checkbox.set_value(True) else: checkbox.set_value(False) checkbox.add_behavior(my.get_change_satisfied(check.get('__search_key__'))) table.add_cell(checkbox) table.add_row() if group in allowed_groups: table.add_cell(' ') req_text = TextWdg('new_source_req') req_text.add_style('width: 500px') req_text.add_behavior(my.get_insert_new_req_from_change(code, user_name)) table.add_cell(req_text) add_button = table.add_cell('<input type="button" class="add_req_button" value="+"/>') add_button.add_behavior(my.get_insert_new_req(code, user_name)) if do_inserted_msg: table.add_row() inserted_row = table.add_cell('<font color="#f0000">!!!Please Enter the High Security Requirements!!!</font>') colspan = 2 if group in allowed_groups: colspan = 3 inserted_row.add_attr('colspan',colspan) widget.add(table) return widget
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
def get_display(my): assert my.load_script widget = DivWdg() widget.add_style('float', 'right') load_button = TextOptionBtnWdg(label=' Load ', size='medium') load_button.get_top_el().add_style('float', 'left') load_button.get_top_el().set_id(my.LOAD_BUTTON_ID) load_button.add_behavior( {'type': "click_up", "cbjs_action": "setTimeout(function() {%s}, 200) "% my.load_script }) widget.add(load_button) arrow_button = load_button.get_option_widget() #widget.add(arrow_button) suffix = "ASSET_LOADER_FUNCTIONS" menus_in = [ my.smart_menu_data ] SmartMenu.add_smart_menu_set( arrow_button, menus_in) SmartMenu.assign_as_local_activator(arrow_button, None, True) #SmartMenu.attach_smart_context_menu( load_button, menus_in, False ) x_div = FloatDivWdg("x") x_div.add_color('color','color') x_div.add_style('margin-right: 6px') widget.add(x_div) multiplier = TextWdg() multiplier.set_id("load_multiplier") multiplier.set_option("size", "1.5") multiplier.add_style("font-size: 0.8em") multiplier.add_style("float: left") multiplier.add_class("load_multiplier") widget.add( multiplier ) return widget
def get_display(my): top = DivWdg() top.add_class("spt_top") dialog = DialogWdg() dialog_id = dialog.get_id() # create the button button = DivWdg() button.add_style("padding: 5px") button.add_style("width: 30px") button.add_style("text-align: center") button.add_style("float: left") button.add_gradient("background", "background") button.add_border() top.add(button) icon = IconWdg("Press Me", IconWdg.ZOOM) icon.add_style("float: left") button.add(icon) icon = IconWdg("Press Me", IconWdg.INFO_OPEN_SMALL) icon.add_style("margin-left: -9px") button.add(icon) button.add_behavior( { 'type': 'click_up', 'dialog_id': dialog_id, 'cbjs_action': ''' var pos = bvr.src_el.getPosition(); var el = $(bvr.dialog_id); el.setStyle("left", pos.x+1); el.setStyle("top", pos.y+32); el.setStyle("display", ""); ''' } ) # defined the dialog top.add(dialog) dialog.add_title("Search Limit") table = Table() table.add_color("color", "color2") dialog.add(table) table.add_row() td = table.add_cell() td.add("Search Limit: ") td = table.add_cell() select = SelectWdg("search_limit") select.set_option("values", "5|10|20|50|100|200|Custom") td.add(select) save_button = ProdIconButtonWdg("Save") td.add(save_button) cancel_script = dialog.get_cancel_script(); save_button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var dialog_top = bvr.src_el.getParent(".spt_dialog_top"); var values = spt.api.get_input_values(dialog_top); var top = spt.get_parent(bvr.src_el, ".spt_top"); var input = top.getElement(".spt_search_limit"); input.value = values.search_limit; %s ''' % cancel_script } ) text = TextWdg("search_limit") text.add_class("spt_search_limit") top.add(text) return top
def get_display(my): login = Environment.get_login() user_name = login.get_login() work_order_code = '' if 'work_order_code' in my.kwargs.keys(): work_order_code = str(my.kwargs.get('work_order_code')) else: sobject = my.get_current_sobject() work_order_code = sobject.get_code() work_order = my.server.eval("@SOBJECT(twog/work_order['code','%s'])" % work_order_code)[0] widget = DivWdg() widget.add_attr('class','ov_sources_%s' % work_order_code) table = Table() table.add_attr('width','100%s' % '%') table.add_attr('class','source_display_%s' % work_order_code) at_least1 = False table.add_row() tbl_top = Table() tbl_top.add_row() missing = tbl_top.add_cell('<u>Report Missing Source</u>') missing.add_attr('nowrap','nowrap') missing.add_style('cursor: pointer;') missing.add_behavior(my.report_missing(work_order_code, user_name, work_order.get('platform'))) middle = tbl_top.add_cell(' ') middle.set_style('width: 100%s;' % '%') right = tbl_top.add_cell('Add Source: ') right.add_attr('nowrap','nowrap') right.add_attr('align','right') add_tb = TextWdg('wo_barcode_insert_%s' % work_order_code) add_tb.add_behavior(my.get_wo_barcode_insert_behavior(work_order_code)) adder = tbl_top.add_cell(add_tb) adder.add_behavior(my.get_wo_barcode_insert_behavior(work_order_code)) table.add_row() table.add_cell(tbl_top) #INS wo_sources = my.server.eval("@SOBJECT(twog/work_order_sources['work_order_code','%s'])" % work_order_code) for wo_source in wo_sources: table.add_row() table.add_cell(my.make_source_unit(wo_source, work_order_code, 'IN', 'SRC')) at_least1 = True passin_deliverables = my.server.eval("@SOBJECT(twog/work_order_passin['work_order_code','%s'])" % work_order_code) for wo_source in passin_deliverables: if wo_source.get('deliverable_source_code') not in [None,'']: table.add_row() table.add_cell(my.make_source_unit(wo_source, work_order_code, 'IN', 'SRC-PASSIN')) at_least1 = True passin_interms = my.server.eval("@SOBJECT(twog/work_order_passin['work_order_code','%s'])" % work_order_code) for interm in passin_interms: if interm.get('intermediate_file_code') not in [None,'']: table.add_row() table.add_cell(my.make_intermediate_unit(interm, work_order_code, 'IN', 'INTM-PASSIN')) at_least1 = True #OUTS intermediates = my.server.eval("@SOBJECT(twog/work_order_intermediate['work_order_code','%s'])" % work_order_code) for interm in intermediates: table.add_row() table.add_cell(my.make_intermediate_unit(interm, work_order_code, 'OUT', 'INTM-OUT')) at_least1 = True deliverable_sources = my.server.eval("@SOBJECT(twog/work_order_deliverables['work_order_code','%s'])" % work_order_code) for dsource in deliverable_sources: table.add_row() table.add_cell(my.make_source_unit(dsource, work_order_code, 'OUT', 'DLV-OUT')) at_least1 = True #also need intermediates and other stuff shown in work_order_assets_wdg if at_least1: table.add_row() button_cell = table.add_cell('<input type="button" value="Issue Alert(s)"/>') button_cell.add_behavior(my.alert_popup(work_order_code, user_name, work_order.get('platform'))) cell3 = table.add_cell(' ') cell3.add_attr('width','80%s' % '%') widget.add(table) #--print "LEAVING OBLW" return widget
def get_display(my): top_wdg = DivWdg() top_wdg.add_style("color: black") top_wdg.add_style("width: 350px") top_wdg.add_style("margin-top: 10px") top_wdg.add_style("padding: 10px") top_wdg.add_border() title = DivWdg() title.add_style("color: black") title.add_style("margin-top: -22px") top_wdg.add(title) #if not my.name_string: # title.add('No database column') # return top_wdg title.add("Widget Definition") widget_types = { 'foreign_key': 'tactic.ui.table.ForeignKeyElementWdg', 'button': 'tactic.ui.table.ButtonElementWdg', 'expression': 'tactic.ui.table.ExpressionElementWdg' } web = WebContainer.get_web() config_string = web.get_form_value("config_xml") if not config_string: config_string = '<config/>' xml = Xml() xml.read_string(config_string) #print "config_string: ", config_string # get values from the config file element_name = xml.get_value('element/@name') config = WidgetConfig.get( view='element', xml='<config><element>%s</element></config>' % config_string) display_options = config.get_display_options(element_name) title = xml.get_value('element/@title') display_handler = xml.get_value('element/display/@class') if not display_handler: display_handler = 'tactic.ui.panel.TypeTableElementWdg' widget_name = xml.get_value('element/display/@widget') if not widget_name: widget_name = 'custom' custom_table = Table() custom_table.add_style("color: black") top_wdg.add(custom_table) name_text = DivWdg() name_text.add_style("color: black") name_text.add(element_name) custom_table.add_row() custom_table.add_cell("Name: ") custom_table.add_cell(name_text) # add title custom_table.add_row() title_wdg = TextWdg("custom_title") title_wdg.set_value(title) title_wdg.add_attr("size", "50") custom_table.add_cell("Title: ") custom_table.add_cell(title_wdg) # add description #custom_table.add_row() #description_wdg = TextAreaWdg("custom_description") #td = custom_table.add_cell( "Description: " ) #td.add_style("vertical-align: top") #custom_table.add_cell( description_wdg ) type_select = SelectWdg("custom_type") #type_select.add_empty_option("-- Select --") type_select.set_option( "values", "string|integer|float|boolean|currency|date|foreign_key|link|list|button|custom" ) type_select.set_option( "labels", "String(db)|Integer(db)|Float(db)|Boolean(db)|Currency(db)|Date(db)|Foreign Key|Link|List|Button|Custom" ) type_select.set_value(widget_name) #type_select.set_option("values", "string|integer|float|boolean|currency|date|link|list|foreign_key|button|empty") #type_select.set_option("labels", "String|Integer|Float|Boolean|Currency|Date|Link|List|Foreign Key|Button|Empty") custom_table.add_row() td = custom_table.add_cell("Widget Type: ") td.add_style("vertical-align: top") td = custom_table.add_cell(type_select) type_select.add_event( "onchange", "spt.CustomProject.property_type_select_cbk(this)") td.add(HtmlElement.br()) display_handler_text = TextWdg("display_handler") display_handler_text.add_attr("size", "50") display_handler_text.set_value(display_handler) td.add(display_handler_text) # 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
def get_simple_definition_wdg(my): detail_wdg = DivWdg() detail_wdg.add_color("color", "color") 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("margin-top: -23px") detail_wdg.add(title) if not my.name_string: title.add('No database column') return detail_wdg title.add("Column Definition") # add a name entry detail_wdg.add("<br/>") title = SpanWdg() detail_wdg.add("Name: ") detail_wdg.add(title) input = SpanWdg() input.add_style('padding-top: 6px') input.set_id("config_element_name") input.add(HtmlElement.b(my.name_string)) detail_wdg.add(input) hidden = HiddenWdg('column_name', my.name_string) detail_wdg.add(hidden) 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 = SpanWdg() checkbox = CheckboxWdg('config_nullable', label='Allow null(empty) value: ') #detail_wdg.add(": ") nullable.add(checkbox) if my.nullable_string in ['True', 'true']: checkbox.set_checked() detail_wdg.add(nullable) #constraint = DivWdg() #detail_wdg.add(constraint) #constraint.add_style("margin-top: 10px") #constraint.add("Constraint: ") #select = SelectWdg("config_constraint") #constraint.add(select) #select.set_option("values", "unique|indexed") #select.add_empty_option("-- None --") button_div = DivWdg() button_div.add_style("text-align: center") button_div.add_behavior({ 'type': 'load', 'cbjs_action': ''' spt.manage_search_type = {}; spt.manage_search_type.change_column_cbk = function(bvr) { var class_name = 'tactic.ui.panel.AlterSearchTypeCbk'; var options ={ 'alter_mode': bvr.alter_mode, 'title': bvr.title }; try { var server = TacticServerStub.get(); var panel = $('search_type_detail'); if (! panel.getAttribute("spt_class_name") ) { panel = panel.getParent(".spt_panel"); } var values = spt.api.Utility.get_input_values(panel); rtn = server.execute_cmd(class_name, options, values); if (bvr.alter_mode == 'Remove Column') spt.info("Column [" + bvr.column + "] has been deleted."); else if (bvr.alter_mode == 'Modify Column') spt.notify.show_message("Column [" + bvr.column + "] has been modified."); } catch (e) { spt.alert(spt.exception.handler(e)); } var view = 'db_column'; spt.panel.refresh("ManageSearchTypeMenuWdg_" + view); var view = 'definition'; spt.panel.refresh("ManageSearchTypeMenuWdg_" + view); } ''' }) detail_wdg.add(button_div) button_div.add("<hr/><br/>") if my.is_new_column: button = ActionButtonWdg(title="Commit") #button = ProdIconButtonWdg("Commit New Column") button.add_behavior({"type": "click_up", "cbjs_action": "spt.manage_search_type.change_column_cbk(bvr)", \ "alter_mode": my.ADD_COLUMN}) button_div.add(button) else: table = Table() button_div.add(table) table.add_row() table.center() button = ActionButtonWdg(title="Modify") #button = ProdIconButtonWdg("Modify Column") button.add_behavior({ "type": "click_up", "cbjs_action": '''spt.manage_search_type.change_column_cbk(bvr); ''', "alter_mode": my.MODIFY_COLUMN, "column": my.name_string, "title": my.title_string }) table.add_cell(button) button = ActionButtonWdg(title="Delete") #button = ProdIconButtonWdg("Delete Column") #button.add_style('background-color: #BF462E') button.add_behavior({ "type": "click_up", "cbjs_action": ''' var yes = function() { spt.manage_search_type.change_column_cbk(bvr); } spt.confirm("Are you sure you wish to delete this column?", yes) ''', "alter_mode": my.REMOVE_COLUMN, "column": my.name_string }) table.add_cell(button) button_div.add(HiddenWdg('delete_column')) button_div.add(HiddenWdg('modify_column')) return detail_wdg
def get_display(my): widget = DivWdg() table = Table() table.add_attr('class', 'scraper') table.add_style('background-color: #FFFFFF;') table.add_style('height: 1000px;') table.add_row() tb = TextWdg('title_box') tb.add_attr('id', 'title_box') tb.add_attr('size', '45') multiple_titles = None searched_imdb = False orders = [] # TODO: Remove hard-coded URL no_img = 'http://tactic.2gdigital.com/imdb_images/no_image.png' if 'code' in my.kwargs.keys() and my.title_of_show in [None, '']: server = TacticServerStub.get() this_order = server.eval("@SOBJECT(twog/order['code','%s'])" % my.kwargs.get('code'))[0] my.title_of_show = this_order.get('name') if my.title_of_show not in [None, '']: tb.set_value(my.title_of_show) if my.search_when_loaded: # poster_url_text = my.get_poster_url(my.title_of_show) # poster_url = poster_url_text.split('=')[1] server = TacticServerStub.get() orders = server.eval("@SOBJECT(twog/order['name','~','%s']['classification','not in','Master|Cancelled'])" % my.title_of_show) # order_s = Search("twog/order") # order_s.add_where("\"name\" like '%s%s%s'" % ('%', my.title_of_show.lower(), '%')) # statement = order_s.get_statement() # print "STATEMENT = %s" % statement # orders = order_s.get_sobjects() # print "ORDER LEN = %s" % len(orders) if len(orders) > 0: multiple_titles = get_multiple_title_info(my.title_of_show) # print "MULTIPLE TITLES = %s" % multiple_titles searched_imdb = True tb.add_behavior(my.get_search()) top_tbl = Table() top_tbl.add_attr('width', '400px') top_tbl.add_attr('height', '50px') top_tbl.add_attr('cellpadding', '20') top_tbl.add_attr('cellspacing', '20') top_tbl.add_style('background-color: #417e97;') top_tbl.add_row() if len(orders) > 0: butt = top_tbl.add_cell('<input type="button" value="Associate All Selected"/>') butt.add_behavior(my.get_associate_em()) sn = top_tbl.add_cell('<font color="#d9af1f"><b>Search Name:</b></font> ') sn.add_attr('align', 'right') sn.add_attr('nowrap', 'nowrap') tb_cell1 = top_tbl.add_cell(tb) tb_cell = table.add_cell(top_tbl) tb_cell.add_attr('colspan', '2') tb_cell.add_attr('align', 'center') order_table = Table() order_table.add_attr('border', '1') order_table.add_attr('cellpadding', '10') order_table.add_row() if len(orders) > 0: toggler = CustomCheckboxWdg(name='chk_toggler', additional_js=my.get_toggler(), value_field='toggler', id='selection_toggler', checked='false', text='<b><- Select/Deselect ALL</b>', text_spot='right', text_align='left', nowrap='nowrap') order_table.add_cell(toggler) order_table.add_row() order_table.add_cell('Selector') order_table.add_cell('Poster') order_table.add_cell('Order Builder') order_table.add_cell('Code') order_table.add_cell('Name') order_table.add_cell('Client') order_table.add_cell('PO Number') order_table.add_cell('Classification') order_table.add_cell('Platform') order_table.add_cell('Due Date') order_table.add_cell('Completion Ratio') order_table.add_cell('Scheduler') elif my.title_of_show not in [None, ''] and my.search_when_loaded: description_box = order_table.add_cell('<b>No Tactic Orders Were Found With "%s" In The Name</b>' % my.title_of_show) description_box.add_style('font-size: 14px;') else: description_box = order_table.add_cell('<b>Please type the name of the show in the box above</b>') description_box.add_style('font-size: 14px;') for order in orders: checkbox = CustomCheckboxWdg(name='associate_order_%s' % order.get('code'), additional_js=my.highlight_order_row(order.get('code')), alert_name=order.get('name'), value_field=order.get('code'), checked='false', dom_class='associated_orders') imarow = order_table.add_row() imarow.add_attr('id', 'row_%s' % order.get('code')) chk = order_table.add_cell(checkbox) chk.add_attr('align', 'center') poster_cell = order_table.add_cell(OrderImageWdg(code=order.get('code'))) poster_cell.add_attr('id', 'img_%s' % order.get('code')) ob = OrderBuilderLauncherWdg(code=order.get('code')) obc = order_table.add_cell(ob) obc.add_attr('align', 'center') order_table.add_cell(order.get('code')) order_table.add_cell(order.get('name')) order_table.add_cell(order.get('client_name')) order_table.add_cell(order.get('po_number')) order_table.add_cell(order.get('classification')) order_table.add_cell(order.get('platform')) order_table.add_cell(order.get('due_date')) order_table.add_cell('%s/%s' % (order.get('titles_completed'), order.get('titles_total'))) order_table.add_cell(order.get('login')) imdb_table = Table() imdb_table.add_attr('border', '1') imdb_table.add_attr('cellpadding', '10') if multiple_titles not in [None, ''] and len(multiple_titles) > 0: mcount = 0 seen_titles = [] for m in multiple_titles: title_id = m['TopLevel']['title_id'] if title_id not in seen_titles: seen_titles.append(title_id) imarow = imdb_table.add_row() imarow.add_attr('id', 'row_%s' % m['TopLevel']['title_id']) this_img = no_img # TODO: Download the image and save in a temp folder if m['TopLevel']['poster'] not in [None, '']: this_img = m['TopLevel']['poster'] imdb_image_url = m['TopLevel']['poster'] checkbox = CustomCheckboxWdg(name='associate_imdb_%s' % m['TopLevel']['title_id'], additional_js=my.act_like_radio(m['TopLevel']['title_id']), alert_name=m['TopLevel']['title'], value_field=m['TopLevel']['title_id'], checked='false', dom_class='associated_imdb', extra1=m['TopLevel']['title_id'], extra2=m['TopLevel']['title'], extra3=m['TopLevel']['runtime'], extra4=m['TopLevel']['release_date'], extra5=m['TopLevel']['imdb_url'], extra6=this_img) chk = imdb_table.add_cell(checkbox) chk.add_attr('align', 'center') imdb_table.add_cell('<img src="%s"/>' % this_img) info_tbl = Table() info_tbl.add_row() title_cell = info_tbl.add_cell('<b>Title: %s</b>' % m['TopLevel']['title']) title_cell.add_style('cursor: pointer;') title_cell.add_behavior(my.get_more_info(mcount)) info_tbl.add_row() info_tbl.add_cell('<i>Original Title: %s</i>' % m['TopLevel']['original_title']) info_tbl.add_row() info_tbl.add_cell('<i>Run Time: %s</i>' % m['TopLevel']['runtime']) info_tbl.add_row() info_tbl.add_cell('<i>Release Date: %s</i>' % m['TopLevel']['release_date']) info_tbl.add_row() info_tbl.add_cell('<i>Rating: %s</i>' % m['TopLevel']['rating']) info_tbl.add_row() info_tbl.add_cell('<i>IMDb URL: %s</i>' % m['TopLevel']['imdb_url']) info_tbl.add_row() info_tbl.add_cell('<i>Plot: %s</i>' % m['TopLevel']['plot']) info2 = Table() mkeys = m.keys() for k in mkeys: if k not in ['media_images', 'recommended_titles', 'videos', 'cinematographers', 'editors', 'producers', 'cast', 'directors', 'writers', 'stars', 'plot_keywords', 'musicians', 'TopLevel']: info2.add_row() info2.add_cell('<b><u>%s</u></b>' % k) dudes = m[k] dkeys = dudes.keys() for d in dkeys: info2.add_row() info2.add_cell('%s: %s' % (d, dudes[d])) intable = imdb_table.add_cell(info_tbl) intable.add_attr('valign', 'top') intable.add_attr('align', 'left') # intable.add_behavior(my.get_hover_behavior(mcount)) hidrow = imdb_table.add_row() hidrow.add_attr('hidden_id', mcount) hidrow.add_attr('class', 'hidden_info') hidrow.add_style('display: none;') intable2 = imdb_table.add_cell(info2) intable2.add_attr('valign', 'top') intable2.add_attr('align', 'left') mcount += 1 elif my.title_of_show not in [None, ''] and searched_imdb: imdb_table.add_row() description_box = imdb_table.add_cell('<b>No IMDb Titles Were Found With "%s" In The Name</b>' % my.title_of_show) description_box.add_style('font-size: 14px;') imarow = imdb_table.add_row() imarow.add_attr('id', 'row_%s' % 'none') checkbox = CustomCheckboxWdg(name='associate_imdb_%s' % 'none', additional_js=my.act_like_radio('none'), alert_name='No IMDb Link', value_field='none', checked='false', dom_class='associated_imdb', extra1='none', extra2='No IMDb Link', extra3='', extra4='', extra5='none', extra6=no_img) chk = imdb_table.add_cell(checkbox) chk.add_attr('align', 'center') imdb_table.add_cell('<img src="%s"/>' % no_img) info_tbl = Table() info_tbl.add_row() title_cell = info_tbl.add_cell('<b>Title: %s</b>' % 'No IMDb Link') title_cell.add_style('cursor: pointer;') intable = imdb_table.add_cell(info_tbl) intable.add_attr('valign', 'top') intable.add_attr('align', 'left') hidrow = imdb_table.add_row() hidrow.add_attr('class', 'hidden_info') hidrow.add_style('display: none;') elif my.title_of_show not in [None, '']: imdb_table.add_row() description_box = imdb_table.add_cell("<b>No Tactic Orders Found, Didn't Query IMDb</b>") description_box.add_style('font-size: 14px;') table.add_row() order_div = DivWdg() order_div.add_style('overflow-y: scroll;') order_div.add_style('height: 1000px;') order_div.add_style('width: 750px;') order_div.add('<font size=7><b>Tactic Orders</b></font>') order_div.add(order_table) ot = table.add_cell(order_div) ot.add_attr('valign', 'top') imdb_div = DivWdg() imdb_div.add_style('overflow-y: scroll;') imdb_div.add_style('height: 1000px;') imdb_div.add_style('width: 750px;') imdb_div.add('<font size=7><b>IMDb</b></font>') imdb_div.add(imdb_table) it = table.add_cell(imdb_div) it.add_attr('valign', 'top') widget.add(table) return widget
def handle_simple_mode(my, custom_table, mode): tbody = custom_table.add_tbody() tbody.add_class("spt_custom_simple") if mode != 'simple': tbody.add_style('display: none') name_text = TextWdg("custom_name") name_text.add_class("spt_input") tr = custom_table.add_row() tr.add_color("background", "background", -7) td = custom_table.add_cell("Name: ") td.add_style("min-width: 150px") custom_table.add_cell(name_text) # add title custom_table.add_row() title_wdg = TextWdg("custom_title") title_wdg.add_attr("size", "50") custom_table.add_cell( "Title: " ) custom_table.add_cell( title_wdg ) # add description tr = custom_table.add_row() tr.add_color("background", "background", -7) description_wdg = TextAreaWdg("custom_description") custom_table.add_cell( "Description: " ) custom_table.add_cell( description_wdg ) type_select = SelectWdg("custom_type") type_select.add_class("spt_input") #type_select.add_empty_option("-- Select --") type_select.set_option("values", "string|text|integer|float|boolean|currency|date|foreign_key|list|button|empty") type_select.set_option("labels", "String(db)|Text(db)|Integer(db)|Float(db)|Boolean(db)|Currency(db)|Date(db)|Foreign Key(db)|List(db)|Button|Empty") #type_select.set_option("labels", "String|Integer|Boolean|Currency|Timestamp|Link|Foreign Key|List|Checkbox|Text|Number|Date|Date Range") tr = custom_table.add_row() custom_table.add_cell("Property Type: ") td = custom_table.add_cell(type_select) type_select.add_event("onchange", "spt.custom_property_adder.property_type_select_cbk(this)") # 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_class("button_options") div.add_style("display: none") div.add_style("margin-top: 10px") class_path = "tactic.ui.table.ButtonElementWdg" 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(): div.add("Name: ") option_name_text = TextWdg("option_name") option_name_text.add_attr("readonly", "true") option_name_text.set_value(key) div.add(option_name_text) div.add(" ") div.add("Value: ") input = button.get_input_by_arg_key(key) div.add(input) #option_value_text = TextWdg("option_value") #div.add(option_value_text) div.add(HtmlElement.br()) td.add(div) # is searchable checkbox tr = custom_table.add_row() tr.add_color("background", "background", -7) current_searchable_wdg = CheckboxWdg("is_searchable") #current_view_wdg.set_checked() custom_table.add_cell("Is Searchable? ") td = custom_table.add_cell(current_searchable_wdg) custom_table.close_tbody()
def handle_widget_mode(my, custom_table, mode): tbody = custom_table.add_tbody() tbody.add_class("spt_custom_widget") if mode != 'widget': tbody.add_style('display: none') # add the name name_text = TextWdg("custom_name") name_text.add_class("spt_input") custom_table.add_row() custom_table.add_cell("Name: ") custom_table.add_cell(name_text) # add title custom_table.add_row() title_wdg = TextWdg("custom_title") title_wdg.add_attr("size", "50") custom_table.add_cell( "Title: " ) custom_table.add_cell( title_wdg ) # add description custom_table.add_row() description_wdg = TextAreaWdg("custom_description") custom_table.add_cell( "Description: " ) custom_table.add_cell( description_wdg ) # add widget class custom_table.add_row() class_wdg = TextWdg("custom_class") class_wdg.add_attr("size", "50") custom_table.add_cell( "Widget Class: " ) custom_table.add_cell( class_wdg ) # add options custom_table.add_row() td = custom_table.add_cell() td.add("Options") td = custom_table.add_cell() div = DivWdg() div.set_id("another_list_options") div.add_style("display: block") div.add_style("margin-top: 10px") # TODO: this class should not be in prod!! from pyasm.prod.web import SearchTypeSelectWdg div.add("Name: ") option_name_text = TextWdg("option_name") div.add(option_name_text) div.add(" ") div.add("Value: ") option_value_text = TextWdg("option_value") div.add(option_value_text) td.add(div) td.add(div) td.add(div) custom_table.close_tbody()
def get_display(my): web = WebContainer.get_web() top = my.top top.add_class("spt_ace_editor_top") script = my.kwargs.get("custom_script") if script: language = script.get_value("language") else: language = my.kwargs.get("language") if not language: language = 'javascript' code = my.kwargs.get("code") if not code: code = "" show_options = my.kwargs.get("show_options") if show_options in ['false', False]: show_options = False else: show_options = True options_div = DivWdg() top.add(options_div) if not show_options: options_div.add_style("display: none") options_div.add_color("background", "background3") options_div.add_border() options_div.add_style("text-align: center") options_div.add_style("padding: 2px") select = SelectWdg("language") select.add_style("width: 100px") select.add_style("display: inline") options_div.add(select) select.add_class("spt_language") select.set_option("values", "javascript|python|expression|xml") select.add_behavior( { 'type': 'change', 'editor_id': my.get_editor_id(), 'cbjs_action': ''' spt.ace_editor.set_editor(bvr.editor_id); var value = bvr.src_el.value; spt.ace_editor.set_language(value); //register_change(bvr); ''' } ) select = SelectWdg("font_size") select.add_style("width: 100px") select.add_style("display: inline") options_div.add(select) select.set_option("labels", "8 pt|9 pt|10 pt|11 pt|12 pt|14 pt|16 pt") select.set_option("values", "8 pt|9pt|10pt|11pt|12pt|14pt|16pt") select.set_value("10pt") select.add_behavior( { 'type': 'click_up', 'editor_id': my.get_editor_id(), 'cbjs_action': ''' spt.ace_editor.set_editor(bvr.editor_id); var editor = spt.ace_editor.editor; var editor_id = spt.ace_editor.editor_id; var value = bvr.src_el.value; $(editor_id).setStyle("font-size", value) //editor.resize(); ''' } ) select = SelectWdg("keybinding") select.add_style("width: 100px") #options_div.add(select) select.set_option("labels", "Ace|Vim|Emacs") select.set_option("values", "ace|vim|emacs") select.set_value("10pt") select.add_behavior( { 'type': 'change', 'editor_id': my.get_editor_id(), 'cbjs_action': ''' spt.ace_editor.set_editor(bvr.editor_id); var editor = spt.ace_editor.editor; var editor_id = spt.ace_editor.editor_id; var vim = require("ace/keyboard/keybinding/vim").Vim; editor.setKeyboardHandler(vim) ''' } ) editor_div = DivWdg() top.add(editor_div) if code: load_div = DivWdg() top.add(load_div) readonly = my.kwargs.get("readonly") if readonly in ['true', True]: readonly = True else: readonly = False load_div.add_behavior( { 'type': 'load', 'code': code, 'language': language, 'editor_id': my.get_editor_id(), 'readonly': readonly, 'cbjs_action': ''' spt.ace_editor.set_editor(bvr.editor_id); var func = function() { var editor = spt.ace_editor.editor; var document = editor.getSession().getDocument(); if (bvr.code) { spt.ace_editor.set_value(bvr.code); } spt.ace_editor.set_language(bvr.language); editor.setReadOnly(bvr.readonly); var session = editor.getSession(); //session.setUseWrapMode(true); //session.setWrapLimitRange(120, 120); }; var editor = spt.ace_editor.editor; if (!editor) { setTimeout( func, 1000); } else { func(); } ''' } ) # theme select = SelectWdg("theme") select.add_style("width: 100px") select.add_style("display: inline") options_div.add(select) select.set_option("labels", "Eclipse|Twilight|TextMate|Vibrant Ink|Merbivore|Clouds") select.set_option("values", "eclipse|twilight|textmate|vibrant_ink|merbivore|clouds") select.set_value("twilight") select.add_behavior( { 'type': 'change', 'editor_id': my.get_editor_id(), 'cbjs_action': ''' spt.ace_editor.set_editor(bvr.editor_id); var editor = spt.ace_editor.editor; var editor_id = spt.ace_editor.editor_id; value = bvr.src_el.value; editor.setTheme("ace/theme/" + value); ''' } ) editor_div = DivWdg() top.add(editor_div) my.text_area.add_style("margin-top: -1px") my.text_area.add_style("margin-bottom: 0px") my.text_area.add_color("background", "background") my.text_area.add_style("font-family: courier new") my.text_area.add_border() editor_div.add(my.text_area) my.text_area.add_style("position: relative") #text_area.add_style("margin: 20px") size = web.get_form_value("size") if size: width, height = size.split(",") else: width = my.kwargs.get("width") if not width: width = "650px" height = my.kwargs.get("height") if not height: height = "450px" my.text_area.add_style("width: %s" % width) my.text_area.add_style("height: %s" % height) bottom_div = DivWdg() top.add(bottom_div) bottom_div.add_color("background", "background3") bottom_div.add_border() bottom_div.add_style("text-align: center") bottom_div.add_style("padding: 2px") bottom_div.add_style("height: 20px") bottom_title = "Script Editor" bottom_div.add(bottom_title) icon = IconWdg("Resize Editor", IconWdg.RESIZE_CORNER) bottom_div.add(icon) icon.add_style("float: right") icon.add_style("margin-right: -4px") icon.add_style("cursor: se-resize") icon.add_behavior( { 'type': 'drag', "cb_set_prefix": 'spt.ace_editor.drag_resize', } ) #hidden = HiddenWdg("size") hidden = TextWdg("size") bottom_div.add(hidden) hidden.add_style("width: 85px") hidden.add_style("text-align: center") hidden.add_style("float: right") hidden.add_class("spt_size") hidden.set_value("%s,%s" % (width, height)) theme = top.get_theme() if theme == 'dark': theme = 'twilight' else: theme = 'eclipse' print "theme: ", theme top.add_behavior( { 'type': 'load', 'unique_id': my.unique_id, 'theme': theme, 'cbjs_action': ''' if (typeof(ace) == 'undefined') { // fist time loading spt.ace_editor = {} spt.ace_editor.editor = null; spt.ace_editor.editor_id = bvr.unique_id; spt.ace_editor.theme = bvr.theme; spt.ace_editor.set_editor = function(editor_id) { spt.ace_editor.editor_id = editor_id; spt.ace_editor.editor = $(editor_id).editor; } spt.ace_editor.set_editor_top = function(top_el) { if (!top_el.hasClass("spt_ace_editor")) { top_el = top_el.getElement(".spt_ace_editor"); } var editor_id = top_el.getAttribute("id"); spt.ace_editor.set_editor(editor_id); } spt.ace_editor.get_editor = function() { return spt.ace_editor.editor; } spt.ace_editor.clear_selection = function() { var editor = spt.ace_editor.editor; editor.clearSelection(); } spt.ace_editor.get_selection = function() { var editor = spt.ace_editor.editor; //return editor.getSelection(); return editor.getCopyText(); } spt.ace_editor.get_value = function() { var editor = spt.ace_editor.editor; var document = editor.getSession().getDocument() var value = document.getValue(); return value; } spt.ace_editor.set_value = function(value) { var editor = spt.ace_editor.editor; var document = editor.getSession().getDocument() document.setValue(value); editor.gotoLine(2); editor.resize(); editor.focus(); } spt.ace_editor.goto_line = function(number) { var editor = spt.ace_editor.editor; var document = editor.getSession().getDocument() editor.gotoLine(2); editor.resize(); editor.focus(); } spt.ace_editor.insert = function(value) { var editor = spt.ace_editor.editor; var position = editor.getCursorPosition(); var doc = editor.getSession().getDocument() doc.insertInLine(position, value); } spt.ace_editor.insert_lines = function(values) { var editor = spt.ace_editor.editor; var position = editor.getCursorPosition(); var doc = editor.getSession().getDocument() doc.insertLines(position.row, values); } spt.ace_editor.get_document = function() { var document = spt.ace_editor.editor.getSession().getDocument() return document; } spt.ace_editor.set_language = function(value) { if (!value) { value = 'javascript'; } var editor = spt.ace_editor.editor; var top = $(spt.ace_editor.editor_id).getParent(".spt_ace_editor_top"); var lang_el = top.getElement(".spt_language"); for ( var i = 0; i < lang_el.options.length; i++ ) { if ( lang_el.options[i].value == value ) { lang_el.options[i].selected = true; break; } } var session = editor.getSession(); var mode; if (value == 'python') { mode = require("ace/mode/python").Mode; } else if (value == 'xml') { mode = require("ace/mode/xml").Mode; } else if (value == 'expression') { mode = require("ace/mode/xml").Mode; } else { mode = require("ace/mode/javascript").Mode; } session.setMode( new mode() ); } spt.ace_editor.drag_start_x; spt.ace_editor.drag_start_y; spt.ace_editor.drag_size; spt.ace_editor.drag_editor_el; spt.ace_editor.drag_size_el; spt.ace_editor.drag_resize_setup = function(evt, bvr, mouse_411) { var editor = spt.ace_editor.editor; var editor_id = spt.ace_editor.editor_id; spt.ace_editor.drag_start_x = mouse_411.curr_x; spt.ace_editor.drag_start_y = mouse_411.curr_y; var editor_el = $(editor_id); spt.ace_editor.drag_editor_el = editor_el; spt.ace_editor.drag_size = editor_el.getSize(); var top = bvr.src_el.getParent(".spt_ace_editor_top"); spt.ace_editor.drag_size_el = top.getElement(".spt_size"); } spt.ace_editor.drag_resize_motion = function(evt, bvr, mouse_411) { var diff_x = parseFloat(mouse_411.curr_x - spt.ace_editor.drag_start_x); var diff_y = parseFloat(mouse_411.curr_y - spt.ace_editor.drag_start_y); var size = spt.ace_editor.drag_size; var editor_el = spt.ace_editor.drag_editor_el; var width = size.x + diff_x if (width < 300) { width = 300; } var height = size.y + diff_y if (height < 200) { height = 200; } editor_el.setStyle("width", width); editor_el.setStyle("height", height); spt.ace_editor.drag_size_el.value = width + "," + height; var editor = spt.ace_editor.editor; editor.resize(); } var js_files = [ "ace/ace-0.2.0/src/ace.js", //"ace/ace-0.2.0/src/ace-uncompressed.js", ]; var ace_setup = function() { var editor = ace.edit(bvr.unique_id); spt.ace_editor.editor = editor; // put the editor into the dom spt.ace_editor.editor_id = bvr.unique_id; $(bvr.unique_id).editor = editor; editor.setTheme("ace/theme/" + spt.ace_editor.theme); var JavaScriptMode = require("ace/mode/javascript").Mode; editor.getSession().setMode(new JavaScriptMode()) } spt.dom.load_js(js_files, function() { ace; require; define; var core_js_files = [ "ace/ace-0.2.0/src/mode-javascript.js", "ace/ace-0.2.0/src/mode-xml.js", "ace/ace-0.2.0/src/mode-python.js", "ace/ace-0.2.0/src/theme-twilight.js", "ace/ace-0.2.0/src/theme-textmate.js", "ace/ace-0.2.0/src/theme-vibrant_ink.js", "ace/ace-0.2.0/src/theme-merbivore.js", "ace/ace-0.2.0/src/theme-clouds.js", "ace/ace-0.2.0/src/theme-eclipse.js" ]; //var supp_js_files = []; spt.dom.load_js(core_js_files, ace_setup); //spt.dom.load_js(supp_js_files); }); } else { var editor = ace.edit(bvr.unique_id); editor.setTheme("ace/theme/" + bvr.theme); var JavaScriptMode = require("ace/mode/javascript").Mode; editor.getSession().setMode(new JavaScriptMode()) spt.ace_editor.editor_id = bvr.unique_id; spt.ace_editor.editor = editor; $(bvr.unique_id).editor = editor; } ''' } ) return top
def get_display(my): widget = DivWdg(id='new_item_panel') widget.add_class("new_item_panel") widget.add_class("spt_new_item_top") div = DivWdg() div.add_color("background", "background") div.add_color("color", "color") div.add_style("padding", "5px") div.add_border() if my.is_personal: is_personal = 'true' else: is_personal = 'false' if my.type == 'new_folder': #div.set_attr('spt_view', 'new_folder') div.add(HtmlElement.b('Create New Folder')) div.add(HtmlElement.br(2)) item_div = DivWdg(css='spt_new_item') item_div.add_style('display: none') div.add(HtmlElement.br()) div.add(item_div) """ # add exisiting views in the div for checking with client's input # add exiting views: from panel_wdg import ViewPanelSaveWdg views = ViewPanelSaveWdg.get_existing_views(my.is_personal) hidden = HiddenWdg('existing_views', '|'.join(views)) div.add(hidden) """ text2 = TextWdg("new_title") text2.add_class("spt_new_item_title") span = SpanWdg("Title: ") span.set_id('create_new_title') #span.add_style('display: none') span.add_style('padding-left: 8px') span.add(text2) div.add(span) div.add(HtmlElement.br(2)) div.add_style("width: 350px") action = ''' var top = bvr.src_el.getParent(".spt_new_item_top"); var name_el = top.getElement(".spt_new_item_name"); var title = bvr.src_el.value; var name = title.replace(/[\?.!@#$%^&*()'"]/g, ""); name = name.replace(/ /g, "_"); name = name.toLowerCase(); name_el.value = name; ''' # change the name based on the title text2.add_behavior({'type': 'change', 'cbjs_action': action}) div.add( "The name of the folder is a hidden name that is used by other elements to refer to uniquely to this item.<br/><br/>" ) text = TextWdg('new_name') text.add_class("spt_new_item_name") span = SpanWdg('Name: ') span.add(text) div.add(span) div.add(HtmlElement.br(2)) #script = "spt.side_bar.manage_section_action_cbk({'value':'predefined'},'project_view');" #link = HtmlElement.js_href(script, data='[ Predefined View ]') #div3 = DivWdg('Optional: drag existing elements from Project Views or %s into this new folder' %link.get_buffer_display()) #div.add(div3) #item_div = DivWdg(css='spt_new_item spt_side_bar_content') #div.add(item_div) div.add("<hr/>") #save_div = SpanWdg(css='med hand') #div.add(save_div) #save_div.add(IconWdg('Save Folder', IconWdg.SAVE)) save_button = ActionButtonWdg(title='Create', tip='Create a new folder') div.add(save_button) bvr = { "type": "click_up", "view": my.view, "is_personal": is_personal == 'true', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_new_item_top"); var name_el = top.getElement(".spt_new_item_name"); var name_value = name_el.value; if (name_value == "") { var title_el = top.getElement(".spt_new_item_title"); var title = title_el.value; var name = spt.convert_to_alpha_numeric(title); name_el.value = name; } if (name_value == "") { spt.alert("Please fill in a value for name."); return; } spt.side_bar.manage_section_action_cbk( { 'value':'save_folder'}, bvr.view, bvr.is_personal); ''' } save_button.add_behavior(bvr) div.add(HtmlElement.br()) elif my.type == 'new_link': div.set_attr('spt_view', 'new_link') div.add(HtmlElement.b('Create New Link')) div.add(HtmlElement.br()) item_div = DivWdg(css='spt_new_item') item_div.add_style('display: none') div.add(HtmlElement.br()) div.add(item_div) text = TextWdg('new_link_title') span = SpanWdg('Title: ') span.add(text) div.add(span) div.add(HtmlElement.br(2)) cb = CheckboxWdg('include_search_view', label='Include Saved Search') cb.set_default_checked() div.add(cb) div.add(HtmlElement.br(2)) div.add("Select a search type and view of this link") div.add(HtmlElement.br()) select = SelectWdg("new_search_type") select.add_empty_option("-- Select Search type --") security = Environment.get_security() if security.check_access("builtin", "view_site_admin", "allow"): search_types = Project.get().get_search_types( include_sthpw=True, include_config=True) else: search_types = Project.get().get_search_types() values = [x.get_value("search_type") for x in search_types] labels = [ "%s (%s)" % (x.get_value("search_type"), x.get_title()) for x in search_types ] values.append("CustomLayoutWdg") labels.append("CustomLayoutWdg") select.set_option("values", values) select.set_option("labels", labels) #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='new_search_type', \ # mode=select_mode) select.add_behavior({ 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".new_item_panel"); var link_view_select = top.getElement(".link_view_select"); var input = spt.api.Utility.get_input(top, 'new_search_type'); var values = {'search_type': input.value, 'is_refresh': 'true'}; spt.panel.refresh(link_view_select, values);''' }) div.add(HtmlElement.br()) div.add(select) div.add(HtmlElement.br()) link_view_sel = NewLinkViewSelectWdg() div.add(HtmlElement.br()) div.add(link_view_sel) div.add(HtmlElement.br()) #select.add_behavior('change') div.add(HtmlElement.hr()) div.add(HtmlElement.br()) #save_div = DivWdg(css='med hand') #div.add(save_div) #save_button = ProdIconButtonWdg('Save Link', IconWdg.SAVE) #save_div.add(save_button) save_button = ActionButtonWdg(title='Create', tip='Create a new link') div.add(save_button) bvr = { "type": "click_up", 'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\ "'value':'save_link'},'%s', %s);" %(my.view, is_personal)} save_button.add_behavior(bvr) div.add(HtmlElement.br(1)) elif my.type == 'new_separator': div.set_attr('spt_view', 'new_separator') div.add(HtmlElement.b('Creating New Separator. . .')) div.add(HtmlElement.br()) item_div = DivWdg(css='spt_new_item') item_div.add_style('display: none') div.add(HtmlElement.br()) div.add(item_div) # since it's automated, this button is not needed """ save_div = SpanWdg(css='med hand') save_div.add(IconWdg('Save', IconWdg.SAVE)) bvr = { "type": "click_up",\ 'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\ "'value':'save_separator'},'%s');" %my.view} save_div.add_behavior(bvr) div.add(save_div) """ widget.add(div) return widget
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() day_wdg.add(day) td = table.add_cell() td.add_style("width: %spx" % my.day_width) text = TextWdg('%sday_%s' % (time_prefix, day)) if disabled: text.set_option('read_only', 'true') text.set_attr('disabled', 'disabled') td.add(text) text.add_class('spt_day%s' % (time_prefix)) text.add_styles( "width: %spx;text-align: right;padding-left: 2px" % (my.day_width - 2)) #text.add_styles("width: 100%;text-align: right;padding-left: 2px") if day == today: text.add_style("border: solid 1px black") week_day = my.weekday_dict[idx] if week_day in ['Sat', 'Sun']: # MAIN: Overtime, weekend if row_to_draw == my.OT_ROW: text.add_color("background", "background2", modifier=[-15, 0, 5]) else: text.add_color("background", "background2", modifier=[0, 15, 20]) if row_to_draw == my.OT_ROW: text.add_attr('input_field_type', 'ot') else: text.add_attr('input_field_type', 'st') if my.kwargs.get('show_all_users') == 'false': pass else: text.set_option('read_only', 'true') #TODO: while we may have multiple entries per task, we will only use the latest one here # for now, making the UI cleaner # if a corresponding entry exists, display its value entry_list_dict = entries.get(day) daily_sum = 0 value = 0 entry_list = [] if entry_list_dict: row_key = my.ROW_DICT.get(row_to_draw) entry_list = entry_list_dict.get(row_key) if entry_list: for entry in entry_list: # Check if there is something in the category column. category = entry.get_value("category") if row_to_draw == my.OT_ROW: # Skip if the category field does not have a 'ot' indicated. if not category: print "Warning this work_hour entry has no category [%s]" % entry.get_code( ) continue # Check if there exist a value in the straight_time column value, delta = my.get_time_value(entry, row_to_draw) if value: text.set_value(value) text.add_attr('orig_input_value', value) if row_to_draw == my.OT_ROW: total_hours_ot += float(delta) else: total_hours_st += float(delta) daily_sum += delta # we only use value instead of the sum "daily_sum" for now if row_to_draw == my.OT_ROW: my.summary_ot[idx].update({search_key: daily_sum}) else: my.summary_st[idx].update({search_key: daily_sum}) script = ''' var orig_value = bvr.src_el.getAttribute("orig_input_value"); var input_field_type = bvr.src_el.getAttribute("input_field_type"); bvr.src_el.value = bvr.src_el.value.strip(); if (bvr.src_el.value == '') { if (orig_value) { bvr.src_el.value = 0; } else { return; } } else if (bvr.src_el.value == orig_value) { return; } bvr.prefix_list.splice( bvr.prefix_list.indexOf(bvr.time_prefix),1) var other_time_prefix = bvr.prefix_list[0]; spt.work_hour.update_total(bvr, '.spt_day' + bvr.time_prefix); // register this as changed item var all_top_el = bvr.src_el.getParent(".spt_work_hours_top"); var values1 = spt.api.Utility.get_input_values(all_top_el, '.spt_day'+ bvr.time_prefix, false); var values2 = spt.api.Utility.get_input_values(all_top_el, '.spt_day'+ other_time_prefix, false); // Merge values from straight time and overtime fields in values variable. for (var attr in values2) { values1[attr] = values2[attr]; } for (val in values1) { if (values1[val] && isNaN(values1[val])) { spt.error('You have non-numeric values in your work hours. Please correct it: ' + values[val]); return; } } delete values1.data; var value_wdg = all_top_el.getElement(".spt_data"); var value = JSON.stringify(values1); value_wdg.value = value; var layout = bvr.src_el.getParent(".spt_layout"); var version = layout.getAttribute("spt_version"); if (version == "2") { spt.table.set_layout(layout); spt.table.accept_edit(all_top_el, value, false); } else { var cached_data = {}; spt.dg_table.edit.widget = all_top_el; spt.dg_table.inline_edit_cell_cbk( value_wdg, cached_data ); } ''' # accept on pressing Enter behavior = { 'type': 'keydown', 'time_prefix': time_prefix, 'prefix_list': prefix_list, 'cbjs_action': ''' if (evt.key=='enter') { %s } ''' % script } text.add_behavior(behavior) behavior = { 'type': 'blur', 'time_prefix': time_prefix, 'prefix_list': prefix_list, 'cbjs_action': ''' %s ''' % script } text.add_behavior(behavior) text = TextWdg("total") td = table.add_cell(text) td.add_style("width: 35px") text.add_attr('spt_total', '.spt_total%s' % (time_prefix)) text.add_class('spt_total%s' % (time_prefix)) text.add_styles( "width: %spx; text-align: right; padding-right: 3px" % my.day_width) text.set_attr("readonly", "readonly") # MAIN: Overtime, total. if row_to_draw == my.OT_ROW: text.add_color("background", "background2", modifier=[5, -15, 0]) if total_hours_ot: text.set_value("%0.1f" % total_hours_ot) my.summary_ot[7].update({search_key: total_hours_ot}) else: text.add_color("background", "background2", modifier=[20, 0, 15]) if total_hours_st: text.set_value("%0.1f" % total_hours_st) my.summary_st[7].update({search_key: total_hours_st}) td = table.add_blank_cell() td.add_style('width: 100%') return top
def get_display(self): top = DivWdg() top.add_class("ad_input_top") name = self.get_name() text = TextWdg(self.get_input_name()) # get the login sobject = self.get_current_sobject() client = sobject.get_value("contact_name") print "client: ", client if client: login_sobj = Login.get_by_code(client) else: login_sobj = Environment.get_login() # build the display_name login = login_sobj.get_value("login") display_name = login_sobj.get_value("display_name") if not display_name: display_name = "%s %s" % (user.get('first_name'), user.get('last_name')) display_name = display_name.replace('"', "'") print "login: "******"spt_ad_input") if login: hidden.set_value(login) top.add(hidden) # copy over some options #text.set_options( self.options.copy() ) if login: text.set_value(display_name) text.set_option("read_only", "true") text.add_class("spt_ad_display") top.add(text) top.add(" ") groups_str = self.get_option("groups_allowed_to_search") if groups_str: stmt = 'groups_list = %s' % groups_str exec stmt else: groups_list = None allow_search = True if groups_list: allow_search = False login_in_group_list = Search.eval("@SOBJECT(sthpw/login_in_group['login','=','%s'])" % login) for login_in_group in login_in_group_list: group = login_in_group.get_value("login_group") if group in groups_list: allow_search = True break if login == 'admin': allow_search = True if allow_search: button = IconButtonWdg('Search for User', IconWdg.USER) #button = ButtonWdg() button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent('.ad_input_top'); var content = top.getElement('.ad_input_content'); spt.toggle_show_hide(content); ''' } ) top.add(button) ad_top = DivWdg() ad_top.add_class("ad_input_content") ad_top.add_style("display: none") ad_top.add_style("position: absolute") ad_top.add_style("background: #222") ad_top.add_style("min-width: 300px") ad_top.add_style("border: solid 1px #000") ad_top.add_style("padding: 20px") cbjs_action = ''' var value = bvr.src_el.getAttribute('spt_input_value'); var display_value = bvr.src_el.getAttribute('spt_display_value'); var phone_number = bvr.src_el.getAttribute('spt_phone_number'); var email = bvr.src_el.getAttribute('spt_mail'); var top = bvr.src_el.getParent('.ad_input_top'); var content = top.getElement('.ad_input_content'); var input = top.getElement('.spt_ad_input'); var display = top.getElement('.spt_ad_display'); input.value = value; display.value = display_value; server = TacticServerStub.get() server.execute_cmd("tactic.active_directory.ADCacheUserCbk", {login: value}) spt.toggle_show_hide(content); ''' ad_search_wdg = ADSearchWdg(cbjs_action=cbjs_action) ad_top.add(ad_search_wdg) top.add(ad_top) return top
def get_gear_menu(my): top = DivWdg() # FIXME: the gear menu widget should be here from tactic.ui.container import GearMenuWdg, Menu, MenuItem menu = Menu(width=180) menu_item = MenuItem(type="title", label="Actions") menu.add(menu_item) # create a new element menu_item = MenuItem(type="action", label="New Element") behavior = { "options": {"is_insert": "true", "search_type": my.search_type, "view": my.view}, "cbjs_action": """ var activator = spt.smenu.get_activator(bvr); var top = activator.getParent(".spt_view_manager_top"); var detail_panel = top.getElement(".spt_view_manager_detail"); var class_name = 'tactic.ui.manager.ElementDefinitionWdg'; var options = bvr.options var values = {}; spt.panel.load(detail_panel, class_name, options, values, false); """, } menu_item.add_behavior(behavior) menu.add(menu_item) menu_item = MenuItem(type="separator") menu.add(menu_item) # Show preview of the view menu_item = MenuItem(type="action", label="Show Preview") behavior = { "search_type": my.search_type, "view": my.view, "cbjs_action": """ var kwargs = { search_type: bvr.search_type, view: bvr.view }; var title = "Search Type: [" + bvr.search_type + "], View [" + bvr.view + "]"; spt.panel.load_popup(title, 'tactic.ui.panel.ViewPanelWdg', kwargs); """, } menu_item.add_behavior(behavior) menu.add(menu_item) # Show preview of the view menu_item = MenuItem(type="action", label="Show Full XML Config") behavior = { "search_type": my.search_type, "view": my.view, "cbjs_action": """ var kwargs = { search_type: 'config/widget_config', view: 'table', expression: "@SOBJECT(config/widget_config['search_type','"+bvr.search_type+"']['view','"+bvr.view+"'])", filter: [{}] }; var title = "Widget Config - ["+bvr.search_type+"] ["+bvr.view+"]"; spt.panel.load_popup(title, 'tactic.ui.panel.ViewPanelWdg', kwargs); """, } menu_item.add_behavior(behavior) menu.add(menu_item) menu_item = MenuItem(type="separator") menu.add(menu_item) # New view popup new_view_wdg = DivWdg() new_view_wdg.add_class("spt_new_view") new_view_wdg.add_style("display: none") new_view_wdg.add_style("position: absolute") new_view_wdg.add_color("background", "background") new_view_wdg.add_style("z-index: 100") new_view_wdg.add_border() new_view_wdg.set_round_corners() new_view_wdg.set_box_shadow() new_view_wdg.add_style("padding: 30px") new_view_wdg.add("New View Name: ") new_view_text = TextWdg("new_view") new_view_text.add_class("spt_new_view_text") new_view_wdg.add(new_view_text) new_view_wdg.add(HtmlElement.br(2)) # new_view_button = ProdIconButtonWdg('Save New View') new_view_button = ActionButtonWdg(title="Save", tip="Save New View") new_view_button.add_style("float: left") new_view_wdg.add(new_view_button) new_view_button.add_behavior( { "type": "click_up", "search_type": my.search_type, "cbjs_action": """ var top = bvr.src_el.getParent(".spt_view_manager_top"); var new_view_wdg = bvr.src_el.getParent(".spt_new_view"); var new_view_text = new_view_wdg.getElement(".spt_new_view_text"); var view = new_view_text.value; if (view != '') { var server = TacticServerStub.get() server.update_config(bvr.search_type, view, []); var values = { search_type: bvr.search_type, view: view }; spt.panel.refresh(top, values); spt.hide(new_view_wdg); } else { alert("Must supply view name"); } """, } ) # new_view_cancel_button = ProdIconButtonWdg('Cancel') new_view_cancel_button = ActionButtonWdg(title="Cancel", tip="Cancel Save") new_view_cancel_button.add_behavior( { "type": "click_up", "cbjs_action": """ var new_view_wdg = bvr.src_el.getParent(".spt_new_view"); spt.hide(new_view_wdg); """, } ) new_view_wdg.add(new_view_cancel_button) top.add(new_view_wdg) # TODO: to be implemented.. no more xx please! """ # Save to Project View menu_item = MenuItem(type='action', label='xx Save to Project View') behavior = { 'options': { 'search_type': 'SideBarWdg', 'view': 'project_view' }, 'cbjs_action': ''' spt.panel.load_popup('SideBar Section', 'tactic.ui.manager.SideBarSectionWdg', bvr.options); '''} menu_item.add_behavior(behavior) menu.add(menu_item) """ # Create a new view menu_item = MenuItem(type="action", label="Create New View") behavior = { "search_type": my.search_type, "view": my.view, "cbjs_action": """ var activator = spt.smenu.get_activator(bvr); var top = activator.getParent(".spt_view_manager_top"); var new_view_wdg = top.getElement(".spt_new_view"); spt.show(new_view_wdg); """, } menu_item.add_behavior(behavior) menu.add(menu_item) # Clear the current view menu_item = MenuItem(type="action", label="Clear View") behavior = { "options": {"is_insert": "true", "search_type": my.search_type, "view": my.view}, "cbjs_action": """ if (confirm("Are you sure you wih to clear this view?")) { var activator = spt.smenu.get_activator(bvr); var top = activator.getParent(".spt_view_manager_top"); var list_top = top.getElement(".spt_menu_item_list"); var elements = spt.side_bar.get_elements(bvr.view,list_top); for (var i=0; i<elements.length; i++) { var element = elements[i]; if (element.hasClass("spt_side_bar_dummy")) { continue; } element.destroy(); } } """, } menu_item.add_behavior(behavior) menu.add(menu_item) gear_menu = GearMenuWdg() gear_menu.add(menu) top.add(gear_menu) return top
def get_display(self): web = WebContainer.get_web() key = web.get_form_value('name') top = DivWdg() top.add_class('ad_search_wdg_top') self.set_as_panel(top) text = TextWdg("name") text.set_value(key) close_wdg = SpanWdg() close_wdg.add( IconWdg("Close", IconWdg.POPUP_WIN_CLOSE) ) close_wdg.add_style("float: right") close_wdg.add_class("hand") # NOTE: the div we are looking for to hide on 'close' is outside of the this widget and # is part of the parent widget close_wdg.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var ad_input_content = bvr.src_el.getParent(".ad_input_content"); spt.toggle_show_hide(ad_input_content); ''' }) top.add( close_wdg ) top.add("Active Directory Search:<br clear='all'/> ") table = Table() table.add_row() table.add_cell(text) td = table.add_cell(self.get_search_wdg()) td.add_style("display", "") top.add(table) results_div = DivWdg() top.add(results_div) results_div.add_style("border: solid 1px #444") results_div.add_style("margin: 10px") results_div.add_style("padding: 5px") #results_div.add_style("max-height: 400px") results_div.add_style("overflow: auto") if not key: results_div.add("Please enter search criteria") return top results_div.add("Results Found ...") users = self.find_users(key) max_num_users = 20 if len(users) > max_num_users: display_users = users[:max_num_users] else: display_users = users for user in display_users: user_div = DivWdg() user_div.add_style("margin: 5px") user_div.add_class("hand") user_div.add_event("onmouseover", "$(this).setStyle('background','#444')") user_div.add_event("onmouseout", "$(this).setStyle('background','#222')") checkbox = CheckboxWdg() user_div.add(checkbox) display_name = user.get('display_name') if not display_name: display_name = "%s %s" % (user.get('first_name'), user.get('last_name')) email = user.get('email') login = user.get('login') phone_number = user.get('phone_number') user_div.add(display_name) if email: user_div.add(" (%s) " % email) self.cbjs_action = self.kwargs.get('cbjs_action') if self.cbjs_action: user_behavior = { 'type': 'click_up', 'cbjs_action': self.cbjs_action } user_div.add_behavior( user_behavior ) else: user_behavior = { 'type': 'click_up', 'cbjs_action': 'alert("Not implemented")' } user_div.add_behavior( user_behavior ) user_div.add_attr("spt_input_value", login) user_div.add_attr("spt_display_value", display_name) user_div.add_attr("spt_phone_number", phone_number) user_div.add_attr("spt_email", email) results_div.add(user_div) num_users = len(users) if num_users > max_num_users: results_div.add("... and %s more results matched" % (num_users-max_num_users)) results_div.add("<br/>Please narrow your search") #nav_div = DivWdg() #num_categories = num_users / max_num_users + 1 #if num_categories > 10: # nav_div.add("<br/>Please narrow your search") #else: # for i in range(0, num_categories): # span = SpanWdg() # span.add(i) # span.add(" ") # nav_div.add(span) #results_div.add(nav_div) if not users: user_div = DivWdg() user_div.add_style("margin: 5px") user_div.add("No Results") results_div.add(user_div) return top
def get_display(my): top = DivWdg() top.add_class("spt_top") dialog = DialogWdg() dialog_id = dialog.get_id() # create the button button = DivWdg() button.add_style("padding: 5px") button.add_style("width: 30px") button.add_style("text-align: center") button.add_style("float: left") button.add_gradient("background", "background") button.add_border() top.add(button) icon = IconWdg("Press Me", IconWdg.ZOOM) icon.add_style("float: left") button.add(icon) icon = IconWdg("Press Me", IconWdg.INFO_OPEN_SMALL) icon.add_style("margin-left: -9px") button.add(icon) button.add_behavior({ 'type': 'click_up', 'dialog_id': dialog_id, 'cbjs_action': ''' var pos = bvr.src_el.getPosition(); var el = $(bvr.dialog_id); el.setStyle("left", pos.x+1); el.setStyle("top", pos.y+32); el.setStyle("display", ""); ''' }) # defined the dialog top.add(dialog) dialog.add_title("Search Limit") table = Table() table.add_color("color", "color2") dialog.add(table) table.add_row() td = table.add_cell() td.add("Search Limit: ") td = table.add_cell() select = SelectWdg("search_limit") select.set_option("values", "5|10|20|50|100|200|Custom") td.add(select) save_button = ProdIconButtonWdg("Save") td.add(save_button) cancel_script = dialog.get_cancel_script() save_button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var dialog_top = bvr.src_el.getParent(".spt_dialog_top"); var values = spt.api.get_input_values(dialog_top); var top = spt.get_parent(bvr.src_el, ".spt_top"); var input = top.getElement(".spt_search_limit"); input.value = values.search_limit; %s ''' % cancel_script }) text = TextWdg("search_limit") text.add_class("spt_search_limit") top.add(text) return top
def get_display(self): div = DivWdg() div.add_class("spt_message_top") div. add("<h1>Message</h1>") outer = DivWdg() div.add(outer) outer.add_style("width: 250px") outer.add_border() progress = DivWdg() outer.add(progress) progress.add_class("spt_message_progress") progress.add_style("background", "#AAD") progress.add_style("width: 0%") progress.add_style("height: 20px") div.add("<img src='/context/icons/common/indicator_snake.gif'/>") text = TextWdg("complete") div.add(text) text.add_class("spt_message_text"); div.add_behavior( { 'type': 'load', 'cbjs_action': self.get_onload_js() } ) div.add_behavior( { 'type': 'load', 'cbjs_action': ''' var key = spt.message.generate_key(); // create a subscription var server = TacticServerStub.get(); login = spt.Environment.get().get_user(); server.insert("sthpw/subscription", {'message_code':key, login: login, category: "script"} ); var server = TacticServerStub.get(); var x = function() {}; server.execute_python_script("message/action", {key:key}, {on_complete: x}); var el = bvr.src_el.getElement(".spt_message_text"); var progress_el = bvr.src_el.getElement(".spt_message_progress"); var callback = function(message) { if (message.status == "complete") { el.value = "OK DONE FINISHED" width = "100" } else { var value = JSON.parse(message.message); el.value = value.progress; width = value.progress; } progress_el.setStyle("width", width+"%"); } spt.message.set_interval(key, callback, 1000, bvr.src_el); ''' } ) div.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.message.stop_all_intervals(); ''' } ) return div
def get_display(my): widget = DivWdg(id='new_item_panel') widget.add_class("new_item_panel") widget.add_class("spt_new_item_top") div = DivWdg() div.add_color("background", "background") div.add_color("color", "color") div.add_style("padding", "5px") div.add_border() if my.is_personal: is_personal = 'true' else: is_personal = 'false' if my.type == 'new_folder': #div.set_attr('spt_view', 'new_folder') div.add(HtmlElement.b('Create New Folder')) div.add(HtmlElement.br(2)) """ # add exisiting views in the div for checking with client's input # add exiting views: from panel_wdg import ViewPanelSaveWdg views = ViewPanelSaveWdg.get_existing_views(my.is_personal) hidden = HiddenWdg('existing_views', '|'.join(views)) div.add(hidden) """ text2 = TextWdg("new_title") text2.add_class("spt_new_item_title") span = SpanWdg("Title: ") span.set_id('create_new_title') #span.add_style('display: none') span.add_style('padding-left: 8px') span.add(text2) div.add(span) div.add(HtmlElement.br(2)) div.add_style("width: 350px") action = ''' var top = bvr.src_el.getParent(".spt_new_item_top"); var name_el = top.getElement(".spt_new_item_name"); var title = bvr.src_el.value; var name = title.replace(/[\?.!@#$%^&*()'"]/g, ""); name = name.replace(/ /g, "_"); name = name.toLowerCase(); name_el.value = name; ''' # change the name based on the title text2.add_behavior( { 'type': 'change', 'cbjs_action': action } ) div.add("The name of the folder is a hidden name that is used by other elements to refer to uniquely to this item.<br/><br/>") text = TextWdg('new_name') text.add_class("spt_new_item_name") span = SpanWdg('Name: ') span.add(text) div.add(span) div.add(HtmlElement.br(2)) #script = "spt.side_bar.manage_section_action_cbk({'value':'predefined'},'project_view');" #link = HtmlElement.js_href(script, data='[ Predefined View ]') #div3 = DivWdg('Optional: drag existing elements from Project Views or %s into this new folder' %link.get_buffer_display()) #div.add(div3) #item_div = DivWdg(css='spt_new_item spt_side_bar_content') #div.add(item_div) div.add("<hr/>") #save_div = SpanWdg(css='med hand') #div.add(save_div) #save_div.add(IconWdg('Save Folder', IconWdg.SAVE)) save_button = ActionButtonWdg(title='Create', tip='Create a new folder') div.add(save_button) bvr = { "type": "click_up", "view": my.view, "is_personal": is_personal == 'true', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_new_item_top"); var name_el = top.getElement(".spt_new_item_name"); var name_value = name_el.value; if (name_value == "") { var title_el = top.getElement(".spt_new_item_title"); var title = title_el.value; var name = spt.convert_to_alpha_numeric(title); name_el.value = name; } if (name_value == "") { spt.alert("Please fill in a value for name."); return; } spt.side_bar.manage_section_action_cbk( { 'value':'save_folder'}, bvr.view, bvr.is_personal); ''' } save_button.add_behavior(bvr) div.add(HtmlElement.br()) elif my.type == 'new_link': div.set_attr('spt_view', 'new_link') div.add(HtmlElement.b('Create New Link')) div.add(HtmlElement.br()) item_div = DivWdg(css='spt_new_item') item_div.add_style('display: none') div.add(HtmlElement.br()) div.add(item_div) text = TextWdg('new_link_title') span = SpanWdg('Title: ') span.add(text) div.add(span) div.add(HtmlElement.br(2)) cb = CheckboxWdg('include_search_view', label='Include Saved Search') cb.set_default_checked() div.add(cb) div.add(HtmlElement.br(2)) div.add("Select a search type and view of this link") div.add(HtmlElement.br()) select = SelectWdg("new_search_type") select.add_empty_option("-- Select Search type --") security = Environment.get_security() if security.check_access("builtin", "view_site_admin", "allow"): search_types = Project.get().get_search_types(include_sthpw=True, include_config=True) else: search_types = Project.get().get_search_types() values = [x.get_value("search_type") for x in search_types] labels = ["%s (%s)" % (x.get_value("search_type"), x.get_title()) for x in search_types] values.append("CustomLayoutWdg") labels.append("CustomLayoutWdg") select.set_option("values", values) select.set_option("labels", labels) #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='new_search_type', \ # mode=select_mode) select.add_behavior({'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".new_item_panel"); var link_view_select = top.getElement(".link_view_select"); var input = spt.api.Utility.get_input(top, 'new_search_type'); var values = {'search_type': input.value, 'is_refresh': 'true'}; spt.panel.refresh(link_view_select, values);''' }) div.add(HtmlElement.br()) div.add(select) div.add(HtmlElement.br()) link_view_sel = NewLinkViewSelectWdg() div.add(HtmlElement.br()) div.add(link_view_sel) div.add(HtmlElement.br()) #select.add_behavior('change') div.add(HtmlElement.hr()) div.add(HtmlElement.br()) #save_div = DivWdg(css='med hand') #div.add(save_div) #save_button = ProdIconButtonWdg('Save Link', IconWdg.SAVE) #save_div.add(save_button) save_button = ActionButtonWdg(title='Create', tip='Create a new link') div.add(save_button) bvr = { "type": "click_up", 'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\ "'value':'save_link'},'%s', %s);" %(my.view, is_personal)} save_button.add_behavior(bvr) div.add(HtmlElement.br(1)) elif my.type == 'new_separator': div.set_attr('spt_view', 'new_separator') div.add(HtmlElement.b('Creating New Separator. . .')) div.add(HtmlElement.br()) item_div = DivWdg(css='spt_new_item') item_div.add_style('display: none') div.add(HtmlElement.br()) div.add(item_div) # since it's automated, this button is not needed """ save_div = SpanWdg(css='med hand') save_div.add(IconWdg('Save', IconWdg.SAVE)) bvr = { "type": "click_up",\ 'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\ "'value':'save_separator'},'%s');" %my.view} save_div.add_behavior(bvr) div.add(save_div) """ widget.add(div) return widget
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