def get_title(self): if self.title: title = self.title title = title.replace(r'\n', '<br/>') if self.title.find("->") != -1: parts = self.title.split("->") title = parts[-1] else: title = self.name if self.name.find("->") != -1: parts = self.name.split("->") title = parts[-1] if not title: title = "" else: title = Common.get_display_title(title) title = _(title) from pyasm.web import DivWdg div = DivWdg() div.add_attr("title", title) div.add_style("margin-top", "6px") div.add(title) return div
def get_display(my): sobject = my.get_current_sobject() first_name = sobject.get_value("first_name") last_name = sobject.get_value("last_name") div = DivWdg() div.add("%s %s" % (first_name, last_name) ) div.add("<a target='_blank' href='/tactic/ziryab/link/reports_homepage'>Graph</a> ") info_div = DivWdg() #info_div.add( sobject.get_name() ) #info_div.add( " <i style='font-size: 0.8em; opacity: 0.5'>(%s)</i>" % sobject.get_code() ) #info_div.add("<hr/>") info_div.add_attr("spt_search_key", '/tactic/ziryab/link/reports_homepage') info_div.add("<a href='%s' target='_blank'>" % '/tactic/ziryab/link/reports_homepage') info_div.add("%s %s" % (first_name, last_name)) info_div.add(" <i style='opacity: 0.5; font-size: 0.8em'> - ") info_div.add("Foo Bar") info_div.add(" (v%0.3d)" % 7) info_div.add("</i></a><br/>") return info_div
def get_menu_item(my, element_name, display_handler): content = DivWdg() content.add_attr("spt_element_name", element_name) content.add_class("hand") # add the drag/drop behavior behavior = { "type": 'drag', "mouse_btn": 'LMB', "modkeys": '', "src_el": '@', "cbfn_setup": 'spt.side_bar.pp_setup', "cbfn_motion": 'spt.side_bar.pp_motion', "cbfn_action": 'spt.side_bar.pp_action', } content.add_behavior(behavior) content.set_id("manage_%s" % element_name) content.add_style("position: relative") content.add_style("margin: 3px") content.add_style("left: 0") content.add_style("top: 0") content.add_style("z-index: 100") if display_handler == "SeparatorWdg": content.add(HtmlElement.hr()) else: content.add(element_name) return content
def add_dummy(my, config, subsection_div): div = DivWdg() div.add_attr("spt_view", config.get_view() ) div.add_class("spt_side_bar_element") div.add_class("spt_side_bar_dummy") div.add( my.get_drop_wdg() ) subsection_div.add(div)
def add_dummy(self, config, subsection_div): div = DivWdg() div.add_attr("spt_view", config.get_view()) div.add_class("spt_side_bar_element") div.add_class("spt_side_bar_dummy") div.add(self.get_drop_wdg()) subsection_div.add(div)
def get_menu_item(my, element_name, display_handler): content = DivWdg() content.add_attr("spt_element_name", element_name) content.add_class("hand") # add the drag/drop behavior behavior = { "type": "drag", "mouse_btn": "LMB", "modkeys": "", "src_el": "@", "cbfn_setup": "spt.side_bar.pp_setup", "cbfn_motion": "spt.side_bar.pp_motion", "cbfn_action": "spt.side_bar.pp_action", } content.add_behavior(behavior) content.set_id("manage_%s" % element_name) content.add_style("position: relative") content.add_style("margin: 3px") content.add_style("left: 0") content.add_style("top: 0") content.add_style("z-index: 100") if display_handler == "SeparatorWdg": content.add(HtmlElement.hr()) else: content.add(element_name) return content
def get_title(self): if self.title: title = self.title title = title.replace(r'\n','<br/>') if self.title.find("->") != -1: parts = self.title.split("->") title = parts[-1] else: title = self.name if self.name.find("->") != -1: parts = self.name.split("->") title = parts[-1] if not title: title = "" else: title = Common.get_display_title(title) title = _(title) from pyasm.web import DivWdg div = DivWdg() div.add_attr("title", title) div.add_style("margin-top", "6px") div.add(title) return div
def get_display(my): width = my.kwargs.get("width") if not width: width = "100%" height = my.kwargs.get("height") sobject = my.get_current_sobject() div = DivWdg() div.add_class("spt_thumb_top") path = my.path if path: img = HtmlElement.img(src=path) else: search_type = sobject.get_search_type_obj() path = my.get_path_from_sobject(search_type) if path: img = DivWdg() img.add_style("opacity: 0.2") img_inner = HtmlElement.img(src=path) img.add(img_inner) img_inner.add_style("width: %s" % width) if path and path.startswith("/context"): img.add_style("padding: 10px 15%") img.add_style("width: 70%") elif path: img.add_style("width: %s" % width) if height: img.add_style("height: %s" % height) img.add_style('margin-left','auto') img.add_style('margin-right','auto') if not path: img = DivWdg() img.add_class("spt_image") div.add(img) if height or my.show_name_hover in ["True","true",True]: div.add_style("height: 100%") if my.show_name_hover in ["True","true",True]: name_hover = DivWdg() name_hover.add_class("spt_name_hover") name_hover.add(sobject.get('name')) name_hover.add_attr('onmouseenter',"this.setStyle('opacity',1)") name_hover.add_attr('onmouseleave',"this.setStyle('opacity',0)") name_hover.add_styles('opacity: 0; font-size: 16px; color: rgb(217, 217, 217); top: 0px; \ transition: opacity 0s ease-out; -webkit-transition: opacity 0s ease-out; \ height: 100%; width: 100%; position: absolute; padding-top: 20px; \ text-align: center; background-color: rgba(0, 0, 0, 0.6);') div.add(name_hover) return div
def get_item_div(self, sobject): ''' get the item div the sobject''' top = DivWdg() top.add_style("padding: 3px 2px") top.add_class("spt_drop_item") top.add_class("SPT_DROP_ITEM") item_div = DivWdg() top.add(item_div, "item_div") item_div.add_style("text-overflow: ellipsis") item_div.add_style("white-space: nowrap") item_div.add_style("width: 80%") item_div.add_attr('title','Click to remove') item_div.add_style("display", "inline-block") item_div.add_style("vertical-align", "top") item_div.add_style("overflow", "hidden") icon_div = DivWdg() top.add(icon_div) icon = IconWdg(icon="BS_REMOVE") icon_div.add(icon) icon_div.add_behavior( { 'type': 'click_up', #'cbjs_action': '''spt.dg_table_action.sobject_drop_remove(evt,bvr)''' 'cbjs_action': '''spt.drop.sobject_drop_remove(evt,bvr)''' } ) icon.add_style("opacity: 0.3") icon_div.add_class("hand") icon_div.add_style("display", "inline-block") icon_div.add_style("vertical-align", "top") #icon_div.add_border() #self.menu.set_over(item_div, event="mousein") #self.menu.set_out(top, event="mouseleave") # set this as the place for the display value to go item_div.add_class("spt_drop_display_value") add_icon = True ExpressionParser.clear_cache() if sobject: if add_icon: self._add_icon(sobject, item_div) if self.display_expr: display_value = Search.eval(self.display_expr, sobjects = sobject, single=True) else: display_value = sobject.get_display_value() if isinstance(display_value, list): display_value = display_value[0] item_div.add( display_value ) self.values.append( SearchKey.get_by_sobject(sobject) ) return top
def get_item_div(my, sobject): ''' get the item div the sobject''' top = DivWdg() top.add_style("padding: 3px 2px") top.add_class("spt_drop_item") top.add_class("SPT_DROP_ITEM") item_div = DivWdg() top.add(item_div, "item_div") item_div.add_style("text-overflow: ellipsis") item_div.add_style("white-space: nowrap") item_div.add_style("width: 80%") item_div.add_attr('title', 'Click to remove') item_div.add_style("display", "inline-block") item_div.add_style("vertical-align", "top") item_div.add_style("overflow", "hidden") icon_div = DivWdg() top.add(icon_div) icon = IconWdg(icon="BS_REMOVE") icon_div.add(icon) icon_div.add_behavior({ 'type': 'click_up', #'cbjs_action': '''spt.dg_table_action.sobject_drop_remove(evt,bvr)''' 'cbjs_action': '''spt.drop.sobject_drop_remove(evt,bvr)''' }) icon.add_style("opacity: 0.3") icon_div.add_class("hand") icon_div.add_style("display", "inline-block") icon_div.add_style("vertical-align", "top") #icon_div.add_border() #my.menu.set_over(item_div, event="mousein") #my.menu.set_out(top, event="mouseleave") # set this as the place for the display value to go item_div.add_class("spt_drop_display_value") add_icon = True ExpressionParser.clear_cache() if sobject: if add_icon: my._add_icon(sobject, item_div) if my.display_expr: display_value = Search.eval(my.display_expr, sobjects=sobject, single=True) else: display_value = sobject.get_display_value() if isinstance(display_value, list): display_value = display_value[0] item_div.add(display_value) my.values.append(SearchKey.get_by_sobject(sobject)) return top
def get_filter_wdg(self, filter_name): if not filter_name: filter_name = self.get_name() from pyasm.web import DivWdg from tactic.ui.widget import IconButtonWdg filter_wdg = DivWdg() button = IconButtonWdg(title="Show Filter", icon="BS_SEARCH") filter_wdg.add_class("spt_filter_button") filter_wdg.add(button) filter_wdg.add_style("display: inline-block") filter_wdg.add_style("vertical-align: middle") filter_wdg.add_style("opacity: 0.5") filter_wdg.add_attr("spt_filter_name", filter_name) filter_wdg.add_behavior( { 'type': 'click', 'cbjs_action': ''' var panel = bvr.src_el.getParent(".spt_view_panel_top"); var th = bvr.src_el.getParent("th"); var pos = th.getPosition(panel); var name = bvr.src_el.getAttribute("spt_filter_name"); if (! spt.simple_search.has_element(name) ) { return; } pos.y += 35; spt.simple_search.show_elements([name]); spt.simple_search.set_position(pos); spt.simple_search.hide_title(); spt.simple_search.show(); var top = spt.simple_search.get_top(); var size = top.getSize(); var cur_pos = top.getPosition( $(document.body) ); var window_size = $(document.body).getSize(); if (cur_pos.x + size.x > window_size.x) { var panel_size = panel.getSize(); pos.x = panel_size.x - size.x; spt.simple_search.set_position(pos); } ''' } ) return filter_wdg
def get_filter_wdg(self, filter_name): if not filter_name: filter_name = self.get_name() from pyasm.web import DivWdg from tactic.ui.widget import IconButtonWdg filter_wdg = DivWdg() button = IconButtonWdg(title="Show Filter", icon="BS_SEARCH") filter_wdg.add_class("spt_filter_button") filter_wdg.add(button) filter_wdg.add_style("display: inline-block") filter_wdg.add_style("vertical-align: middle") filter_wdg.add_style("opacity: 0.5") filter_wdg.add_attr("spt_filter_name", filter_name) filter_wdg.add_behavior({ 'type': 'click', 'cbjs_action': ''' var panel = bvr.src_el.getParent(".spt_view_panel_top"); var th = bvr.src_el.getParent("th"); var pos = th.getPosition(panel); var name = bvr.src_el.getAttribute("spt_filter_name"); if (! spt.simple_search.has_element(name) ) { return; } pos.y += 35; spt.simple_search.show_elements([name]); spt.simple_search.set_position(pos); spt.simple_search.hide_title(); spt.simple_search.show(); var top = spt.simple_search.get_top(); var size = top.getSize(); var cur_pos = top.getPosition( $(document.body) ); var window_size = $(document.body).getSize(); if (cur_pos.x + size.x > window_size.x) { var panel_size = panel.getSize(); pos.x = panel_size.x - size.x; spt.simple_search.set_position(pos); } ''' }) return filter_wdg
def get_display(my): widget = DivWdg() pipeline_code = my.get_option('pipeline') pipeline = Pipeline.get_by_code(pipeline_code) if not pipeline: widget.add("No pipeline defined") return widget processes = pipeline.get_process_names() widget.add_style("border: solid 1px blue") widget.add_style("position: absolute") widget.add_style("top: 300") widget.add_style("left: -500") for process in processes: #inputs = pipeline.get_input_processes(process) outputs = pipeline.get_output_processes(process) div = DivWdg() widget.add(div) div.add_class("spt_input_option") div.add_attr("spt_input_key", process) #if not outputs: # # then we can't go anywhere, so just add a message # text = "" # div.add(text) # continue values = [] #values.extend( [str(x) for x in inputs] ) values.append(process) values.extend( [str(x) for x in outputs] ) select = SelectWdg(my.get_input_name()) select.set_value(process) select.add_empty_option('-- Select --') select.set_option("values", values) div.add(select) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) return widget
def get_display(self): widget = DivWdg() pipeline_code = self.get_option('pipeline') pipeline = Pipeline.get_by_code(pipeline_code) if not pipeline: widget.add("No pipeline defined") return widget processes = pipeline.get_process_names() widget.add_style("border: solid 1px blue") widget.add_style("position: absolute") widget.add_style("top: 300") widget.add_style("left: -500") for process in processes: #inputs = pipeline.get_input_processes(process) outputs = pipeline.get_output_processes(process) div = DivWdg() widget.add(div) div.add_class("spt_input_option") div.add_attr("spt_input_key", process) #if not outputs: # # then we can't go anywhere, so just add a message # text = "" # div.add(text) # continue values = [] #values.extend( [str(x) for x in inputs] ) values.append(process) values.extend( [str(x) for x in outputs] ) select = SelectWdg(self.get_input_name()) select.set_value(process) select.add_empty_option('-- Select --') select.set_option("values", values) div.add(select) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) return widget
def get_logins_wdg(self, logins): logins_div = DivWdg() for login in logins: login_div = DivWdg() logins_div.add(login_div) login_div.add_style("padding: 5px") #login_div.add_style("height: 30px") login_div.add_style("margin: 0 5px 5px 0") login_div.add_attr("spt_login", login.get_value("login")) thumb_div = DivWdg() login_div.add(thumb_div) thumb_div.add_style("float: left") thumb_div.add_style("margin-right: 5px") thumb_div.add_style("padding-top: 1px") thumb = ThumbWdg() thumb.set_sobject(login) thumb_div.add(thumb) thumb.set_icon_size(15) login_div.add(login.get_full_name()) login_div.add_behavior({ 'type': 'click_up', 'sobject_display_expr': self.sobject_display_expr, 'tab_view': self.tab_view, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_schedule_top"); var class_name = 'tactic.ui.tools.schedule_wdg.ScheduleUserToolWdg'; var login = bvr.src_el.getAttribute("spt_login") var kwargs = { login: login }; if (bvr.sobject_display_expr) kwargs['sobject_display_expr'] = bvr.sobject_display_expr; if (bvr.tab_view) kwargs['tab_view'] = bvr.tab_view; var content = top.getElement(".spt_schedule_content"); spt.panel.load(content, class_name, kwargs); ''' }) login_div.add_hover() return logins_div
def get_otherdb_wdg(my): div = DivWdg() div.add_class("spt_db_options") div.add_attr("spt_vendor", "Other") div.add_style("margin: 20px") table = Table() div.add(table) table.add_color("color", "color") table.add_row() table.add_cell("Server: ") text = TextInputWdg(name="server") text.set_value("localhost") table.add_cell(text) server = Config.get_value("database", "server") if server: text.set_value(server) table.add_row() table.add_cell("Port: ") text = TextInputWdg(name="port") table.add_cell(text) port = Config.get_value("database", "port") if port: text.set_value(port) table.add_row() table.add_cell("Login: "******"user") table.add_cell(text) user = Config.get_value("database", "user") if user: text.set_value(user) table.add_row() text = PasswordInputWdg(name="password") table.add_cell("Password: "******"database", "password") if password: text.set_value(password) #from pyasm.search import Sql #sql.connect() return div
def get_logins_wdg(my, logins): logins_div = DivWdg() for login in logins: login_div = DivWdg() logins_div.add(login_div) login_div.add_style("padding: 5px") # login_div.add_style("height: 30px") login_div.add_style("margin: 0 5px 5px 0") login_div.add_attr("spt_login", login.get_value("login")) thumb_div = DivWdg() login_div.add(thumb_div) thumb_div.add_style("float: left") thumb_div.add_style("margin-right: 5px") thumb_div.add_style("padding-top: 1px") thumb = ThumbWdg() thumb.set_sobject(login) thumb_div.add(thumb) thumb.set_icon_size(15) login_div.add(login.get_full_name()) login_div.add_behavior( { "type": "click_up", "sobject_display_expr": my.sobject_display_expr, "tab_view": my.tab_view, "cbjs_action": """ var top = bvr.src_el.getParent(".spt_schedule_top"); var class_name = 'tactic.ui.tools.schedule_wdg.ScheduleUserToolWdg'; var login = bvr.src_el.getAttribute("spt_login") var kwargs = { login: login }; if (bvr.sobject_display_expr) kwargs['sobject_display_expr'] = bvr.sobject_display_expr; if (bvr.tab_view) kwargs['tab_view'] = bvr.tab_view; var content = top.getElement(".spt_schedule_content"); spt.panel.load(content, class_name, kwargs); """, } ) login_div.add_hover() return logins_div
def get_section_wdg(my, title, description, image, behavior): section_wdg = DivWdg() section_wdg.set_round_corners() section_wdg.add_border() section_wdg.add_style("width: 120px") section_wdg.add_style("height: 100px") section_wdg.add_style("overflow: hidden") section_wdg.add_style("margin: 5px") section_wdg.set_box_shadow("0px 0px 10px") title_wdg = DivWdg() section_wdg.add(title_wdg) title_wdg.add(title) title_wdg.add_style("height: 20px") title_wdg.add_style("padding: 3px") title_wdg.add_style("margin-top: 0px") title_wdg.add_style("font-weight: bold") title_wdg.add_color("background", "background", -10) section_wdg.add_color("background", "background") #section_wdg.add_gradient("background", "background", 0, -3) section_wdg.add_behavior({ 'type': 'hover', 'add_color_modifier': -5, 'cb_set_prefix': 'spt.mouse.table_layout_hover', }) """ desc_div = DivWdg() desc_div.add(description) desc_div.add_style("padding: 5px 10px 10px 5px") """ div = DivWdg() section_wdg.add(div) div.add_style("margin-top: 20px") div.center() div.add_style("width: 32px") div.add(image) section_wdg.add_behavior(behavior) section_wdg.add_class("hand") section_wdg.add_attr('title', description) return section_wdg
def get_section_wdg(self, title, description, image, behavior): section_wdg = DivWdg() section_wdg.set_round_corners() section_wdg.add_border() section_wdg.add_style("width: 120px") section_wdg.add_style("height: 100px") section_wdg.add_style("overflow: hidden") section_wdg.add_style("margin: 5px") section_wdg.set_box_shadow("0px 0px 10px") title_wdg = DivWdg() section_wdg.add(title_wdg) title_wdg.add(title) title_wdg.add_style("height: 20px") title_wdg.add_style("padding: 3px") title_wdg.add_style("margin-top: 0px") title_wdg.add_style("font-weight: bold") title_wdg.add_color("background", "background", -10) section_wdg.add_color("background", "background") #section_wdg.add_gradient("background", "background", 0, -3) section_wdg.add_behavior( { 'type': 'hover', 'add_color_modifier': -5, 'cb_set_prefix': 'spt.mouse.table_layout_hover', } ) """ desc_div = DivWdg() desc_div.add(description) desc_div.add_style("padding: 5px 10px 10px 5px") """ div = DivWdg() section_wdg.add(div) div.add_style("margin-top: 20px") div.center() div.add_style("width: 32px") div.add(image) section_wdg.add_behavior( behavior ) section_wdg.add_class("hand") section_wdg.add_attr('title', description) return section_wdg
def get_sqlite_wdg(my): div = DivWdg() div.add_class("spt_db_options") div.add_attr("spt_vendor", "Sqlite") div.add_style("padding: 20px") div.add("Database Folder: ") text = TextInputWdg(name="database/sqlite_db_dir") div.add(text) db_dir = Config.get_value("database", "sqlite_db_dir") if not db_dir: data_dir = Environment.get_data_dir() db_dir = "%s/db" % data_dir text.set_value(db_dir) return div
def get_item_div(my, sobject): ''' get the item div the sobject''' top = DivWdg() top.add_attr('title', 'Click to remove') # FIXME: put this here for now top.add_behavior({ 'type': 'click_up', #'cbjs_action': '''spt.dg_table_action.sobject_drop_remove(evt,bvr)''' 'cbjs_action': '''spt.drop.sobject_drop_remove(evt,bvr)''' }) top.add_class("spt_drop_item") top.add_class("SPT_DROP_ITEM") item_div = DivWdg() item_div.add_class("hand") item_div.add_style("float: clear") top.add(item_div, "item_div") #my.menu.set_over(item_div, event="mousein") #my.menu.set_out(top, event="mouseleave") # set this as the place for the display value to go item_div.add_class("spt_drop_display_value") add_icon = True ExpressionParser.clear_cache() if sobject: if add_icon: my._add_icon(sobject, item_div) if my.display_expr: display_value = Search.eval(my.display_expr, sobjects=sobject, single=True) else: display_value = sobject.get_display_value() if isinstance(display_value, list): display_value = display_value[0] item_div.add(display_value) my.values.append(SearchKey.get_by_sobject(sobject)) return top
def get_item_div(my, sobject): ''' get the item div the sobject''' top = DivWdg() top.add_style("padding: 3px 2px") top.add_attr('title','Click to remove') # FIXME: put this here for now top.add_behavior( { 'type': 'click_up', #'cbjs_action': '''spt.dg_table_action.sobject_drop_remove(evt,bvr)''' 'cbjs_action': '''spt.drop.sobject_drop_remove(evt,bvr)''' } ) top.add_class("spt_drop_item") top.add_class("SPT_DROP_ITEM") item_div = DivWdg() item_div.add_class("hand") item_div.add_style("float: clear") top.add(item_div, "item_div") #my.menu.set_over(item_div, event="mousein") #my.menu.set_out(top, event="mouseleave") # set this as the place for the display value to go item_div.add_class("spt_drop_display_value") add_icon = True ExpressionParser.clear_cache() if sobject: if add_icon: my._add_icon(sobject, item_div) if my.display_expr: display_value = Search.eval(my.display_expr, sobjects = sobject, single=True) else: display_value = sobject.get_display_value() if isinstance(display_value, list): display_value = display_value[0] item_div.add( display_value ) my.values.append( SearchKey.get_by_sobject(sobject) ) return top
def get_display(my): top = DivWdg() top.add_color("color", "color") #top.add_color("background", "background") top.add_class("spt_simple_upload_top") top.add(my.browse) hidden = HiddenWdg( "%s|path" % my.get_input_name() ) hidden.add_class("spt_upload_hidden") top.add(hidden) # this can be used for some other transaction that picks up this file to checkin hidden = HiddenWdg( "%s|ticket" % my.get_input_name() ) hidden.add_class("spt_upload_ticket") top.add(hidden) # if not specified, get the sobject's icon context my.context = my.kwargs.get("context") if not my.context: current = my.get_current_sobject() if current: my.context = current.get_icon_context() else: from pyasm.biz import Snapshot my.context = Snapshot.get_default_context() top.add_attr("spt_context", my.context) top.add( my.get_info_wdg() ) files_div = DivWdg() top.add(files_div) files_div.add_class("spt_upload_files") files_div.add_style("font-size: 11px") files_div.add_style("margin-top: 10px") my.add_action() return top
def get_title(my): if my.title: title = my.title title = title.replace(r'\n','<br/>') else: title = my.name if not title: title = "" else: title = Common.get_display_title(title) from pyasm.web import DivWdg div = DivWdg() div.add_attr("title", title) div.add(title) return div # FIXME: not sure about autofit here? This should be a mode """
def get_title(my): if my.title: title = my.title title = title.replace(r'\n','<br/>') else: title = my.name if not title: title = "" else: title = Common.get_display_title(title) title = _(title) from pyasm.web import DivWdg div = DivWdg() div.add_attr("title", title) div.add(title) return div
def get_title(my): if my.title: title = my.title title = title.replace(r'\n', '<br/>') else: title = my.name if not title: title = "" else: title = Common.get_display_title(title) title = _(title) from pyasm.web import DivWdg div = DivWdg() div.add_attr("title", title) div.add(title) return div
def get_display(my): top = DivWdg() top.add_color("color", "color") #top.add_color("background", "background") top.add_class("spt_simple_upload_top") top.add(my.browse) hidden = HiddenWdg("%s|path" % my.get_input_name()) hidden.add_class("spt_upload_hidden") top.add(hidden) # this can be used for some other transaction that picks up this file to checkin hidden = HiddenWdg("%s|ticket" % my.get_input_name()) hidden.add_class("spt_upload_ticket") top.add(hidden) # if not specified, get the sobject's icon context my.context = my.kwargs.get("context") if not my.context: current = my.get_current_sobject() if current: my.context = current.get_icon_context() else: from pyasm.biz import Snapshot my.context = Snapshot.get_default_context() top.add_attr("spt_context", my.context) top.add(my.get_info_wdg()) files_div = DivWdg() top.add(files_div) files_div.add_class("spt_upload_files") files_div.add_style("font-size: 11px") files_div.add_style("margin-top: 10px") my.add_action() return top
def get_display(self): top = DivWdg() top.add_class("spt_input_top") div = DivWdg() div.add_class("spt_input_option") key = 'main' div.add_attr("spt_input_key", key) query = self.kwargs.get("query"); query_filter = self.kwargs.get("query_filter"); input_name = self.kwargs.get("name"); select = SelectWdg(input_name) select.add_empty_option('-- Select --') values = self.kwargs.get("values") if values: select.set_option("values", values) labels = self.kwargs.get("labels") if labels: select.set_option("labels", labels) else: select.set_option("query", query) select.set_option("query_filter", query_filter) div.add(select) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) top.add(div) return top
def get_display(my): top = DivWdg() top.add_class("spt_input_top") div = DivWdg() div.add_class("spt_input_option") key = 'main' div.add_attr("spt_input_key", key) query = my.kwargs.get("query"); query_filter = my.kwargs.get("query_filter"); input_name = my.kwargs.get("name"); select = SelectWdg(input_name) select.add_empty_option('-- Select --') values = my.kwargs.get("values") if values: select.set_option("values", values) labels = my.kwargs.get("labels") if labels: select.set_option("labels", labels) else: select.set_option("query", query) select.set_option("query_filter", query_filter) div.add(select) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) top.add(div) return top
def get_item_wdg(my, sobject): div = DivWdg() div.add_class("spt_item_top") div.add_style("padding: 10px") SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' ) div.add_class("spt_table_row") div.add_attr("spt_search_key", sobject.get_search_key(use_id=True)) div.add_attr("spt_search_code", sobject.get_code()) name = sobject.get_value("name", no_exception=True) if not name: name = sobject.get_code() div.add_attr("spt_name", name) table = Table() div.add(table) table.set_max_width() tr = table.add_row() width = my.kwargs.get("preview_width") if not width: width = "240px" td = table.add_cell() td.add_style("width: %s" % width); td.add_style("vertical-align: top") """ from tile_layout_wdg import ThumbWdg2 thumb_div = DivWdg() #td.add(thumb_div) thumb_div.add_border() thumb_div.set_box_shadow("0px 0px 5px") thumb_div.add_color("background", "background", -5) thumb_div.add_class("spt_item_content") #thumb_div.add_style("min-height: 120px") thumb = ThumbWdg2() thumb_div.add(thumb) thumb.set_sobject(sobject) """ tile_wdg = my.tile_layout.get_tile_wdg(sobject) td.add(tile_wdg) info_div = my.get_info_wdg(sobject) td = table.add_cell(info_div) td.add_style("vertical-align: top") return div
def get_display(my): from calendar_wdg import CalendarInputWdg top = DivWdg() top.add_class("spt_input_top") if not my.calendar_key: my.calendar_key = 'read' top.add_attr("spt_cbjs_get_input_key", \ "var value=spt.dg_table.get_element_value(cell_to_edit, '%s'); return value" %my.get_name()) #top.add_style("background: black") # put in a default default_sel = SelectWdg(my.get_name()) for key, value in my.kwargs.items(): default_sel.set_option(key, value) sel_div = DivWdg(css='spt_input_option') sel_div.add_attr("spt_input_key", "default") #default_div.add("No options for selected [%s]" % depend_element) sel_div.add(default_sel) top.add(sel_div) cal = CalendarInputWdg(my.get_name()) cal_div = DivWdg(css='spt_input_option') cal_div.add_attr("spt_input_key", my.calendar_key) cal_div.add(cal) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(default_sel) top.add(cal_div) return top
def get_display(self): from calendar_wdg import CalendarInputWdg top = DivWdg() top.add_class("spt_input_top") if not self.calendar_key: self.calendar_key = 'read' top.add_attr("spt_cbjs_get_input_key", \ "var value=spt.dg_table.get_element_value(cell_to_edit, '%s'); return value" %self.get_name()) #top.add_style("background: black") # put in a default default_sel = SelectWdg(self.get_name()) for key, value in self.kwargs.items(): default_sel.set_option(key, value) sel_div = DivWdg(css='spt_input_option') sel_div.add_attr("spt_input_key", "default") #default_div.add("No options for selected [%s]" % depend_element) sel_div.add(default_sel) top.add(sel_div) cal = CalendarInputWdg(self.get_name()) cal_div = DivWdg(css='spt_input_option') cal_div.add_attr("spt_input_key", self.calendar_key) cal_div.add(cal) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(default_sel) top.add(cal_div) return top
def get_display(my): my.sobject = my.get_sobject() top = DivWdg() top.add_class("spt_detail_top") top.add_color("background", "background") top.add_color("color", "color") if not my.sobject: top.add("No SObject defined for this widget") return top if my.parent: my.search_type = my.parent.get_base_search_type() my.search_key = SearchKey.get_by_sobject(my.parent) top.add_attr("spt_parent_key", my.search_key) my.pipeline_code = my.parent.get_value("pipeline_code", no_exception=True) my.full_search_type = my.parent.get_search_type() else: my.pipeline_code = my.sobject.get_value("pipeline_code", no_exception=True) my.search_type = my.sobject.get_base_search_type() my.search_key = SearchKey.get_by_sobject(my.sobject) my.full_search_type = my.sobject.get_search_type() if not my.pipeline_code: my.pipeline_code = 'default' top.add_style("text-align: left") my.set_as_panel(top) table = Table() #from tactic.ui.container import ResizableTableWdg #table = ResizableTableWdg() table.add_color("background", "background") table.add_color("color", "color") top.add(table) table.set_max_width() table.add_row() # left #td = table.add_cell(resize=False) td = table.add_cell() #td.add_style("padding: 10px") td.add_style("width: 200px") td.add_style("min-width: 200px") td.add_style("vertical-align: top") #td.add_border() #td.add_style("border-style: solid") #td.add_style("border-width: 1px 0 1px 1px") #td.add_color("border-color", "border") #td.add_color("background", "background", -10) if my.parent: code = my.parent.get_code() else: code = my.sobject.get_code() # add the tile title = DivWdg() td.add(title) title.add_gradient("background", "background3", 0, -10) title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add_style("font-size: 1.4em") title.add("%s" % code) title.add_border() div = DivWdg() td.add(div) div.add_class("spt_sobject_detail_top") thumb_table = Table() div.add(thumb_table) thumb_table.add_row() thumb = ThumbWdg() # use a larger version for clearer display thumb.set_icon_type('web') # prefer to see the original image, then web thumb.set_option('image_link_order', 'main|web|.swf') thumb.set_option("detail", "false") thumb.set_option("icon_size", "100%") td = thumb_table.add_cell(thumb) td.add_style("vertical-align: top") td.add_style("width: 200px") td.add_style("padding: 20px") if my.parent: thumb.set_sobject(my.parent) else: thumb.set_sobject(my.sobject) sobject_info_wdg = my.get_sobject_info_wdg() sobject_info_wdg.add_style("width: 200px") td.add(sobject_info_wdg) if my.search_type == 'sthpw/task' and not my.parent: pass else: sobject_info_wdg = my.get_sobject_detail_wdg() td = table.add_cell() td.add(sobject_info_wdg) td.add_style("vertical-align: top") #td.add_color("background", "background", -10) td.add_style("overflow: hidden") #td.add_style("border-style: solid") #td.add_style("border-width: 1px 1px 1px 0px") #td.add_color("border-color", "border") # right td = table.add_cell() td.add_style("text-align: left") td.add_style("vertical-align: top") #td.add_color("background", "background", -10) td.add_class("spt_notes_wrapper") #td.add_border() # add the title title = DivWdg() td.add(title) title.add_gradient("background", "background3", 0, -10) title.add_style("height: 20px") title.add_style("padding: 4px") title.add_style("font-weight: bold") title.add("Notes") title.add_border() notes_div = DivWdg() td.add(notes_div) from tactic.ui.widget.discussion_wdg import DiscussionWdg discussion_wdg = DiscussionWdg(search_key=my.search_key, context_hidden=False, show_note_expand=False) notes_div.add(discussion_wdg) notes_div.add_style("min-width: 300px") notes_div.add_style("height: 200") notes_div.add_style("overflow-y: auto") notes_div.add_class("spt_resizable") # get the process if my.parent: process = my.sobject.get_value("process") else: process = '' # content tr = table.add_row() td = table.add_cell() td.add_attr("colspan", "5") #td.add_attr("colspan", "3") # create a state for tab. The tab only passes a search key # parent key search_key = SearchKey.get_by_sobject(my.sobject) parent = my.sobject.get_parent() if parent: parent_key = parent.get_search_key() else: parent_key = "" state = { 'search_key': search_key, 'parent_key': parent_key, 'process': process, } WebState.get().push(state) config_xml = my.get_config_xml() config = WidgetConfig.get(view="tab", xml=config_xml) if process: custom_view = "tab_config_%s" % process else: custom_view = "tab_config" search = Search("config/widget_config") search.add_filter("category", "TabWdg") search.add_filter("search_type", my.search_type) search.add_filter("view", custom_view) custom_config_sobj = search.get_sobject() if custom_config_sobj: custom_config_xml = custom_config_sobj.get_value("config") custom_config = WidgetConfig.get(view=custom_view, xml=custom_config_xml) config = WidgetConfigView(search_type='TabWdg', view=custom_view, configs=[custom_config, config]) #menu = my.get_extra_menu() #tab = TabWdg(config=config, state=state, extra_menu=menu) tab = TabWdg(config=config, state=state, show_add=False, show_remove=False, tab_offset=5 ) tab.add_style("margin: 0px -2px -2px -2px") td.add(tab) td.add_style("padding-top: 10px") return top
def get_display(my): top = my.top top.add_class("spt_sandbox_select_top") sandbox_options = [ { 'name': 'fast', 'base_dir': 'C:/Fast', }, { 'name': 'faster', 'base_dir': 'C:/Faster', }, { 'name': 'slow', 'base_dir': 'Z:/Slow', } ] process = my.kwargs.get("process") search_key = my.kwargs.get("search_key") sobject = Search.get_by_search_key(search_key) search_type = sobject.get_base_search_type() client_os = Environment.get_env_object().get_client_os() if client_os == 'nt': prefix = "win32" else: prefix = "linux" alias_dict = Config.get_dict_value("checkin", "%s_sandbox_dir" % prefix) search_key = sobject.get_search_key() key = "sandbox_dir:%s" % search_key from pyasm.web import WidgetSettings value = WidgetSettings.get_value_by_key(key) sandboxes_div = DivWdg() top.add(sandboxes_div) sandboxes_div.add_relay_behavior( { 'type': 'mouseenter', 'bvr_match_class': 'spt_sandbox_option', 'cbjs_action': ''' var last_background = bvr.src_el.getStyle("background-color"); bvr.src_el.setAttribute("spt_last_background", last_background); bvr.src_el.setStyle("background-color", "#E0E0E0"); bvr.src_el.setStyle("opacity", "1.0"); ''' } ) sandboxes_div.add_relay_behavior( { 'type': 'mouseleave', 'bvr_match_class': 'spt_sandbox_option', 'cbjs_action': ''' var last_background = bvr.src_el.getAttribute("spt_last_background"); bvr.src_el.setStyle("background-color", last_background); if (!bvr.src_el.hasClass("spt_selected")) { bvr.src_el.setStyle("opacity", "0.5"); } ''' } ) sandboxes_div.add_relay_behavior( { 'type': 'mouseup', 'key': key, 'bvr_match_class': 'spt_sandbox_option', 'cbjs_action': ''' var sandbox_dir = bvr.src_el.getAttribute("spt_sandbox_dir"); var server = TacticServerStub.get(); server.set_widget_setting(bvr.key, sandbox_dir); var applet = spt.Applet.get(); applet.makedirs(sandbox_dir); //var top = bvr.src_el.getParent(".spt_sandbox_select_top"); var top = bvr.src_el.getParent(".spt_checkin_top"); spt.panel.refresh(top); ''' } ) #search = Search("config/naming") #search.add_filter("search_type", search_type) #search.add_filter("process", process) #namings = search.get_sobjects() #naming = namings[0] from pyasm.biz import Snapshot, Naming virtual_snapshot = Snapshot.create_new() virtual_snapshot.set_value("process", process) # for purposes of the sandbox folder for the checkin widget, # the context is the process virtual_snapshot.set_value("context", process) naming = Naming.get(sobject, virtual_snapshot) if naming: naming_expr = naming.get_value("sandbox_dir_naming") alias_options = naming.get_value("sandbox_dir_alias") else: naming_expr = None alias_options = None if alias_options == "__all__": alias_options = alias_dict.keys() elif alias_options: alias_options = alias_options.split("|") else: alias_options = ['default'] for alias in alias_options: from pyasm.biz import DirNaming dir_naming = DirNaming(sobject=sobject, snapshot=virtual_snapshot) dir_naming.set_protocol("sandbox") dir_naming.set_naming(naming_expr) base_dir = dir_naming.get_dir(alias=alias) sandbox_div = DivWdg() sandboxes_div.add(sandbox_div) sandbox_div.add_class("spt_sandbox_option") sandbox_div.add_attr("spt_sandbox_dir", base_dir) if value == base_dir: sandbox_div.add_color("background", "background3") #sandbox_div.set_box_shadow() sandbox_div.add_class("spt_selected") else: sandbox_div.add_style("opacity", "0.5") sandbox_div.add_style("width: auto") sandbox_div.add_style("height: 55px") sandbox_div.add_style("padding: 5px") #sandbox_div.add_style("float: left") sandbox_div.add_style("margin: 15px") sandbox_div.add_border() if alias: alias_div = DivWdg() sandbox_div.add(alias_div) alias_div.add(alias) alias_div.add_style("font-size: 1.5em") alias_div.add_style("font-weight: bold") alias_div.add_style("margin-bottom: 15px") icon_wdg = IconWdg("Folder", IconWdg.FOLDER) sandbox_div.add(icon_wdg) sandbox_div.add(base_dir) return top
def get_display(self): #self.chunk_size = 10000 if self.kwargs.get("do_search") != "false": self.handle_search() self.mode = self.kwargs.get("mode") if self.mode != 'raw': self.mode = 'widget' # extraneous variables inherited from TableLayoutWdg self.edit_permission = False top = DivWdg() self.set_as_panel(top) top.add_class("spt_sobject_top") inner = DivWdg() top.add(inner) inner.add_color("background", "background") inner.add_color("color", "color") inner.add_class("spt_table") inner.add_class("spt_layout") inner.add_attr("spt_version", "2") table = self.table table.add_class("spt_table_table") # set the sobjects to all the widgets then preprocess if self.mode == 'widget': for widget in self.widgets: widget.handle_layout_behaviors(table) widget.set_sobjects(self.sobjects) widget.set_parent_wdg(self) # preprocess the elements widget.preprocess() else: for i, widget in enumerate(self.widgets): #widget.handle_layout_behaviors(table) widget.set_sobjects(self.sobjects) #widget.set_parent_wdg(self) # preprocess the elements widget.preprocess() self.process_groups() self.order_sobjects(self.sobjects, self.group_columns) self.remap_sobjects() self.attributes = [] for i, widget in enumerate(self.widgets): element_name = widget.get_name() if element_name and element_name != "None": attrs = self.config.get_element_attributes(element_name) else: attrs = {} self.attributes.append(attrs) is_refresh = self.kwargs.get("is_refresh") if self.kwargs.get("show_shelf") not in ['false', False]: action = self.get_action_wdg() inner.add(action) index = 0 table.add_attr("spt_view", self.kwargs.get("view")) table.set_attr("spt_search_type", self.kwargs.get('search_type')) table.set_id(self.table_id) table.add_style("width: 100%") inner.add(table) table.add_color("color", "color") # initialize the spt.table js #self.handle_table_behaviors(table) self.handle_headers(table) border_color = table.get_color("table_border", default="border") for row, sobject in enumerate(self.sobjects): # put in a group row if self.is_grouped: self.handle_groups(table, row, sobject) tr = table.add_row() if row % 2: background = tr.add_color("background", "background") else: background = tr.add_color("background", "background", -1) tr.add_class("spt_table_row") tr.add_attr("spt_search_key", sobject.get_search_key()) for i, widget in enumerate(self.widgets): value_div = DivWdg() value_div.add_style("padding: 3px") td = table.add_cell(value_div) td.add_style("vertical-align: top") td.add_style("border: solid 1px %s" % border_color) if self.mode == 'widget': widget.set_current_index(row) value_div.add(widget.get_buffer_display()) else: element_name = widget.get_name() value = sobject.get_value(element_name, no_exception=True) value_div.add(value) top.add_class("spt_table_top") class_name = Common.get_full_class_name(self) top.add_attr("spt_class_name", class_name) table.add_class("spt_table_content") inner.add_attr("spt_search_type", self.kwargs.get('search_type')) inner.add_attr("spt_view", self.kwargs.get('view')) # extra ?? Doesn't really work to keep the mode inner.add_attr("spt_mode", self.mode) top.add_attr("spt_mode", self.mode) inner.add("<br clear='all'/>") if self.kwargs.get("is_refresh") == 'true': return inner else: return top
def get_display(my): relative_dir = my.kwargs.get("relative_dir") my.relative_dir = relative_dir div = DivWdg() div.add_class("spt_ingest_top") div.add_style("width: 100%px") div.add_style("min-width: 500px") div.add_style("padding: 20px") div.add_color("background", "background") title_div = DivWdg() div.add(title_div) title_div.add("Ingest Files") title_div.add_style("font-size: 14px") title_div.add_style("font-weight: bold") title_div.add_style("padding: 10px") title_div.add_color("background", "background3") title_div.add_border() my.search_type = my.kwargs.get("search_type") if not my.search_type: div.add("No search type specfied") return div if relative_dir: folder_div = DivWdg() div.add(folder_div) folder_div.add("Folder: %s" % relative_dir) folder_div.add_style("opacity: 0.5") folder_div.add_style("font-style: italic") folder_div.add_style("margin-bottom: 10px") title_div.add_style("margin: -20px -21px 5px -21px") else: title_div.add_style("margin: -20px -21px 15px -21px") div.add("Add files or drag/drop files to be uploaded and ingested:") div.add("<br/>"*2) data_div = my.get_data_wdg() data_div.add_style("float: left") data_div.add_style("float: left") div.add(data_div) # create the help button help_button_wdg = DivWdg() div.add(help_button_wdg) help_button_wdg.add_style("margin-top: -3px") help_button_wdg.add_style("float: right") help_button = ActionButtonWdg(title="?", tip="Ingestion Widget Help", size='s') help_button_wdg.add(help_button) help_button.add_behavior( { 'type': 'click_up', 'cbjs_action': '''spt.help.load_alias("ingestion_widget")''' } ) from tactic.ui.input import Html5UploadWdg upload = Html5UploadWdg(multiple=True) div.add(upload) button = ActionButtonWdg(title="Add") button.add_style("float: right") button.add_style("margin-top: -3px") div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingest_top"); var files_el = top.getElement(".spt_upload_files"); var onchange = function (evt) { var files = spt.html5upload.get_files(); for (var i = 0; i < files.length; i++) { spt.drag.show_file(files[i], files_el, 0, true); } } spt.html5upload.set_form( top ); spt.html5upload.select_file( onchange ); ''' } ) button = ActionButtonWdg(title="Clear") button.add_style("float: right") button.add_style("margin-top: -3px") div.add(button) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingest_top"); var file_els = top.getElements(".spt_upload_file"); for ( var i = 0; i < file_els.length; i++) { spt.behavior.destroy( file_els[i] ); }; ''' } ) div.add("<br clear='all'/>") files_div = DivWdg() files_div.add_style("position: relative") files_div.add_class("spt_upload_files") div.add(files_div) files_div.add_style("max-height: 300px") files_div.add_style("height: 300px") files_div.add_style("overflow-y: auto") files_div.add_border() files_div.add_style("padding: 3px") files_div.add_color("background", "background3") #files_div.add_style("display: none") bgcolor = div.get_color("background3") bgcolor2 = div.get_color("background3", -3) files_div.add_behavior( { 'type': 'mouseenter', 'bgcolor': bgcolor2, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.bgcolor) ''' } ) files_div.add_behavior( { 'type': 'mouseout', 'bgcolor': bgcolor, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.bgcolor) ''' } ) background = DivWdg() background.add_class("spt_files_background") files_div.add(background) background.add_style("font-size: 4.0em") background.add_style("font-weight: bold") background.add_style("opacity: 0.1") background.add_style("position: absolute") background.add_style("left: 50%") background.add_style("top: 100px") background.add_border() inner_background = DivWdg("Drag Files Here") background.add(inner_background) inner_background.set_style("position: absolute") inner_background.set_style("margin-left: -50%") # Test drag and drop files files_div.add_attr("ondragenter", "return false") files_div.add_attr("ondragover", "return false") files_div.add_attr("ondrop", "spt.drag.noop(event, this)") files_div.add_behavior( { 'type': 'load', 'cbjs_action': ''' spt.drag = {} var background; spt.drag.show_file = function(file, top, delay, icon) { if (!background) { background = top.getElement(".spt_files_background"); background.setStyle("display", "none"); } var template = top.getElement(".spt_upload_file_template"); var clone = spt.behavior.clone(template); clone.removeClass("spt_upload_file_template"); clone.addClass("spt_upload_file"); clone.setStyle("display", ""); if (typeof(delay) == 'undefined') { delay = 0; } // remember the file handle clone.file = file; var name = file.name; var size = parseInt(file.size / 1024 * 10) / 10; var thumb_el = clone.getElement(".spt_thumb"); var date_label_el = clone.getElement(".spt_date_label"); var date_el = clone.getElement(".spt_date"); //var loadingImage = loadImage( setTimeout( function() { if (icon) { var loadingImage = loadImage( file, function (img) { thumb_el.appendChild(img); }, {maxWidth: 80, maxHeight: 60, canvas: true, contain: true} ); } else { var img = $(document.createElement("div")); img.setStyle("width", "60"); img.setStyle("height", "40"); //img.innerHTML = "MP4"; img.setStyle("border", "solid 1px black") thumb_el.appendChild(img); } loadImage.parseMetaData( file, function(data) { if (data.exif) { var date = data.exif.get('DateTimeOriginal'); if (date) { date_label_el.innerHTML = date; if (date_el) { date_el.value = date; } } } } ); }, delay ); /* var reader = new FileReader(); reader.thumb_el = thumb_el; reader.onload = function(e) { this.thumb_el.innerHTML = [ '<img class="thumb" src="', e.target.result, '" title="', escape(name), '" width="60px"', '" padding="5px"', '"/>' ].join(''); } reader.readAsDataURL(file); */ clone.getElement(".spt_name").innerHTML = file.name; clone.getElement(".spt_size").innerHTML = size + " KB"; clone.inject(top); } spt.drag.noop = function(evt, el) { var top = $(el).getParent(".spt_ingest_top"); var files_el = top.getElement(".spt_upload_files"); evt.stopPropagation(); evt.preventDefault(); evt.dataTransfer.dropEffect = 'copy'; var files = evt.dataTransfer.files; var delay = 0; var skip = false; for (var i = 0; i < files.length; i++) { var size = files[i].size; if (size >= 10*1024*1024) { spt.drag.show_file(files[i], files_el, 0, false); } else { spt.drag.show_file(files[i], files_el, delay, true); if (size < 100*1024) delay += 50; else if (size < 1024*1024) delay += 500; else if (size < 10*1024*1024) delay += 1000; } } } ''' } ) # create a template that will be filled in for each file files_div.add_relay_behavior( { 'type': 'mouseenter', 'color': files_div.get_color("background3", -5), 'bvr_match_class': 'spt_upload_file', 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); ''' } ) files_div.add_relay_behavior( { 'type': 'mouseleave', 'bvr_match_class': 'spt_upload_file', 'cbjs_action': ''' bvr.src_el.setStyle("background", ""); ''' } ) files_div.add_relay_behavior( { 'type': 'mouseup', 'bvr_match_class': 'spt_remove', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_upload_file"); spt.behavior.destroy_element(top); ''' } ) """ metadata_view = "test/wizard/metadata" files_div.add_relay_behavior( { 'type': 'mouseup', 'view': metadata_view, 'bvr_match_class': 'spt_upload_file', 'cbjs_action': ''' var class_name = 'tactic.ui.panel.CustomLayoutWdg'; var kwargs = { view: bvr.view } spt.app_busy.show("Loading Metadata"); spt.panel.load_popup("Metadata", class_name, kwargs); spt.app_busy.hide(); ''' } ) """ # template for each file item file_template = DivWdg() file_template.add_class("spt_upload_file_template") files_div.add(file_template) file_template.add_style("margin-bottom: 3px") file_template.add_style("padding: 3px") file_template.add_style("height: 40px") file_template.add_style("display: none") thumb_div = DivWdg() file_template.add(thumb_div) thumb_div.add_style("float: left") thumb_div.add_style("width: 60"); thumb_div.add_style("height: 40"); thumb_div.add_style("overflow: hidden"); thumb_div.add_style("margin: 3 10 3 0"); thumb_div.add_class("spt_thumb") info_div = DivWdg() file_template.add(info_div) info_div.add_style("float: left") name_div = DivWdg() name_div.add_class("spt_name") info_div.add(name_div) name_div.add("image001.jpg") name_div.add_style("width: 150px") """ dialog = DialogWdg(display="false", show_title=False) info_div.add(dialog) dialog.set_as_activator(info_div, offset={'x':0,'y':10}) dialog_data_div = DivWdg() dialog_data_div.add_color("background", "background") dialog_data_div.add_style("padding", "10px") dialog.add(dialog_data_div) dialog_data_div.add("Category: ") text = TextInputWdg(name="category") dialog_data_div.add(text) text.add_class("spt_category") text.add_style("padding: 1px") """ date_div = DivWdg() date_div.add_class("spt_date_label") info_div.add(date_div) date_div.add("") date_div.add_style("opacity: 0.5") date_div.add_style("font-size: 0.8em") date_div.add_style("font-style: italic") date_div.add_style("margin-top: 3px") hidden_date_div = HiddenWdg("date") hidden_date_div.add_class("spt_date") info_div.add(date_div) size_div = DivWdg() size_div.add_class("spt_size") file_template.add(size_div) size_div.add("433Mb") size_div.add_style("float: left") size_div.add_style("width: 150px") size_div.add_style("text-align: right") remove_div = DivWdg() remove_div.add_class("spt_remove") file_template.add(remove_div) icon = IconButtonWdg(title="Remove", icon=IconWdg.DELETE) icon.add_style("float: right") remove_div.add(icon) #remove_div.add_style("text-align: right") div.add("<br/>") info = DivWdg() div.add(info) info.add_class("spt_upload_info") progress_div = DivWdg() progress_div.add_class("spt_upload_progress_top") div.add(progress_div) progress_div.add_style("width: 100%") progress_div.add_style("height: 15px") progress_div.add_style("margin-bottom: 10px") progress_div.add_border() #progress_div.add_style("display: none") progress = DivWdg() progress_div.add(progress) progress.add_class("spt_upload_progress") progress.add_style("width: 0px") progress.add_style("height: 100%") progress.add_gradient("background", "background3", -10) progress.add_style("text-align: right") progress.add_style("overflow: hidden") progress.add_style("padding-right: 3px") from tactic.ui.app import MessageWdg progress.add_behavior( { 'type': 'load', 'cbjs_action': MessageWdg.get_onload_js() } ) # NOTE: files variable is passed in automatically upload_init = ''' var server = TacticServerStub.get(); server.start( {description: "Upload and check-in of ["+files.length+"] files"} ); var info_el = top.getElement(".spt_upload_info"); info_el.innerHTML = "Uploading ..."; ''' upload_progress = ''' var top = bvr.src_el.getParent(".spt_ingest_top"); progress_el = top.getElement(".spt_upload_progress"); var percent = Math.round(evt.loaded * 100 / evt.total); progress_el.setStyle("width", percent + "%"); progress_el.innerHTML = String(percent) + "%"; ''' on_complete = ''' var top = bvr.src_el.getParent(".spt_ingest_top"); var progress_el = top.getElement(".spt_upload_progress"); progress_el.innerHTML = "100%"; progress_el.setStyle("width", "100%"); var info_el = top.getElement(".spt_upload_info"); var search_type = bvr.kwargs.search_type; var relative_dir = bvr.kwargs.relative_dir; var filenames = []; for (var i = 0; i != files.length;i++) { var name = files[i].name; filenames.push(name); } var key = spt.message.generate_key(); var values = spt.api.get_input_values(top); //var category = values.category[0]; var keywords = values.keywords[0]; var extra_data = values.extra_data[0]; var parent_key = values.parent_key[0]; var convert_el = top.getElement(".spt_image_convert") var convert = spt.api.get_input_values(convert_el); var processes = values.process; if (processes) { process = processes[0]; if (!process) { process = null; } } else { process = null; } var kwargs = { search_type: search_type, relative_dir: relative_dir, filenames: filenames, key: key, parent_key: parent_key, //category: category, keywords: keywords, extra_data: extra_data, process: process, convert: convert, } on_complete = function() { spt.info("Ingest complete"); server.finish(); var file_els = top.getElements(".spt_upload_file"); for ( var i = 0; i < file_els.length; i++) { spt.behavior.destroy( file_els[i] ); }; var background = top.getElement(".spt_files_background"); background.setStyle("display", ""); spt.message.stop_interval(key); }; var class_name = bvr.action_handler; server.execute_cmd(class_name, kwargs, null, {on_complete:on_complete}); on_progress = function(message) { msg = JSON.parse(message.message); var percent = msg.progress; var description = msg.description; info_el.innerHTML = description; progress_el.setStyle("width", percent+"%"); progress_el.innerHTML = percent + "%"; } spt.message.set_interval(key, on_progress, 2000); ''' upload_div = DivWdg() div.add(upload_div) #button = UploadButtonWdg(**kwargs) button = ActionButtonWdg(title="Ingest") upload_div.add(button) button.add_style("float: right") upload_div.add_style("margin-bottom: 15px") upload_div.add("<br clear='all'/>") action_handler = my.kwargs.get("action_handler") if not action_handler: action_handler = 'tactic.ui.tools.IngestUploadCmd'; button.add_behavior( { 'type': 'click_up', 'action_handler': action_handler, 'kwargs': { 'search_type': my.search_type, 'relative_dir': relative_dir }, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_ingest_top"); var file_els = top.getElements(".spt_upload_file"); // get the server that will be used in the callbacks var server = TacticServerStub.get(); // retrieved the stored file handles var files = []; for (var i = 0; i < file_els.length; i++) { files.push( file_els[i].file ); } if (files.length == 0) { alert("No files selected"); return; } // defined the callbacks var upload_start = function(evt) { } var upload_progress = function(evt) { %s; } var upload_complete = function(evt) { %s; spt.app_busy.hide(); } var upload_file_kwargs = { files: files, upload_start: upload_start, upload_complete: upload_complete, upload_progress: upload_progress }; if (bvr.ticket) upload_file_kwargs['ticket'] = bvr.ticket; %s; spt.html5upload.set_form( top ); spt.html5upload.upload_file(upload_file_kwargs); ''' % (upload_progress, on_complete, upload_init) } ) return div
def get_display(my): my.add_style("position: relative") my.add_class("spt_button_top") my.add_style("height: %spx" % my.get_height() ) my.add_style("width: %spx" % my.get_width() ) display = DivWdg() my.add(display) display.add_class("spt_icon_button_top") offset = my.get_offset() out_div = DivWdg() display.add(out_div) out_div.add_class("spt_button_out") out_img = my.get_out_img() out_div.add_style("left: %spx" % offset[0]) out_div.add_style("top: %spx" % offset[1]) if out_img: out_div.add(out_img) out_div.add_style("position: absolute") over_div = DivWdg() display.add(over_div) over_div.add_class("spt_button_over") over_img = my.get_over_img() over_div.add_style("left: %spx" % offset[0]) over_div.add_style("top: %spx" % offset[1]) over_div.add(over_img) over_div.add_style("position: absolute") over_div.add_style("display: none") click_div = DivWdg() display.add(click_div) click_div.add_class("spt_button_click") click_img = my.get_click_img() click_div.add_style("left: %spx" % offset[0]) click_div.add_style("top: %spx" % offset[1]) click_div.add(click_img) click_div.add_style("position: absolute") click_div.add_style("display: none") icon_str = my.kwargs.get("icon") title = my.kwargs.get("title") tip = my.kwargs.get("tip") if not tip: tip = title icon_div = DivWdg() icon_div.add_class("hand") icon_div.add_style("top: 3px") icon_div.add_style("left: 5px") display.add(icon_div) icon_div.add_style("position: absolute") if my.get_width() < 30: width = 16 else: width = None icon = IconWdg(title, icon_str, width=width) icon_div.add(icon) if tip: display.add_attr("title", tip) my.show_arrow = my.kwargs.get("show_arrow") in [True, 'true'] #if my.show_arrow or my.dialog: if my.show_arrow: arrow_div = DivWdg() icon_div.add(arrow_div) arrow_div.add_style("position: absolute") arrow_div.add_style("top: 13px") arrow_div.add_style("left: 11px") arrow = IconWdg(title, IconWdg.ARROW_MORE_INFO) arrow_div.add(arrow) spacer = DivWdg() display.add(spacer) spacer.add("") return super(IconButtonWdg, my).get_display()
def get_display(my): top = DivWdg() top.add_border() top.add_style("padding: 10px") top.add_color("color", "color") top.add_gradient("background", "background", 0, -5) #top.add_style("height: 550px") top.add_behavior( { 'type': 'load', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|hide_now", {} ); ''' } ) project = Project.get() title = DivWdg() title.add("Project Startup and Configuration") title.add_style("font-size: 18px") title.add_style("font-weight: bold") title.add_style("text-align: center") title.add_style("padding: 10px") title.add_style("margin: -10px -10px 10px -10px") top.add(title) title.add_gradient("background", "background3", 5, -10) shelf = DivWdg() top.add(shelf) shelf.add_style("margin-left: -8px") shelf.add_style("width: 130px") button_div = DivWdg() shelf.add(button_div) button_div.add_style("float: left") button_div.add_style("margin-top: -3px") security = Environment.get_security() view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow') if view_side_bar: button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT) button_div.add(button) shelf.add("Toggle Side Bar") shelf.add_attr("title", "Toggle Side Bar (or press '1')") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' } ) shelf.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' } ) shelf.add_class("hand") else: shelf.add(" ") search_wdg = Table() top.add(search_wdg) search_wdg.add_row() search_wdg.add_class("spt_main_top") search_wdg.add_style("padding: 10px") search_wdg.add_style("margin: 20px auto") search_wdg.add_style("width: 430px") td = search_wdg.add_cell("Search: ") td.add_style("vertical-align: top") td.add_style("padding-top: 8px") custom_cbk = {} custom_cbk['enter'] = ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords != '') { var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'result_list', 'keywords': keywords, 'simple_search_view': 'simple_filter', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); } ''' from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg #text = TextInputWdg(name="search") text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk, width='280', height='42px') #text = TextWdg("search") text.add_class("spt_main_search") text.add_style("width: 290px") search_wdg.add_cell(text) search_wdg.add_style("font-weight: bold") search_wdg.add_style("font-size: 16px") icon_div = DivWdg() td = search_wdg.add_cell(icon_div) td.add_style("vertical-align: top") icon_div.add_style("width: 38px") icon_div.add_style("height: 27px") icon_div.add_style("padding-top: 7px") icon_div.add_style("padding-left: 4px") icon_div.add_style("text-align: center") #icon_div.add_gradient("background", "background3", 15, -10) icon_div.add_color("background", "background3", 10) over_color = icon_div.get_color("background3", 0) out_color = icon_div.get_color("background3", 10) icon_div.set_round_corners(5) icon_div.set_box_shadow("1px 1px 1px 1px") icon = IconWdg("Search", IconWdg.SEARCH_32, width=24) icon_div.add(icon) button = icon_div icon_div.add_class("hand") icon_div.add_behavior( { 'type': 'mouseover', 'color': over_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); ''' } ) icon_div.add_behavior( { 'type': 'mouseout', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' } ) icon_div.add_behavior( { 'type': 'click', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-3"); bvr.src_el.setStyle("margin-right", "-2"); ''' } ) icon_div.add_behavior( { 'type': 'click_up', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' } ) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords == '') { return; } var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'result_list', 'keywords': keywords, 'simple_search_view': 'simple_filter', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); ''' } ) #desc = DivWdg() #top.add(desc) #desc.add("Dashboard") #desc.add_style("width: 600px") # create a bunch of panels table = Table() table.add_color("color", "color") table.add_style("margin-bottom: 20px") table.center() top.add(table) table.add_row() #security = Environment.get_security() #if not security.check_access("builtin", "view_site_admin", "allow"): td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Configuration" #description = '''All TACTIC projects can be uniquely designed and managed using our configuration tools.''' description = '''Configure a Project from start to finish.''' image = "<img src='/context/icons/64x64/configuration_64.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.ProjectConfigWdg'; var kwargs = { help_alias: 'project-startup-configuration' }; spt.tab.add_new("project_configuration", "Configuration", class_name, kwargs); ''' } config_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(config_wdg) # Manage Users td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Manage Users and Security" image = "<img src='/context/icons/64x64/dashboard_64.png'/>" image = DivWdg() image_link = "<div style='margin-bottom: -64px'><img src='/context/icons/64x64/lock_64.png'/></div>" image.add(image_link) image1 = IconWdg("Manage Users", IconWdg.USER_32) image2 = IconWdg("Manage Users", IconWdg.USER_32) image3 = IconWdg("Manage Users", IconWdg.USER_32) image4 = IconWdg("Manage Users", IconWdg.USER_32) image.add(image1) image.add(image2) image.add("<br/>") image.add(image3) image.add(image4) description = '''Manage users that can access the system''' behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.UserConfigWdg'; var kwargs = { help_alias: 'project-startup-manage-users' }; spt.tab.add_new("manage_user", "Manage Users", class_name, kwargs); ''' } manage_users_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(manage_users_wdg) # custom layout editor td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Custom Layouts" description = '''Create interfaces using the Custom Layout Editor.''' image = "<img src='/context/icons/64x64/layout_64.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.tools.CustomLayoutEditWdg'; var kwargs = { help_alias: 'project-startup-configuration' }; spt.tab.add_new("custom_layout_editor", "Custom Layout Editor", class_name, kwargs); ''' } config_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(config_wdg) tr = table.add_row() # Plugins td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Manage Plugin" image = IconWdg("Manage Plugin", IconWdg.PLUGIN_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Upload, install, remove and create TACTIC plugins.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.PluginWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("plugins", "Manage Plugin", class_name, kwargs); ''' } plugin_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(plugin_wdg) # Examples td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Tools" image = IconWdg("Tools", IconWdg.SHARE_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''A collection of example views.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ToolsWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("tools", "Tools", class_name, kwargs); ''' } share_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) # Share """ td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Shares" image = IconWdg("Shares", IconWdg.SHARE_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Share project with other TACTIC installs.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ShareWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("shares", "Shares", class_name, kwargs); ''' } share_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) """ # Advanced td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Advanced Setup" image = IconWdg("Advanced", IconWdg.ADVANCED_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''A set of advanced configuration tools.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.ProjectStartWdg'; spt.tab.set_main_body_tab() spt.tab.add_new("project_setup", "Project Setup", class_name) ''' } share_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) """ td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Documentation" description = '''TACTIC Documentation. * Project Setup Documentation<br/> <br/> * End User Documentation<br/> <br/> * Developer Documentation<br/> <br/> * System Administrator Documentation<br/> <br/> ''' image = "<img src='/context/images/getting_started_pipeline.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.help.load_alias("main") ''' } doc_wdg = my.get_section_wdg(title, description, image, behavior) td.add(doc_wdg) """ tr, td = table.add_row_cell() td.add_style("font-size: 14px") td.add("<br/>") from misc_wdg import QuickLinksWdg quick_links_wdg = QuickLinksWdg() td.add(quick_links_wdg) #td = table.add_cell() #totals_wdg = my.get_totals_wdg() #td.add(totals_wdg) return top
def get_display(self): sobject = self.get_current_sobject() column = self.kwargs.get('column') if column: name = column else: name = self.get_name() value = self.get_value(name=name) empty = self.get_option("empty") if empty and self.is_editable() and not value: from pyasm.web import SpanWdg div = DivWdg() div.add_style("text-align: center") div.add_style("width: 100%") div.add_style("white-space: nowrap") if empty in [True, 'true']: div.add("--Select--") div.add_style("opacity: 0.5") return div if sobject: data_type = SearchType.get_column_type(sobject.get_search_type(), name) else: data_type = 'text' if type(value) in types.StringTypes: wiki = WikiUtil() value = wiki.convert(value) if name == 'id' and value == -1: value = '' elif data_type in ["timestamp", "time"] or name == "timestamp": if value == 'now': value = '' elif value: # This date is assumed to be GMT date = parser.parse(value) # convert to user timezone if not SObject.is_day_column(name): date = self.get_timezone_value(date) try: encoding = locale.getlocale()[1] value = date.strftime("%b %d, %Y - %H:%M").decode(encoding) except: value = date.strftime("%b %d, %Y - %H:%M") else: value = '' else: if isinstance(value, Widget): return value elif not isinstance(value, basestring): try: value + 1 except TypeError: value = str(value) #else: # value_wdg.add_style("float: right") # value_wdg.add_style("padding-right: 3px") if sobject and SearchType.column_exists(sobject.get_search_type(), name): value_wdg = DivWdg() self.add_value_update(value_wdg, sobject, name) # don't call str() to prevent utf-8 encode error value_wdg.add(value) value_wdg.add_style("overflow-x: hidden") value_wdg.add_style("text-overflow: ellipsis") # sompe properties min_height = 25 value_wdg.add_style("min-height: %spx" % min_height) single_line = self.get_option("single_line") or False if single_line in ["true", True]: value_wdg.add_style("line-height: %spx" % min_height) value_wdg.add_style("white-space: nowrap") #value_wdg.add_style("overflow-y: hidden") #value_wdg.add_class("spt_scrollable") #value_wdg.add_attr("title", value) link_expression = self.get_option("link_expression") if link_expression: value_wdg.add_class("tactic_new_tab") value_wdg.add_style("display: inline-block") value_wdg.add_attr("search_key", sobject.get_search_key()) value_wdg.add_style("text-decoration: underline") #value_wdg.add_attr("spt_class_name", "tactic.ui.tools.SObjectDetailWdg") value_wdg.add_class("hand") return value_wdg return value
def get_day_wdg(my, month, day): # find the day of the week wday = day.strftime("%w") # if it's the first day ... if wday == "0": my.current_week += 1 sobjects_week_index = my.sobjects_week_index[my.current_week] my.handler.set_sobjects_index( sobjects_week_index ) my.handler.set_current_week(my.current_week) sobjects = my.date_sobjects.get(str(day)) div = DivWdg() div.add_style("vertical-align: top") div.add_class("spt_calendar_day") div.add_class("hand") if my.custom_layout: my.custom_layout.kwargs['day_obj'] = day my.custom_layout.kwargs['day'] = str(day) if sobjects: # this causes mako processing error complaining about timestamp # send in just the search_keys for the day for now #sobject_dict_list = [ x.get_sobject_dict() for x in sobjects] #my.custom_layout.kwargs['search_objects'] = sobject_dict_list sobject_keys = [ x.get_search_key() for x in sobjects] my.custom_layout.kwargs['search_keys'] = sobject_keys wdg = my.custom_layout.get_buffer_display() my.custom_layout.kwargs['search_keys'] = [] div.add(wdg) return div day_div = DivWdg() div.add( day_div ) day_div.add(day.day) day_div.add_style("float: right") day_div.add_style("margin: 2px") div.add("<br clear='all'/>") """ mode = my.kwargs.get("mode") if mode in ["line","square"]: day_div.add_style("font-size: 0.6em") day_div.add_style("padding: 1px 0px 2px 2px") else: day_div.add_style("font-size: 1.2em") day_div.add_style("padding: 3px 0 3px 5px") """ if my.width: div.add_style("width: %s" % my.width); div.add_style("min-height: %s" % my.height); div.add_style("overflow: hidden"); div.add_style("padding: 2px 0 2px 0") div.add_color("color", "color") div.add_style("vertical-align: top") st_title = SearchType.get(my.search_type).get_value('title') if sobjects: #ids = "".join( [ "['id','%s']" % x.get_id() for x in sobjects ]) ids = [ str(x.get_id()) for x in sobjects ] ids_filter = "['id' ,'in', '%s']" %'|'.join(ids) expression = "@SOBJECT(%s%s)" % (my.search_type, ids_filter) div.add_behavior( { 'type': "click_up", 'cbjs_action': ''' var class_name = 'tactic.ui.panel.TableLayoutWdg'; var title = '%s: %s'; var kwargs = { 'search_type': '%s', 'view': 'table', 'show_insert': 'false', 'expression': "%s" }; spt.app_busy.show("Loading...") setTimeout(function() { //spt.panel.load_popup( title, class_name, kwargs ); spt.tab.set_main_body_tab(); spt.tab.add_new(title, title, class_name, kwargs); spt.app_busy.hide(); }, 200) ''' % (st_title, str(day),my.search_type, expression ), } ) content = DivWdg() content.add_style("vertical-align: top") content.add_class("spt_calendar_day_content") content.add_style("height: 100%") #content.add_style("width: 400px") content.add_style("min-height: %s" % my.height); my.handler.set_sobjects(sobjects) else: content = DivWdg() content.add_style("vertical-align: top") content.add_style("height: 100%") #content.add_style("width: 400px") content.add_style("min-height: %s" % my.height); my.handler.set_sobjects([]) # force it to be 120px for now if my.width: content.add_style("width: %spx" % my.width) my.handler.set_date(day) content.add( my.handler.get_buffer_display() ) div.add(content) today = datetime.today() # store date like the database does YYYY-MM-DD date_str = "%04d-%02d-%02d" % (day.year, day.month, day.day) div.add_attr('spt_date', date_str) div.add_class('spt_date_day') color1 = div.get_color("background") color2 = div.get_color("background", -10) # put a different color for days that are not in the current month if day.month != month: div.add_style("color: #c22") div.add_style("opacity: 0.7") #div.add_style("background-image", "linear-gradient(135deg, #ccc 0%, #ccc 25%, #bbb 25%, #bbb 50%, #ccc 50%, #ccc 75%, #bbb 75%);"); div.add_style("background-size", "15px 15px") div.add_style("background-color", "") div.add_style("background-image", "linear-gradient(135deg, rgba(0, 0, 0, 0.06) 25%, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.06) 50%, rgba(0, 0, 0, 0.06) 75%, rgba(0, 0, 0, 0) 75%, rgba(0, 0, 0, 0));") elif day.year == today.year and day.month == today.month and day.day == today.day: div.add_color("background", "background", [-10, -10, 20]) color1 = div.get_color("background", [-10, -10, 20]) div.add_event("onmouseover", "$(this).setStyle('background-color','%s')" % color2) div.add_event("onmouseout", "$(this).setStyle('background-color','%s')" % color1) return div
def get_display(my): top = DivWdg() top.add_style("overflow-x: hidden") top.add_style("padding-left: 3px") top.add_style("padding-right: 3px") mode = my.kwargs.get("mode") if not mode: mode = 'normal' assert mode in ['normal', 'line', 'square'] # check if it is the first day of the week and then try to cascade # the indexes up wday = my.date.strftime("%w") if wday == "0": first_day = True else: first_day = False num_today = 0 for index, sobject in enumerate(my.sobjects_index): if sobject not in my.sobjects: continue num_today += 1 if not num_today: no_tasks = DivWdg() no_tasks.add_style("height: 100%") no_tasks.add(" ") top.add(no_tasks) #color = top.get_color("background", [-2, -10, -10]) #top.add_style("background: %s" % color) #top.add_style("opacity: 0.5") else: for index, sobject in enumerate(my.sobjects_index): content_wdg = DivWdg() top.add(content_wdg) content_wdg.add_style("white-space: nowrap") content_wdg.add_style("padding: 1px 3px 1px 3px") if sobject not in my.sobjects: # account for the border if mode == "line": content_wdg.add_style("height: 1px") content_wdg.add_style("overflow: hidden") elif mode == "square": content_wdg.add_style("display: none") else: content_wdg.add_style("margin: 4px -1px 4px -1px") content_wdg.add(" ") continue else: if mode == "line": content_wdg.add_style("height: 1px") content_wdg.add_style("margin: 1px 1px 1px 1px") elif mode == "square": content_wdg.add_style("height: 1px") content_wdg.add_style("width: 1px") content_wdg.add_style("margin: 1px 1px 1px 1px") content_wdg.add_style("float: left") else: content_wdg.add_border() #content_wdg.set_box_shadow("0px 0px 5px") #content_wdg.set_round_corners() content_wdg.add_style("margin: 3px 0px 3px 0px") content_wdg.add_style("overflow: hidden") if not first_day and my.sobjects_drawn.get(sobject) == True: display_value = " " title_value = my.display_values.get(sobject.get_search_key()) if title_value: content_wdg.add_attr("title", title_value) else: if my.sobject_display_expr: display_value = Search.eval(my.sobject_display_expr, [sobject], single=True) else: display_value = my.get_display_value(sobject) content_wdg.add_attr("title", display_value) my.display_values[sobject.get_search_key()] = display_value if len(display_value) > 17: display_value = "%s..." % display_value[:20] my.sobjects_drawn[sobject] = True color = my.get_color(sobject, index) content_wdg.add_style("background: %s" % color) content_wdg.add(display_value) return top
def get_link_wdg(self, element_name, config, options): attributes = config.get_element_attributes(element_name) title = self._get_title(config, element_name) default_access = "view" path = options.get('path') security = Environment.get_security() if not security.check_access( "side_bar", element_name, "view", default=default_access): return # backwards compatibility?? #if not security.check_access("url", path, "view"): # return link_wdg = DivWdg(css="hand") link_wdg.add_style("padding-top: 4px") link_wdg.add_attr("spt_title", title) link_wdg.add_attr("spt_icon", attributes.get("icon")) link_wdg.add_class("spt_side_bar_link") link_wdg.add_attr("spt_view", config.get_view()) link_wdg.add_attr("spt_element_name", element_name) link_wdg.add_attr("spt_path", options['path']) # add the mouseover color change link_wdg.add_style("color: #292929") link_wdg.add_class("SPT_DTS") hover = link_wdg.get_color("background3", -10) link_wdg.add_event("onmouseover", "this.style.background='%s'" % hover) link_wdg.add_event("onmouseout", "this.style.background=''") link_wdg.add_class("spt_side_bar_element") link_wdg.add_looks("fnt_text") link_wdg.add_attr("spt_view", config.get_view()) # add an invisible drop widget drop_wdg = self.get_drop_wdg() drop_wdg.add_style("margin-top: -3px") link_wdg.add(drop_wdg) span = SpanWdg() span.add_class("spt_side_bar_title") # add an icon icon = attributes.get("icon") if icon: icon = icon.upper() from pyasm.widget import IconWdg try: span.add(IconWdg(title, eval("IconWdg.%s" % icon))) except: pass span.add(title) link_wdg.add(span) return link_wdg
def generate_section(self, config, subsection_div, info, base_path=""): title = self.kwargs.get('title') view = self.kwargs.get('view') base_path_flag = True if not base_path: base_path = "/%s" % info.get('view').capitalize() base_path_flag = False current_path = base_path # add in the elements if config.get_view() == "definition": element_names = config.get_element_names() sort = False # not sorting for now if sort == True: element_names.sort() else: element_names = config.get_element_names() # if there are no elements, then just add a drop widget if not element_names: if self.mode == 'view': item_div = DivWdg() item_div.add_style("margin: 3px") item_div.add_style("color: #555") item_div.add("<i>-- No items --</i>") subsection_div.add(item_div) else: self.add_dummy(config, subsection_div) return for element_name in element_names: display_class = config.get_display_handler(element_name) if display_class == "SeparatorWdg": div = DivWdg() div.add_attr("spt_view", config.get_view()) div.add_class("spt_side_bar_element") div.add_class("spt_side_bar_separator") div.add_attr("spt_element_name", element_name) hr = HtmlElement.hr() hr.add_style("size: 1px") div.add(hr) div.add_style("height", "5") subsection_div.add(div) options = config.get_display_options(element_name) self.add_separator_behavior(div, element_name, config, options) continue elif display_class in ["SideBarSectionLinkWdg", "FolderWdg"]: security = Environment.get_security() default_access = "view" if not security.check_access( "side_bar", element_name, "view", default=default_access): continue title = self._get_title(config, element_name) paths = [] if current_path in paths: is_open = True else: is_open = False options = config.get_display_options(element_name) config_view = config.get_view() current_path = "%s/%s" % (base_path, element_name) # create HTML elements for Section Link ... outer_div = DivWdg() outer_div.add_attr("spt_view", config_view) outer_div.add_class("spt_side_bar_element") outer_div.add_class("spt_side_bar_section") outer_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar") outer_div.add_attr("spt_element_name", element_name) outer_div.add_attr("spt_title", title) #if info.get('login') : # outer_div.add_attr("spt_login", info.get('login')) # add an invisible drop widget outer_div.add(self.get_drop_wdg()) # Create the link s_link_div = DivWdg() s_link_div.add_class("SPT_DTS") s_link_div.add_class("spt_side_bar_section_link") s_link_div.add_style("cursor: pointer") s_link_div.add_style("padding-top: 4px") s_link_div.add_looks("navmenu_section fnt_text fnt_bold") # FIXME: currently 'is_open' is hardcoded to be False (see above) ... the state of open or close # of sections is currently stored in a cookie on the client machine. So, at some point if # we decide to store the open/close state of side bar sections then we need to fix this. # here ... # if is_open: s_link_div.add( "<img src='/context/icons/silk/_spt_bullet_arrow_down_dark.png' " \ "style='float: top left; margin-left: -5px; margin-top: -4px;' />" \ "<span style=''>%s</span>" % title ) else: s_link_div.add( "<img src='/context/icons/silk/_spt_bullet_arrow_right_dark.png' " \ "style='float: top left; margin-left: -5px; margin-top: -4px;' />" \ "<span style=''>%s</span>" % title ) # create the content of the link div s_content_div = DivWdg() info['counter'] = info['counter'] + 1 s_content_div.add_class("SPT_DTS") s_content_div.add_attr("spt_path", current_path) s_content_div.add_class("spt_side_bar_section_content") s_content_div.add_style("padding-left: 11px") if is_open: s_content_div.add_style("display: block") else: s_content_div.add_style("display: none") # add the behaviors self.add_folder_behavior(s_link_div, element_name, config, options) # then get view name from options in order to read a new # config and recurse ... options_view_name = options.get('view') if options_view_name: sub_config = self.get_config(self.config_search_type, options_view_name, default=self.default) self.generate_section(sub_config, s_content_div, info, current_path) outer_div.add(s_link_div) outer_div.add(s_content_div) subsection_div.add(outer_div) else: # FIXME: specify LinkWdg, it's too loosely defined now options = config.get_display_options(element_name) options['path'] = '%s/%s' % (current_path, element_name) # put in a default class name if not options.get('class_name'): options['class_name'] = "tactic.ui.panel.ViewPanelWdg" #FIXME: this cause an error in xmlrpc #options['haha'] = False link_wdg = self.get_link_wdg(element_name, config, options) if link_wdg: self.add_link_behavior(link_wdg, element_name, config, options) subsection_div.add(link_wdg)
def common_wdg(my, vendor): div = DivWdg() div.add_class("spt_db_options") div.add_style("margin: 20px") if vendor != 'MySQL': div.add_attr("spt_vendor", "Other") table = Table() div.add(table) table.add_color("color", "color") table.add_row() table.add_cell("Server: ") text = TextInputWdg(name="server") text.set_value("localhost") table.add_cell(text) server = Config.get_value("database", "server") if server: text.set_value(server) table.add_row() table.add_cell("Port: ") text = TextInputWdg(name="port") table.add_cell(text) port = Config.get_value("database", "port") if port: text.set_value(port) table.add_row() table.add_cell("Login: "******"user") table.add_cell(text) user = Config.get_value("database", "user") if user: text.set_value(user) table.add_row() text = PasswordInputWdg(name="password") table.add_cell("Password: "******"database", "password") if password: text.set_value(password) if vendor == 'MySQL': div.add_attr("spt_vendor", "MySQL") table.add_row() text = TextInputWdg(name="encoding") table.add_cell("Encoding: ") table.add_cell(text) encoding = Config.get_value("database", "encoding") if encoding: text.set_value(encoding) table.add_row() text = TextInputWdg(name="charset") table.add_cell("Charset: ") table.add_cell(text) charset = Config.get_value("database", "charset") if charset: text.set_value(charset) #from pyasm.search import Sql #sql.connect() return div
def get_display(my): my.labels_attr = my.get_option('label_attr') if my.labels_attr: my.labels_attr = my.labels_attr.split('|') from tactic.ui.panel import EditWdg if hasattr(my, 'parent_wdg') and isinstance(my.get_parent_wdg(), EditWdg): sobject = my.get_current_sobject() parent = sobject.get_parent() group = None pipeline_code = None if parent: pipeline_code = parent.get_value('pipeline_code') pipeline = Pipeline.get_by_code(pipeline_code) labels_expr = None if pipeline: attrs = pipeline.get_process_attrs(sobject.get_value('process')) group = attrs.get('%s_login_group'%my.get_name()) if group: values_expr = "@GET(sthpw/login_group['login_group', '%s'].sthpw/login_in_group.sthpw/login.login)"%group if my.labels_attr: labels_expr = ["@GET(sthpw/login_group['login_group', '%s'].sthpw/login_in_group.sthpw/login.%s)"%(group, x.strip()) for x in my.labels_attr] labels_expr = ' +   + '.join(labels_expr) else: values_expr = "@GET(sthpw/login.login)" if my.labels_attr: labels_expr = ["@GET(sthpw/login.%s)"%(x.strip()) for x in my.labels_attr] labels_expr = ' +   + '.join(labels_expr) select = SelectWdg(my.get_input_name()) select.add_empty_option("-- Select a User --") """ values = [] labels = [] for user in group_users: values.append(user) labels.append(' %s'%user) """ select.set_option('values_expr', values_expr) if labels_expr: select.set_option('labels_expr', labels_expr) current_value = sobject.get_value(my.get_name()) if current_value: select.set_value(current_value) return select #all_users = Search.eval("@GET(sthpw/login.login)") all_users = Search.eval("@SOBJECT(sthpw/login)") all_users_label = [] # don't use expression here since it's not as db-efficient as retrieving the sobjects """ if my.labels_attr: labels_expr = ["@GET(sthpw/login.login.%s)"%x.strip() for x in my.labels_attr] """ ''' groups = Search.eval("@SOBJECT(sthpw/login_group)") group_dict = {} for group in groups: group_users = Search.eval("@GET(sthpw/login_group['login_group', '%s'].sthpw/login_in_group.sthpw/login.login)"%group.get_value('login_group')) group_dict[group.get_value('login_group')] = group_users ''' logins_dict = {} for user in all_users: user_name = user.get_value('login') logins_dict[user_name] = {} group_dict = {} items = Search.eval("@SOBJECT(sthpw/login_in_group)") for item in items: item_login = item.get_value("login") if logins_dict.get(item_login) == None: continue item_group = item.get_value("login_group") group_list = group_dict.get(item_group) if group_list == None: group_list = [] group_dict[item_group] = group_list group_list.append(item_login) top = DivWdg() top.add_class("spt_input_top") # HACK! This isn't very well constructed ### Tore: Not my code! Copied from ProcessContextInputWdg. Seems to work though. top.add_attr("spt_cbjs_get_input_key", "return cell_to_edit.getAttribute('spt_pipeline_code');") # Adding an "all users" select option in case it can't find a useful select widget. div = DivWdg() div.add_class("spt_input_option") #div.add_attr("spt_input_key", '__all__') #Not needed, since it defaults to the first one anyway. select = SelectWdg(my.get_name()) select.add_empty_option("-- Select a User --") values = [] labels = [] labels_dict = {} for user in all_users: user_name = user.get_value('login') values.append(user_name) label = user_name if my.labels_attr: user_labels = [user.get_value(x) for x in my.labels_attr] label = ' '.join(user_labels) labels_dict[user_name] = label labels.append('%s'%label) #print "select ", user_name # -- NOTE: leaving this commented out code here for reference. Not sure why this is the case but when # -- this click behavior is used instead of a 'change' behavior that forces a blur on select, # -- click selection only works for this widget in Firefox and does NOT work in IE # # select.add_behavior( { 'type': 'click', # 'cbjs_action': 'spt.dg_table.select_wdg_clicked( evt, bvr.src_el );' } ) # -- Replace previous 'click' behavior with a 'change' behavior to force blur() of select element ... # -- this works for both Firefox and IE # select.add_behavior( { 'type': 'change', 'cbjs_action': 'bvr.src_el.blur();' } ) #behavior = { # 'type': 'keyboard', # 'kbd_handler_name': 'DgTableSelectWidgetKeyInput', #} #select.add_behavior( behavior ) select.set_option("values", values) select.set_option("labels", labels) div.add(select) top.add(div) #Building each of the select widgets per group here. for group in group_dict.keys(): div = DivWdg() div.add_class("spt_input_option") div.add_attr("spt_input_key", group) select = SelectWdg(my.get_name()) select.add_empty_option("-- Select a User --") values = [''] labels = ['<< %s >>'%group] for user in group_dict[group]: values.append(user) label = labels_dict.get(user) labels.append(' %s'%label) select.add_behavior( { 'type': 'click', 'cbjs_action': 'spt.dg_table.select_wdg_clicked( evt, bvr.src_el );' } ) #behavior = { # 'type': 'keyboard', # 'kbd_handler_name': 'DgTableSelectWidgetKeyInput', #} #select.add_behavior( behavior ) select.set_option("values", values) select.set_option("labels", labels) div.add(select) top.add(div) return top
def get_display(my): query = my.get_option("query") depend_col = my.get_option("dependency") # for example # FIXME: this has to be fleshed out ... it's a little too complicated # at the moment!!! query = "MMS/product_type|id|product_name" depend_col = "discipline_id" depend_element = 'discipline' top = DivWdg() top.add_class("spt_input_top") top.add_attr( "spt_cbjs_get_input_key", "var value=spt.dg_table.get_element_value(cell_to_edit, '%s');return value" % depend_element) top.add_style("background: black") # get all of the sobjects search_type, value_col, label_col = query.split("|") search = Search(search_type) sobjects = search.get_sobjects() # arrange the sobjects according to keys selections = {} for sobject in sobjects: depend_value = sobject.get_value(depend_col) selection_list = selections.get(depend_value) if not selection_list: selection_list = [] selections[depend_value] = selection_list selection_list.append(sobject) # put in a default default_div = DivWdg() default_div.add_class("spt_input_option") default_div.add_attr("spt_input_key", "default") default_div.add("No options for selected [%s]" % depend_element) top.add(default_div) # add list of possible select statements for key, selection_list in selections.items(): div = DivWdg() div.add_class("spt_input_option") div.add_attr("spt_input_key", key) values = [] labels = [] for sobject in selection_list: values.append(sobject.get_value(value_col)) labels.append(sobject.get_value(label_col)) select = SelectWdg(my.get_input_name()) select.add_empty_option('-- Select --') select.set_option("values", values) select.set_option("labels", labels) div.add(select) from tactic.ui.panel import CellEditWdg CellEditWdg.add_edit_behavior(select) top.add(div) return top
def get_day_wdg(self, month, day): div = DivWdg() div.add_style("width: 120px") div.add_style("height: 150px") div.add_style("padding: 5px") # disabled until further development is done on WeekWdg """ div.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.widget.week_wdg.WeekWdg'; spt.panel.load_popup("Week", class_name); ''' } ) """ # if the day is today today = datetime.today() if day.year == today.year and day.month == today.month and day.day == today.day: div.add_color("background", "background", [-20, -20, 20]) div.add("[%s]" % day.day) elif day.weekday() in [5, 6]: div.add_color("background", "background", -3) if day.month != self.month: div.add("<i style='opacity: 0.3'>[%s]</i>" % day.day) else: div.add("[%s]" % day.day) # if the month is different than today elif day.month != self.month: #div.add_color("background", "background", [-5, -5, -5]) div.add("<i style='opacity: 0.3'>[%s]</i>" % day.day) else: div.add("[%s]" % day.day) div.add(HtmlElement.br(2)) key = "%s-%0.2d-%0.2d 00:00:00" % (day.year, day.month, day.day) div.add_attr("date", key) div.add_class("spt_date_div_content") line_div = DivWdg() div.add(line_div) line_div.add_style("padding: 3px") icon = IconWdg("Number of task due", IconWdg.CALENDAR) line_div.add(icon) num_tasks = self.tasks_count.get(key) if not num_tasks: num_tasks = 0 line_div.add_style("opacity: 0.15") line_div.add_style("font-style: italic") line_div.add("%s task/s due" % num_tasks) line_div.add(HtmlElement.br()) line_div = DivWdg() div.add(line_div) line_div.add_style("padding: 3px") icon = IconWdg("Number of check-ins", IconWdg.PUBLISH) line_div.add(icon) num_snapshots = self.snapshots_count.get(key) if not num_snapshots: num_snapshots = 0 line_div.add_style("opacity: 0.15") line_div.add_style("font-style: italic") line_div.add("%s check-in/s" % num_snapshots) line_div.add(HtmlElement.br()) line_div = DivWdg() div.add(line_div) line_div.add_style("padding: 3px") icon = IconWdg("Number of notes", IconWdg.NOTE) line_div.add(icon) num_notes = self.notes_count.get(key) if not num_notes: num_notes = 0 line_div.add_style("opacity: 0.15") line_div.add_style("font-style: italic") line_div.add("%s note/s" % num_notes) line_div.add(HtmlElement.br()) line_div = DivWdg() div.add(line_div) line_div.add_style("padding: 3px") icon = IconWdg("Work Hours", IconWdg.CLOCK) line_div.add(icon) work_hours = self.work_hours_count.get(key) if not work_hours: work_hours = 0 line_div.add_style("opacity: 0.15") line_div.add_style("font-style: italic") line_div.add("%s work hours" % work_hours) line_div.add(HtmlElement.br()) line_div = DivWdg() div.add(line_div) line_div.add_style("padding: 3px") num_milestone = self.milestones_count.get(key) if num_milestone: icon = IconWdg("Milestones", IconWdg.GOOD) line_div.add(icon) line_div.add_style("font-style: italic") line_div.add_style("cursor: pointer;") line_div.add("%i milestone/s" % (num_milestone)) line_div.add(HtmlElement.br()) line_div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var key_array = "%s".split(" "); // array var single_day = key_array[0]; // string var time_key = Date.parse(single_day); // time object var time_key_str = time_key.format('db'); // string var next_day = time_key.increment('day', 1).format('db'); // string var class_name = "tactic.ui.panel.FastTableLayoutWdg"; var popup_kwargs = { "search_type": "sthpw/milestone", "expression": "@SOBJECT(sthpw/milestone['due_date', '>=', '" + time_key_str + "']['due_date', '<=', '" + next_day + "']['@ORDER_BY', 'due_date desc'])" }; spt.tab.set_main_body_tab(); spt.tab.add_new("add_milestone", "Add Milestone", class_name, popup_kwargs); //spt.panel.load_popup("Add Milestone", class_name, popup_kwargs); ''' % (key) }) else: num_milestone = 0 icon = IconWdg("Milestones", "BS_PLUS") line_div.add(icon) #line_div.add_style("opacity: 0.85") line_div.add("Add milestone") line_div.add(HtmlElement.br()) line_div.add_style("cursor: pointer") line_div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var server = TacticServerStub.get(); var date_div = bvr.src_el.getParent("td"); var full_date = date_div.getElement(".spt_date_div_content").getAttribute("date"); var date_array = full_date.split(" "); full_date = date_array[0]; date_array = full_date.split("-"); var date = date_array[2]; var month = date_array[1]; var year = date_array[0]; var due_date_string = month.concat(" " + date + ", ").concat(year); var project_code = server.get_project(); data = { "due_date": due_date_string, "project_code": project_code }; var class_name = "tactic.ui.panel.EditWdg"; var popup_kwargs = { "default": data, "search_type": "sthpw/milestone" }; spt.panel.load_popup("Add Milestone", class_name, popup_kwargs); ''' }) #div.add("%s tasks completed<br/>" % self.task_count) #div.add("%s notes entered<br/>" % self.notes_count) #div.add("%s work hours<br/>" % self.work_hours_count) return div
def get_display(my): my.view_editable = True if my.kwargs.get("do_search") != "false": my.handle_search() #my.kwargs['show_gear'] = 'false' # set the sobjects to all the widgets then preprocess for widget in my.widgets: widget.set_sobjects(my.sobjects) widget.set_parent_wdg(my) # preprocess the elements widget.preprocess() """ # TEST code to return only the content temp = my.kwargs.get("temp") if temp: content = DivWdg() content.add( my.get_content_wdg() ) return content """ # extraneous variables inherited from TableLayoutWdg my.edit_permission = True top = DivWdg() my.set_as_panel(top) top.add_class("spt_sobject_top") inner = DivWdg() top.add(inner) # This is handled elsewhere #inner.add_color("background", "background") inner.add_color("color", "color") inner.add_attr("spt_version", "2") inner.add_class("spt_table") inner.add_class("spt_layout") if not Container.get_dict("JSLibraries", "spt_html5upload"): from tactic.ui.input import Html5UploadWdg upload_wdg = Html5UploadWdg() inner.add(upload_wdg) my.upload_id = upload_wdg.get_upload_id() inner.add_attr('upload_id',my.upload_id) # this interferes with Html5Upload function on first load, commenting it out #thumb = ThumbWdg() #thumb.handle_layout_behaviors(inner) is_refresh = my.kwargs.get("is_refresh") if my.kwargs.get("show_shelf") not in ['false', False]: action = my.get_action_wdg() inner.add(action) content = DivWdg() inner.add( content ) content.add( my.get_content_wdg() ) # NOTE: a lot of scaffolding to convince that search_cbk that this # is a proper layout top.add_class("spt_table_top"); class_name = Common.get_full_class_name(my) top.add_attr("spt_class_name", class_name) # NOTE: adding a fake header to conform to a table layout. Not # sure if this is the correct interface for this header_row_div = DivWdg() header_row_div.add_class("spt_table_header_row") content.add(header_row_div) content.add_class("spt_table_table") content.set_id(my.table_id) my.handle_load_behaviors(content) inner.add_class("spt_table_content"); inner.add_attr("spt_search_type", my.kwargs.get('search_type')) inner.add_attr("spt_view", my.kwargs.get('view')) limit_span = DivWdg() inner.add(limit_span) limit_span.add_style("margin-top: 4px") limit_span.add_class("spt_table_search") limit_span.add_style("width: 250px") limit_span.add_style("margin: 5 auto") info = my.search_limit.get_info() if info.get("count") == None: info["count"] = len(my.sobjects) from tactic.ui.app import SearchLimitSimpleWdg limit_wdg = SearchLimitSimpleWdg( count=info.get("count"), search_limit=info.get("search_limit"), current_offset=info.get("current_offset"), ) inner.add(limit_wdg) my.add_layout_behaviors(inner) if my.kwargs.get("is_refresh") == 'true': return inner else: return top
def get_display(self): self.view_editable = True #if self.kwargs.get("do_search") != "false": # self.handle_search() self._process_search_args() #self.kwargs['show_gear'] = 'false' from tile_layout_wdg import TileLayoutWdg self.tile_layout = TileLayoutWdg(search_type=self.search_type, expand_mode=self.expand_mode, process=self.process) # set the sobjects to all the widgets then preprocess for widget in self.widgets: widget.set_sobjects(self.sobjects) widget.set_parent_wdg(self) # preprocess the elements widget.preprocess() """ # TEST code to return only the content temp = self.kwargs.get("temp") if temp: content = DivWdg() content.add( self.get_content_wdg() ) return content """ # extraneous variables inherited from TableLayoutWdg self.edit_permission = True top = self.top self.set_as_panel(top) top.add_class("spt_sobject_top") top.add_class("spt_layout_top") inner = DivWdg() top.add(inner) # This is handled elsewhere #inner.add_color("background", "background") inner.add_color("color", "color") inner.add_attr("spt_version", "2") inner.add_class("spt_table") inner.add_class("spt_layout") self.layout_wdg = inner class_name = Common.get_full_class_name(self) inner.add_attr("spt_class_name", class_name) if not Container.get_dict("JSLibraries", "spt_html5upload"): from tactic.ui.input import Html5UploadWdg upload_wdg = Html5UploadWdg() inner.add(upload_wdg) self.upload_id = upload_wdg.get_upload_id() inner.add_attr('upload_id',self.upload_id) # this interferes with Html5Upload function on first load, commenting it out #thumb = ThumbWdg() #thumb.handle_layout_behaviors(inner) is_refresh = self.kwargs.get("is_refresh") if self.kwargs.get("show_shelf") not in ['false', False]: action = self.get_action_wdg() inner.add(action) info = self.search_limit.get_info() if info.get("count") == None: info["count"] = len(self.sobjects) show_search_limit = self.kwargs.get("show_search_limit") if show_search_limit in ['false', False]: search_limit_mode = None else: search_limit_mode = self.kwargs.get('search_limit_mode') if not search_limit_mode: search_limit_mode = 'bottom' if search_limit_mode in ['top','both']: from tactic.ui.app import SearchLimitSimpleWdg limit_wdg = SearchLimitSimpleWdg( count=info.get("count"), search_limit=info.get("search_limit"), current_offset=info.get("current_offset") ) inner.add(limit_wdg) content = DivWdg() inner.add( content ) content.add( self.get_content_wdg() ) # NOTE: a lot of scaffolding to convince that search_cbk that this # is a proper layout top.add_class("spt_table_top"); class_name = Common.get_full_class_name(self) top.add_attr("spt_class_name", class_name) # NOTE: adding a fake header to conform to a table layout. Not # sure if this is the correct interface for this header_row_div = DivWdg() header_row_div.add_class("spt_table_header_row") content.add(header_row_div) content.add_class("spt_table_table") content.set_id(self.table_id) self.handle_load_behaviors(content) inner.add_class("spt_table_content"); inner.add_attr("spt_search_type", self.kwargs.get('search_type')) inner.add_attr("spt_view", self.kwargs.get('view')) limit_span = DivWdg() inner.add(limit_span) limit_span.add_style("margin-top: 4px") limit_span.add_class("spt_table_search") limit_span.add_style("width: 250px") limit_span.add_style("margin: 5 auto") inner.add_attr("total_count", info.get("count")) if search_limit_mode in ['bottom','both']: from tactic.ui.app import SearchLimitSimpleWdg limit_wdg = SearchLimitSimpleWdg( count=info.get("count"), search_limit=info.get("search_limit"), current_offset=info.get("current_offset"), ) inner.add(limit_wdg) self.add_layout_behaviors(inner) if self.kwargs.get("is_refresh") == 'true': return inner else: return top
def get_item_wdg(self, sobject): self.element_names = self.kwargs.get("element_names") if not self.element_names: self.element_names = ["preview","code","name","description",] else: self.element_names = self.element_names.split(",") if self.element_names[0] == "preview": has_preview = True self.element_names = self.element_names[1:] else: has_preview = False view = self.kwargs.get("view") if not view: view = "table" from pyasm.widget import WidgetConfigView search_type = sobject.get_search_type() self.config = WidgetConfigView.get_by_search_type(search_type, view) div = DivWdg() div.add_class("spt_item_top") div.add_style("padding: 10px") SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' ) #div.add_class("spt_table_row") #div.add_class("spt_table_row_%s" % self.table_id) div.add_attr("spt_search_key", sobject.get_search_key(use_id=True)) div.add_attr("spt_search_code", sobject.get_code()) name = sobject.get_value("name", no_exception=True) if not name: name = sobject.get_code() div.add_attr("spt_name", name) table = Table() div.add(table) table.set_max_width() tr = table.add_row() width = self.kwargs.get("preview_width") if not width: width = "240px" if has_preview: td = table.add_cell() td.add_style("width: %s" % width); td.add_style("vertical-align: top") options = self.config.get_display_options("preview") redirect_expr = options.get("redirect_expr") if redirect_expr: parent = Search.eval(redirect_expr, sobject, single=True) #parent = sobject.get_parent() tile_wdg = self.tile_layout.get_tile_wdg(parent) else: tile_wdg = self.tile_layout.get_tile_wdg(sobject) td.add(tile_wdg) info_div = self.get_info_wdg(sobject) td = table.add_cell(info_div) td.add_style("vertical-align: top") return div
def get_chat_wdg(self, key, interval=False): div = DivWdg() div.add_class("spt_chat_session_top") div.add_color("background", "background") title_wdg = DivWdg() div.add(title_wdg) title_wdg.add_color("background", "background3") title_wdg.add_style("padding: 5px") title_wdg.add_style("font-weight: bold") title_wdg.add_border() icon = IconButtonWdg(title="Remove Chat", icon=IconWdg.DELETE) icon.add_style("float: right") icon.add_style("margin-top: -5px") title_wdg.add(icon) icon.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var server = TacticServerStub.get(); var top = bvr.src_el.getParent(".spt_chat_session_top"); spt.behavior.destroy_element(top); ''' } ) current_user = Environment.get_user_name() logins = Search.eval("@SOBJECT(sthpw/subscription['message_code','%s'].sthpw/login)" % key) for login in logins: if login.get_value("login") == current_user: continue thumb = ThumbWdg() thumb.set_icon_size(45) thumb.set_sobject(login) thumb.add_style("float: left") thumb.add_style("margin: -5px 10px 0px -5px") title_wdg.add(thumb) title_wdg.add(login.get_value("display_name")) title_wdg.add("<br clear='all'/>") history_div = DivWdg() div.add(history_div) history_div.add_class("spt_chat_history") history_div.add_style("width: auto") history_div.add_style("height: auto") history_div.add_style("max-height: 400px") history_div.add_style("padding: 5px") history_div.add_class("spt_resizable") history_div.add_border() history_div.add_style("overflow-y: auto") #history_div.add_style("font-size: 0.9em") search = Search("sthpw/message_log") search.add_filter("message_code", key) search.add_order_by("timestamp") message_logs = search.get_sobjects() last_login = None; last_date = None; for message_log in message_logs: login = message_log.get("login") message = message_log.get("message") timestamp = message_log.get_datetime_value("timestamp") #timestamp = timestamp.strftime("%b %d, %Y - %H:%M") timestamp_str = timestamp.strftime("%H:%M") date_str = timestamp.strftime("%b %d, %Y") if login != last_login: table = Table() history_div.add(table) table.add_row() table.add_style("width: 100%") table.add_style("margin-top: 15px") login_sobj = Search.get_by_code("sthpw/login", login) thumb_div = DivWdg() td = table.add_cell() td.add_style("vertical-align: top") td.add_style("width: 75px") thumb_div = DivWdg() td.add(thumb_div) thumb_div.add_style("overflow: hidden") thumb = ThumbWdg() thumb_div.add(thumb) thumb.set_sobject(login_sobj) thumb.set_icon_size(60) display_name = login_sobj.get("display_name") td = table.add_cell() td.add_style("padding-top: 3px") name_div = DivWdg() td.add(name_div) name_div.add_style("color", "#214e75") name_div.add_style("font-size", "1.3em") name_div.add(display_name) msg = ""; msg += "<table style='margin-top: 5px; font-size: 1.0em; width: 100%'>"; if date_str != last_date: msg += "<tr><td colspan='2' style='text-align: right'><br/><b style='font-size: 1.0em'>"+date_str+"</b></td></tr>"; last_login = None msg += "<tr><td>" msg += message.replace("\n",'<br/>') msg += "</td><td style='vertical-align: top; text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top; opacity: 0.7;'>"; msg += timestamp_str; msg += "</td></tr></table>"; td.add(msg) last_login = login last_date = date_str history_div.add_behavior( { 'type': 'load', 'cbjs_action': ''' bvr.src_el.scrollTop = bvr.src_el.scrollHeight; ''' } ) if message_logs: last_message = message_logs[-1].get("message") last_login = message_logs[-1].get("login") else: last_message = "" last_login = "" div.add_attr("spt_last_message", last_message) div.add_attr("spt_last_login", last_login) if interval: div.add_behavior( { 'type': 'load', 'key': key, 'cbjs_action': r''' var text_el = bvr.src_el.getElement(".spt_chat_text"); var history_el = bvr.src_el.getElement(".spt_chat_history"); var callback = function(message) { //history_el.setStyle("background", "red"); var login = message.login; var timestamp = message.timestamp; if (timestamp) { var parts = timestamp.split(" "); parts = parts[1].split("."); timestamp = parts[0]; } else { timestamp = ""; } var tmp = message.message || ""; var last_message = bvr.src_el.getAttribute("spt_last_message"); var last_login = bvr.src_el.getAttribute("spt_last_login"); if (tmp == last_message && login == last_login) { return; } bvr.src_el.setAttribute("spt_last_message", tmp); bvr.src_el.setAttribute("spt_last_login", login); var msg = ""; msg += "<table style='margin-top: 5px; font-size: 1.0em; width: 100%'><tr><td>"; if (login != last_login) { msg += "<b>"+login+"</b><br/>"; } msg += tmp.replace(/\n/g,'<br/>'); msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>"; msg += timestamp; msg += "</td></tr></table>"; if (msg == history_el.last_msg) { return; } history_el.innerHTML = history_el.innerHTML + msg; // remember last message history_el.last_msg = msg; history_el.scrollTop = history_el.scrollHeight; } spt.message.set_interval(bvr.key, callback, 3000, bvr.src_el); ''' } ) text = TextAreaWdg("chat") div.add(text) text.add_class("spt_chat_text") text.add_style("width: 100%") text.add_style("padding: 5px") #text.add_style("margin-top: -1px") text.add_style("margin-top: 5px") text.add_behavior( { 'type': 'load', 'cbjs_action': ''' bvr.src_el.addEvent("keydown", function(e) { var keys = ['tab','keys(control+enter)', 'enter']; var key = e.key; var input = bvr.src_el if (keys.indexOf(key) > -1) e.stop(); if (key == 'tab') { } else if (key == 'enter') { if (e.control == false) { pass; } else { // TODO: check if it's multi-line first //... use ctrl-ENTER for new-line, regular ENTER (RETURN) accepts value //var tvals = parse_selected_text(input); //input.value = tvals[0] + "\\n" + tvals[1]; //spt.set_cursor_position( input, tvals[0].length + 1 ); } } } ) ''' } ) button = ActionButtonWdg(title="Send") div.add(button) button.add_style("float: right") button.add_style("margin: 5px") button.add_behavior( { 'type': 'click_up', 'key': key, 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_chat_session_top"); var text_el = top.getElement(".spt_chat_text"); var message = text_el.value; if (!message) { return; } var history_el = top.getElement(".spt_chat_history"); var category = "chat"; var server = TacticServerStub.get(); var key = bvr.key; var last_message = server.log_message(key, message, {category:category, status:"in_progress"}); text_el.value = ""; ''' } ) div.add("<br clear='all'/>") return div
def get_display(self): top = DivWdg() top.add_border() top.add_style("padding: 10px") top.add_color("color", "color") top.add_gradient("background", "background", 0, -5) #top.add_style("height: 550px") top.add_behavior({ 'type': 'load', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|hide_now", {} ); ''' }) project = Project.get() title = DivWdg() title.add("Project Startup and Configuration") title.add_style("font-size: 18px") title.add_style("font-weight: bold") title.add_style("text-align: center") title.add_style("padding: 10px") title.add_style("margin: -10px -10px 10px -10px") top.add(title) title.add_gradient("background", "background3", 5, -10) shelf = DivWdg() top.add(shelf) shelf.add_style("margin-left: -8px") shelf.add_style("width: 130px") button_div = DivWdg() shelf.add(button_div) button_div.add_style("float: left") button_div.add_style("margin-top: -3px") security = Environment.get_security() view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow') if view_side_bar: button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT) button_div.add(button) shelf.add("Toggle Side Bar") shelf.add_attr("title", "Toggle Side Bar (or press '1')") button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' }) shelf.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' }) shelf.add_class("hand") else: shelf.add(" ") search_wdg = Table() top.add(search_wdg) search_wdg.add_row() search_wdg.add_class("spt_main_top") search_wdg.add_style("padding: 10px") search_wdg.add_style("margin: 20px auto") search_wdg.add_style("width: 430px") td = search_wdg.add_cell("Search: ") td.add_style("vertical-align: top") td.add_style("padding-top: 8px") custom_cbk = {} custom_cbk['enter'] = ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords != '') { var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'result_list', 'keywords': keywords, 'simple_search_view': 'simple_filter', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); } ''' from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg #text = TextInputWdg(name="search") text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk, width='280', height='42px') #text = TextWdg("search") text.add_class("spt_main_search") text.add_style("width: 290px") search_wdg.add_cell(text) search_wdg.add_style("font-weight: bold") search_wdg.add_style("font-size: 16px") icon_div = DivWdg() td = search_wdg.add_cell(icon_div) td.add_style("vertical-align: top") icon_div.add_style("width: 38px") icon_div.add_style("height: 27px") icon_div.add_style("padding-top: 7px") icon_div.add_style("padding-left: 4px") icon_div.add_style("text-align: center") #icon_div.add_gradient("background", "background3", 15, -10) icon_div.add_color("background", "background3", 10) over_color = icon_div.get_color("background3", 0) out_color = icon_div.get_color("background3", 10) icon_div.set_round_corners(5) icon_div.set_box_shadow("1px 1px 1px 1px") icon = IconWdg("Search", IconWdg.SEARCH_32, width=24) icon_div.add(icon) button = icon_div icon_div.add_class("hand") icon_div.add_behavior({ 'type': 'mouseover', 'color': over_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); ''' }) icon_div.add_behavior({ 'type': 'mouseout', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' }) icon_div.add_behavior({ 'type': 'click', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-3"); bvr.src_el.setStyle("margin-right", "-2"); ''' }) icon_div.add_behavior({ 'type': 'click_up', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' }) button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords == '') { return; } var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'result_list', 'keywords': keywords, 'simple_search_view': 'simple_filter', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); ''' }) #desc = DivWdg() #top.add(desc) #desc.add("Dashboard") #desc.add_style("width: 600px") # create a bunch of panels table = Table() table.add_color("color", "color") table.add_style("margin-bottom: 20px") table.center() top.add(table) table.add_row() #security = Environment.get_security() #if not security.check_access("builtin", "view_site_admin", "allow"): td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Configuration" #description = '''All TACTIC projects can be uniquely designed and managed using our configuration tools.''' description = '''Configure a Project from start to finish.''' image = "<img src='/context/icons/64x64/configuration_64.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.ProjectConfigWdg'; var kwargs = { help_alias: 'project-startup-configuration' }; spt.tab.add_new("project_configuration", "Configuration", class_name, kwargs); ''' } config_wdg = self.get_main_section_wdg(title, description, image, behavior) td.add(config_wdg) # Manage Users td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Manage Users and Security" image = "<img src='/context/icons/64x64/dashboard_64.png'/>" image = DivWdg() image_link = "<div style='margin-bottom: -64px'><img src='/context/icons/64x64/lock_64.png'/></div>" image.add(image_link) image1 = IconWdg("Manage Users", IconWdg.USER_32) image2 = IconWdg("Manage Users", IconWdg.USER_32) image3 = IconWdg("Manage Users", IconWdg.USER_32) image4 = IconWdg("Manage Users", IconWdg.USER_32) image.add(image1) image.add(image2) image.add("<br/>") image.add(image3) image.add(image4) description = '''Manage users that can access the system''' behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.UserConfigWdg'; var kwargs = { help_alias: 'project-startup-manage-users' }; spt.tab.add_new("manage_user", "Manage Users", class_name, kwargs); ''' } manage_users_wdg = self.get_main_section_wdg(title, description, image, behavior) td.add(manage_users_wdg) # custom layout editor td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Custom Layouts" description = '''Create interfaces using the Custom Layout Editor.''' image = "<img src='/context/icons/64x64/layout_64.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.tools.CustomLayoutEditWdg'; var kwargs = { help_alias: 'project-startup-configuration' }; spt.tab.add_new("custom_layout_editor", "Custom Layout Editor", class_name, kwargs); ''' } config_wdg = self.get_main_section_wdg(title, description, image, behavior) td.add(config_wdg) tr = table.add_row() # Plugins td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Manage Plugins" image = IconWdg("Manage Plugins", IconWdg.PLUGIN_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Upload, install, remove and create TACTIC plugins.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.PluginWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("plugins", "Manage Plugin", class_name, kwargs); ''' } plugin_wdg = self.get_small_section_wdg(title, description, image, behavior) td.add(plugin_wdg) # Examples td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Tools" image = IconWdg("Tools", IconWdg.SHARE_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''A collection of example views.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ToolsWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("tools", "Tools", class_name, kwargs); ''' } share_wdg = self.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) # Share """ td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Shares" image = IconWdg("Shares", IconWdg.SHARE_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Share project with other TACTIC installs.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ShareWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("shares", "Shares", class_name, kwargs); ''' } share_wdg = self.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) """ # Advanced td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Advanced Setup" image = IconWdg("Advanced", IconWdg.ADVANCED_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''A set of advanced configuration tools.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.ProjectStartWdg'; spt.tab.set_main_body_tab() spt.tab.add_new("project_setup", "Project Setup", class_name) ''' } share_wdg = self.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) """ td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Documentation" description = '''TACTIC Documentation. * Project Setup Documentation<br/> <br/> * End User Documentation<br/> <br/> * Developer Documentation<br/> <br/> * System Administrator Documentation<br/> <br/> ''' image = "<img src='/context/images/getting_started_pipeline.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.help.load_alias("main") ''' } doc_wdg = self.get_section_wdg(title, description, image, behavior) td.add(doc_wdg) """ tr, td = table.add_row_cell() td.add_style("font-size: 14px") td.add("<br/>") from misc_wdg import QuickLinksWdg quick_links_wdg = QuickLinksWdg() td.add(quick_links_wdg) #td = table.add_cell() #totals_wdg = self.get_totals_wdg() #td.add(totals_wdg) return top
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