def get_display(my): smenu_div = DivWdg() smenu_div.add_class( "SPT_SMENU" ) smenu_div.add_class( "SPT_SMENU_%s" % my.menu_tag_suffix ) smenu_div.set_box_shadow() smenu_div.add_border() smenu_div.add_color("background", "background") smenu_div.add_color("color", "color") smenu_div.add_behavior( { 'type': 'load', 'cbjs_action': ''' spt.dom.load_js( ["ctx_menu.js"], function() { spt.dom.load_js( ["smart_menu.js"], function() { } ) } ); ''' } ) if my.setup_cbfn: smenu_div.set_attr( "SPT_SMENU_SETUP_CBFN", my.setup_cbfn ) smenu_div.set_z_start( 300 ) #smenu_div.add_looks( "smenu border curs_default" ) # smenu_div.add_styles( "padding-top: 3px; padding-bottom: 5px;" ) m_width = my.width - 2 smenu_div.add_style( ("width: %spx" % m_width) ) smenu_div.add_style("overflow-x: hidden") icon_width = 16 icon_col_width = 0 if my.allow_icons: icon_col_width = icon_width + 2 label_width = m_width - icon_col_width - icon_width menu_table = Table() menu_table.add_styles( "text-align: left; text-indent: 3px; border-collapse: collapse;" ) #menu_table.add_color("background", "background") menu_table.add_color("color", "color") options = my.opt_spec_list opt_count = 0 if options[0].get('type') != 'title': my._add_spacer_row(menu_table, 3, icon_width, icon_col_width, label_width) """ menu_table.add_relay_behavior( { 'type': 'mouseenter', 'bvr_match_class': 'SPT_SMENU_ENTRY', 'bgcolor': menu_table.get_color("side_bar_title", -15, default="background3"), 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); bvr.src_el.setStyle("color", bvr.bgcolor); spt.smenu.entry_over( evt, bvr ); ''' } ) menu_table.add_relay_behavior( { 'type': 'mouseleave', 'bvr_match_class': 'SPT_SMENU_ENTRY', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ""); spt.smenu.entry_out( evt, bvr ); ''' } ) """ for opt in options: # if entry is a title, then add a spacer before if opt.get('type') == 'title' and opt_count: my._add_spacer_row(menu_table, 6, icon_width, icon_col_width, label_width) tbody = menu_table.add_tbody() tbody.add_style("display","table-row-group") tr = menu_table.add_row() #tr.add_looks( "smenu" ) tr.add_class( "SPT_SMENU_ENTRY" ) tr.add_class( "SPT_SMENU_ENTRY_%s" % opt['type'].upper() ) if opt.has_key('enabled_check_setup_key'): tr.set_attr( "SPT_ENABLED_CHECK_SETUP_KEY", opt.get('enabled_check_setup_key') ) if opt.has_key('hide_when_disabled') and opt.get('hide_when_disabled'): tr.set_attr( "SPT_HIDE_WHEN_DISABLED", "true" ) if opt['type'] in [ 'action', 'toggle' ]: hover_bvr = {'type':'hover', 'add_looks': 'smenu_hilite', 'cbjs_action_over': 'spt.smenu.entry_over( evt, bvr );', 'cbjs_action_out': 'spt.smenu.entry_out( evt, bvr );' } if opt.has_key('hover_bvr_cb'): hover_bvr.update( opt.get('hover_bvr_cb') ) tr.add_behavior( hover_bvr ) tr.add_class("hand") if opt['type'] == 'action': if opt.has_key('bvr_cb') and type(opt['bvr_cb']) == dict: bvr = {} bvr.update( opt['bvr_cb'] ) bvr['cbjs_action_for_menu_item'] = bvr['cbjs_action'] bvr['cbjs_action'] = 'spt.smenu.cbjs_action_wrapper( evt, bvr );' bvr.update( { 'type': 'click_up' } ) tr.add_behavior( bvr ) if opt['type'] == 'submenu': hover_bvr = { 'type': 'hover', 'add_looks': 'smenu_hilite', 'cbjs_action_over': 'spt.smenu.submenu_entry_over( evt, bvr );', 'cbjs_action_out': 'spt.smenu.submenu_entry_out( evt, bvr );', 'submenu_tag': "SPT_SMENU_%s" % opt['submenu_tag_suffix'], } if opt.has_key('hover_bvr_cb'): hover_bvr.update( opt.get('hover_bvr_cb') ) tr.add_behavior( hover_bvr ) # now trap click on submenu, so that it doesn't make the current menu disappear ... tr.add_behavior( { 'type': 'click', 'cbjs_action': ';', 'activator_type': 'smart_menu' } ) tr.add_looks( "curs_default" ) # Left icon cell ... if my.allow_icons: td = menu_table.add_cell() td.add_styles("text-align: center; vertical-align: middle; width: %spx;" % icon_col_width) #td.add_looks("smenu_icon_column") td.add_color("color", "color3") td.add_color("background", "background3") if opt.has_key( 'icon' ): icon_wdg = IconWdg("", opt['icon']) icon_wdg.add_class("SPT_ENABLED_ICON_LOOK") td.add( icon_wdg ) # if disabled: # icon_wdg.add_style( "opacity: .4" ) # icon_wdg.add_style( "filter: alpha(opacity=40)" ) # Menu option label cell ... td = menu_table.add_cell() td.add_style("width", ("%spx" % label_width)) td.add_style("height", ("%spx" % icon_col_width)) #if opt.get('type') != 'title': # td.add_style( "padding-left: 6px" ) #td.add_style( "padding-top: 2px" ) td.add_style("padding: 6px 4px") if opt.has_key( 'label' ): label_str = opt.get('label').replace('"','"') td.add_class("SPT_LABEL") td.add( label_str ) td.set_attr( "SPT_ORIG_LABEL", label_str ) #td.add_looks("fnt_text") td.add_style("font-size: 1.0em") if opt.get('type') == 'title': #td.add_looks("smenu_title") td.add_color("background", "background2") td.add_color("color", "color2") td.add_style("font-weight", "bold") td.add_style("padding", "3px") elif opt.get('type') == 'separator': hr = HtmlElement("hr") hr.add_looks( "smenu_separator" ) td.add( hr ) td.add_class("SPT_ENABLED_LOOK") # if disabled: # td.add_style( "opacity: .2" ) # td.add_style( "filter: alpha(opacity=20)" ) # Submenu arrow icon cell ... td = menu_table.add_cell() td.add_style("width", ("%spx" % icon_width)) if opt['type'] == 'submenu': icon_wdg = IconWdg("", IconWdg.ARROWHEAD_DARK_RIGHT) td.add(icon_wdg) td.add_class("SPT_ENABLED_ICON_LOOK") # extend title entry styling into the submenu arrow cell and add some spacing after if opt.get('type') == 'title': #td.add_looks("smenu_title") td.add_color("background", "background2") td.add_color("color", "color2") td.add_style("font-weight", "bold") td.add_style("padding", "3px") my._add_spacer_row(menu_table, 3, icon_width, icon_col_width, label_width) # if disabled: # td.add_style( "opacity: .4" ) # td.add_style( "filter: alpha(opacity=40)" ) opt_count += 1 my._add_spacer_row(menu_table, 5, icon_width, icon_col_width, label_width) smenu_div.add( menu_table ) smenu_div.add_style( "display: none" ) smenu_div.add_style( "position: absolute" ) return smenu_div
def get_display(self): table = Table() table.add_attr('id', 'hot_today') table.add_style('width', '100%') table.add_style('background-color', '#FCFCFC') table.add_style('font-size', '12px') table.add_style('font-family', 'Helvetica') table.add_border(style='solid', color='#F2F2F2', size='1px') # Because Tactic doesn't allow for the <thead> element (that I know of), the table header has to be split # into it's own <tbody>. Highly inelegant, but I don't have a choice. header_body = table.add_tbody() header_body.add_attr('id', 'thead-section') # Initialize the Tactic server server = TacticServerStub.get() # Get today's date as a string todays_date = datetime.datetime.today() due_date_string = todays_date.strftime('%Y-%m-%d') # Search for orders that are either due today or are past due. orders_due_today_or_earlier_list = server.eval( "@SOBJECT(twog/order['due_date', 'is before', '{0}']['@ORDER_BY', 'due_date asc'])".format( due_date_string)) orders_due_today_or_earlier_not_complete_list = [ order for order in orders_due_today_or_earlier_list if order.get('status') != 'complete' ] components_list = self.get_component_or_package_list(orders_due_today_or_earlier_not_complete_list, 'twog/component') packages_list = self.get_component_or_package_list(orders_due_today_or_earlier_not_complete_list, 'twog/package') task_list = self.get_tasks_for_search_type(components_list, 'twog/component?project=twog') task_list.extend(self.get_tasks_for_search_type(packages_list, 'twog/package?project=twog')) header_groups = self.get_header_groups(task_list) # Get the header groups as a sorted set header_groups = self.sort_header_groups(header_groups) self.set_header(table, header_groups) hotlist_body = table.add_tbody() hotlist_body.add_style('display', 'table') hotlist_body.add_style('overflow-x', 'hidden') hotlist_body.add_style('overflow-y', 'scroll') hotlist_body.add_style('height', '850px') hotlist_body.add_style('width', '100%') hotlist_body.add_attr('id', 'hotlist-body') dictionary_of_tasks = {} for task in task_list: order_sobject = get_order_sobject_from_task_sobject(task) order_code = order_sobject.get_code() process_name = task.get('process') if len(process_name.split(':')) > 1: task_header = process_name.split(':')[0] if order_code not in dictionary_of_tasks.keys(): dictionary_of_tasks[order_code] = {task_header: None} if not dictionary_of_tasks[order_code].get(task_header): dictionary_of_tasks[order_code][task_header] = [task] else: dictionary_of_tasks[order_code][task_header].append(task) counter = 1 for hot_item in orders_due_today_or_earlier_not_complete_list: # Get the tasks that correspond to a title by comparing the task's title_code to the title's code item_tasks = dictionary_of_tasks.get(hot_item.get('code')) if item_tasks: self.set_row(hot_item, table, counter, header_groups, item_tasks) counter += 1 # Put the table in a DivWdg, makes it fit better with the Tactic side bar hotlist_div = DivWdg() hotlist_div.add_attr('id', 'hotlist_div') hotlist_div.add_attr('overflow', 'hidden') hotlist_div.add(table) # Add an 'outer' div that holds the hotlist div, with the buttons below. outer_div = DivWdg() outer_div.add(hotlist_div) outer_div.add_behavior(get_scrollbar_width()) return outer_div
def get_display(self): top = self.top self.set_as_panel(top) top.add_class("spt_ingestion_top") top.add_color("background", "background", -5) self.data = {} rules_div = DivWdg() top.add(rules_div) rules_div.add_style("padding: 10px") rules_div.add("Rules: ") rules_select = SelectWdg("rule_code") rule_code = self.get_value('rule_code') if rule_code: rules_select.set_value(rule_code) rules_select.set_option("query", "config/ingest_rule|code|title") rules_select.add_empty_option("-- New --") rules_div.add(rules_select) rules_select.add_behavior( { 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var class_name = 'tactic.ui.tools.IngestionToolWdg'; spt.panel.load(top, class_name, {rule_code: value} ); ''' } ) rules_div.add("<hr/>") # read from the database if rule_code: search = Search("config/ingest_rule") search.add_filter("code", rule_code) sobject = search.get_sobject() else: sobject = None if sobject: self.data = sobject.get_value("data") if self.data: self.data = jsonloads(self.data) session_code = self.kwargs.get("session_code") if session_code: session = Search.get_by_code("config/ingest_session", session_code) else: if sobject: session = sobject.get_related_sobject("config/ingest_session") print("sobject: ", sobject.get_code(), sobject.get_value("spt_ingest_session_code")) print("parent: ", session) else: session = None if not session: #session = SearchType.create("config/ingest_session") #session.set_value("code", "session101") #session.set_value("location", "local") ##session.set_value("base_dir", "C:") top.add("No session defined!!!") return top rule = "" filter = "" ignore = "" # get the base path if sobject: base_dir = sobject.get_value("base_dir") else: base_dir = '' #else: # base_dir = self.get_value("base_dir") #if not base_dir: # base_dir = '' if sobject: title = sobject.get_value("title") else: title = '' if sobject: code = sobject.get_value("code") else: code = '' file_list = self.get_value("file_list") scan_type = self.get_value("scan_type") action_type = self.get_value("action_type") rule = self.get_value("rule") if not rule: rule = base_dir # get the rule for this path checkin_mode = "dir" depth = 0 table = Table() rules_div.add(table) table.add_color("color", "color") from tactic.ui.input.text_input_wdg import TextInputWdg # add the title table.add_row() td = table.add_cell() td.add("Title: ") td = table.add_cell() text = TextInputWdg(name="title") td.add(text) if title: text.set_value(title) text.add_class("spt_title") text.add_style("width: 400px") #text.add_color("background", "background", -10) # add the optional code table.add_row() td = table.add_cell() td.add("Code (optional): ") td = table.add_cell() text = TextInputWdg(name="code") td.add(text) if code: text.set_value(code) text.set_readonly() text.add_color("background", "background", -10) text.add_class("spt_code") text.add_style("width: 400px") table.add_row() td = table.add_cell() td.add_style("height: 10px") td.add("<hr/>") table.add_row() td = table.add_cell() td.add("<b>Scan:</b><br/>") td.add("The following information will be used to find the paths that will be operated on by the ingestion process<br/><br/>") # add a scan type table.add_row() td = table.add_cell() td.add("Type: ") select = SelectWdg("scan_type") select.add_class("spt_scan_type") td = table.add_cell() td.add(select) select.set_value( self.get_value("action") ) labels = ['Simple List', 'Rule', 'Script'] values = ['list', 'rule', 'script'] select.set_option("values", values) select.set_option("labels", labels) if scan_type: select.set_value(scan_type) table.add_row() table.add_cell(" ") select.add_behavior( { 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var elements = top.getElements(".spt_scan_list"); for (var i = 0; i < elements.length; i++) { if (value == 'list') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_scan_rule"); for (var i = 0; i < elements.length; i++) { if (value == 'rule') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_scan_script"); for (var i = 0; i < elements.length; i++) { if (value == 'script') spt.show(elements[i]); else spt.hide(elements[i]); } ''' } ) # add in a list of stuff tbody = table.add_tbody() tbody.add_class("spt_scan_list") if scan_type != 'list': tbody.add_style("display: none") tr = table.add_row() td = table.add_cell() td.add("List of files: ") td = table.add_cell() text = TextAreaWdg(name="file_list") td.add(text) text.add_style("width: 400px") #text.set_readonly() #text.add_color("background", "background", -10) text.set_value(file_list) table.close_tbody() # add rule scan mode tbody = table.add_tbody() tbody.add_class("spt_scan_rule") if scan_type != 'rule': tbody.add_style("display: none") # add the path tr = table.add_row() td = table.add_cell() td.add("Starting Path: ") td = table.add_cell() hidden = HiddenWdg("session_code", session.get_code() ) td.add(hidden) text = TextInputWdg(name="base_dir") td.add(text) text.set_value(base_dir) text.add_style("width: 400px") #text.set_readonly() #text.add_color("background", "background", -10) text.set_value(base_dir) # add rule tr = table.add_row() td = table.add_cell() td.add("Tag Rule: ") td = table.add_cell() text = TextInputWdg(name="rule") td.add(text) text.add_style("width: 400px") text.set_value(rule) tr = table.add_row() td = table.add_cell() td.add("Filter: ") td = table.add_cell() text = TextWdg("filter") td.add(text) text.set_value( self.get_value("filter") ) text.add_style("width: 400px") text.add_style("padding: 2px") text.add_style("-moz-border-radius: 5px") tr = table.add_row() td = table.add_cell() td.add("Ignore: ") td = table.add_cell() text = TextWdg("ignore") td.add(text) text.set_value( self.get_value("ignore") ) text.set_value(ignore) text.add_style("width: 400px") text.add_style("padding: 2px") text.add_style("-moz-border-radius: 5px") table.add_row() td = table.add_cell() td.add("Validation script: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextInputWdg(name="validation_script") text.set_value( self.get_value("validation_script") ) text.add_style("width: 400px") td.add(text) icon = IconButtonWdg(title='Edit Validation Script', icon=IconWdg.EDIT) icon.add_style("float: right") td.add(icon) icon.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_script_editor"); var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); var kwargs = { script_path: values.validation_script } setTimeout( function() { spt.js_edit.display_script_cbk(evt, kwargs) }, 500 ); ''' } ) table.close_tbody() # add the script path tbody = table.add_tbody() tbody.add_class("spt_scan_script") if scan_type != 'script': tbody.add_style("display: none") tr = table.add_row() td = table.add_cell() td.add("Script Path: ") td = table.add_cell() text = TextInputWdg(name="script_path") td.add(text) text.add_style("width: 400px") table.close_tbody() table.add_row() td = table.add_cell("<hr/>") table.add_row() td = table.add_cell() td.add("<b>Action</b><br/>") td.add("The following information define the actions that will be used on each matched path<br/><br/>") # pick the type of action table.add_row() td = table.add_cell() td.add("Type: ") select = SelectWdg("action_type") td = table.add_cell() td.add(select) labels = ['Checkin', 'Ignore'] values = ['checkin', 'ignore'] select.set_option("values", values) select.set_option("labels", labels) select.add_empty_option("-- Select --") if action_type: select.set_value(action_type) select.add_behavior( { 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var elements = top.getElements(".spt_action_ignore"); for (var i = 0; i < elements.length; i++) { if (value == 'ignore') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_action_checkin"); for (var i = 0; i < elements.length; i++) { if (value == 'checkin') spt.show(elements[i]); else spt.hide(elements[i]); } ''' } ) table.add_row() td = table.add_cell("<br/>") # add the script path tbody = table.add_tbody() tbody.add_class("spt_action_checkin") if action_type != 'checkin': tbody.add_style("display: none") # add the checkin type table.add_row() td = table.add_cell() td.add("Action: ") select = SelectWdg("action") td = table.add_cell() td.add(select) select.set_value( self.get_value("action") ) labels = ['File Checkin', 'Directory Checkin', 'Sequence Checkin'] values = ['file', 'directory', 'sequence', 'ignore'] select.set_option("values", values) select.set_option("labels", labels) table.add_row() td = table.add_cell() td.add("Mode: ") select = SelectWdg("mode") td = table.add_cell() td.add(select) labels = ['Copy', 'Move', 'In Place'] values = ['copy', 'move', 'inplace'] select.set_option("values", values) select.set_option("labels", labels) # add the search_type table.add_row() td = table.add_cell() td.add("sType: ") td = table.add_cell() select = SelectWdg("search_type") td.add(select) search_types = Project.get().get_search_types() values = [x.get_value("search_type") for x in search_types] select.set_option("values", values) search_type = self.kwargs.get("search_type") if search_type: select.set_value(search_type) # add the search_type table.add_row() td = table.add_cell() td.add("Context: ") td = table.add_cell() select = SelectWdg("context") td.add(select) select.set_option("values", ['publish', 'by rule', 'custom']) # add extra values extra_div = DivWdg() text = TextWdg("extra_name") text.add_attr("spt_is_multiple", "true") extra_div.add(text) extra_div.add(" = ") text = TextWdg("extra_value") extra_div.add(text) text.add_attr("spt_is_multiple", "true") template_div = DivWdg() text = TextWdg("extra_name") text.add_attr("spt_is_multiple", "true") template_div.add(text) template_div.add(" = ") text = TextWdg("extra_value") template_div.add(text) text.add_attr("spt_is_multiple", "true") table.close_tbody() table.add_row() td = table.add_cell("<br/>") table.add_row() td = table.add_cell() td.add("Extra Keywords: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("keywords") text.add_style("width: 300px") td.add(text) table.add_row() td = table.add_cell() td.add("Extra Values: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() extra_list = DynamicListWdg() td.add(extra_list) extra_list.add_item(extra_div) extra_list.add_template(template_div) table.add_row() table.add_cell(" ") table.add_row() td = table.add_cell() td.add("Process script: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("process_script") text.add_style("width: 300px") td.add(text) text.set_value( self.get_value("process_script") ) icon = IconButtonWdg(title='Edit Process Script', icon=IconWdg.EDIT) icon.add_style("float: right") td.add(icon) icon.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_script_editor"); var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); var kwargs = { script_path: values.process_script } // need to wait for this setTimeout( function() { spt.js_edit.display_script_cbk(evt, kwargs) }, 500 ); ''' } ) table.add_row() td = table.add_cell() td.add("Custom Naming: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("naming") text.add_style("width: 300px") td.add(text) table.add_row() td = table.add_cell() #td.add("<br clear='all'/>") td.add("<hr/>") behavior = { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); spt.app_busy.show("Scanning ...", values.base_dir); var class_name = 'tactic.ui.tools.IngestionProcessWdg'; var server = TacticServerStub.get(); values.mode = bvr.mode; values.is_local = 'true'; // scan client side if (values.is_local == 'true') { var base_dir = values.base_dir; var applet = spt.Applet.get(); var files = applet.list_recursive_dir(base_dir); // turn into a string var files_in_js = []; for (var i = 0; i < files.length; i++) { var file = files[i].replace(/\\\\/g, "/"); files_in_js.push( file ); } values.files = files_in_js; values.base_dir = base_dir; /* var server = TacticServerStub.get(); var handoff_dir = server.get_handoff_dir(); var applet = spt.Applet.get(); for (var i = 0; i < files_in_js.length; i++) { try { var parts = files_in_js[i].split("/"); var filename = parts[parts.length-1]; spt.app_busy.show("Copying files to handoff", filename); applet.copy_file(files_in_js[i], handoff_dir+"/"+filename); } catch(e) { log.error(e); } } */ } var info_el = top.getElement(".spt_info"); spt.panel.load(info_el, class_name, values); spt.app_busy.hide(); ''' } # Save button button = ActionButtonWdg(title="Save", tip="Save Rule") td.add(button) button.add_style("float: right") behavior['mode'] = 'save' button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); spt.app_busy.show("Saving ..."); var class_name = 'tactic.command.CheckinRuleSaveCmd'; var server = TacticServerStub.get(); server.execute_cmd(class_name, values); spt.panel.refresh(top, {}); spt.app_busy.hide(); ''' } ) # Scan button button = ActionButtonWdg(title="Scan", tip="Click to Scan") td.add(button) button.add_style("float: left") # set a limit #limit = TextWdg("limit") #td.add(limit) #text.add_style("float: left") behavior = behavior.copy() behavior['mode'] = 'scan' button.add_behavior(behavior) # Test button button = ActionButtonWdg(title="Test", tip="Do a test of this rule") td.add(button) behavior = behavior.copy() behavior['mode'] = 'test' button.add_behavior(behavior) button.add_style("float: left") # Ingest button button = ActionButtonWdg(title="Ingest", tip="Click to start ingesting") td.add(button) behavior = behavior.copy() behavior['mode'] = 'checkin' button.add_behavior(behavior) table.add_behavior( { 'type': 'listen', 'event_name': 'file_browser|select', 'cbjs_action': ''' var dirname = bvr.firing_data.dirname; var top = bvr.src_el.getParent(".spt_ingestion_top"); var kwargs = { base_dir: dirname }; spt.panel.load(top, top.getAttribute("spt_class_name"), kwargs); ''' }) top.add( self.get_info_wdg() ) return top
def get_display(my): smenu_div = DivWdg() smenu_div.add_class("SPT_SMENU") smenu_div.add_class("SPT_SMENU_%s" % my.menu_tag_suffix) smenu_div.set_box_shadow() smenu_div.add_border() smenu_div.add_color("background", "background") smenu_div.add_color("color", "color") smenu_div.add_behavior({ 'type': 'load', 'cbjs_action': ''' spt.dom.load_js( ["ctx_menu.js"], function() { spt.dom.load_js( ["smart_menu.js"], function() { } ) } ); ''' }) if my.setup_cbfn: smenu_div.set_attr("SPT_SMENU_SETUP_CBFN", my.setup_cbfn) smenu_div.set_z_start(300) #smenu_div.add_looks( "smenu border curs_default" ) # smenu_div.add_styles( "padding-top: 3px; padding-bottom: 5px;" ) m_width = my.width - 2 smenu_div.add_style(("width: %spx" % m_width)) smenu_div.add_style("overflow-x: hidden") icon_width = 16 icon_col_width = 0 if my.allow_icons: icon_col_width = icon_width + 2 label_width = m_width - icon_col_width - icon_width menu_table = Table() menu_table.add_styles( "text-align: left; text-indent: 3px; border-collapse: collapse;") #menu_table.add_color("background", "background") menu_table.add_color("color", "color") options = my.opt_spec_list opt_count = 0 if options[0].get('type') != 'title': my._add_spacer_row(menu_table, 3, icon_width, icon_col_width, label_width) """ menu_table.add_relay_behavior( { 'type': 'mouseenter', 'bvr_match_class': 'SPT_SMENU_ENTRY', 'bgcolor': menu_table.get_color("side_bar_title", -15, default="background3"), 'cbjs_action': ''' bvr.src_el.setStyle("background-color", bvr.bgcolor); bvr.src_el.setStyle("color", bvr.bgcolor); spt.smenu.entry_over( evt, bvr ); ''' } ) menu_table.add_relay_behavior( { 'type': 'mouseleave', 'bvr_match_class': 'SPT_SMENU_ENTRY', 'cbjs_action': ''' bvr.src_el.setStyle("background-color", ""); spt.smenu.entry_out( evt, bvr ); ''' } ) """ for opt in options: # if entry is a title, then add a spacer before if opt.get('type') == 'title' and opt_count: my._add_spacer_row(menu_table, 6, icon_width, icon_col_width, label_width) tbody = menu_table.add_tbody() tbody.add_style("display", "table-row-group") tr = menu_table.add_row() #tr.add_looks( "smenu" ) tr.add_class("SPT_SMENU_ENTRY") tr.add_class("SPT_SMENU_ENTRY_%s" % opt['type'].upper()) if opt.has_key('enabled_check_setup_key'): tr.set_attr("SPT_ENABLED_CHECK_SETUP_KEY", opt.get('enabled_check_setup_key')) if opt.has_key('hide_when_disabled') and opt.get( 'hide_when_disabled'): tr.set_attr("SPT_HIDE_WHEN_DISABLED", "true") if opt['type'] in ['action', 'toggle']: hover_bvr = { 'type': 'hover', 'add_looks': 'smenu_hilite', 'cbjs_action_over': 'spt.smenu.entry_over( evt, bvr );', 'cbjs_action_out': 'spt.smenu.entry_out( evt, bvr );' } if opt.has_key('hover_bvr_cb'): hover_bvr.update(opt.get('hover_bvr_cb')) tr.add_behavior(hover_bvr) tr.add_class("hand") if opt['type'] == 'action': if opt.has_key('bvr_cb') and type(opt['bvr_cb']) == dict: bvr = {} bvr.update(opt['bvr_cb']) bvr['cbjs_action_for_menu_item'] = bvr['cbjs_action'] bvr['cbjs_action'] = 'spt.smenu.cbjs_action_wrapper( evt, bvr );' bvr.update({'type': 'click_up'}) tr.add_behavior(bvr) if opt['type'] == 'submenu': hover_bvr = { 'type': 'hover', 'add_looks': 'smenu_hilite', 'cbjs_action_over': 'spt.smenu.submenu_entry_over( evt, bvr );', 'cbjs_action_out': 'spt.smenu.submenu_entry_out( evt, bvr );', 'submenu_tag': "SPT_SMENU_%s" % opt['submenu_tag_suffix'], } if opt.has_key('hover_bvr_cb'): hover_bvr.update(opt.get('hover_bvr_cb')) tr.add_behavior(hover_bvr) # now trap click on submenu, so that it doesn't make the current menu disappear ... tr.add_behavior({ 'type': 'click', 'cbjs_action': ';', 'activator_type': 'smart_menu' }) tr.add_looks("curs_default") # Left icon cell ... if my.allow_icons: td = menu_table.add_cell() td.add_styles( "text-align: center; vertical-align: middle; width: %spx;" % icon_col_width) #td.add_looks("smenu_icon_column") td.add_color("color", "color3") td.add_color("background", "background3") if opt.has_key('icon'): icon_wdg = IconWdg("", opt['icon']) icon_wdg.add_class("SPT_ENABLED_ICON_LOOK") td.add(icon_wdg) # if disabled: # icon_wdg.add_style( "opacity: .4" ) # icon_wdg.add_style( "filter: alpha(opacity=40)" ) # Menu option label cell ... td = menu_table.add_cell() td.add_style("width", ("%spx" % label_width)) td.add_style("height", ("%spx" % icon_col_width)) if opt.get('type') != 'title': td.add_style("padding-left: 6px") td.add_style("padding-top: 2px") if opt.has_key('label'): label_str = opt.get('label').replace('"', '"') td.add_class("SPT_LABEL") td.add(label_str) td.set_attr("SPT_ORIG_LABEL", label_str) #td.add_looks("fnt_text") td.add_style("font-size: 11px") if opt.get('type') == 'title': #td.add_looks("smenu_title") td.add_color("background", "background2") td.add_color("color", "color2") td.add_style("font-weight", "bold") td.add_style("padding", "3px") elif opt.get('type') == 'separator': hr = HtmlElement("hr") hr.add_looks("smenu_separator") td.add(hr) td.add_class("SPT_ENABLED_LOOK") # if disabled: # td.add_style( "opacity: .2" ) # td.add_style( "filter: alpha(opacity=20)" ) # Submenu arrow icon cell ... td = menu_table.add_cell() td.add_style("width", ("%spx" % icon_width)) if opt['type'] == 'submenu': icon_wdg = IconWdg("", IconWdg.ARROWHEAD_DARK_RIGHT) td.add(icon_wdg) td.add_class("SPT_ENABLED_ICON_LOOK") # extend title entry styling into the submenu arrow cell and add some spacing after if opt.get('type') == 'title': #td.add_looks("smenu_title") td.add_color("background", "background2") td.add_color("color", "color2") td.add_style("font-weight", "bold") td.add_style("padding", "3px") my._add_spacer_row(menu_table, 3, icon_width, icon_col_width, label_width) # if disabled: # td.add_style( "opacity: .4" ) # td.add_style( "filter: alpha(opacity=40)" ) opt_count += 1 my._add_spacer_row(menu_table, 5, icon_width, icon_col_width, label_width) smenu_div.add(menu_table) smenu_div.add_style("display: none") smenu_div.add_style("position: absolute") return smenu_div
def get_display(self): top = self.top self.set_as_panel(top) top.add_class("spt_ingestion_top") top.add_color("background", "background", -5) self.data = {} rules_div = DivWdg() top.add(rules_div) rules_div.add_style("padding: 10px") rules_div.add("Rules: ") rules_select = SelectWdg("rule_code") rule_code = self.get_value('rule_code') if rule_code: rules_select.set_value(rule_code) rules_select.set_option("query", "config/ingest_rule|code|title") rules_select.add_empty_option("-- New --") rules_div.add(rules_select) rules_select.add_behavior({ 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var class_name = 'tactic.ui.tools.IngestionToolWdg'; spt.panel.load(top, class_name, {rule_code: value} ); ''' }) rules_div.add("<hr/>") # read from the database if rule_code: search = Search("config/ingest_rule") search.add_filter("code", rule_code) sobject = search.get_sobject() else: sobject = None if sobject: self.data = sobject.get_value("data") if self.data: self.data = jsonloads(self.data) session_code = self.kwargs.get("session_code") if session_code: session = Search.get_by_code("config/ingest_session", session_code) else: if sobject: session = sobject.get_related_sobject("config/ingest_session") print("sobject: ", sobject.get_code(), sobject.get_value("spt_ingest_session_code")) print("parent: ", session) else: session = None if not session: #session = SearchType.create("config/ingest_session") #session.set_value("code", "session101") #session.set_value("location", "local") ##session.set_value("base_dir", "C:") top.add("No session defined!!!") return top rule = "" filter = "" ignore = "" # get the base path if sobject: base_dir = sobject.get_value("base_dir") else: base_dir = '' #else: # base_dir = self.get_value("base_dir") #if not base_dir: # base_dir = '' if sobject: title = sobject.get_value("title") else: title = '' if sobject: code = sobject.get_value("code") else: code = '' file_list = self.get_value("file_list") scan_type = self.get_value("scan_type") action_type = self.get_value("action_type") rule = self.get_value("rule") if not rule: rule = base_dir # get the rule for this path checkin_mode = "dir" depth = 0 table = Table() rules_div.add(table) table.add_color("color", "color") from tactic.ui.input.text_input_wdg import TextInputWdg # add the title table.add_row() td = table.add_cell() td.add("Title: ") td = table.add_cell() text = TextInputWdg(name="title") td.add(text) if title: text.set_value(title) text.add_class("spt_title") text.add_style("width: 400px") #text.add_color("background", "background", -10) # add the optional code table.add_row() td = table.add_cell() td.add("Code (optional): ") td = table.add_cell() text = TextInputWdg(name="code") td.add(text) if code: text.set_value(code) text.set_readonly() text.add_color("background", "background", -10) text.add_class("spt_code") text.add_style("width: 400px") table.add_row() td = table.add_cell() td.add_style("height: 10px") td.add("<hr/>") table.add_row() td = table.add_cell() td.add("<b>Scan:</b><br/>") td.add( "The following information will be used to find the paths that will be operated on by the ingestion process<br/><br/>" ) # add a scan type table.add_row() td = table.add_cell() td.add("Type: ") select = SelectWdg("scan_type") select.add_class("spt_scan_type") td = table.add_cell() td.add(select) select.set_value(self.get_value("action")) labels = ['Simple List', 'Rule', 'Script'] values = ['list', 'rule', 'script'] select.set_option("values", values) select.set_option("labels", labels) if scan_type: select.set_value(scan_type) table.add_row() table.add_cell(" ") select.add_behavior({ 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var elements = top.getElements(".spt_scan_list"); for (var i = 0; i < elements.length; i++) { if (value == 'list') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_scan_rule"); for (var i = 0; i < elements.length; i++) { if (value == 'rule') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_scan_script"); for (var i = 0; i < elements.length; i++) { if (value == 'script') spt.show(elements[i]); else spt.hide(elements[i]); } ''' }) # add in a list of stuff tbody = table.add_tbody() tbody.add_class("spt_scan_list") if scan_type != 'list': tbody.add_style("display: none") tr = table.add_row() td = table.add_cell() td.add("List of files: ") td = table.add_cell() text = TextAreaWdg(name="file_list") td.add(text) text.add_style("width: 400px") #text.set_readonly() #text.add_color("background", "background", -10) text.set_value(file_list) table.close_tbody() # add rule scan mode tbody = table.add_tbody() tbody.add_class("spt_scan_rule") if scan_type != 'rule': tbody.add_style("display: none") # add the path tr = table.add_row() td = table.add_cell() td.add("Starting Path: ") td = table.add_cell() hidden = HiddenWdg("session_code", session.get_code()) td.add(hidden) text = TextInputWdg(name="base_dir") td.add(text) text.set_value(base_dir) text.add_style("width: 400px") #text.set_readonly() #text.add_color("background", "background", -10) text.set_value(base_dir) # add rule tr = table.add_row() td = table.add_cell() td.add("Tag Rule: ") td = table.add_cell() text = TextInputWdg(name="rule") td.add(text) text.add_style("width: 400px") text.set_value(rule) tr = table.add_row() td = table.add_cell() td.add("Filter: ") td = table.add_cell() text = TextWdg("filter") td.add(text) text.set_value(self.get_value("filter")) text.add_style("width: 400px") text.add_style("padding: 2px") text.add_style("-moz-border-radius: 5px") tr = table.add_row() td = table.add_cell() td.add("Ignore: ") td = table.add_cell() text = TextWdg("ignore") td.add(text) text.set_value(self.get_value("ignore")) text.set_value(ignore) text.add_style("width: 400px") text.add_style("padding: 2px") text.add_style("-moz-border-radius: 5px") table.add_row() td = table.add_cell() td.add("Validation script: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextInputWdg(name="validation_script") text.set_value(self.get_value("validation_script")) text.add_style("width: 400px") td.add(text) icon = IconButtonWdg(title='Edit Validation Script', icon=IconWdg.EDIT) icon.add_style("float: right") td.add(icon) icon.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_script_editor"); var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); var kwargs = { script_path: values.validation_script } setTimeout( function() { spt.js_edit.display_script_cbk(evt, kwargs) }, 500 ); ''' }) table.close_tbody() # add the script path tbody = table.add_tbody() tbody.add_class("spt_scan_script") if scan_type != 'script': tbody.add_style("display: none") tr = table.add_row() td = table.add_cell() td.add("Script Path: ") td = table.add_cell() text = TextInputWdg(name="script_path") td.add(text) text.add_style("width: 400px") table.close_tbody() table.add_row() td = table.add_cell("<hr/>") table.add_row() td = table.add_cell() td.add("<b>Action</b><br/>") td.add( "The following information define the actions that will be used on each matched path<br/><br/>" ) # pick the type of action table.add_row() td = table.add_cell() td.add("Type: ") select = SelectWdg("action_type") td = table.add_cell() td.add(select) labels = ['Checkin', 'Ignore'] values = ['checkin', 'ignore'] select.set_option("values", values) select.set_option("labels", labels) select.add_empty_option("-- Select --") if action_type: select.set_value(action_type) select.add_behavior({ 'type': 'change', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); value = bvr.src_el.value; var elements = top.getElements(".spt_action_ignore"); for (var i = 0; i < elements.length; i++) { if (value == 'ignore') spt.show(elements[i]); else spt.hide(elements[i]); } var elements = top.getElements(".spt_action_checkin"); for (var i = 0; i < elements.length; i++) { if (value == 'checkin') spt.show(elements[i]); else spt.hide(elements[i]); } ''' }) table.add_row() td = table.add_cell("<br/>") # add the script path tbody = table.add_tbody() tbody.add_class("spt_action_checkin") if action_type != 'checkin': tbody.add_style("display: none") # add the checkin type table.add_row() td = table.add_cell() td.add("Action: ") select = SelectWdg("action") td = table.add_cell() td.add(select) select.set_value(self.get_value("action")) labels = ['File Checkin', 'Directory Checkin', 'Sequence Checkin'] values = ['file', 'directory', 'sequence', 'ignore'] select.set_option("values", values) select.set_option("labels", labels) table.add_row() td = table.add_cell() td.add("Mode: ") select = SelectWdg("mode") td = table.add_cell() td.add(select) labels = ['Copy', 'Move', 'In Place'] values = ['copy', 'move', 'inplace'] select.set_option("values", values) select.set_option("labels", labels) # add the search_type table.add_row() td = table.add_cell() td.add("sType: ") td = table.add_cell() select = SelectWdg("search_type") td.add(select) search_types = Project.get().get_search_types() values = [x.get_value("search_type") for x in search_types] select.set_option("values", values) search_type = self.kwargs.get("search_type") if search_type: select.set_value(search_type) # add the search_type table.add_row() td = table.add_cell() td.add("Context: ") td = table.add_cell() select = SelectWdg("context") td.add(select) select.set_option("values", ['publish', 'by rule', 'custom']) # add extra values extra_div = DivWdg() text = TextWdg("extra_name") text.add_attr("spt_is_multiple", "true") extra_div.add(text) extra_div.add(" = ") text = TextWdg("extra_value") extra_div.add(text) text.add_attr("spt_is_multiple", "true") template_div = DivWdg() text = TextWdg("extra_name") text.add_attr("spt_is_multiple", "true") template_div.add(text) template_div.add(" = ") text = TextWdg("extra_value") template_div.add(text) text.add_attr("spt_is_multiple", "true") table.close_tbody() table.add_row() td = table.add_cell("<br/>") table.add_row() td = table.add_cell() td.add("Extra Keywords: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("keywords") text.add_style("width: 300px") td.add(text) table.add_row() td = table.add_cell() td.add("Extra Values: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() extra_list = DynamicListWdg() td.add(extra_list) extra_list.add_item(extra_div) extra_list.add_template(template_div) table.add_row() table.add_cell(" ") table.add_row() td = table.add_cell() td.add("Process script: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("process_script") text.add_style("width: 300px") td.add(text) text.set_value(self.get_value("process_script")) icon = IconButtonWdg(title='Edit Process Script', icon=IconWdg.EDIT) icon.add_style("float: right") td.add(icon) icon.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("show_script_editor"); var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); var kwargs = { script_path: values.process_script } // need to wait for this setTimeout( function() { spt.js_edit.display_script_cbk(evt, kwargs) }, 500 ); ''' }) table.add_row() td = table.add_cell() td.add("Custom Naming: ") td.add_style("vertical-align: top") td.add_style("padding-top: 5px") td = table.add_cell() text = TextWdg("naming") text.add_style("width: 300px") td.add(text) table.add_row() td = table.add_cell() #td.add("<br clear='all'/>") td.add("<hr/>") behavior = { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); spt.app_busy.show("Scanning ...", values.base_dir); var class_name = 'tactic.ui.tools.IngestionProcessWdg'; var server = TacticServerStub.get(); values.mode = bvr.mode; values.is_local = 'true'; // scan client side if (values.is_local == 'true') { var base_dir = values.base_dir; var applet = spt.Applet.get(); var files = applet.list_recursive_dir(base_dir); // turn into a string var files_in_js = []; for (var i = 0; i < files.length; i++) { var file = files[i].replace(/\\\\/g, "/"); files_in_js.push( file ); } values.files = files_in_js; values.base_dir = base_dir; /* var server = TacticServerStub.get(); var handoff_dir = server.get_handoff_dir(); var applet = spt.Applet.get(); for (var i = 0; i < files_in_js.length; i++) { try { var parts = files_in_js[i].split("/"); var filename = parts[parts.length-1]; spt.app_busy.show("Copying files to handoff", filename); applet.copy_file(files_in_js[i], handoff_dir+"/"+filename); } catch(e) { log.error(e); } } */ } var info_el = top.getElement(".spt_info"); spt.panel.load(info_el, class_name, values); spt.app_busy.hide(); ''' } # Save button button = ActionButtonWdg(title="Save", tip="Save Rule") td.add(button) button.add_style("float: right") behavior['mode'] = 'save' button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingestion_top"); var values = spt.api.Utility.get_input_values(top, null, false); spt.app_busy.show("Saving ..."); var class_name = 'tactic.command.CheckinRuleSaveCmd'; var server = TacticServerStub.get(); server.execute_cmd(class_name, values); spt.panel.refresh(top, {}); spt.app_busy.hide(); ''' }) # Scan button button = ActionButtonWdg(title="Scan", tip="Click to Scan") td.add(button) button.add_style("float: left") # set a limit #limit = TextWdg("limit") #td.add(limit) #text.add_style("float: left") behavior = behavior.copy() behavior['mode'] = 'scan' button.add_behavior(behavior) # Test button button = ActionButtonWdg(title="Test", tip="Do a test of this rule") td.add(button) behavior = behavior.copy() behavior['mode'] = 'test' button.add_behavior(behavior) button.add_style("float: left") # Ingest button button = ActionButtonWdg(title="Ingest", tip="Click to start ingesting") td.add(button) behavior = behavior.copy() behavior['mode'] = 'checkin' button.add_behavior(behavior) table.add_behavior({ 'type': 'listen', 'event_name': 'file_browser|select', 'cbjs_action': ''' var dirname = bvr.firing_data.dirname; var top = bvr.src_el.getParent(".spt_ingestion_top"); var kwargs = { base_dir: dirname }; spt.panel.load(top, top.getAttribute("spt_class_name"), kwargs); ''' }) top.add(self.get_info_wdg()) return top
def get_display(my): #content.add_event("oncontextmenu", "spt.side_bar.manage_context_menu_action_cbk(); return false") context_menu = DivWdg() context_menu.add_class('spt_menu_top') context_menu.add_behavior({ 'type': 'load', 'cbjs_action': ''' spt.finger_menu = {}; spt.finger_menu.timeout_id = -1; ''' }) context_menu.add_behavior({ 'type': 'mouseover', 'cbjs_action': ''' if (spt.finger_menu.timeout_id != -1) { clearTimeout(spt.finger_menu.timeout_id); spt.finger_menu.timeout_id = -1; } ''' }) #context_menu.set_box_shadow(color='#fff') # this may not be needed as it is set in JS context_menu.add_style("z-index: 200") # set up what happens when the mouse leaves the actual menu my._set_menu_out(context_menu) width = my.kwargs.get('width') height = my.kwargs.get('height') if not height: height = 20 if not width: width = 35 font_size = my.kwargs.get('font_size') if not font_size: font_size = 'smaller' force = my.kwargs.get("force") if my.mode == 'horizontal': div = DivWdg(css='spt_finger_menu') if force: div.add_attr("spt_finger_force", force) div.add_style("border-color: #aaa") div.add_style("border-style: solid") if force == "left": div.add_style("border-width: 1px 0px 1px 1px") div.add_style("border-radius: 12px 0px 0px 12px") else: div.add_style("border-width: 1px 1px 1px 0px") div.add_style("border-radius: 0px 12px 12px 0px") div.set_box_shadow(value="0px 0px 2px 1px") #div.add_style("z-index: 1000") total_width = width * len(my.items) + 15 div.add_style('width', total_width) div.add_styles('height: %spx; padding: 2px;' % height) context_menu.add(div) div.add_color('background', 'background', -10) palette = div.get_palette() sb_title_bg = palette.color('side_bar_title') bg_color = div.get_color('background', -10) color = div.get_color('color') for item in my.items: mouse_enter_bvr = { 'type': 'mouseenter', 'cbjs_action': ''' bvr.src_el.setStyles({'background': '%s', 'color': 'white'})''' % sb_title_bg } mouse_leave_bvr = { 'type': 'mouseleave', 'cbjs_action': ''' bvr.src_el.setStyles({'background': '%s', 'color': '%s'})''' % (bg_color, color) } menu_item = FloatDivWdg(css='unselectable hand') menu_item.add_color('background', 'background', -10) menu_item.add(item.get_option('label')) menu_item.add_behavior(mouse_enter_bvr) menu_item.add_behavior(mouse_leave_bvr) # add the passed-in bvr bvr = item.get_option('bvr_cb') menu_item.add_behavior(bvr) menu_item.add_styles( 'margin: 0px 0 0 0; padding: 2px 0 2px 0; text-align: center; font-size: %s; width: %s; height: %spx' % (font_size, width, height - 4)) menu_item.add_behavior({ 'type': 'click_up', 'cbjs_action': '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);''' }) div.add(menu_item) else: # this width only matters in vertical mode context_menu.add_style("width: %s" % width) menu_table = Table() menu_table.add_styles( "text-align: left; text-indent: 4px; border-collapse: collapse; cell-padding: 8px; border-radius: 32px;" ) context_menu.add(menu_table) my._add_spacer_row(menu_table, 3, width) for widget in my.widgets: tbody = menu_table.add_tbody() tbody.add_style("display", "table-row-group") tr = menu_table.add_row() tr.add_looks("smenu") #tr.add_class( "SPT_SMENU_ENTRY" ) hover_bvr = {'type': 'hover', 'add_looks': 'smenu_hilite'} #'cbjs_action_over': 'spt.smenu.entry_over( evt, bvr );', #'cbjs_action_out': 'spt.smenu.entry_out( evt, bvr );' } tr.add_behavior(hover_bvr) menu_item = menu_table.add_cell() font_size = '4px' menu_item.add_styles( 'padding: 0px 0 0 6px; font-size: %s; width: %s; height: 16px' % (font_size, width)) menu_item.add_behavior({ 'type': 'click_up', 'cbjs_action': '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);''' }) menu_item.add(widget) my._add_spacer_row(menu_table, 3, width) return context_menu
def get_display(my): #content.add_event("oncontextmenu", "spt.side_bar.manage_context_menu_action_cbk(); return false") context_menu = DivWdg() context_menu.add_class('spt_menu_top') context_menu.add_behavior( { 'type': 'load', 'cbjs_action': ''' spt.finger_menu = {}; spt.finger_menu.timeout_id = -1; ''' } ) context_menu.add_behavior( { 'type': 'mouseover', 'cbjs_action': ''' if (spt.finger_menu.timeout_id != -1) { clearTimeout(spt.finger_menu.timeout_id); spt.finger_menu.timeout_id = -1; } ''' } ) #context_menu.set_box_shadow(color='#fff') # this may not be needed as it is set in JS context_menu.add_style("z-index: 200") # set up what happens when the mouse leaves the actual menu my._set_menu_out(context_menu) width = my.kwargs.get('width') height = my.kwargs.get('height') if not height: height = 20 if not width: width = 35 font_size = my.kwargs.get('font_size') if not font_size: font_size = 'smaller' force = my.kwargs.get("force") if my.mode == 'horizontal': div = DivWdg(css='spt_finger_menu') if force: div.add_attr("spt_finger_force", force) div.add_style("border-color: #aaa") div.add_style("border-style: solid") if force == "left": div.add_style("border-width: 1px 0px 1px 1px") div.add_style("border-radius: 12px 0px 0px 12px") else: div.add_style("border-width: 1px 1px 1px 0px") div.add_style("border-radius: 0px 12px 12px 0px") div.set_box_shadow(value="0px 0px 2px 1px") #div.add_style("z-index: 1000") total_width = width * len(my.items) + 15 div.add_style('width', total_width) div.add_styles('height: %spx; padding: 2px;' %height) context_menu.add(div) div.add_color('background','background', -10) palette = div.get_palette() sb_title_bg = palette.color('side_bar_title') bg_color = div.get_color('background', -10) color = div.get_color('color') for item in my.items: mouse_enter_bvr = {'type':'mouseenter', 'cbjs_action': ''' bvr.src_el.setStyles({'background': '%s', 'color': 'white'})''' %sb_title_bg} mouse_leave_bvr = {'type':'mouseleave', 'cbjs_action': ''' bvr.src_el.setStyles({'background': '%s', 'color': '%s'})''' %(bg_color, color)} menu_item = FloatDivWdg(css='unselectable hand') menu_item.add_color('background','background', -10) menu_item.add(item.get_option('label')) menu_item.add_behavior( mouse_enter_bvr ) menu_item.add_behavior( mouse_leave_bvr ) # add the passed-in bvr bvr = item.get_option('bvr_cb') menu_item.add_behavior(bvr ) menu_item.add_styles('margin: 0px 0 0 0; padding: 2px 0 2px 0; text-align: center; font-size: %s; width: %s; height: %spx'%(font_size, width, height-4)) menu_item.add_behavior({'type': 'click_up', 'cbjs_action': '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);'''}) div.add(menu_item) else: # this width only matters in vertical mode context_menu.add_style("width: %s" %width) menu_table = Table() menu_table.add_styles( "text-align: left; text-indent: 4px; border-collapse: collapse; cell-padding: 8px; border-radius: 32px;" ) context_menu.add(menu_table) my._add_spacer_row(menu_table, 3, width) for widget in my.widgets: tbody = menu_table.add_tbody() tbody.add_style("display","table-row-group") tr = menu_table.add_row() tr.add_looks( "smenu" ) #tr.add_class( "SPT_SMENU_ENTRY" ) hover_bvr = {'type':'hover', 'add_looks': 'smenu_hilite'} #'cbjs_action_over': 'spt.smenu.entry_over( evt, bvr );', #'cbjs_action_out': 'spt.smenu.entry_out( evt, bvr );' } tr.add_behavior( hover_bvr ) menu_item = menu_table.add_cell() font_size = '4px' menu_item.add_styles('padding: 0px 0 0 6px; font-size: %s; width: %s; height: 16px'%(font_size, width)) menu_item.add_behavior({'type': 'click_up', 'cbjs_action': '''var menu = bvr.src_el.getParent('.spt_menu_top'); spt.hide(menu);'''}) menu_item.add(widget) my._add_spacer_row(menu_table, 3, width) return context_menu
def get_display(self): table = Table() table.add_attr('id', 'bigboard') table.add_style('width', '100%') table.add_style('background-color', '#FCFCFC') table.add_style('font-size', '12px') table.add_style('font-family', 'Helvetica') table.add_border(style='solid', color='#F2F2F2', size='1px') # Because Tactic doesn't allow for the <thead> element (that I know of), the table header has to be split # into it's own <tbody>. Highly inelegant, but I don't have a choice. header_body = table.add_tbody() header_body.add_style('display', 'block') header_body.add_attr('id', 'thead-section') # Get the titles that fall under 'external rejection' (they need to be on the top of the board) search_for_external_rejections = Search('twog/title') search_for_external_rejections.add_filter('is_external_rejection', 'true') external_rejections_sobjects = search_for_external_rejections.get_sobjects() external_rejections = [hot_item for hot_item in external_rejections_sobjects if hot_item.get_value('status') != 'Completed'] search_in_external_rejection_database = Search('twog/external_rejection') search_in_external_rejection_database.add_filter('status', 'Open') external_rejection_title_codes = [item.get_value('title_code') for item in search_in_external_rejection_database.get_sobjects()] external_rejection_title_codes = [code for code in external_rejection_title_codes if code not in [item.get_value('code') for item in external_rejections]] search_for_external_rejection_extra_titles = Search('twog/title') search_for_external_rejection_extra_titles.add_filters('code', external_rejection_title_codes) external_rejections.extend([item for item in search_for_external_rejection_extra_titles.get_sobjects()]) # Search for titles that are marked as 'hot' search_for_hot_items = Search('twog/title') search_for_hot_items.add_filter('bigboard', True) search_for_hot_items.add_filter('is_external_rejection', 'false') search_for_hot_items.add_order_by('priority') search_for_hot_items.add_order_by('expected_delivery_date') hot_items_sobjects = search_for_hot_items.get_sobjects() hot_items = [hot_item for hot_item in hot_items_sobjects if hot_item.get_value('status') != 'Completed'] # The database query for tasks will fail if there are no external rejections being passed in, causing the # whole hotlist to crash. This if/else prevents that. if external_rejections: external_rejection_tasks = self.get_tasks(external_rejections) else: external_rejection_tasks = [] tasks = self.get_tasks(hot_items) # Current priority will be updated each time a title has a different priority from the last value current_priority = 0 title_counter = 1 # Get a list of all the users allowed to change priorities on the list. Only they will be able to see # the input box to change priority. is_admin_user = False admin_search = Search("twog/global_resource") admin_search.add_filter('name', 'Usernames Allowed Hot Today Changes') admin_search_object = admin_search.get_sobject() if admin_search_object: # The users allowed to make priority changes are stored in the 'description' section of this sobject, # in a comma separated list admin_users = admin_search_object.get_value('description').split(',') # Check if current user is in the list (no idea why you need get_login twice, but it doesn't work otherwise) if Environment.get_login().get_login() in admin_users: is_admin_user = True # 'title' is also in the headers, but since that always displays we'll leave it out here header_groups = self.get_header_groups(tasks) self.set_header(table, header_groups) hotlist_body = table.add_tbody() hotlist_body.add_style('display', 'block') hotlist_body.add_style('overflow-x', 'hidden') hotlist_body.add_style('overflow-y', 'scroll') hotlist_body.add_style('height', '850px') hotlist_body.add_style('width', '100%') hotlist_body.add_attr('id', 'hotlist-body') dictionary_of_tasks = {} dictionary_of_external_rejection_tasks = {} for task in external_rejection_tasks: task_title_code = task.get_value('title_code') task_header = task.get_value('assigned_login_group') if task_title_code not in dictionary_of_external_rejection_tasks.keys(): dictionary_of_external_rejection_tasks[task_title_code] = {task_header: None} if not dictionary_of_external_rejection_tasks[task_title_code].get(task_header): dictionary_of_external_rejection_tasks[task_title_code][task_header] = [task] else: dictionary_of_external_rejection_tasks[task_title_code][task_header].append(task) for task in tasks: task_title_code = task.get_value('title_code') task_header = task.get_value('assigned_login_group') if task_title_code not in dictionary_of_tasks.keys(): dictionary_of_tasks[task_title_code] = {task_header: None} if not dictionary_of_tasks[task_title_code].get(task_header): dictionary_of_tasks[task_title_code][task_header] = [task] else: dictionary_of_tasks[task_title_code][task_header].append(task) # Put external rejections on the board first for external_rejection in external_rejections: item_tasks = dictionary_of_external_rejection_tasks.get(external_rejection.get_value('code')) self.set_row(external_rejection, table, title_counter, header_groups, item_tasks, current_priority, is_admin_user, True) title_counter += 1 for hot_item in hot_items: hot_item_priority = float(hot_item.get_value('priority')) # Get the tasks that correspond to a title by comparing the task's title_code to the title's code # item_tasks = (task for task in tasks if task.get_value('title_code') == hot_item.get_value('code')) item_tasks = dictionary_of_tasks.get(hot_item.get_value('code')) # If an item requires QC Mastering, it should go on the hot board, regardless of if it has tasks or not requires_mastering_qc = hot_item.get_value('requires_mastering_qc', False) if item_tasks or requires_mastering_qc: if current_priority < hot_item_priority: self.set_priority_row(table, hot_item_priority) current_priority = hot_item_priority self.set_row(hot_item, table, title_counter, header_groups, item_tasks, current_priority, is_admin_user) title_counter += 1 # Put the table in a DivWdg, makes it fit better with the Tactic side bar hotlist_div = DivWdg() hotlist_div.add_attr('id', 'hotlist_div') hotlist_div.add_style('height', '900px') hotlist_div.add_attr('overflow', 'hidden') hotlist_div.add(table) # Add an 'outer' div that holds the hotlist div, with the buttons below. outer_div = DivWdg() outer_div.add(hotlist_div) outer_div.add(self.get_buttons(is_admin_user)) outer_div.add_behavior(get_scrollbar_width()) return outer_div