def get_custom_layout_wdg(my, layout_view): content_div = DivWdg() from tactic.ui.panel import CustomLayoutWdg layout = CustomLayoutWdg(view=layout_view) content_div.add(layout) for widget in my.widgets: name = widget.get_name() if my.input_prefix: widget.set_input_prefix(my.input_prefix) layout.add_widget(widget, name) search_key = SearchKey.get_by_sobject(my.sobjects[0], use_id=True) search_type = my.sobjects[0].get_base_search_type() element_names = my.element_names[:] for element_name in my.skipped_element_names: element_names.remove(element_name) config_xml = my.kwargs.get("config_xml") bvr = { 'type': 'click_up', 'mode': my.mode, 'element_names': element_names, 'search_key': search_key, 'input_prefix': my.input_prefix, 'view': my.view, 'config_xml': config_xml } if my.mode == 'insert': bvr['refresh'] = 'true' # for adding parent relationship in EditCmd if my.parent_key: bvr['parent_key'] = my.parent_key hidden_div = DivWdg() hidden_div.add_style("display: none") content_div.add(hidden_div) hidden = TextAreaWdg("__data__") hidden_div.add(hidden) hidden.set_value( jsondumps(bvr) ) show_action = my.kwargs.get("show_action") if show_action in [True, 'true']: content_div.add( my.get_action_html() ) return content_div
def get_view_wdg(my, sobject, view): div = DivWdg() #div.add_style("overflow: hidden") kwargs = { 'view': view, } from tactic.ui.panel import CustomLayoutWdg layout = CustomLayoutWdg(**kwargs) layout.set_sobject(sobject) div.add(layout.get_buffer_display()) return div
def get_display(self): from tactic.ui.panel import ViewPanelWdg, CustomLayoutWdg top = self.top detail_view = self.kwargs.get("detail_view") if detail_view: self.kwargs['view'] = detail_view layout = CustomLayoutWdg(**self.kwargs) else: top.add_style("margin: 20px") day = self.kwargs.get("day") title = self.kwargs.get("st_title") title = Common.pluralize(title) title_wdg = DivWdg() top.add(title_wdg) title_wdg.add( "<div style='font-size: 25px'>%s for date: %s</div>" % (title, day)) title_wdg.add("List of %s on this day." % title) title_wdg.add("<hr/>") self.kwargs['show_shelf'] = False layout = ViewPanelWdg(**self.kwargs) top.add(layout) return top
def get_content_wdg(my): view = my.kwargs.get("view") from tactic.ui.panel import CustomLayoutWdg layout = CustomLayoutWdg(view=view) return layout
def get_display(my): top = Widget() from tactic.ui.panel import CustomLayoutWdg #widget = CustomLayoutWdg(view="bootstrap.basic.test_mootools", is_top=True) widget = CustomLayoutWdg(view="bootstrap.themes.jumbotron.main2", is_top=True) #widget = CustomLayoutWdg(view="bootstrap.basic.test2", is_top=True) top.add(widget) return top
def get_display(self): from tactic.ui.panel import CustomLayoutWdg top = self.top top.add_class("spt_content_box") top.add_class("spt_content_box_inline") top.add_style("min-width: 200px") #top.add_style("opacity: 0.1") """ top.add_behavior( { 'type': 'loadX', 'cbjs_action': ''' new Fx.Tween(bvr.src_el, {duration: 500}).start("opacity", 1.0); ''' } ) """ colors = { #"color3": top.get_color("color3"), #"background3": top.get_color("background3"), #"background3": "rgba(18, 50, 91, 1.0)", "background3": "#323232", "color3": "#FFF", "border": top.get_color("border", -10), } style = HtmlElement.style() top.add(style) style.add(''' .spt_content_box_inline { margin: 15px; } .spt_content_box_max { margin: 0px; width: 100%%; height: 100%%; background: rgba(0,0,0,0.0); z-index: 1000; position: fixed; top: 0px; left: 0px; } .spt_content_box_max .spt_content_box_content { //height: 100%% !important; } .spt_content_box .spt_content_box_title { width: auto; border: none; background: %(background3)s; color: %(color3)s; height: 18px; padding: 6px 8px; font-weight: bold; font-size: 1.2em; border: solid 1px %(border)s; } .spt_content_box .spt_content_box_shelf { margin-top: 0px; border: solid 1px #AAA; padding: 8px 15px; height: 23px; background: #F8F8F8; } .spt_content_box .spt_content_box_content { width: auto; margin-top: -1px; margin-bottom: 5px; border: solid 1px #AAA; padding: 15px 0px 0px 0px; background: #FFF; overflow-x: auto; } .spt_content_box .spt_content_box_footer { margin-top: -1px; border: solid 1px #AAA; padding: 8px 15px; height: 23px; background: #F8F8F8; } ''' % colors) top.add(self.get_title_wdg()) inner = DivWdg() top.add(inner) inner.add_class("spt_content_box_inner") inner.add_style("overflow: hidden") inner.add_style("margin-top: 0px") # handle the shelf shelf_view = self.kwargs.get("shelf_view") if shelf_view: shelf_div = DivWdg() inner.add(shelf_div) shelf_div.add_class("spt_content_box_shelf") if shelf_view == "true": pass else: layout = CustomLayoutWdg(view=shelf_view) shelf_div.add(layout) content_div = DivWdg() content_div.add_class("spt_content_box_content") inner.add(content_div) content_div.add_style("width: auto") content_height = self.kwargs.get("content_height") if content_height: content_div.add_style("height: %s" % content_height) content_div.add_style("overflow-x: auto") content_view = self.kwargs.get("content_view") #content_div.add(content_view) if content_view: layout = CustomLayoutWdg(view=content_view) content_div.add(layout) content_margin = self.kwargs.get("content_margin") if content_margin: layout.add_style("margin", content_margin) config_xml = self.kwargs.get("config_xml") if config_xml: config = WidgetConfig.get(view="tab", xml=config_xml) layout = config.get_display_widget("content") content_div.add(layout) content_wdg = self.get_widget("content") if not content_wdg and self.widgets: content_wdg = self.widgets[0] if content_wdg: content_div.add(content_wdg) # handle the footer footer_view = self.kwargs.get("footer_view") if footer_view: footer_div = DivWdg() inner.add(footer_div) footer_div.add_class("spt_content_box_footer") layout = CustomLayoutWdg(view=footer_view) shelf_div.add(layout) return top
def get_display(my): top = my.top top.add_style("height: 100%") top.add_style("overflow-x: hidden") top.set_unique_id() width = my.kwargs.get("width") if width: top.add_style("width: %s" % width) from tactic.ui.panel import CustomLayoutWdg html = my.kwargs.get("html") view = my.kwargs.get("view") alias = my.kwargs.get("alias") if alias: aliases = alias.split("|") alias = aliases[0] aliases = aliases[1:] else: aliases = [] top.add_relay_behavior( { 'type': 'mouseover', 'bvr_match_class': 'spt_link', 'cbjs_action': ''' spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -5}); ''' } ) top.add_relay_behavior( { 'type': 'mouseout', 'bvr_match_class': 'spt_link', 'cbjs_action': ''' spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el}) ''' } ) top.add_smart_style("spt_link", "margin-left", "5px") if alias == 'main': top.add_smart_style("spt_link", "text-decoration", "none") else: top.add_smart_style("spt_link", "text-decoration", "underline") top.add_smart_style("spt_link", "padding", "1px") if aliases: related_wdg = my.get_related_wdg(aliases) top.add( related_wdg ) rel_path = my.kwargs.get("rel_path") # attempt to get if from the widget config search = Search("config/widget_config") search.add_filter("category", "HelpWdg") search.add_filter("view", alias) config = search.get_sobject() if html: layout = CustomLayoutWdg(html=html, view=view) top.add(layout) # config can override alias elif config: layout = CustomLayoutWdg(config=config, view=alias) author = config.get_value("login") timestamp = config.get_value("timestamp") top.add(layout) elif alias: widget = HelpDocFilterWdg(alias=alias) top.add(widget) elif rel_path: widget = HelpDocFilterWdg(rel_path=rel_path) top.add(widget) elif not view: layout = DivWdg() top.add(layout) allow_create = my.kwargs.get("allow_create") if allow_create not in ['false', False]: layout.add(HelpCreateWdg()) else: layout.add("No documentation found") layout.add_style("padding: 30px 20px") layout.add_style("margin-left: auto") layout.add_style("margin-right: auto") layout.add_style("margin-top: 50px") layout.add_style("text-align: center") layout.add_style("width: 250px;") layout.add_color("background", "background3") layout.add_color("color", "color3") layout.add_border() elif view == 'default': top.add(my.get_default_wdg()) else: author = "TACTIC" timestamp = None search = Search("config/widget_config") search.add_filter("category", "HelpWdg") search.add_filter("view", view) config = search.get_sobject() if config: layout = CustomLayoutWdg(config=config, view=view) author = config.get_value("login") timestamp = config.get_value("timestamp") else: # get it from the file system layout = DivWdg() install_dir = Environment.get_install_dir() path = "%s/src/context/help/%s.html" % (install_dir,view) if os.path.exists(path): f = open(path) html = f.read() f.close() layout.add(html) else: div = DivWdg() layout.add(div) div.add_style("padding: 15px") div.add_style("margin: 10px") div.add_border() div.add_color("background", "background", -5) div.add_style("text-align: center") div.add_style("font-weight: bold") icon = IconWdg("WARNING", IconWdg.WARNING) div.add(icon) div.add("There are no help pages available for this key [%s]<br/><br/>" % view) div.add("<br/>") div.add("Click to create a new custom doc:") from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Create", tip="Create docs for this view") div.add(button) button.add_style("margin-right: auto") button.add_style("margin-left: auto") button.add_style("margin-top: 15px") button.add_style("margin-bottom: 15px") # FIXME: copied code from above button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.app.HelpEditWdg'; var element_name = spt.help.get_view(); if (!element_name) { element_name = "default"; } var kwargs = { view: element_name } spt.tab.add_new("help_edit", "Help Edit", class_name, kwargs); ''' } ) layout.add_style("margin-top: 10px") info_div = DivWdg() info_div.add("<i>Author: %s</i>" % author) info_div.add_style("opacity: 0.5") info_div.add_style("font-size: 10px") info_div.add_style("position: absolute") info_div.add_style("bottom: 20px") content_div = DivWdg() top.add(content_div) content_div.add_style("padding: 5px") content_div.add(layout) top.add(info_div) #top.add(HelpContentWdg.get_default_wdg(aliases)) return top
def get_display(my): widget = my.widget widget.set_box_shadow() widget.add_class("spt_dialog_top") widget.add_class("spt_popup") z_index = my.kwargs.get("z_index") if not z_index: z_index = "500" widget.add_style("z-index: %s" % z_index) web = WebContainer.get_web() widget.set_id(my.name) widget.add_attr("spt_dialog_id", my.name) if my.kwargs.get("display") not in [True, "true"]: widget.add_style("display: none") widget.add_style("position: absolute") widget.add_behavior({ 'type': 'listen', 'event_name': '%s|dialog_close' % my.name, 'cbjs_action': my.get_cancel_script() }) offset = my.kwargs.get("offset") if not offset: offset = my.offset show_header = True show_resize = False drag_div = DivWdg() if show_header: widget.add(drag_div) show_pointer = my.kwargs.get("show_pointer") if show_pointer not in [False, 'false']: from tactic.ui.container import ArrowWdg offset_x = 15 - offset.get('x') offset_y = offset.get("y") arrow = ArrowWdg(offset_x=offset_x, offset_y=offset_y, color=widget.get_color("background", -10)) arrow.add_class("spt_popup_pointer") arrow.add_style("z-index: 10") widget.add(arrow) # create the 'close' button ... close_wdg = SpanWdg() close_wdg.add(IconWdg("Close", "BS_REMOVE")) close_wdg.add_style("float: right") close_wdg.add_class("hand") close_wdg.add_style("margin: 3px 1px 3px 1px") close_wdg.add_behavior({ 'type': 'click_up', 'cbjs_action': my.get_cancel_script() }) drag_div.add(close_wdg) anchor_wdg = SpanWdg() drag_div.add(anchor_wdg) anchor_wdg.add_style("margin: 5px 5px 3px 1px") anchor_wdg.add(IconWdg("Anchor Dialog", "BS_PUSHPIN")) anchor_wdg.add_style("float: right") anchor_wdg.add_class("hand") anchor_wdg.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_dialog_top"); var position = top.getStyle("position"); if (position == 'fixed') { top.setStyle("position", "absolute"); bvr.src_el.setStyle("opacity", "1.0"); } else { top.setStyle("position", "fixed"); bvr.src_el.setStyle("opacity", "0.5"); } ''' }) width = my.kwargs.get("width") if not width: width = "100px" if width: drag_div.add_style("min-width: %s" % width) # style #drag_div.add_looks("popup") drag_div.add_style("text-align: left") drag_div.add_class("spt_popup_width") drag_div.add_style("border-style: solid") drag_div.add_color("border-color", "border") drag_div.add_style("border-size: 0 0 1 0") drag_handle_div = DivWdg(id='%s_title' % my.name) drag_div.add(drag_handle_div) drag_handle_div.add_style("padding: 3px;") #drag_handle_div.add_gradient("background", "background", +10) drag_handle_div.add_color("background", "background", -10) drag_handle_div.add_color("color", "color") drag_handle_div.add_style("padding: 8px 5px 8px 8px") drag_handle_div.add_behavior({ 'type': 'double_click', 'cbjs_action': my.get_cancel_script() }) # add the drag capability drag_handle_div.add_behavior({ 'type': 'smart_drag', 'drag_el': 'spt.popup.get_popup(@);', 'options': { 'z_sort': 'bring_forward' }, 'ignore_default_motion': 'false', 'cbjs_setup': ''' var pointer = bvr.drag_el.getElement(".spt_popup_pointer"); if (pointer) { spt.hide(pointer); } ''' }) # add the content content_div = DivWdg() title_wdg = my.title_wdg if not title_wdg: title_wdg = "No Title" # if the title is empty, just don't show if my.kwargs.get("show_title") in [False, 'false']: drag_div.add_style("display: none") #else: # content_div.add_style("margin-top: -1px") drag_handle_div.add(title_wdg) drag_handle_div.add_class("spt_popup_title") drag_handle_div.add_style("font-weight: bold") widget.add(content_div) content_div.add_color("color", "color2") content_div.add_gradient("background", "background2") content_div.set_id("%s_content" % my.name) content_div.add_class("spt_popup_content") content_div.add_class("spt_dialog_content") content_div.add_style("overflow: hidden") content_div.add_style("display: block") #content_div.add_style("padding: 5px") view = my.kwargs.get("view") if view: from tactic.ui.panel import CustomLayoutWdg my.add(CustomLayoutWdg(view=view)) if not my.content_wdg: my.content_wdg = "No Content" content_div.add(my.content_wdg) # add the resize icon if show_resize: icon = IconWdg("Resize", IconWdg.RESIZE_CORNER) icon.add_style("cursor: nw-resize") icon.add_style("z-index: 1000") icon.add_class("spt_popup_resize") icon.add_style("float: right") icon.add_style("margin-top: -25px") icon.add_style("margin-right: 5px") icon.add_behavior({ 'type': 'drag', "drag_el": '@', "cb_set_prefix": 'spt.popup.resize_drag' }) widget.add(icon) return widget
def init(my): super(SObjectCalendarWdg,my).init() custom_view = my.kwargs.get('view') my.custom_layout = None if custom_view: from tactic.ui.panel import CustomLayoutWdg #custom_kwargs = my.kwargs.copy() custom_kwargs = my.kwargs.get("kwargs") if not custom_kwargs: custom_kwargs = {} elif isinstance(custom_kwargs, basestring): custom_kwargs = eval(custom_kwargs) custom_kwargs['view'] = custom_view my.custom_layout = CustomLayoutWdg(**custom_kwargs) class_name = "tactic.ui.widget.BaseCalendarDayWdg" else: class_name = my.kwargs.get('handler') if not class_name: class_name = 'tactic.ui.widget.TaskCalendarDayWdg' my.custom_layout = None my.handler = Common.create_from_class_path(class_name, [], my.kwargs) my.sobject_display_expr = my.kwargs.get('sobject_display_expr') # set the border style my.kwargs['border_type'] = 'all' my.handle_search() my.width = my.kwargs.get("cell_width") if not my.width: my.width = '100%' my.height = my.kwargs.get("cell_height") if not my.height: my.height = '80px' # preprocess the sobjects so that they are order by date my.date_sobjects = {} # get all of the weeks in this month my.sobjects_week_index = [] for i in my.weeks: my.sobjects_week_index.append([]) for index, sobject in enumerate(my.sobjects): start_date = sobject.get_value(my.start_column) if not start_date: continue start_date = parser.parse(start_date) end_date = sobject.get_value(my.end_column) if not end_date: continue end_date = parser.parse(end_date) for i, week in enumerate(my.weeks): first_day = week[0] first_day = datetime(first_day.year, first_day.month, first_day.day) last_day = week[6] + timedelta(days=1) last_day = datetime(last_day.year, last_day.month, last_day.day) is_in_week = False # if this sobject falls in this week if start_date >= first_day and start_date < last_day: is_in_week = True elif end_date >= first_day and end_date < last_day: is_in_week = True elif start_date < first_day and end_date > last_day: is_in_week = True if is_in_week: my.sobjects_week_index[i].append(sobject) # for each day in the sobject's timeline, add it to the appropriate # day list days = list(rrule.rrule(rrule.DAILY, dtstart=start_date, until=end_date)) for date in days: date_str = date.strftime("%Y-%m-%d") sobj_list = my.date_sobjects.get(date_str) if not sobj_list: # create a new list for that day sobj_list = [] my.date_sobjects[date_str] = sobj_list sobj_list.append(sobject) my.current_week = -1
class SObjectCalendarWdg(CalendarWdg): ARGS_KEYS = { #'expression': 'expression used to get the tasks' 'start_date_col': 'Start date column', 'end_date_col': 'End date column', 'handler': 'handler class to display each day', 'sobject_display_expr': 'display expression for each sobject', 'search_type': 'search type to search for', 'search_expr': 'Initial SObjects Expression', 'view': 'Day view', 'sobject_view': 'Day sobject view when the user clicks on each day', 'detail_view': 'Custom view when the user clicks on each day' } def __init__(self, **kwargs): if kwargs.get("show_border") == None: kwargs['show_border'] = 'false' super(SObjectCalendarWdg, self).__init__(**kwargs) def handle_search(self): parent_key = self.kwargs.get("parent_key") # this is an absolute expression self.search_expr = self.kwargs.get("search_expr") self.search_type = self.kwargs.get("search_type") if not self.search_type: self.search_type = 'sthpw/task' if self.search_expr: result = Search.eval(self.search_expr) if isinstance(result, list): search = Search(self.search_type) codes = [x.get_code() for x in result] search.add_filters("code", codes) else: search = result else: self.op_filters = self.kwargs.get("filters") if self.op_filters: if isinstance(self.op_filters, basestring): self.op_filters = eval(self.op_filters) search = Search(self.search_type) if self.op_filters: search.add_op_filters(self.op_filters) self.start_column = self.kwargs.get('start_date_col') if not self.start_column: self.start_column = 'bid_start_date' self.end_column = self.kwargs.get('end_date_col') if not self.end_column: self.end_column = 'bid_end_date' if parent_key: parent = Search.get_by_search_key(parent_key) search.add_parent_filter(parent) search.add_op('begin') if self.handler: self.handler.alter_search(search) search.add_op('or') self.start_date = datetime(self.year, self.month, 1) next_month = self.month + 1 next_year = self.year if next_month > 12: next_month = 1 next_year += 1 self.end_date = datetime(next_year, next_month, 1) self.end_date = self.end_date - timedelta(days=1) # outer begin search.add_op('begin') search.add_op('begin') search.add_date_range_filter(self.start_column, self.start_date, self.end_date) search.add_date_range_filter(self.end_column, self.start_date, self.end_date) search.add_op('or') search.add_op('begin') search.add_filter(self.start_column, self.start_date, op='<=') search.add_filter(self.end_column, self.end_date, op='>=') search.add_op('and') search.add_op('or') extra_codes = self.kwargs.get("extra_codes") if extra_codes: search.add_op('and') extra_codes = extra_codes.split("|") search.add_filters("code", extra_codes) search.add_op('or') search.add_order_by(self.start_column) self.sobjects = search.get_sobjects() def init(self): super(SObjectCalendarWdg, self).init() custom_view = self.kwargs.get('view') self.custom_sobject_view = self.kwargs.get('sobject_view') self.custom_detail_view = self.kwargs.get("detail_view") if not self.custom_sobject_view and not self.custom_detail_view: self.custom_sobject_view = 'table' self.custom_layout = None if custom_view: from tactic.ui.panel import CustomLayoutWdg #custom_kwargs = self.kwargs.copy() custom_kwargs = self.kwargs.get("kwargs") if not custom_kwargs: custom_kwargs = {} elif isinstance(custom_kwargs, basestring): custom_kwargs = eval(custom_kwargs) custom_kwargs['view'] = custom_view self.custom_layout = CustomLayoutWdg(**custom_kwargs) class_name = "tactic.ui.widget.BaseCalendarDayWdg" else: class_name = self.kwargs.get('handler') if not class_name: class_name = 'tactic.ui.widget.TaskCalendarDayWdg' self.custom_layout = None self.handler = Common.create_from_class_path(class_name, [], self.kwargs) self.sobject_display_expr = self.kwargs.get('sobject_display_expr') # set the border style self.kwargs['border_type'] = 'all' self.handle_search() self.width = self.kwargs.get("cell_width") if not self.width: self.width = '100%' self.height = self.kwargs.get("cell_height") if not self.height: self.height = '80px' # preprocess the sobjects so that they are order by date self.date_sobjects = {} # get all of the weeks in this month self.sobjects_week_index = [] for i in self.weeks: self.sobjects_week_index.append([]) for index, sobject in enumerate(self.sobjects): start_date = sobject.get_value(self.start_column) if not start_date: continue start_date = parser.parse(start_date) end_date = sobject.get_value(self.end_column) if not end_date: continue end_date = parser.parse(end_date) for i, week in enumerate(self.weeks): first_day = week[0] first_day = datetime(first_day.year, first_day.month, first_day.day) last_day = week[6] + timedelta(days=1) last_day = datetime(last_day.year, last_day.month, last_day.day) is_in_week = False # if this sobject falls in this week if start_date >= first_day and start_date < last_day: is_in_week = True elif end_date >= first_day and end_date < last_day: is_in_week = True elif start_date < first_day and end_date > last_day: is_in_week = True if is_in_week: self.sobjects_week_index[i].append(sobject) # for each day in the sobject's timeline, add it to the appropriate # day list days = list( rrule.rrule(rrule.DAILY, dtstart=start_date, until=end_date)) for date in days: date_str = date.strftime("%Y-%m-%d") sobj_list = self.date_sobjects.get(date_str) if not sobj_list: # create a new list for that day sobj_list = [] self.date_sobjects[date_str] = sobj_list sobj_list.append(sobject) self.current_week = -1 def get_day_header_wdg(self, day): self.size = self.kwargs.get("size") if not self.size: self.size = 3 if self.size: weekday = self.WEEKDAYS[day.weekday()][0:self.size] else: weekday = self.WEEKDAYS[day.weekday()] div = DivWdg() div.add_style("font-weight: bold") div.add_style("font-size: 1.2em") div.add_style("padding: 8px") div.add(weekday) return div def get_legend_wdg(self): return None def get_header_wdg(self): outer = DivWdg() div = DivWdg() outer.add(div) div.add_color("background", "background", -3) div.add_style("padding: 5px") div.add_border() table = Table() table.add_style("margin-left: auto") table.add_style("margin-right: auto") table.add_color("color", "color") table.add_style("font-size: 1.5em") table.add_style("font-weight: bold") table.add_row() # add the month navigators date_str = "%s, %s" % (self.MONTHS[self.month - 1], self.year) month_wdg = DivWdg() month_wdg.add_style("width: 150px") month_wdg.add(date_str) prev_month_wdg = self.get_prev_month_wdg() next_month_wdg = self.get_next_month_wdg() table.add_cell(prev_month_wdg) td = table.add_cell(month_wdg) td.add_style("text-align: center") table.add_cell(next_month_wdg) div.add(table) return outer def get_week_left_wdg(self, week): return self.handler.get_week_left_wdg(week) def get_week_right_wdg(self, week): return self.handler.get_week_right_wdg(week) def get_day_wdg(self, month, day): # find the day of the week wday = day.strftime("%w") # if it's the first day ... if wday == "0": self.current_week += 1 sobjects_week_index = self.sobjects_week_index[self.current_week] self.handler.set_sobjects_index(sobjects_week_index) self.handler.set_current_week(self.current_week) sobjects = self.date_sobjects.get(str(day)) div = DivWdg() div.add_style("vertical-align: top") div.add_class("spt_calendar_day") div.add_class("hand") if self.custom_layout: self.custom_layout.kwargs['day_obj'] = day self.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] #self.custom_layout.kwargs['search_objects'] = sobject_dict_list sobject_keys = [x.get_search_key() for x in sobjects] self.custom_layout.kwargs['search_keys'] = sobject_keys wdg = self.custom_layout.get_buffer_display() self.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 = self.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 self.width: div.add_style("width: %s" % self.width) div.add_style("min-height: %s" % self.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(self.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)" % (self.search_type, ids_filter) div.add_behavior({ 'type': "click", 'sobject_view': self.custom_sobject_view, 'detail_view': self.custom_detail_view, 'search_type': self.search_type, 'day': str(day), 'st_title': st_title, 'expression': expression, 'cbjs_action': ''' var class_name = 'tactic.ui.widget.SObjectCalendarDayDetailWdg'; var title = bvr.st_title + ' ' + bvr.day; var kwargs = { 'search_type': bvr.search_type, 'day': bvr.day, 'st_title': bvr.st_title, 'view': bvr.sobject_view, 'detail_view': bvr.detail_view, 'show_insert': 'false', 'expression': bvr.expression }; //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) ''' }) 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" % self.height) self.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" % self.height) self.handler.set_sobjects([]) # force it to be 120px for now if self.width: content.add_style("width: %spx" % self.width) self.handler.set_date(day) content.add(self.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(self): top = DivWdg() top.add_class("spt_wizard_top") self.height = self.kwargs.get("height") width = self.kwargs.get("width") if not width: width = "" self.width = width inner = DivWdg() top.add(inner) inner.add_style("width: %s" % width) title = self.kwargs.get("title") if not title: title = "none" if title != "none": title_wdg = DivWdg() inner.add(title_wdg) title_wdg.add(title) title_wdg.add_style("font-size: 16px") title_wdg.add_style("font-weight: bold") inner.add("<br/>") self.titles = self.kwargs.get("titles") if isinstance(self.titles, basestring): self.titles = self.titles.split("|") if not self.titles: self.titles = [] views = self.kwargs.get("views") if views: from tactic.ui.panel import CustomLayoutWdg if isinstance(views, basestring): views = views.split("|") for i, view in enumerate(views): if i < len(self.titles): title = self.titles[i] else: title = widget.get_name() title = title.replace(".", " ") title = Common.get_display_title(title) widget = CustomLayoutWdg(view=view) self.add(widget, title) header_wdg = self.get_header_wdg() inner.add(header_wdg) #header_wdg.add_color("background", "background", -5) header_wdg.add_class("spt_popup_header") inner.add("<br/>") inner.add("<hr/>") pages_div = DivWdg() pages_div.add_class("spt_popup_body") inner.add(pages_div) pages_div.add_style("overflow-y: auto") for i, widget in enumerate(self.widgets): page_div = DivWdg() page_div.add_class("spt_wizard_page") pages_div.add(page_div) page_div.add_style("padding: 10px") page_div.add_style("min-height: 300px") if self.height: page_div.add_style("height: %s" % self.height) page_div.add_style("overflow-y: auto") if i != 0: page_div.add_style("display: none") else: page_div.add_class("spt_wizard_selected") page_div.add(widget) pages_div.add("<hr/>") bottom_wdg = self.get_bottom_wdg() bottom_wdg.add_class("spt_popup_footer") inner.add(bottom_wdg) return top
class SObjectCalendarWdg(CalendarWdg): ARGS_KEYS = { #'expression': 'expression used to get the tasks' 'start_date_col': 'Start date column', 'end_date_col': 'End date column', 'handler': 'handler class to display each day', 'sobject_display_expr': 'display expression for each sobject', 'search_type': 'search type to search for', 'search_expr': 'Initial SObjects Expression', 'view': 'Day view', 'sobject_view': 'Day sobject view when the user clicks on each day', 'detail_view': 'Custom view when the user clicks on each day' } def __init__(self, **kwargs): if kwargs.get("show_border") == None: kwargs['show_border'] = 'false' super(SObjectCalendarWdg, self).__init__(**kwargs) def handle_search(self): parent_key = self.kwargs.get("parent_key") # this is an absolute expression self.search_expr = self.kwargs.get("search_expr") self.search_type = self.kwargs.get("search_type") if not self.search_type: self.search_type = 'sthpw/task' if self.search_expr: result = Search.eval(self.search_expr) if isinstance(result, list): search = Search(self.search_type) codes = [x.get_code() for x in result] search.add_filters("code", codes) else: search = result else: self.op_filters = self.kwargs.get("filters") if self.op_filters: if isinstance(self.op_filters, basestring): self.op_filters = eval(self.op_filters) search = Search(self.search_type) if self.op_filters: search.add_op_filters(self.op_filters) self.start_column = self.kwargs.get('start_date_col') if not self.start_column: self.start_column = 'bid_start_date' self.end_column = self.kwargs.get('end_date_col') if not self.end_column: self.end_column = 'bid_end_date' if parent_key: parent = Search.get_by_search_key(parent_key) search.add_parent_filter(parent) search.add_op('begin') if self.handler: self.handler.alter_search(search) search.add_op('or') self.start_date = datetime(self.year, self.month, 1) next_month = self.month+1 next_year = self.year if next_month > 12: next_month = 1 next_year += 1 self.end_date = datetime(next_year, next_month, 1) self.end_date = self.end_date - timedelta(days=1) # outer begin search.add_op('begin') search.add_op('begin') search.add_date_range_filter(self.start_column, self.start_date, self.end_date) search.add_date_range_filter(self.end_column, self.start_date, self.end_date) search.add_op('or') search.add_op('begin') search.add_filter(self.start_column, self.start_date, op='<=') search.add_filter(self.end_column, self.end_date, op='>=') search.add_op('and') search.add_op('or') extra_codes = self.kwargs.get("extra_codes") if extra_codes: search.add_op('and') extra_codes = extra_codes.split("|") search.add_filters("code", extra_codes) search.add_op('or') search.add_order_by(self.start_column) self.sobjects = search.get_sobjects() def init(self): super(SObjectCalendarWdg,self).init() custom_view = self.kwargs.get('view') self.custom_sobject_view = self.kwargs.get('sobject_view') self.custom_detail_view = self.kwargs.get("detail_view") if not self.custom_sobject_view and not self.custom_detail_view: self.custom_sobject_view = 'table' self.custom_layout = None if custom_view: from tactic.ui.panel import CustomLayoutWdg #custom_kwargs = self.kwargs.copy() custom_kwargs = self.kwargs.get("kwargs") if not custom_kwargs: custom_kwargs = {} elif isinstance(custom_kwargs, basestring): custom_kwargs = eval(custom_kwargs) custom_kwargs['view'] = custom_view self.custom_layout = CustomLayoutWdg(**custom_kwargs) class_name = "tactic.ui.widget.BaseCalendarDayWdg" else: class_name = self.kwargs.get('handler') if not class_name: class_name = 'tactic.ui.widget.TaskCalendarDayWdg' self.custom_layout = None self.handler = Common.create_from_class_path(class_name, [], self.kwargs) self.sobject_display_expr = self.kwargs.get('sobject_display_expr') # set the border style self.kwargs['border_type'] = 'all' self.handle_search() self.width = self.kwargs.get("cell_width") if not self.width: self.width = '100%' self.height = self.kwargs.get("cell_height") if not self.height: self.height = '80px' # preprocess the sobjects so that they are order by date self.date_sobjects = {} # get all of the weeks in this month self.sobjects_week_index = [] for i in self.weeks: self.sobjects_week_index.append([]) for index, sobject in enumerate(self.sobjects): start_date = sobject.get_value(self.start_column) if not start_date: continue start_date = parser.parse(start_date) end_date = sobject.get_value(self.end_column) if not end_date: continue end_date = parser.parse(end_date) for i, week in enumerate(self.weeks): first_day = week[0] first_day = datetime(first_day.year, first_day.month, first_day.day) last_day = week[6] + timedelta(days=1) last_day = datetime(last_day.year, last_day.month, last_day.day) is_in_week = False # if this sobject falls in this week if start_date >= first_day and start_date < last_day: is_in_week = True elif end_date >= first_day and end_date < last_day: is_in_week = True elif start_date < first_day and end_date > last_day: is_in_week = True if is_in_week: self.sobjects_week_index[i].append(sobject) # for each day in the sobject's timeline, add it to the appropriate # day list days = list(rrule.rrule(rrule.DAILY, dtstart=start_date, until=end_date)) for date in days: date_str = date.strftime("%Y-%m-%d") sobj_list = self.date_sobjects.get(date_str) if not sobj_list: # create a new list for that day sobj_list = [] self.date_sobjects[date_str] = sobj_list sobj_list.append(sobject) self.current_week = -1 def get_day_header_wdg(self, day): self.size = self.kwargs.get("size") if not self.size: self.size = 3 if self.size: weekday = self.WEEKDAYS[day.weekday()][0:self.size] else: weekday = self.WEEKDAYS[day.weekday()] div = DivWdg() div.add_style("font-weight: bold") div.add_style("font-size: 1.2em") div.add_style("padding: 8px") div.add( weekday ) return div def get_legend_wdg(self): return None def get_header_wdg(self): outer = DivWdg() div = DivWdg() outer.add(div) div.add_color("background", "background", -3) div.add_style("padding: 5px") div.add_border() table = Table() table.add_style("margin-left: auto") table.add_style("margin-right: auto") table.add_color("color", "color") table.add_style("font-size: 1.5em") table.add_style("font-weight: bold") table.add_row() # add the month navigators date_str = "%s, %s" % (self.MONTHS[self.month-1], self.year) month_wdg = DivWdg() month_wdg.add_style("width: 150px") month_wdg.add(date_str) prev_month_wdg = self.get_prev_month_wdg() next_month_wdg = self.get_next_month_wdg() table.add_cell(prev_month_wdg) td = table.add_cell(month_wdg) td.add_style("text-align: center") table.add_cell(next_month_wdg) div.add(table) return outer def get_week_left_wdg(self, week): return self.handler.get_week_left_wdg(week) def get_week_right_wdg(self, week): return self.handler.get_week_right_wdg(week) def get_day_wdg(self, month, day): # find the day of the week wday = day.strftime("%w") # if it's the first day ... if wday == "0": self.current_week += 1 sobjects_week_index = self.sobjects_week_index[self.current_week] self.handler.set_sobjects_index( sobjects_week_index ) self.handler.set_current_week(self.current_week) sobjects = self.date_sobjects.get(str(day)) div = DivWdg() div.add_style("vertical-align: top") div.add_class("spt_calendar_day") div.add_class("hand") if self.custom_layout: self.custom_layout.kwargs['day_obj'] = day self.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] #self.custom_layout.kwargs['search_objects'] = sobject_dict_list sobject_keys = [ x.get_search_key() for x in sobjects] self.custom_layout.kwargs['search_keys'] = sobject_keys wdg = self.custom_layout.get_buffer_display() self.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 = self.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 self.width: div.add_style("width: %s" % self.width); div.add_style("min-height: %s" % self.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(self.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)" % (self.search_type, ids_filter) div.add_behavior( { 'type': "click", 'sobject_view' : self.custom_sobject_view, 'detail_view' : self.custom_detail_view, 'search_type': self.search_type, 'day': str(day), 'st_title': st_title, 'expression': expression, 'cbjs_action': ''' var class_name = 'tactic.ui.widget.SObjectCalendarDayDetailWdg'; var title = bvr.st_title + ' ' + bvr.day; var kwargs = { 'search_type': bvr.search_type, 'day': bvr.day, 'st_title': bvr.st_title, 'view': bvr.sobject_view, 'detail_view': bvr.detail_view, 'show_insert': 'false', 'expression': bvr.expression }; //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) ''' } ) 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" % self.height); self.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" % self.height); self.handler.set_sobjects([]) # force it to be 120px for now if self.width: content.add_style("width: %spx" % self.width) self.handler.set_date(day) content.add( self.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 = my.top top.add_style("height: 100%") top.add_style("overflow-x: hidden") top.set_unique_id() width = my.kwargs.get("width") if width: top.add_style("width: %s" % width) from tactic.ui.panel import CustomLayoutWdg html = my.kwargs.get("html") view = my.kwargs.get("view") alias = my.kwargs.get("alias") if alias: aliases = alias.split("|") alias = aliases[0] aliases = aliases[1:] else: aliases = [] top.add_relay_behavior({ 'type': 'mouseover', 'bvr_match_class': 'spt_link', 'cbjs_action': ''' spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -5}); ''' }) top.add_relay_behavior({ 'type': 'mouseout', 'bvr_match_class': 'spt_link', 'cbjs_action': ''' spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el}) ''' }) top.add_smart_style("spt_link", "margin-left", "5px") if alias == 'main': top.add_smart_style("spt_link", "text-decoration", "none") else: top.add_smart_style("spt_link", "text-decoration", "underline") top.add_smart_style("spt_link", "padding", "1px") if aliases: related_wdg = my.get_related_wdg(aliases) top.add(related_wdg) rel_path = my.kwargs.get("rel_path") # attempt to get if from the widget config search = Search("config/widget_config") search.add_filter("category", "HelpWdg") search.add_filter("view", alias) config = search.get_sobject() if html: layout = CustomLayoutWdg(html=html, view=view) top.add(layout) # config can override alias elif config: layout = CustomLayoutWdg(config=config, view=alias) author = config.get_value("login") timestamp = config.get_value("timestamp") top.add(layout) elif alias: widget = HelpDocFilterWdg(alias=alias) top.add(widget) elif rel_path: widget = HelpDocFilterWdg(rel_path=rel_path) top.add(widget) elif not view: layout = DivWdg() top.add(layout) allow_create = my.kwargs.get("allow_create") if allow_create not in ['false', False]: layout.add(HelpCreateWdg()) else: layout.add("No documentation found") layout.add_style("padding: 30px 20px") layout.add_style("margin-left: auto") layout.add_style("margin-right: auto") layout.add_style("margin-top: 50px") layout.add_style("text-align: center") layout.add_style("width: 250px;") layout.add_color("background", "background3") layout.add_color("color", "color3") layout.add_border() elif view == 'default': top.add(my.get_default_wdg()) else: author = "TACTIC" timestamp = None search = Search("config/widget_config") search.add_filter("category", "HelpWdg") search.add_filter("view", view) config = search.get_sobject() if config: layout = CustomLayoutWdg(config=config, view=view) author = config.get_value("login") timestamp = config.get_value("timestamp") else: # get it from the file system layout = DivWdg() install_dir = Environment.get_install_dir() path = "%s/src/context/help/%s.html" % (install_dir, view) if os.path.exists(path): f = open(path) html = f.read() f.close() layout.add(html) else: div = DivWdg() layout.add(div) div.add_style("padding: 15px") div.add_style("margin: 10px") div.add_border() div.add_color("background", "background", -5) div.add_style("text-align: center") div.add_style("font-weight: bold") icon = IconWdg("WARNING", IconWdg.WARNING) div.add(icon) div.add( "There are no help pages available for this key [%s]<br/><br/>" % view) div.add("<br/>") div.add("Click to create a new custom doc:") from tactic.ui.widget import ActionButtonWdg button = ActionButtonWdg(title="Create", tip="Create docs for this view") div.add(button) button.add_style("margin-right: auto") button.add_style("margin-left: auto") button.add_style("margin-top: 15px") button.add_style("margin-bottom: 15px") # FIXME: copied code from above button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.app.HelpEditWdg'; var element_name = spt.help.get_view(); if (!element_name) { element_name = "default"; } var kwargs = { view: element_name } spt.tab.add_new("help_edit", "Help Edit", class_name, kwargs); ''' }) layout.add_style("margin-top: 10px") info_div = DivWdg() info_div.add("<i>Author: %s</i>" % author) info_div.add_style("opacity: 0.5") info_div.add_style("font-size: 10px") info_div.add_style("position: absolute") info_div.add_style("bottom: 20px") content_div = DivWdg() top.add(content_div) content_div.add_style("padding: 5px") content_div.add(layout) top.add(info_div) #top.add(HelpContentWdg.get_default_wdg(aliases)) return top
def get_display(my): top = DivWdg() top.add_class("spt_wizard_top") my.height = my.kwargs.get("height") width = my.kwargs.get("width") if not width: width = "550px" my.width = width inner = DivWdg() top.add(inner) inner.add_style("width: %s" % width) title = my.kwargs.get("title") if not title: title = "No Title" if title != "none": title_wdg = DivWdg() inner.add(title_wdg) title_wdg.add(title) title_wdg.add_style("font-size: 16px") title_wdg.add_style("font-weight: bold") inner.add("<br/>") views = my.kwargs.get("views") if views: from tactic.ui.panel import CustomLayoutWdg if isinstance(views, basestring): views = views.split("|") for view in views: title = Common.get_display_title(view) widget = CustomLayoutWdg(view=view) my.add(widget, title) header_wdg = my.get_header_wdg() inner.add(header_wdg) #header_wdg.add_color("background", "background", -5) inner.add("<br/>") inner.add("<hr/>") for i, widget in enumerate(my.widgets): page_div = DivWdg() page_div.add_class("spt_wizard_page") inner.add(page_div) page_div.add_style("padding: 10px") page_div.add_style("min-height: 300px") if my.height: page_div.add_style("height: %s" % my.height) page_div.add_style("overflow-y: auto") if i != 0: page_div.add_style("display: none") else: page_div.add_class("spt_wizard_selected") page_div.add(widget) inner.add("<hr/>") bottom_wdg = my.get_bottom_wdg() inner.add(bottom_wdg) return top
def init(self): super(SObjectCalendarWdg,self).init() custom_view = self.kwargs.get('view') self.custom_sobject_view = self.kwargs.get('sobject_view') self.custom_detail_view = self.kwargs.get("detail_view") if not self.custom_sobject_view and not self.custom_detail_view: self.custom_sobject_view = 'table' self.custom_layout = None if custom_view: from tactic.ui.panel import CustomLayoutWdg #custom_kwargs = self.kwargs.copy() custom_kwargs = self.kwargs.get("kwargs") if not custom_kwargs: custom_kwargs = {} elif isinstance(custom_kwargs, basestring): custom_kwargs = eval(custom_kwargs) custom_kwargs['view'] = custom_view self.custom_layout = CustomLayoutWdg(**custom_kwargs) class_name = "tactic.ui.widget.BaseCalendarDayWdg" else: class_name = self.kwargs.get('handler') if not class_name: class_name = 'tactic.ui.widget.TaskCalendarDayWdg' self.custom_layout = None self.handler = Common.create_from_class_path(class_name, [], self.kwargs) self.sobject_display_expr = self.kwargs.get('sobject_display_expr') # set the border style self.kwargs['border_type'] = 'all' self.handle_search() self.width = self.kwargs.get("cell_width") if not self.width: self.width = '100%' self.height = self.kwargs.get("cell_height") if not self.height: self.height = '80px' # preprocess the sobjects so that they are order by date self.date_sobjects = {} # get all of the weeks in this month self.sobjects_week_index = [] for i in self.weeks: self.sobjects_week_index.append([]) for index, sobject in enumerate(self.sobjects): start_date = sobject.get_value(self.start_column) if not start_date: continue start_date = parser.parse(start_date) end_date = sobject.get_value(self.end_column) if not end_date: continue end_date = parser.parse(end_date) for i, week in enumerate(self.weeks): first_day = week[0] first_day = datetime(first_day.year, first_day.month, first_day.day) last_day = week[6] + timedelta(days=1) last_day = datetime(last_day.year, last_day.month, last_day.day) is_in_week = False # if this sobject falls in this week if start_date >= first_day and start_date < last_day: is_in_week = True elif end_date >= first_day and end_date < last_day: is_in_week = True elif start_date < first_day and end_date > last_day: is_in_week = True if is_in_week: self.sobjects_week_index[i].append(sobject) # for each day in the sobject's timeline, add it to the appropriate # day list days = list(rrule.rrule(rrule.DAILY, dtstart=start_date, until=end_date)) for date in days: date_str = date.strftime("%Y-%m-%d") sobj_list = self.date_sobjects.get(date_str) if not sobj_list: # create a new list for that day sobj_list = [] self.date_sobjects[date_str] = sobj_list sobj_list.append(sobject) self.current_week = -1
def get_display(my): from tactic.ui.panel import CustomLayoutWdg top = my.top top.add_class("spt_content_box") top.add_class("spt_content_box_inline") top.add_style("min-width: 200px") #top.add_style("opacity: 0.1") """ top.add_behavior( { 'type': 'loadX', 'cbjs_action': ''' new Fx.Tween(bvr.src_el, {duration: 500}).start("opacity", 1.0); ''' } ) """ colors = { #"color3": top.get_color("color3"), #"background3": top.get_color("background3"), #"background3": "rgba(18, 50, 91, 1.0)", "background3": "#323232", "color3": "#FFF", "border": top.get_color("border", -10), } style = HtmlElement.style() top.add(style) style.add(''' .spt_content_box_inline { margin: 15px; } .spt_content_box_max { margin: 0px; width: 100%%; height: 100%%; background: rgba(0,0,0,0.0); z-index: 1000; position: fixed; top: 0px; left: 0px; } .spt_content_box_max .spt_content_box_content { //height: 100%% !important; } .spt_content_box .spt_content_box_title { width: auto; border: none; background: %(background3)s; color: %(color3)s; height: 18px; padding: 6px 8px; font-weight: bold; font-size: 1.2em; border: solid 1px %(border)s; } .spt_content_box .spt_content_box_shelf { margin-top: 0px; border: solid 1px #AAA; padding: 8px 15px; height: 23px; background: #F8F8F8; } .spt_content_box .spt_content_box_content { width: auto; margin-top: -1px; margin-bottom: 5px; border: solid 1px #AAA; padding: 15px 0px 0px 0px; background: #FFF; overflow-x: auto; } .spt_content_box .spt_content_box_footer { margin-top: -1px; border: solid 1px #AAA; padding: 8px 15px; height: 23px; background: #F8F8F8; } ''' % colors) top.add(my.get_title_wdg()) inner = DivWdg() top.add(inner) inner.add_class("spt_content_box_inner") inner.add_style("overflow: hidden") inner.add_style("margin-top: 0px") # handle the shelf shelf_view = my.kwargs.get("shelf_view") if shelf_view: shelf_div = DivWdg() inner.add(shelf_div) shelf_div.add_class("spt_content_box_shelf") if shelf_view == "true": pass else: layout = CustomLayoutWdg(view=shelf_view) shelf_div.add(layout) content_div = DivWdg() content_div.add_class("spt_content_box_content") inner.add(content_div) content_div.add_style("width: auto") content_height = my.kwargs.get("content_height") if content_height: content_div.add_style("height: %s" % content_height) content_div.add_style("overflow-x: auto") content_view = my.kwargs.get("content_view") #content_div.add(content_view) if content_view: layout = CustomLayoutWdg(view=content_view) content_div.add(layout) content_margin = my.kwargs.get("content_margin") if content_margin: layout.add_style("margin", content_margin) config_xml = my.kwargs.get("config_xml") if config_xml: config = WidgetConfig.get(view="tab", xml=config_xml) layout = config.get_display_widget("content") content_div.add(layout) content_wdg = my.get_widget("content") if not content_wdg and my.widgets: content_wdg = my.widgets[0] if content_wdg: content_div.add(content_wdg) # handle the footer footer_view = my.kwargs.get("footer_view") if footer_view: footer_div = DivWdg() inner.add(footer_div) footer_div.add_class("spt_content_box_footer") layout = CustomLayoutWdg(view=footer_view) shelf_div.add(layout) return top
def init(my): my.scale_called = False my.scale = None top_view = my.kwargs.get("top_view") if top_view: kwargs = { 'view': top_view, } from tactic.ui.panel import CustomLayoutWdg my.title_wdg = CustomLayoutWdg(**kwargs) else: my.title_wdg = None my.sticky_scale = my.kwargs.get('sticky_scale') if my.sticky_scale == 'local': # NOTE: each side bar link has a unique name on each level, but it's not always available # not in page refresh or built-in links # element = my.kwargs.get('element_name') my.scale_prefix = '%s:%s' %(my.search_type, my.view) else: my.scale_prefix = '' bottom_view = my.kwargs.get("bottom_view") if bottom_view: kwargs = { 'view': bottom_view, 'load': 'sequence', } from tactic.ui.panel import CustomLayoutWdg my.bottom = CustomLayoutWdg(**kwargs) else: my.bottom = None from tactic.ui.filter import FilterData filter_data = FilterData.get() data_list = filter_data.get_values_by_prefix("tile_layout") if data_list: data = data_list[0] else: data = {} my.scale = data.get("scale") if my.scale == None: my.scale = my.kwargs.get("scale") if my.scale == None: my.scale = 100 my.aspect_ratio = my.kwargs.get('aspect_ratio') if my.aspect_ratio: parts = re.split('[\Wx]+', my.aspect_ratio) my.aspect_ratio = (int(parts[0]), int(parts[1])) else: my.aspect_ratio = (240, 160) my.show_name_hover = my.kwargs.get('show_name_hover') my.top_styles = my.kwargs.get('styles') my.spacing = my.kwargs.get('spacing') if not my.spacing: my.spacing = '10' super(TileLayoutWdg, my).init()