Example #1
0
    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_class("spt_reports_top")
        my.set_as_panel(top)

        inner = DivWdg()
        top.add(inner)


        title = DivWdg()
        title.add("Reports")
        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 0px -10px")

        inner.add(title)
        title.add_gradient("background", "background3", 5, -10)


        from tactic.ui.widget import TitleWdg
        subtitle = TitleWdg(name_of_title='List of Built in Reports',help_alias='main')
        inner.add(subtitle)
        inner.add("<br/>")

        button_div = DivWdg()
        inner.add(button_div)
        button_div.add_class("spt_buttons_top")
        button_div.add_style("margin-top: -5px")
        button_div.add_style("margin-bottom: 30px")
        button_div.add_border()

        button_div.add_style("margin-top: -15px")
        button_div.add_style("margin-bottom: 0px")
        button_div.add_style("width: 100%")
        button_div.add_style("height: 33px")
        button_div.add_color("background", "background2")
        button_div.add_style("margin-left: auto")
        button_div.add_style("margin-right: auto")


        button = SingleButtonWdg(title="Collapse", icon=IconWdg.HOME)
        button_div.add(button)
        button.add_style("float: left")
        button.add_style("left: 5px")
        button.add_style("top: 5px")


        # FIXME: get home for the user
        #home = 'tactic.ui.startup.ContentCreatorWdg'
        home = 'tactic.ui.startup.MainWdg'


        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.MainWdg';
            var kwargs = {
                help_alias: 'main'
                };
            spt.tab.add_new("_startup", "Startup", class_name, kwargs);

            '''
        } )



        """
        button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP)
        button_div.add(button)
        button.add_class("spt_collapse")
        inner.add(button_div)
        button.add_style("float: left")
        button.add_style("left: 5px")
        button.add_style("top: 5px")

        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_reports_top");
            var element = top.getElement(".spt_reports_list");

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            expand = buttons.getElement(".spt_expand");
            new Fx.Tween(element).start('margin-top', "-400px");
            expand.setStyle("display", "");
            bvr.src_el.setStyle("display", "none");
            '''
        } )

        button = SingleButtonWdg(title="Expand", icon=IconWdg.ARROW_DOWN)
        button.add_style("display: none")
        button.add_class("spt_expand")
        button_div.add(button)
        button.add_style("left: 5px")
        button.add_style("top: 5px")
        inner.add(button_div)
        button.add_style("float: left")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_reports_top");
            var element = top.getElement(".spt_reports_list");

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            collapse = buttons.getElement(".spt_collapse");
            new Fx.Tween(element).start('margin-top', "0px");
            collapse.setStyle("display", "");
            bvr.src_el.setStyle("display", "none");
            '''
        } )
        """



        reports = []

        # read the config file
        from pyasm.widget import WidgetConfig
        tmp_path = __file__
        dir_name = os.path.dirname(tmp_path)
        file_path="%s/../config/reports-conf.xml" % (dir_name)
        config = WidgetConfig.get(file_path=file_path, view="definition")

        category = my.kwargs.get('category')

        # get all of the configs from the database
        if not category or category in ["custom_reports", "custom_charts"]:
            search = Search("config/widget_config")
            search.add_op("begin")
            if category == "custom_reports":
                search.add_filter("widget_type", "report")
            elif category == "custom_charts":
                search.add_filter("widget_type", "chart")
            elif not category:
                search.add_filters("widget_type", ["chart","report"])

            search.add_op("or")
            db_configs = search.get_sobjects()
        else:
            db_configs = []


        element_names = my.kwargs.get("element_names")
        if element_names is None:
            element_names = config.get_element_names()



        project = Project.get()

        for element_name in element_names:
            key = {'project': project.get_code(), 'element': element_name}
            key2 = {'project': project.get_code(), 'element': '*'}
            key3 = {'element': element_name}
            key4 = {'element': '*'}
            keys = [key, key2, key3, key4]
            if not top.check_access("link", keys, "view", default="deny"):
                continue

            attrs = config.get_element_attributes(element_name)
            report_data = {}
            kwargs = config.get_display_options(element_name)
            class_name = kwargs.get('class_name')

            # the straight xml definition contains the sidebar class_name
            # with LinkWdg ... we shouldn't use this, so build the
            # element from scratch
            #xml = config.get_element_xml(element_name)
            from pyasm.search import WidgetDbConfig
            xml = WidgetDbConfig.build_xml_definition(class_name, kwargs)

            report_data['class_name'] = class_name
            report_data['kwargs'] = kwargs
            report_data['title'] = attrs.get("title")
            report_data['description'] = attrs.get("description")
            report_data['image'] = attrs.get("image")
            report_data['xml'] = xml

            reports.append(report_data)



        for db_config in db_configs:
            element_name = db_config.get_value("view")
            key = {'project': project.get_code(), 'element': element_name}
            key2 = {'project': project.get_code(), 'element': '*'}
            key3 = {'element': element_name}
            key4 = {'element': '*'}
            keys = [key, key2, key3, key4]
            if not top.check_access("link", keys, "view", default="deny"):
                continue

            report_data = {}
            view = db_config.get_value("view")
            kwargs = {
                'view': view
            }
            parts = view.split(".")
            title = Common.get_display_title(parts[-1])

            xml = db_config.get_value("config")

            report_data['class_name'] = "tactic.ui.panel.CustomLayoutWdg"
            report_data['kwargs'] = kwargs
            report_data['title'] = title
            report_data['description'] = title
            report_data['image'] = None
            report_data['xml'] = xml
            report_data['widget_type'] = db_config.get_value("widget_type")
            if report_data['widget_type'] == 'report':
                report_data['category'] = "custom_reports"
            elif report_data['widget_type'] == 'chart':
                report_data['category'] = "custom_charts"


            reports.append(report_data)





        """
        report_data = {
            'title': 'Tasks Completed This Week',
            'class_name': 'tactic.ui.panel.ViewPanelWdg',
            'kwargs': {
                    'search_type': 'sthpw/task',
                    'view': 'table'
                },
        }
        reports.append(report_data)
        """
        if category == 'list_item_reports' or not category:
            search_types = Project.get().get_search_types()
            for search_type in search_types:
                base_key = search_type.get_base_key()

                key = {'project': project.get_code(), 'code': base_key}
                key2 = {'project': project.get_code(), 'code': '*'}
                key3 = {'code': base_key}
                key4 = {'code': '*'}
                keys = [key, key2, key3, key4]
                if not top.check_access("search_type", keys, "view", default="deny"):
                    continue


                if not SearchType.column_exists(base_key, "pipeline_code"):
                    continue

                thumb_div = DivWdg()
                image = thumb_div
                thumb_div.add_border()
                thumb_div.set_box_shadow("1px 1px 1px 1px")
                thumb_div.add_style("width: 60px")

                thumb = ThumbWdg()
                thumb_div.add(thumb)
                thumb.set_sobject(search_type)
                thumb.set_icon_size(60)

                report_data = {
                    'title': '%s Workflow Status' % search_type.get_title(),
                    'description': 'Number of items in each process',
                    'class_name': 'tactic.ui.report.stype_report_wdg.STypeReportWdg',
                    'kwargs': {
                        'search_type': base_key
                    },
                    'image': thumb_div
                }
                reports.append(report_data)

 
                report_data = {
                    'title': '%s Labor Cost Report' % search_type.get_title(),
                    'description': 'Labor Cost Breakdown for each Item',
                    'class_name': 'tactic.ui.panel.ViewPanelWdg',
                    'kwargs': {
                        'search_type': search_type.get_code(),
                        'view': "table",
                        'show_header': False,
                        'mode': 'simple',
                        'element_names': "preview,code,title,cost_breakdown,bid_hours,bid_cost,actual_hours,actual_cost,overbudget,variance"
                    },
                    'image': IconWdg("", IconWdg.REPORT_03)
                }
                reports.append(report_data)



        table2 = Table()
        inner.add(table2)
        table2.add_style("width: 100%")


        categories_div = DivWdg()
        td = table2.add_cell(categories_div)
        td.add_style("vertical-align: top")
        td.add_style("width: 200px")
        td.add_color("background", "background3")
        td.add_border()

        #categories_div.add_style("margin: -1px 0px 0px -1px")
        categories_div.add_style("padding-top: 10px")
        #categories_div.add_style("float: left")
        categories_div.add_color("color", "color3")


        categories = config.get_all_views()
        categories.insert(-1, "list_item_reports")
        categories.insert(-1, "custom_charts")
        categories.insert(-1, "custom_reports")

        table_div = DivWdg()
        td = table2.add_cell(table_div)
        td.add_style("vertical-align: top")
        table_div.add_class("spt_reports_list")
        table_div.add_border()
        table_div.add_color("background", "background", -5)

        table_div.add_style("min-height: 500px")



        for i, category in enumerate(categories):

            if i == len(categories) - 1:
                categories_div.add("<hr/>")


            config.set_view(category)
            element_names = config.get_element_names()

            if category == "definition":
                title = "All Reports"
            else:
                title = Common.get_display_title(category)


            category_div = DivWdg()
            categories_div.add(category_div)
            category_div.add(title)
            category_div.add_style("padding: 5px")
            category_div.add_class("hand")

            category_div.add_behavior( {
            'type': 'click_up',
            'category': category,
            'element_names': element_names,
            'class_name': Common.get_full_class_name(my),
            'cbjs_action': '''
            var kwargs = {
                is_refresh: true,
                category: bvr.category,
                element_names: bvr.element_names
            }

            //spt.panel.refresh(top, kwargs);
            var top = bvr.src_el.getParent(".spt_reports_top");
            spt.panel.load(top, bvr.class_name, kwargs);
            '''
            } )

            bgcolor = category_div.get_color("background3", -10)
            category_div.add_behavior( {
            'type': 'mouseover',
            'bgcolor': bgcolor,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.bgcolor);
            '''
            } )
            category_div.add_behavior( {
            'type': 'mouseout',
            'bgcolor': bgcolor,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", "");
            '''
            } )








        # create a bunch of panels
        table = Table()
        table_div.add(table)
        table.add_color("color", "color")
        table.add_style("margin-top: 20px")
        table.center()
        table_div.add_style("margin: -3px -3px -1px -2px")


        if not reports:
            tr = table.add_row()
            td = table.add_cell()
            td.add("There are no reports defined.")
            td.add_style("padding: 50px")

            if my.kwargs.get("is_refresh") in ['true', True]:
                return inner
            else:
                return top



        for i, report in enumerate(reports):

            #if i == 0 or i%4 == 0:
            if i%3 == 0:
                tr = table.add_row()

            td = table.add_cell()
            td.add_style("vertical-align: top")
            td.add_style("padding: 3px")
            title = report
            #description = '''The schema is used to layout the basic components of your project.  Each component represents a list of items that you use in your business everyday.'''

            description = report.get("title")

            # Each node will contain a list of "items" and will be stored as a table in the database.'''

            class_name = report.get("class_name")
            kwargs = report.get("kwargs")
            title = report.get("title")
            description = report.get("description")
            widget_type = report.get("widget_type")

            image = report.get("image")
            icon = report.get("icon")
            xml = report.get("xml")

            if image:
                div = DivWdg()
                if isinstance(image, basestring):
                    image = image.upper()
                    image = eval("IconWdg('', IconWdg.%s)" % image)
                    div.add_style("margin-left: 15px")
                    div.add_style("margin-top: 5px")
                else:
                    image = image
                div.add(image)
                image = div

            elif icon:
                icon = icon.upper()
                image = eval("IconWdg('', IconWdg.%s)" % icon)

            else:
                div = DivWdg()
                """
                import random
                num = random.randint(0,3)
                if num == 1:
                    image = IconWdg("Bar Chart", IconWdg.GRAPH_BAR_01)
                elif num == 2:
                    image = IconWdg("Bar Chart", IconWdg.GRAPH_LINE_01)
                else:
                    image = IconWdg("Bar Chart", IconWdg.GRAPH_BAR_02)
                """

                if widget_type == "chart":
                    image = IconWdg("Chart", IconWdg.GRAPH_BAR_02)
                else:
                    image = IconWdg("No Image", IconWdg.WARNING)
                div.add_style("margin-left: 15px")
                div.add_style("margin-top: 5px")
                div.add(image)
                image = div


            behavior = {
            'type': 'click_up',
            'title': title,
            'class_name': class_name,
            'kwargs': kwargs,
            'cbjs_action': '''

            spt.tab.set_main_body_tab();
            //var top = bvr.src_el.getParent(".spt_reports_top");
            //spt.tab.set_tab_top(top);
            spt.tab.add_new(bvr.title, bvr.title, bvr.class_name, bvr.kwargs);
            '''
            }
            schema_wdg = my.get_section_wdg(title, description, image, behavior)

            schema_wdg.add_behavior( {
            'type': 'load',
            'title': title,
            'class_name': class_name,
            'xml': xml,
            'kwargs': kwargs,
            'cbjs_action': '''
                var report_top = bvr.src_el;
                report_top.kwargs = bvr.kwargs;
                report_top.class_name = bvr.class_name;
                report_top.element_name = bvr.title;
                report_top.xml = bvr.xml;
            '''
            } )

            td.add(schema_wdg)


        inner.add("<br/>")



        #from tactic.ui.container import TabWdg
        #tab = TabWdg(show_add=False)
        #inner.add(tab)

        if my.kwargs.get("is_refresh") in ['true', True]:
            return inner
        else:
            return top
Example #2
0
    def get_display(my):

        web = WebContainer.get_web()
        show_multi_project = web.get_form_value('show_multi_project')
        project = Project.get()
        search_type_objs = project.get_search_types(include_multi_project=show_multi_project)


        top = my.top
        top.add_class("spt_panel_stype_list_top")
        #top.add_style("min-width: 400px")
        #top.add_style("max-width: 1000px")
        #top.add_style("width: 100%")
        top.center()



        button = SingleButtonWdg(title="Advanced Setup", icon=IconWdg.ADVANCED)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_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)
            '''
        } )


        button = SingleButtonWdg(title="Add", tip="Add New Searchable Type (sType)", icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.app.SearchTypeCreatorWdg';

            var kwargs = {
            };
            var popup = spt.panel.load_popup("Create New Searchable Type", class_name, kwargs);

            var top = bvr.src_el.getParent(".spt_panel_stype_list_top");
            popup.on_register_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )

        cb = CheckboxWdg('show_multi_project', label=' show multi-project')
        if show_multi_project:
            cb.set_checked()
        cb.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
                var panel = bvr.src_el.getParent('.spt_panel_stype_list_top')
                spt.panel.refresh(panel, {show_multi_project: bvr.src_el.checked});
            '''
            })
        span = SpanWdg(css='small')
        top.add(span)
        top.add(cb)
        top.add("<br clear='all'/>")
        #search_type_objs = []
        if not search_type_objs:
            arrow_div = DivWdg()
            top.add(arrow_div)
            icon = IconWdg("Click to Add", IconWdg.ARROW_UP_LEFT_32)
            icon.add_style("margin-top: -20")
            icon.add_style("margin-left: -15")
            icon.add_style("position: absolute")
            arrow_div.add(icon)
            arrow_div.add("&nbsp;"*5)
            arrow_div.add("<b>Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: 5px")
            arrow_div.add_style("margin-left: 20px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 25px")
            arrow_div.set_box_shadow("0px 5px 20px")
            arrow_div.set_round_corners(30)
            arrow_div.add_color("background", "background")

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("width: 600px")
            div.add_style("margin: 30px auto")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg( "WARNING", IconWdg.WARNING )
            div.add(icon)
            div.add("<b>No Searchable Types have been created</b>")
            div.add("<br/><br/>")
            div.add("Searchables Types contain lists of items that are managed in this project.  Each item will automatically have the ability to have files checked into it, track tasks and status and record work hours.")
            div.add("<br/>"*2)
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias="main")
            div.add(help)
            div.add("<br/>")
            div.add("Click on the 'Add' button above to start adding new types.")
            return top


        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")



        table = Table()
        div.add(table)
        table.add_style("margin-top: 10px")
        table.set_max_width()



        # group mouse over
        table.add_relay_behavior( {
            'type': "mouseover",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        } )
        table.add_relay_behavior( {
            'type': "mouseout",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        } )



        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("")
        th.add_style("text-align: left")
        th = table.add_header("Title")
        th.add_style("text-align: left")
        th = table.add_header("# Items")
        th.add_style("text-align: left")
        th = table.add_header("View")
        th.add_style("text-align: left")
        th = table.add_header("Add")
        th.add_style("text-align: left")
        th = table.add_header("Import")
        th.add_style("text-align: left")
        th = table.add_header("Custom Columns")
        th.add_style("text-align: left")
        th = table.add_header("Workflow")
        th.add_style("text-align: left")
        th = table.add_header("Notifications")
        th.add_style("text-align: left")
        th = table.add_header("Triggers")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")
        #th = table.add_header("Security")
        #th.add_style("text-align: left")



        for i, search_type_obj in enumerate(search_type_objs):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i%2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2 )


            thumb = ThumbWdg()
            thumb.set_sobject(search_type_obj)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)



            search_type = search_type_obj.get_value("search_type")
            title = search_type_obj.get_title()

            table.add_cell(title)

            try:
                search = Search(search_type)
                count = search.get_count()
                if count:
                    table.add_cell("%s item/s" % count)
                else:
                    table.add_cell("&nbsp;")
            except:
                td = table.add_cell("&lt; No table &gt;")
                td.add_style("font-style: italic")
                td.add_style("color: #F00")
                continue



            #search = Search(search_type)
            #search.add_interval_filter("timestamp", "today")
            #created_today = search.get_count()
            #table.add_cell(created_today)



            td = table.add_cell()
            button = IconButtonWdg(title="View", icon=IconWdg.ZOOM)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            button.add_style("float: left")


            arrow_button = IconButtonWdg(tip="More Views", icon=IconWdg.ARROWHEAD_DARK_DOWN)
            arrow_button.add_style("margin-left: 20px")
            td.add(arrow_button)

            cbk = '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = bvr.class_name;
            var layout = bvr.layout;

            var kwargs = {
                search_type: bvr.search_type,
                layout: layout,
                view: bvr.view,
                simple_search_view: 'simple_search',
                element_names: bvr.element_names,
            };

            // use tab
            var top = activator.getParent(".spt_dashboard_top");
            spt.tab.set_tab_top(top);
            spt.tab.add_new('%s', '%s', class_name, kwargs);
            ''' % (title, title)


            from tactic.ui.panel import SwitchLayoutMenu
            SwitchLayoutMenu(search_type=search_type, activator=arrow_button, cbk=cbk, is_refresh=False)

            td = table.add_cell()
            button = IconButtonWdg(title="Add", icon=IconWdg.ADD)
            td.add(button)
            button.add_behavior( {
                'type': 'listen',
                'search_type': search_type,
                'event_name': 'startup_save:' + search_type_obj.get_title(),
                'title': search_type_obj.get_title(),
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
 

                '''
            } )
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': search_type_obj.get_title(),
                'cbjs_action': '''

                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: "insert",
                    save_event: "startup_save:" + bvr.title
                }
                spt.panel.load_popup("Add New Items ("+bvr.title+")", class_name, kwargs);

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                '''
            } )


            """
            td = table.add_cell()
            button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'checkin',
                    element_names: ['preview','code','name','description','history','general_checkin','notes']
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            """





            td = table.add_cell()
            button = IconButtonWdg(title="Import", icon=IconWdg.IMPORT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Import Data",
                'cbjs_action': '''

                var class_name = 'tactic.ui.widget.CsvImportWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };

                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )



            td = table.add_cell()
            button = IconButtonWdg(title="Custom Columns", icon=IconWdg.COLUMNS)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Add Custom Columns",
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.ColumnEditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Workflow", icon=IconWdg.PIPELINE)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/pipeline")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")




            button.add_behavior( {
                'type': 'click_up',
                'title': 'Workflow',
                'search_type': search_type,
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.PipelineEditWdg';
                var kwargs = {
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )
 


            td = table.add_cell()
            button = IconButtonWdg(title="Notifications", icon=IconWdg.MAIL)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/notification")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")






            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )


            td = table.add_cell()
            button = IconButtonWdg(title="Triggers", icon=IconWdg.ARROW_OUT)
            td.add(button)
            button.add_style("float: left")

            search = Search("config/trigger")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")


            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Edit Searchable Type", icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_type_obj.get_search_key(),
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/sobject",
                    view: "edit_startup",
                    search_key: bvr.search_key
                }
                spt.panel.load_popup("Edit Searchable Type", class_name, kwargs);


                '''
            } )


 
            """
            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''
                alert("security");
                '''
            } )
            """


        columns_wdg = DivWdg()
        top.add(columns_wdg)


        return top
Example #3
0
    def get_display(my):


        search = Search("sthpw/login")
        logins = search.get_sobjects()

        top = my.top
        top.add_class("spt_panel_user_top")
        top.add_style("min-width: 400px")

        button = SingleButtonWdg(title="Advanced Security", icon=IconWdg.LOCK)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.startup.SecurityWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("Security", "Security", class_name)
            '''
        } )



        button = SingleButtonWdg(title="Add", tip="Add New User", icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        top.add("<br clear='all'/>")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.panel.EditWdg';
            var kwargs = {
                search_type: "sthpw/login",
                view: "edit",
            }
            var popup = spt.panel.load_popup("Create New User", class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_panel_user_top");
            popup.on_save_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )




        #logins = []
        if not logins:
            arrow_div = DivWdg()
            top.add(arrow_div)
            arrow_div.add("<b><<< Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: -35px")
            arrow_div.add_style("margin-left: 35px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 5px")
            arrow_div.set_box_shadow("1px 1px 2px 2px")
            arrow_div.set_round_corners(10, corners=['TL','BL'])

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("margin: 15px 30px 30px 30px")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg( "WARNING", IconWdg.WARNING )
            div.add(icon)
            div.add("<b>No users have been added</b>")
            div.add("<br/><br/>")
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias=my.get_help_alias())
            div.add(help)
            div.add("<br/>")
            div.add("Click on the 'Add' button above to start adding new users.")

            return top




        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")


        table = Table()
        table.set_max_width()
        table.add_style("margin-top: 10px")
        div.add(table)


        # group mouse over
        table.add_relay_behavior( {
            'type': "mouseover",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        } )
        table.add_relay_behavior( {
            'type': "mouseout",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        } )




        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("&nbsp;")
        th.add_style("text-align: left")
        th = table.add_header("Login")
        th.add_style("text-align: left")
        th = table.add_header("First Name")
        th.add_style("text-align: left")
        th = table.add_header("Last Name")
        th.add_style("text-align: left")
        th = table.add_header("Display Name")
        th.add_style("text-align: left")
        th = table.add_header("Activity")
        th.add_style("text-align: left")
        th = table.add_header("Groups")
        th.add_style("text-align: left")
        th = table.add_header("Security")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")





        for i, login in enumerate(logins):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i%2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2 )

            thumb = ThumbWdg()
            thumb.set_sobject(login)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)

            td = table.add_cell(login.get_value("login"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("first_name"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("last_name"))
            td.add_style("padding: 3px")

            td = table.add_cell(login.get_value("display_name"))
            td.add_style("padding: 3px")           

            search_key = login.get_search_key()
            login_code = login.get_code()
            full_name = login.get_full_name()

            td = table.add_cell()
            button = IconButtonWdg(tip="Activity", icon=IconWdg.CALENDAR)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'login_code': login_code,
                'full_name': full_name,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.ScheduleUserToolWdg';
                var kwargs = {
                    login: bvr.login_code
                }

                var title = bvr.full_name + ' Schedule';
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new("user_schedule", title, class_name, kwargs);
                //spt.panel.load_popup("Activty", class_name, kwargs);


                '''
            } )

 
            td = table.add_cell()
            button = IconButtonWdg(title="Groups", icon=IconWdg.GROUP_LINK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_key,
                'cbjs_action': '''

                var class_name = 'tactic.ui.startup.GroupAssignWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Group Assignment", class_name, kwargs);
                '''
            } )

  
            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_key,
                'cbjs_action': '''

                var class_name = 'tactic.ui.startup.GroupSummaryWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Security Summary", class_name, kwargs);
                '''
            } )




            td = table.add_cell()
            button = IconButtonWdg(title="Edit User", icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_key,
                'cbjs_action': '''

                var top = bvr.src_el.getParent(".spt_panel_user_top");
                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/login",
                    view: "edit",
                    search_key: bvr.search_key
                }
                var popup = spt.panel.load_popup("Create New User", class_name, kwargs);

                popup.on_save_cbk = function() {
                    spt.panel.refresh(top);
                }

                '''
            } )

        return top
Example #4
0
    def get_display(my):
        if my.is_refresh:
            top = Widget()
            my.add(top)
        else:
            container = DivWdg()
            my.add(container)
            #parent = SearchKey.get_by_search_key(my.search_key)
            top = DivWdg()
            container.add(top)
            my.set_as_panel(top)
            top.add_style("margin-top: -2px")

            top.add_class("spt_uber_notes_top")

        from tactic.ui.app import HelpButtonWdg
        help_button = HelpButtonWdg(alias="note-sheet-widget")
        top.add(help_button)
        help_button.add_style("float: right")

        table_id = 'sub_table'
        view = 'table'
        span = DivWdg(css='spt_input_group')
        top.add(span)

        span.add_border()
        span.add_style("height: 27px")
        span.add_style("padding: 5px")

        button_div = DivWdg()
        span.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-right: 10px")

        table = Table()
        button_div.add(table)
        table.add_row()

        from tactic.ui.widget import SingleButtonWdg
        refresh = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
        table.add_cell(refresh)
        refresh.add_style("float: left")
        refresh.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var tbody = top.getElements('.spt_table_tbody')[2];
            var values = spt.api.Utility.get_input_values(tbody);
            spt.panel.refresh(top, values, false);
        '''
        })

        save = SingleButtonWdg(title="Save", icon=IconWdg.SAVE)
        table.add_cell(save)
        save.add_style("float: left")
        save.add_behavior({
            'type':
            'click_up',
            'update_current_only':
            True,
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var table = top.getElement(".spt_table");
            bvr.src_el = table;
            spt.dg_table.update_row(evt, bvr)
            '''
        })

        process = SingleButtonWdg(title="Show Processes",
                                  icon=IconWdg.PROCESS,
                                  show_arrow=True)
        table.add_cell(process)

        from tactic.ui.container import DialogWdg
        process_dialog = DialogWdg(display=False)
        span.add(process_dialog)
        process_dialog.set_as_activator(process)
        process_dialog.add_title("Processes")

        process_div = DivWdg()
        process_dialog.add(process_div)
        #process_div.add_style("padding: 5px")
        process_div.add_color("background", "background")
        process_div.add_color("color", "color")
        process_div.add_border()

        refresh = ActionButtonWdg(title="Refresh")
        refresh.add_style('margin: 0 auto 10px auto')
        process_div.add(refresh)
        refresh.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var tbody = top.getElements('.spt_table_tbody')[2];
            var values = spt.api.Utility.get_input_values(tbody);
            spt.panel.refresh(top, values, false);
        '''
        })
        process_div.add("<hr/>")

        selected_process_names = []
        step = 0

        for idx, value in enumerate(my.process_names):
            checkbox_name = 'note_process_cb'
            if my.child_mode:
                selected_process_names.append(value)
                #break
            cb = CheckboxWdg(checkbox_name, label=value)

            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.set_option('value', value)
            #cb.set_persistence()

            cb.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                    spt.input.save_selected(bvr, '%s','%s');
                ''' % (checkbox_name, key)
            })

            # only 1 is selected in child_mode
            if cb.is_checked():
                selected_process_names.append(value)

            if idx == 0 or idx == 10 * step:
                # add a new inner div
                inner_div = my._get_inner_div()
                process_div.add(inner_div, 'inner%s' % step)
                step += 1

            inner_div.add(cb)

            inner_div.add("<br/>")

        # if less than 10, make it wider
        if len(my.process_names) < 10:
            inner_div.add_style('width: 100px')

        # add a master private checkbox
        if not my.child_mode:
            checkbox_name = 'note_master_private_cb'
            cb = CheckboxWdg(checkbox_name, label='make notes private')
            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.add_behavior({
                'type':
                'click_up',
                'propagate_evt':
                True,
                'cbjs_action':
                '''
                    var top = bvr.src_el.getParent(".spt_uber_notes_top");
                    var tbody = top.getElements('.spt_table_tbody')[2];
                    var inputs = spt.api.Utility.get_inputs(tbody,'is_private');
                    for (var i = 0; i < inputs.length; i++)
                        inputs[i].checked = bvr.src_el.checked;
                    spt.input.save_selected(bvr, '%s','%s');
                    ''' % (checkbox_name, key)
            })

            cb_span = DivWdg(cb, css='small')
            cb_span.add_styles(
                'border-left: 1px dotted #bbb; margin-left: 10px')
            span.add(cb_span)

        main_config_view = my._get_main_config(view, selected_process_names)

        sobject_dict = {}

        # TODO: do a union all search or by order number = 1
        for value in selected_process_names:
            search = Search('sthpw/note')
            search.add_filter('project_code', Project.get_project_code())
            search.add_filter('context', value)
            search.add_filter('search_type', my.parent_search_type)
            search.add_filter('search_id', my.parent_search_id)
            search.add_order_by('timestamp desc')
            search.add_limit(1)
            sobject = search.get_sobject()
            if sobject:
                sobject_dict[value] = sobject
        #sobjects = search.get_sobjects()
        # virtual sobject for placeholder, we can put more than 1 maybe?
        sobject = SearchType.create('sthpw/note')

        edit_config = my._get_edit_config('edit', selected_process_names)
        edit_configs = {'sthpw/note': edit_config}
        Container.put("CellEditWdg:configs", edit_configs)

        table = TableLayoutWdg(table_id=table_id,
                               search_type='sthpw/note',
                               view='table',
                               config=main_config_view,
                               aux_info={
                                   'sobjects': sobject_dict,
                                   'parent': my.parent
                               },
                               mode="simple",
                               show_row_select=False,
                               show_insert=False,
                               show_commit_all=True,
                               show_refresh='false',
                               state={'parent_key': my.search_key})
        table.set_sobject(sobject)

        top.add(table)

        return super(NoteSheetWdg, my).get_display()
Example #5
0
    def get_display(my):

        top = my.top

        #help_div = DivWdg()
        help_div = top
        #top.add(help_div)
        help_div.add_class("spt_help_top")
        help_div.set_id("spt_help_top")

        show_title = my.kwargs.get("show_title")
        if show_title in [True, 'true']:
            show_title = True
        else:
            show_title = False

        if show_title:
            title_wdg = DivWdg()
            help_div.add(title_wdg)
            title_wdg.add_style("font-size: 12px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_gradient("background", "background", 0, -20)
            title_wdg.add_style("padding: 3px")
            #title_wdg.add_style("margin-top: 8px")
            title_wdg.add_style("margin-bottom: 5px")
            title_wdg.add_style("height: 26px")
            title_wdg.add_style("padding: 6 0 0 6")
            title_wdg.set_round_corners(corners=['TL','TR'])

            icon = IconWdg("Close", IconWdg.KILL)
            title_wdg.add(icon)
            icon.add_style("float: right")
            title_wdg.add("Help")



        help_div.set_round_corners()
        help_div.add_color("color", "color2")
        help_div.add_color("background", "background")
        help_div.add_border()



        shelf_div = DivWdg()
        help_div.add(shelf_div)
        shelf_div.add_style("padding: 5px")
        shelf_div.add_gradient("background", "background")
        shelf_div.add_style("height: 25px")

        from tactic.ui.widget import SingleButtonWdg

        button = SingleButtonWdg(title="Documentation Main Page", icon=IconWdg.HOME)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_alias("main")
        '''
        } )




        button = SingleButtonWdg(title="Edit Help", icon=IconWdg.EDIT)
        shelf_div.add(button)
        button.add_style("float: left")
        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);
            
        '''
        } )



        button = SingleButtonWdg(title="Go Back One Page", icon=IconWdg.ARROW_LEFT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_prev();
        '''
        } )

        button = SingleButtonWdg(title="Go Forward One Page", icon=IconWdg.ARROW_RIGHT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_next();
        '''
        } )



        button = SingleButtonWdg(title="Documentation Downloads", icon=IconWdg.DOWNLOAD)
        shelf_div.add(button)
        button.add_style("float: right")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_alias("pdf")
        '''
        } )


        shelf_div.add("<br clear='all'/>")



        help_div.add_behavior( {
        'type': 'load',
        'cbjs_action': my.get_onload_js()
        })


        help_div.add_behavior( {
        'type': 'listen',
        'event_name': 'tab|select',
        'cbjs_action': '''

        var content = bvr.src_el.getElement(".spt_help_content");
        var options = bvr.firing_data;
        var element_name = options.element_name;
        var alias = options.alias;

        if (!alias) {
            alias = options.element_name;
        }

        spt.help.set_top();
        if (spt.help.is_visible()) {
            spt.help.load_alias(alias);
        }
        else {
            spt.help.set_view(alias);
        }
        '''

        } )


        help_div.add_behavior( {
        'type': 'listen',
        'event_name': 'show_help',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_help");
        var content = top.getElement(".spt_help_content");
        var firing_data = bvr.firing_data;
        var class_name = firing_data.class_name;
        if (!class_name) {
            class_name = 'tactic.ui.app.HelpContentWdg';
        }

        if (top.getStyle("display") != 'none') {
            spt.hide(top);
            return;
        }

        spt.help.set_top()

        // get the help view
        var help_view = spt.help.get_view();
        var html = firing_data.html;
        if (html) {
            spt.help.load_html(html);    
        }
        else {
            if (!help_view) {
                help_view = 'default'    
            }
            spt.help.load_alias(help_view);
        }

        var size = $(window).getSize();

        var dialog = bvr.src_el.getParent(".spt_dialog_content");

        dialog.setStyle("height", size.y - 100);
        dialog.setStyle("width", 650);

        var top = bvr.src_el.getParent(".spt_dialog_top");
        top.setStyle("left", size.x - 660);
        top.setStyle("top", 40);

        spt.show(top);
        '''
        } )






        content = DivWdg()
        help_div.add(content)
        content.add_class("spt_help_content");
        content.add_style("overflow_x: auto")
        content.add_style("overflow_y: auto")
        content.add_style("margin-bottom: 10px")
        #content.add_style("border: solid 1px blue")
        content.add_style("height: 98%")


        #key = "schema_editor"
        #search = Search("config/doc")
        #search.add_filter("code", key)
        #doc = search.get_sobject()
        #doc_html = doc.get_value("doc")
        #help_div.add(doc_html)


        return top
Example #6
0
    def get_display(my):

        top = my.top

        button_div = DivWdg()
        top.add(button_div)
        button_div.add_class("spt_buttons_top")
        button_div.add_border()

        button_div.add_style("margin-bottom: 0px")
        button_div.add_style("width: 1200px")
        button_div.add_style("height: 33px")
        button_div.add_color("background", "background2")
        button_div.add_style("margin-left: auto")
        button_div.add_style("margin-right: auto")


        button = SingleButtonWdg(title="Collapse", icon=IconWdg.HOME)
        button_div.add(button)
        button.add_style("float: left")
        button.add_style("left: 5px")
        button.add_style("top: 5px")


        # FIXME: get home for the user
        #home = 'tactic.ui.startup.ContentCreatorWdg'
        home = 'tactic.ui.startup.MainWdg'


        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.MainWdg';
            var kwargs = {
                help_alias: 'main'
                };
            spt.tab.add_new("_startup", "Startup", class_name, kwargs);

            '''
        } )


        top_class = my.kwargs.get("top_class")
        list_class = my.kwargs.get("list_class")
        height = my.kwargs.get("height")
        assert(top_class)
        assert(list_class)
        assert(height)

        button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP)
        button_div.add(button)
        button.add_class("spt_collapse")
        top.add(button_div)
        button.add_style("float: left")
        button.add_style("left: 5px")
        button.add_style("top: 5px")

        button.add_behavior( {
            'type': 'click_up',
            'top_class': top_class,
            'list_class': list_class,
            'height': height,
            'cbjs_action': '''
            var top = bvr.src_el.getParent("."+bvr.top_class);
            var element = top.getElement("."+bvr.list_class);

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            expand = buttons.getElement(".spt_expand");
            new Fx.Tween(element).start('margin-top', "-"+bvr.height+"px");
            expand.setStyle("display", "");
            bvr.src_el.setStyle("display", "none");
            '''
        } )

        button = SingleButtonWdg(title="Expand", icon=IconWdg.ARROW_DOWN)
        button.add_style("display: none")
        button.add_class("spt_expand")
        button_div.add(button)
        button.add_style("left: 5px")
        button.add_style("top: 5px")
        top.add(button_div)
        button.add_style("float: left")
        button.add_behavior( {
            'type': 'click_up',
            'top_class': top_class,
            'list_class': list_class,
            'cbjs_action': '''
            var top = bvr.src_el.getParent("."+bvr.top_class);
            var element = top.getElement("."+bvr.list_class);

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            collapse = buttons.getElement(".spt_collapse");
            new Fx.Tween(element).start('margin-top', "0px");
            collapse.setStyle("display", "");
            bvr.src_el.setStyle("display", "none");
            '''
        } )

        return top
Example #7
0
    def get_display(self):

        top = self.top

        button_div = DivWdg()
        top.add(button_div)
        button_div.add_class("spt_buttons_top")
        button_div.add_border()

        button_div.add_style("margin-bottom: 0px")
        button_div.add_style("width: 1200px")
        button_div.add_style("height: 33px")
        button_div.add_color("background", "background2")
        button_div.add_style("margin-left: auto")
        button_div.add_style("margin-right: auto")

        button = SingleButtonWdg(title="Collapse", icon=IconWdg.HOME)
        button_div.add(button)
        button.add_style("float: left")
        button.add_style("left: 5px")
        button.add_style("top: 5px")

        # FIXME: get home for the user
        #home = 'tactic.ui.startup.ContentCreatorWdg'
        home = 'tactic.ui.startup.MainWdg'

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.MainWdg';
            var kwargs = {
                help_alias: 'main'
                };
            spt.tab.add_new("_startup", "Startup", class_name, kwargs);

            '''
        })

        top_class = self.kwargs.get("top_class")
        list_class = self.kwargs.get("list_class")
        height = self.kwargs.get("height")
        assert (top_class)
        assert (list_class)
        assert (height)

        button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP)
        button_div.add(button)
        button.add_class("spt_collapse")
        top.add(button_div)
        button.add_style("float: left")
        button.add_style("left: 5px")
        button.add_style("top: 5px")

        button.add_behavior({
            'type':
            'click_up',
            'top_class':
            top_class,
            'list_class':
            list_class,
            'height':
            height,
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent("."+bvr.top_class);
            var element = top.getElement("."+bvr.list_class);

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            expand = buttons.getElement(".spt_expand");
            new Fx.Tween(element).start('margin-top', "-"+bvr.height+"px");
            expand.setStyle("display", "");
            bvr.src_el.setStyle("display", "none");
            '''
        })

        button = SingleButtonWdg(title="Expand", icon=IconWdg.ARROW_DOWN)
        button.add_style("display: none")
        button.add_class("spt_expand")
        button_div.add(button)
        button.add_style("left: 5px")
        button.add_style("top: 5px")
        top.add(button_div)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'top_class':
            top_class,
            'list_class':
            list_class,
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent("."+bvr.top_class);
            var element = top.getElement("."+bvr.list_class);

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            collapse = buttons.getElement(".spt_collapse");
            new Fx.Tween(element).start('margin-top', "0px");
            collapse.setStyle("display", "");
            bvr.src_el.setStyle("display", "none");
            '''
        })

        return top
Example #8
0
    def get_display(my):

        web = WebContainer.get_web()
        show_multi_project = web.get_form_value('show_multi_project')
        project = Project.get()
        search_type_objs = project.get_search_types(include_multi_project=show_multi_project)


        top = my.top
        top.add_class("spt_panel_stype_list_top")
        #top.add_style("min-width: 400px")
        #top.add_style("max-width: 1000px")
        #top.add_style("width: 100%")
        top.center()



        button = SingleButtonWdg(title="Advanced Setup", icon=IconWdg.ADVANCED)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_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)
            '''
        } )


        button = SingleButtonWdg(title="Add", tip="Add New Searchable Type (sType)", icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.app.SearchTypeCreatorWdg';

            var kwargs = {
            };
            var popup = spt.panel.load_popup("Create New Searchable Type", class_name, kwargs);

            var top = bvr.src_el.getParent(".spt_panel_stype_list_top");
            popup.on_register_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )

        cb = CheckboxWdg('show_multi_project', label=' show multi-project')
        if show_multi_project:
            cb.set_checked()
        cb.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
                var panel = bvr.src_el.getParent('.spt_panel_stype_list_top')
                spt.panel.refresh(panel, {show_multi_project: bvr.src_el.checked});
            '''
            })
        span = SpanWdg(css='small')
        top.add(span)
        top.add(cb)
        top.add("<br clear='all'/>")
        #search_type_objs = []
        if not search_type_objs:
            arrow_div = DivWdg()
            top.add(arrow_div)
            icon = IconWdg("Click to Add", IconWdg.ARROW_UP_LEFT_32)
            icon.add_style("margin-top: -20")
            icon.add_style("margin-left: -15")
            icon.add_style("position: absolute")
            arrow_div.add(icon)
            arrow_div.add("&nbsp;"*5)
            arrow_div.add("<b>Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: 5px")
            arrow_div.add_style("margin-left: 20px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 25px")
            arrow_div.set_box_shadow("0px 5px 20px")
            arrow_div.set_round_corners(30)
            arrow_div.add_color("background", "background")

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("width: 600px")
            div.add_style("margin: 30px auto")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg( "WARNING", IconWdg.WARNING )
            div.add(icon)
            div.add("<b>No Searchable Types have been created</b>")
            div.add("<br/><br/>")
            div.add("Searchables Types contain lists of items that are managed in this project.  Each item will automatically have the ability to have files checked into it, track tasks and status and record work hours.")
            div.add("<br/>"*2)
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias="main")
            div.add(help)
            div.add("<br/>")
            div.add("Click on the 'Add' button above to start adding new types.")
            return top


        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")



        table = Table()
        div.add(table)
        table.add_style("margin-top: 10px")
        table.set_max_width()



        # group mouse over
        table.add_relay_behavior( {
            'type': "mouseover",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        } )
        table.add_relay_behavior( {
            'type': "mouseout",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        } )



        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("")
        th.add_style("text-align: left")
        th = table.add_header("Title")
        th.add_style("text-align: left")
        th = table.add_header("# Items")
        th.add_style("text-align: left")
        th = table.add_header("View")
        th.add_style("text-align: left")
        th = table.add_header("Add")
        th.add_style("text-align: left")
        th = table.add_header("Import")
        th.add_style("text-align: left")
        th = table.add_header("Custom Columns")
        th.add_style("text-align: left")
        th = table.add_header("Workflow")
        th.add_style("text-align: left")
        th = table.add_header("Notifications")
        th.add_style("text-align: left")
        th = table.add_header("Triggers")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")
        #th = table.add_header("Security")
        #th.add_style("text-align: left")



        for i, search_type_obj in enumerate(search_type_objs):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i%2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2 )


            thumb = ThumbWdg()
            thumb.set_sobject(search_type_obj)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)



            search_type = search_type_obj.get_value("search_type")
            title = search_type_obj.get_title()

            table.add_cell(title)

            try:
                search = Search(search_type)
                count = search.get_count()
                if count:
                    table.add_cell("%s item/s" % count)
                else:
                    table.add_cell("&nbsp;")
            except:
                td = table.add_cell("&lt; No table &gt;")
                td.add_style("font-style: italic")
                td.add_style("color: #F00")
                continue



            #search = Search(search_type)
            #search.add_interval_filter("timestamp", "today")
            #created_today = search.get_count()
            #table.add_cell(created_today)



            td = table.add_cell()
            button = IconButtonWdg(title="View", icon=IconWdg.ZOOM)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            button.add_style("float: left")


            arrow_button = IconButtonWdg(tip="More Views", icon=IconWdg.ARROWHEAD_DARK_DOWN)
            arrow_button.add_style("margin-left: 20px")
            td.add(arrow_button)

            cbk = '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = bvr.class_name;
            var layout = bvr.layout;

            var kwargs = {
                search_type: bvr.search_type,
                layout: layout,
                view: bvr.view,
                simple_search_view: 'simple_search',
                element_names: bvr.element_names,
            };

            // use tab
            var top = activator.getParent(".spt_dashboard_top");
            spt.tab.set_tab_top(top);
            spt.tab.add_new('%s', '%s', class_name, kwargs);
            ''' % (title, title)


            from tactic.ui.panel import SwitchLayoutMenu
            SwitchLayoutMenu(search_type=search_type, activator=arrow_button, cbk=cbk, is_refresh=False)

            td = table.add_cell()
            button = IconButtonWdg(title="Add", icon=IconWdg.ADD)
            td.add(button)
            button.add_behavior( {
                'type': 'listen',
                'search_type': search_type,
                'event_name': 'startup_save:' + search_type_obj.get_title(),
                'title': search_type_obj.get_title(),
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
 

                '''
            } )
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': search_type_obj.get_title(),
                'cbjs_action': '''

                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: "insert",
                    save_event: "startup_save:" + bvr.title
                }
                spt.panel.load_popup("Add New Items ("+bvr.title+")", class_name, kwargs);

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                '''
            } )


            """
            td = table.add_cell()
            button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'checkin',
                    element_names: ['preview','code','name','description','history','general_checkin','notes']
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            """





            td = table.add_cell()
            button = IconButtonWdg(title="Import", icon=IconWdg.IMPORT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Import Data",
                'cbjs_action': '''

                var class_name = 'tactic.ui.widget.CsvImportWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };

                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )



            td = table.add_cell()
            button = IconButtonWdg(title="Custom Columns", icon=IconWdg.COLUMNS)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Add Custom Columns",
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.ColumnEditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Workflow", icon=IconWdg.PIPELINE)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/pipeline")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")




            button.add_behavior( {
                'type': 'click_up',
                'title': 'Workflow',
                'search_type': search_type,
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.PipelineEditWdg';
                var kwargs = {
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )
 


            td = table.add_cell()
            button = IconButtonWdg(title="Notifications", icon=IconWdg.MAIL)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/notification")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")






            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )


            td = table.add_cell()
            button = IconButtonWdg(title="Triggers", icon=IconWdg.ARROW_OUT)
            td.add(button)
            button.add_style("float: left")

            search = Search("config/trigger")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")


            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Edit Searchable Type", icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_type_obj.get_search_key(),
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/sobject",
                    view: "edit_startup",
                    search_key: bvr.search_key
                }
                spt.panel.load_popup("Edit Searchable Type", class_name, kwargs);


                '''
            } )


 
            """
            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''
                alert("security");
                '''
            } )
            """


        columns_wdg = DivWdg()
        top.add(columns_wdg)


        return top
Example #9
0
    def get_shelf_wdg(my):

        process = my.get_value("process")
        versions = my.get_value("versions")

        div = DivWdg()

        button = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
        div.add(button)
        button.add_style("float: left")
        div.add("&nbsp;"*5)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.panel.refresh(bvr.src_el);
            '''
        } )

        # get all of the pipelnes for this search type
        pipeline_code = my.sobject.get_value("pipeline_code", no_exception=True)
        processes = []
        if pipeline_code:
            search = Search("sthpw/pipeline")
            search.add_filter("code", pipeline_code)
            pipeline = search.get_sobject()

            process_names = pipeline.get_process_names()
            processes.extend(process_names)

        processes.insert(0, "all")



        div.add("Process: ")
        select = SelectWdg("process")
        if process != 'all':
            select.set_value(process)

        select.set_option("values", processes)

        div.add(select)



        div.add("&nbsp;"*10)

        div.add("Versions: ")
        select = SelectWdg("versions")
        select.set_option("values", "latest|current|today|last 10|all")
        if versions:
            select.set_value(versions)
        div.add(select)


        asset_dir = Environment.get_asset_dir()

        select = IconButtonWdg( tip="Toggle Selection", icon=IconWdg.SELECT, show_arrow=False )
        div.add(select)
        select.add_style("float: right")
        select.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top_class = 'spt_sobject_dir_list_top'
            var toggle_state = bvr.src_el.getAttribute('toggle');
            if (toggle_state && toggle_state=='true')
                bvr.src_el.setAttribute('toggle','false');
            else
                bvr.src_el.setAttribute('toggle','true');

            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            
            toggle_state = bvr.src_el.getAttribute('toggle');
            if (toggle_state == 'true')
                spt.selection.select_all_items();
            else
                spt.selection.unselect_all_items();

            '''
            } )



        show = IconButtonWdg( tip="Switch View", icon=IconWdg.VIEW, show_arrow=False )
        div.add(show)
        show.add_style("float: right")
        show.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top_class = 'spt_sobject_dir_list_top'
            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            var els = top.getElements(".spt_file_dir_item");
            for (var i = 0; i < els.length; i++) {
                var el = els[i];
                if (el.getStyle("display") == "none") {
                    els[i].setStyle("display", "");
                }
                else {
                    els[i].setStyle("display", "none");
                }
            }
            var els = top.getElements(".spt_file_item");
            for (var i = 0; i < els.length; i++) {
                var el = els[i];
                if (el.getStyle("padding-left") == "6px") {
                    var padding = el.getAttribute("spt_padding_left");
                    el.setStyle("padding-left", padding);
                }
                else {
                    el.setStyle("padding-left", "6px");
                }

            }


            '''
        } )






        gear = IconButtonWdg( tip="Download", icon=IconWdg.DOWNLOAD, show_arrow=False )
        div.add(gear)
        gear.add_style("float: right")
        gear.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.app_busy.show('Select a folder to download to','');
            var top_class = 'spt_sobject_dir_list_top';
            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            var items = spt.selection.get_selected();
            
       
            setTimeout( function() {
                var applet = spt.Applet.get();
                var select_dir =true;
                var dir = applet.open_file_browser('', select_dir);
                if (!dir) {
                    dir = applet.get_current_dir();
                }
                if (!dir) {
                    spt.alert("No folder selected to copy to");
                    return;
                }

                var asset_dir = '%s';
                for (var i = 0; i < items.length; i++) {
                    var path = items[i].getAttribute("spt_path");
                    var env = spt.Environment.get();
                    var server_url = env.get_server_url();
                    var url = server_url + "/assets/" + path.replace(asset_dir, "");
                    var parts = path.split("/");
                    var filename = parts[parts.length-1];
                    spt.app_busy.show("Downloading file", filename);
                    applet.download_file(url, dir + "/" + filename);
                }
                spt.app_busy.hide();
                if (dir)
                    spt.notify.show_message("Download to '" + dir + "' completed.")
            }, 100);

            ''' % asset_dir
 
        } )

        return div
Example #10
0
    def get_display(my):

        top = my.top

        #help_div = DivWdg()
        help_div = top
        #top.add(help_div)
        help_div.add_class("spt_help_top")
        help_div.set_id("spt_help_top")

        show_title = my.kwargs.get("show_title")
        if show_title in [True, 'true']:
            show_title = True
        else:
            show_title = False

        if show_title:
            title_wdg = DivWdg()
            help_div.add(title_wdg)
            title_wdg.add_style("font-size: 12px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_gradient("background", "background", 0, -20)
            title_wdg.add_style("padding: 3px")
            #title_wdg.add_style("margin-top: 8px")
            title_wdg.add_style("margin-bottom: 5px")
            title_wdg.add_style("height: 26px")
            title_wdg.add_style("padding: 6 0 0 6")
            title_wdg.set_round_corners(corners=['TL', 'TR'])

            icon = IconWdg("Close", IconWdg.KILL)
            title_wdg.add(icon)
            icon.add_style("float: right")
            title_wdg.add("Help")

        help_div.set_round_corners()
        help_div.add_color("color", "color2")
        help_div.add_color("background", "background")
        help_div.add_border()

        shelf_div = DivWdg()
        help_div.add(shelf_div)
        shelf_div.add_style("padding: 5px")
        shelf_div.add_gradient("background", "background")
        shelf_div.add_style("height: 25px")

        from tactic.ui.widget import SingleButtonWdg

        button = SingleButtonWdg(title="Documentation Main Page",
                                 icon=IconWdg.HOME)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_alias("main")
        '''
        })

        button = SingleButtonWdg(title="Edit Help", icon=IconWdg.EDIT)
        shelf_div.add(button)
        button.add_style("float: left")
        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);
            
        '''
        })

        button = SingleButtonWdg(title="Go Back One Page",
                                 icon=IconWdg.ARROW_LEFT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_prev();
        '''
        })

        button = SingleButtonWdg(title="Go Forward One Page",
                                 icon=IconWdg.ARROW_RIGHT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_next();
        '''
        })

        button = SingleButtonWdg(title="Documentation Downloads",
                                 icon=IconWdg.DOWNLOAD)
        shelf_div.add(button)
        button.add_style("float: right")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_alias("pdf")
        '''
        })

        shelf_div.add("<br clear='all'/>")

        help_div.add_behavior({
            'type': 'load',
            'cbjs_action': my.get_onload_js()
        })

        help_div.add_behavior({
            'type':
            'listen',
            'event_name':
            'tab|select',
            'cbjs_action':
            '''

        var content = bvr.src_el.getElement(".spt_help_content");
        var options = bvr.firing_data;
        var element_name = options.element_name;
        var alias = options.alias;

        if (!alias) {
            alias = options.element_name;
        }

        spt.help.set_top();
        if (spt.help.is_visible()) {
            spt.help.load_alias(alias);
        }
        else {
            spt.help.set_view(alias);
        }
        '''
        })

        help_div.add_behavior({
            'type':
            'listen',
            'event_name':
            'show_help',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_help");
        var content = top.getElement(".spt_help_content");
        var firing_data = bvr.firing_data;
        var class_name = firing_data.class_name;
        if (!class_name) {
            class_name = 'tactic.ui.app.HelpContentWdg';
        }

        if (top.getStyle("display") != 'none') {
            spt.hide(top);
            return;
        }

        spt.help.set_top()

        // get the help view
        var help_view = spt.help.get_view();
        var html = firing_data.html;
        if (html) {
            spt.help.load_html(html);    
        }
        else {
            if (!help_view) {
                help_view = 'default'    
            }
            spt.help.load_alias(help_view);
        }

        var size = $(window).getSize();

        var dialog = bvr.src_el.getParent(".spt_dialog_content");

        dialog.setStyle("height", size.y - 100);
        dialog.setStyle("width", 650);

        var top = bvr.src_el.getParent(".spt_dialog_top");
        top.setStyle("left", size.x - 660);
        top.setStyle("top", 40);

        spt.show(top);
        '''
        })

        content = DivWdg()
        help_div.add(content)
        content.add_class("spt_help_content")
        content.add_style("position: relative")
        content.add_style("overflow_x: auto")
        content.add_style("overflow_y: auto")
        content.add_style("margin-bottom: 10px")
        #content.add_style("border: solid 1px blue")
        content.add_style("height: 98%")

        #key = "schema_editor"
        #search = Search("config/doc")
        #search.add_filter("code", key)
        #doc = search.get_sobject()
        #doc_html = doc.get_value("doc")
        #help_div.add(doc_html)

        return top
Example #11
0
    def get_display(self):
        if self.is_refresh:
            top = Widget()
            self.add(top)
        else:
            container = DivWdg()
            self.add(container)
            #parent = SearchKey.get_by_search_key(self.search_key)
            top = DivWdg()
            container.add(top)
            self.set_as_panel(top)
            top.add_style("margin-top: -2px")
            
            top.add_class("spt_uber_notes_top")


        from tactic.ui.app import HelpButtonWdg
        help_button = HelpButtonWdg(alias="note-sheet-widget")
        top.add(help_button)
        help_button.add_style("float: right")

        table_id = 'sub_table'
        view = 'table'
        span = DivWdg(css='spt_input_group')
        top.add(span)

        span.add_border()
        span.add_style("height: 27px")
        span.add_style("padding: 5px")

        button_div = DivWdg()
        span.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-right: 10px")


        table = Table()
        button_div.add(table)
        table.add_row()

        from tactic.ui.widget import SingleButtonWdg
        refresh = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
        table.add_cell(refresh)
        refresh.add_style("float: left")
        refresh.add_behavior({
        'type': 'click_up',
        'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var tbody = top.getElements('.spt_table_tbody')[2];
            var values = spt.api.Utility.get_input_values(tbody);
            spt.panel.refresh(top, values, false);
        '''
        }) 


        save = SingleButtonWdg(title="Save", icon=IconWdg.SAVE)
        table.add_cell(save)
        save.add_style("float: left")
        save.add_behavior( {
            'type': 'click_up',
            'update_current_only': True,
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var table = top.getElement(".spt_table");
            bvr.src_el = table;
            spt.dg_table.update_row(evt, bvr)
            '''
        })


        process = SingleButtonWdg(title="Show Processes", icon=IconWdg.PROCESS, show_arrow=True)
        table.add_cell(process)

        from tactic.ui.container import DialogWdg
        process_dialog = DialogWdg(display=False)
        span.add(process_dialog)
        process_dialog.set_as_activator(process)
        process_dialog.add_title("Processes")

        process_div = DivWdg()
        process_dialog.add(process_div)
        #process_div.add_style("padding: 5px")
        process_div.add_color("background", "background")
        process_div.add_color("color", "color")
        process_div.add_border()

        refresh = ActionButtonWdg(title="Refresh")
        refresh.add_style('margin: 0 auto 10px auto')
        process_div.add(refresh)
        refresh.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var tbody = top.getElements('.spt_table_tbody')[2];
            var values = spt.api.Utility.get_input_values(tbody);
            spt.panel.refresh(top, values, false);
        '''
        } )
        process_div.add("<hr/>")


        selected_process_names = []
        step = 0
        
        for idx, value in enumerate(self.process_names):
            checkbox_name = 'note_process_cb'
            if self.child_mode:
                selected_process_names.append(value)
                #break
            cb = CheckboxWdg(checkbox_name, label=value)

           
            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.set_option('value', value)
            #cb.set_persistence()

            cb.add_behavior({
                'type': 'click_up',
                'cbjs_action': '''
                    spt.input.save_selected(bvr, '%s','%s');
                ''' % (checkbox_name, key)
            }) 

            # only 1 is selected in child_mode
            if cb.is_checked():
                selected_process_names.append(value)


            if idx == 0 or idx == 10 * step:
                # add a new inner div
                inner_div = self._get_inner_div()
                process_div.add(inner_div, 'inner%s'%step)
                step += 1
                
            inner_div.add(cb)

            inner_div.add("<br/>")
            

        # if less than 10, make it wider
        if len(self.process_names) < 10:
            inner_div.add_style('width: 100px')

        # add a master private checkbox
        if not self.child_mode:
            checkbox_name = 'note_master_private_cb'
            cb = CheckboxWdg(checkbox_name, label='make notes private')
            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.add_behavior({ 
                'type': 'click_up',
                'propagate_evt': True,
                'cbjs_action': '''
                    var top = bvr.src_el.getParent(".spt_uber_notes_top");
                    var tbody = top.getElements('.spt_table_tbody')[2];
                    var inputs = spt.api.Utility.get_inputs(tbody,'is_private');
                    for (var i = 0; i < inputs.length; i++)
                        inputs[i].checked = bvr.src_el.checked;
                    spt.input.save_selected(bvr, '%s','%s');
                    '''%(checkbox_name, key)
                    })

            cb_span = DivWdg(cb, css='small')
            cb_span.add_styles('border-left: 1px dotted #bbb; margin-left: 10px')
            span.add(cb_span)

        main_config_view = self._get_main_config(view, selected_process_names)
        
        sobject_dict = {}

        # TODO: do a union all search or by order number = 1
        for value in selected_process_names:
            search = Search('sthpw/note')
            search.add_filter('project_code', Project.get_project_code())
            search.add_filter('context', value)
            search.add_filter('search_type',self.parent_search_type)
            search.add_filter('search_id',self.parent_search_id)
            search.add_order_by('timestamp desc')
            search.add_limit(1)
            sobject = search.get_sobject()
            if sobject:
                sobject_dict[value] = sobject
        #sobjects = search.get_sobjects()
        # virtual sobject for placeholder, we can put more than 1 maybe?
        sobject = SearchType.create('sthpw/note')

        edit_config = self._get_edit_config('edit', selected_process_names)
        edit_configs = {'sthpw/note': edit_config}
        Container.put("CellEditWdg:configs", edit_configs)

        table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view='table',
            config=main_config_view, aux_info={'sobjects': sobject_dict, 'parent': self.parent}, mode="simple", show_row_select=False, show_insert=False, show_commit_all=True, show_refresh='false', state={'parent_key': self.search_key} )
        table.set_sobject(sobject)

        top.add(table)


        return super(NoteSheetWdg, self).get_display()
Example #12
0
    def get_display(my):

        search = Search("sthpw/login")
        logins = search.get_sobjects()

        top = my.top
        top.add_class("spt_panel_user_top")
        top.add_style("min-width: 400px")

        button = SingleButtonWdg(title="Advanced Security", icon=IconWdg.LOCK)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.startup.SecurityWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("Security", "Security", class_name)
            '''
        })

        button = SingleButtonWdg(title="Add",
                                 tip="Add New User",
                                 icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        top.add("<br clear='all'/>")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.panel.EditWdg';
            var kwargs = {
                search_type: "sthpw/login",
                view: "edit",
            }
            var popup = spt.panel.load_popup("Create New User", class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_panel_user_top");
            popup.on_save_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        })

        #logins = []
        if not logins:
            arrow_div = DivWdg()
            top.add(arrow_div)
            arrow_div.add("<b><<< Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: -35px")
            arrow_div.add_style("margin-left: 35px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 5px")
            arrow_div.set_box_shadow("1px 1px 2px 2px")
            arrow_div.set_round_corners(10, corners=['TL', 'BL'])

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("margin: 15px 30px 30px 30px")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg("WARNING", IconWdg.WARNING)
            div.add(icon)
            div.add("<b>No users have been added</b>")
            div.add("<br/><br/>")
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias=my.get_help_alias())
            div.add(help)
            div.add("<br/>")
            div.add(
                "Click on the 'Add' button above to start adding new users.")

            return top

        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")

        table = Table()
        table.set_max_width()
        table.add_style("margin-top: 10px")
        div.add(table)

        # group mouse over
        table.add_relay_behavior({
            'type':
            "mouseover",
            'bvr_match_class':
            'spt_row',
            'cbjs_action':
            "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        })
        table.add_relay_behavior({
            'type':
            "mouseout",
            'bvr_match_class':
            'spt_row',
            'cbjs_action':
            "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        })

        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("&nbsp;")
        th.add_style("text-align: left")
        th = table.add_header("Login")
        th.add_style("text-align: left")
        th = table.add_header("First Name")
        th.add_style("text-align: left")
        th = table.add_header("Last Name")
        th.add_style("text-align: left")
        th = table.add_header("Display Name")
        th.add_style("text-align: left")
        th = table.add_header("Activity")
        th.add_style("text-align: left")
        th = table.add_header("Groups")
        th.add_style("text-align: left")
        th = table.add_header("Security")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")

        for i, login in enumerate(logins):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i % 2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2)

            thumb = ThumbWdg()
            thumb.set_sobject(login)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)

            td = table.add_cell(login.get_value("login"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("first_name"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("last_name"))
            td.add_style("padding: 3px")

            td = table.add_cell(login.get_value("display_name"))
            td.add_style("padding: 3px")

            search_key = login.get_search_key()
            login_code = login.get_code()
            full_name = login.get_full_name()

            td = table.add_cell()
            button = IconButtonWdg(tip="Activity", icon=IconWdg.CALENDAR)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'login_code':
                login_code,
                'full_name':
                full_name,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.tools.ScheduleUserToolWdg';
                var kwargs = {
                    login: bvr.login_code
                }

                var title = bvr.full_name + ' Schedule';
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new("user_schedule", title, class_name, kwargs);
                //spt.panel.load_popup("Activty", class_name, kwargs);


                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Groups", icon=IconWdg.GROUP_LINK)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_key,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.startup.GroupAssignWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Group Assignment", class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_key,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.startup.GroupSummaryWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Security Summary", class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Edit User", icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_key,
                'cbjs_action':
                '''

                var top = bvr.src_el.getParent(".spt_panel_user_top");
                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/login",
                    view: "edit",
                    search_key: bvr.search_key
                }
                var popup = spt.panel.load_popup("Create New User", class_name, kwargs);

                popup.on_save_cbk = function() {
                    spt.panel.refresh(top);
                }

                '''
            })

        return top
Example #13
0
    def get_shelf_wdg(my):

        process = my.get_value("process")
        versions = my.get_value("versions")

        div = DivWdg()

        button = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
        div.add(button)
        button.add_style("float: left")
        div.add("&nbsp;" * 5)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.panel.refresh(bvr.src_el);
            '''
        })

        # get all of the pipelnes for this search type
        pipeline_code = my.sobject.get_value("pipeline_code",
                                             no_exception=True)
        processes = []
        if pipeline_code:
            pipeline = Pipeline.get_by_code(pipeline_code)
            if pipeline:
                process_names = pipeline.get_process_names()
                processes.extend(process_names)

        processes.insert(0, "all")

        div.add("Process: ")
        select = SelectWdg("process")
        if process != 'all':
            select.set_value(process)

        select.set_option("values", processes)

        div.add(select)

        div.add("&nbsp;" * 10)

        div.add("Versions: ")
        select = SelectWdg("versions")
        select.set_option("values", "latest|current|today|last 10|all")
        if versions:
            select.set_value(versions)
        div.add(select)

        asset_dir = Environment.get_asset_dir()

        select = IconButtonWdg(tip="Toggle Selection",
                               icon=IconWdg.SELECT,
                               show_arrow=False)
        div.add(select)
        select.add_style("float: right")
        select.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top_class = 'spt_sobject_dir_list_top'
            var toggle_state = bvr.src_el.getAttribute('toggle');
            if (toggle_state && toggle_state=='true')
                bvr.src_el.setAttribute('toggle','false');
            else
                bvr.src_el.setAttribute('toggle','true');

            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            
            toggle_state = bvr.src_el.getAttribute('toggle');
            if (toggle_state == 'true')
                spt.selection.select_all_items();
            else
                spt.selection.unselect_all_items();

            '''
        })

        show = IconButtonWdg(tip="Switch View",
                             icon=IconWdg.VIEW,
                             show_arrow=False)
        div.add(show)
        show.add_style("float: right")
        show.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top_class = 'spt_sobject_dir_list_top'
            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            var els = top.getElements(".spt_file_dir_item");
            for (var i = 0; i < els.length; i++) {
                var el = els[i];
                if (el.getStyle("display") == "none") {
                    els[i].setStyle("display", "");
                }
                else {
                    els[i].setStyle("display", "none");
                }
            }
            var els = top.getElements(".spt_file_item");
            for (var i = 0; i < els.length; i++) {
                var el = els[i];
                if (el.getStyle("padding-left") == "6px") {
                    var padding = el.getAttribute("spt_padding_left");
                    el.setStyle("padding-left", padding);
                }
                else {
                    el.setStyle("padding-left", "6px");
                }

            }


            '''
        })

        gear = IconButtonWdg(tip="Download",
                             icon=IconWdg.DOWNLOAD,
                             show_arrow=False)
        div.add(gear)
        gear.add_style("float: right")
        gear.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.app_busy.show('Select a folder to download to...','');
            var top_class = 'spt_sobject_dir_list_top';
            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            var items = spt.selection.get_selected();
            
       
            setTimeout( function() {
                var applet = spt.Applet.get();
                var select_dir =true;
                var dir = applet.open_file_browser('', select_dir);
                if (dir.length == 0)
                    dir = applet.get_current_dir();
                else 
                    dir = dir[0];

                if (!dir) {
                    spt.alert("No folder selected to copy to.");
                    spt.app_busy.hide();
                    return;
                }
                if (items.length == 0){
                    spt.alert("Please select at least one file to download.");
                    spt.app_busy.hide();
                    return;
                }
                

                var asset_dir = '%s';
                for (var i = 0; i < items.length; i++) {
                    var path = items[i].getAttribute("spt_path");
                    var env = spt.Environment.get();
                    var server_url = env.get_server_url();
                    var url = server_url + "/assets/" + path.replace(asset_dir, "");
                    var parts = path.split("/");
                    var filename = parts[parts.length-1];
                    spt.app_busy.show("Downloading file", filename);
                    applet.download_file(url, dir + "/" + filename);
                }
                spt.app_busy.hide();
                if (dir)
                    spt.notify.show_message("Download to '" + dir + "' completed.")
            }, 100);

            ''' % asset_dir
        })

        return div