Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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
Exemplo n.º 4
0
    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