Beispiel #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_behavior( {
            'type': 'load',
            'cbjs_action': '''
            spt.named_events.fire_event("side_bar|hide_now", {} );
            '''
        } )


        project = Project.get()
        title = DivWdg()
        title.add("Project Startup and Configuration")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 10px -10px")

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


        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        button_div = DivWdg()
        shelf.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -3px")

        security = Environment.get_security()
        view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow')
        if view_side_bar:
            button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
            button_div.add(button)
            shelf.add("Toggle Side Bar")
            shelf.add_attr("title", "Toggle Side Bar (or press '1')")
            button.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            } )
            shelf.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            } )
            shelf.add_class("hand")
        else:
            shelf.add(" ")


        search_wdg = Table()
        top.add(search_wdg)
        search_wdg.add_row()

        search_wdg.add_class("spt_main_top")
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 20px auto")
        search_wdg.add_style("width: 430px")

        td = search_wdg.add_cell("Search: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 8px")


        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'result_list',
                    'keywords': keywords,
                    'simple_search_view': 'simple_filter',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''


        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk, width='280', height='42px')
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")

        search_wdg.add_cell(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")


        icon_div = DivWdg()
        td = search_wdg.add_cell(icon_div)
        td.add_style("vertical-align: top")
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 7px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior( {
            'type': 'mouseover',
            'color': over_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        } )
        icon_div.add_behavior( {
            'type': 'mouseout',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click_up',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )





        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'result_list',
                'keywords': keywords,
                'simple_search_view': 'simple_filter',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        } )

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")


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

        #security = Environment.get_security()
        #if not security.check_access("builtin", "view_site_admin", "allow"):

         

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Configuration"
        #description = '''All TACTIC projects can be uniquely designed and managed using our configuration tools.'''
        description = '''Configure a Project from start to finish.'''
	image = "<img src='/context/icons/64x64/configuration_64.png'/>"
        behavior = {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.ProjectConfigWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
                };
            spt.tab.add_new("project_configuration", "Configuration", class_name, kwargs);
            '''
        }
        config_wdg = my.get_main_section_wdg(title, description, image, behavior)
        td.add(config_wdg)



        # Manage Users
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Manage Users and Security"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        image = DivWdg()
        image_link = "<div style='margin-bottom: -64px'><img src='/context/icons/64x64/lock_64.png'/></div>"
        image.add(image_link)

        image1 = IconWdg("Manage Users", IconWdg.USER_32)
        image2 = IconWdg("Manage Users", IconWdg.USER_32)
        image3 = IconWdg("Manage Users", IconWdg.USER_32)
        image4 = IconWdg("Manage Users", IconWdg.USER_32)
        image.add(image1)
        image.add(image2)
        image.add("<br/>")
        image.add(image3)
        image.add(image4)
        description = '''Manage users that can access the system'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.UserConfigWdg';
        var kwargs = {
            help_alias: 'project-startup-manage-users'
            };
        spt.tab.add_new("manage_user", "Manage Users", class_name, kwargs);
        '''
        }
        manage_users_wdg = my.get_main_section_wdg(title, description, image, behavior)
        td.add(manage_users_wdg)



        # custom layout editor 
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Custom Layouts"
        description = '''Create interfaces using the Custom Layout Editor.'''
	image = "<img src='/context/icons/64x64/layout_64.png'/>"
        behavior = {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.tools.CustomLayoutEditWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
                };
            spt.tab.add_new("custom_layout_editor", "Custom Layout Editor", class_name, kwargs);
            '''
        }
        config_wdg = my.get_main_section_wdg(title, description, image, behavior)
        td.add(config_wdg)




        tr = table.add_row()

        # Plugins
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Manage Plugin"
        image = IconWdg("Manage Plugin", IconWdg.PLUGIN_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Upload, install, remove and create TACTIC plugins.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.app.PluginWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("plugins", "Manage Plugin", class_name, kwargs);
        '''
        }
        plugin_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(plugin_wdg)



        # Examples
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Tools"
        image = IconWdg("Tools", IconWdg.SHARE_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''A collection of example views.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.ToolsWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("tools", "Tools", class_name, kwargs);
        '''
        }
        share_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(share_wdg)





        # Share
        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Shares"
        image = IconWdg("Shares", IconWdg.SHARE_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Share project with other TACTIC installs.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.ShareWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("shares", "Shares", class_name, kwargs);
        '''
        }
        share_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(share_wdg)
        """


        # Advanced
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Advanced Setup"
        image = IconWdg("Advanced", IconWdg.ADVANCED_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''A set of advanced configuration tools.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.app.ProjectStartWdg';
        spt.tab.set_main_body_tab()
        spt.tab.add_new("project_setup", "Project Setup", class_name)
        '''
        }
        share_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(share_wdg)




        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
	title = "Documentation"

        description = '''TACTIC Documentation.
        * Project Setup Documentation<br/>
        <br/>
        * End User Documentation<br/>
        <br/>
        * Developer Documentation<br/>
        <br/>
        * System Administrator Documentation<br/>
        <br/>
        '''
        image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.load_alias("main")
        '''
        }
        doc_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(doc_wdg)
        """





        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>")

        from misc_wdg import QuickLinksWdg
        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)
        
        #td = table.add_cell()
        #totals_wdg = my.get_totals_wdg()
	#td.add(totals_wdg)

        return top
Beispiel #2
0
    def get_display(self):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        top.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
            spt.named_events.fire_event("side_bar|hide_now", {} );
            '''
        })

        project = Project.get()
        title = DivWdg()
        title.add("Project Startup and Configuration")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 10px -10px")

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

        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        button_div = DivWdg()
        shelf.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -3px")

        security = Environment.get_security()
        view_side_bar = security.check_access("builtin",
                                              "view_side_bar",
                                              "allow",
                                              default='allow')
        if view_side_bar:
            button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
            button_div.add(button)
            shelf.add("Toggle Side Bar")
            shelf.add_attr("title", "Toggle Side Bar (or press '1')")
            button.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })
            shelf.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })
            shelf.add_class("hand")
        else:
            shelf.add("&nbsp;")

        search_wdg = Table()
        top.add(search_wdg)
        search_wdg.add_row()

        search_wdg.add_class("spt_main_top")
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 20px auto")
        search_wdg.add_style("width: 430px")

        td = search_wdg.add_cell("Search: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 8px")

        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'result_list',
                    'keywords': keywords,
                    'simple_search_view': 'simple_filter',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''

        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search",
                                     custom_cbk=custom_cbk,
                                     width='280',
                                     height='42px')
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")

        search_wdg.add_cell(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")

        icon_div = DivWdg()
        td = search_wdg.add_cell(icon_div)
        td.add_style("vertical-align: top")
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 7px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior({
            'type':
            'mouseover',
            'color':
            over_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        })
        icon_div.add_behavior({
            'type':
            'mouseout',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click_up',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'result_list',
                'keywords': keywords,
                'simple_search_view': 'simple_filter',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        })

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")

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

        #security = Environment.get_security()
        #if not security.check_access("builtin", "view_site_admin", "allow"):

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Configuration"
        #description = '''All TACTIC projects can be uniquely designed and managed using our configuration tools.'''
        description = '''Configure a Project from start to finish.'''
        image = "<img src='/context/icons/64x64/configuration_64.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.ProjectConfigWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
                };
            spt.tab.add_new("project_configuration", "Configuration", class_name, kwargs);
            '''
        }
        config_wdg = self.get_main_section_wdg(title, description, image,
                                               behavior)
        td.add(config_wdg)

        # Manage Users
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Manage Users and Security"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        image = DivWdg()
        image_link = "<div style='margin-bottom: -64px'><img src='/context/icons/64x64/lock_64.png'/></div>"
        image.add(image_link)

        image1 = IconWdg("Manage Users", IconWdg.USER_32)
        image2 = IconWdg("Manage Users", IconWdg.USER_32)
        image3 = IconWdg("Manage Users", IconWdg.USER_32)
        image4 = IconWdg("Manage Users", IconWdg.USER_32)
        image.add(image1)
        image.add(image2)
        image.add("<br/>")
        image.add(image3)
        image.add(image4)
        description = '''Manage users that can access the system'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.UserConfigWdg';
        var kwargs = {
            help_alias: 'project-startup-manage-users'
            };
        spt.tab.add_new("manage_user", "Manage Users", class_name, kwargs);
        '''
        }
        manage_users_wdg = self.get_main_section_wdg(title, description, image,
                                                     behavior)
        td.add(manage_users_wdg)

        # custom layout editor
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Custom Layouts"
        description = '''Create interfaces using the Custom Layout Editor.'''
        image = "<img src='/context/icons/64x64/layout_64.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.tools.CustomLayoutEditWdg';
            var kwargs = {
                help_alias: 'project-startup-configuration'
                };
            spt.tab.add_new("custom_layout_editor", "Custom Layout Editor", class_name, kwargs);
            '''
        }
        config_wdg = self.get_main_section_wdg(title, description, image,
                                               behavior)
        td.add(config_wdg)

        tr = table.add_row()

        # Plugins
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Manage Plugins"
        image = IconWdg("Manage Plugins", IconWdg.PLUGIN_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Upload, install, remove and create TACTIC plugins.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.app.PluginWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("plugins", "Manage Plugin", class_name, kwargs);
        '''
        }
        plugin_wdg = self.get_small_section_wdg(title, description, image,
                                                behavior)
        td.add(plugin_wdg)

        # Examples
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Tools"
        image = IconWdg("Tools", IconWdg.SHARE_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''A collection of example views.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.ToolsWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("tools", "Tools", class_name, kwargs);
        '''
        }
        share_wdg = self.get_small_section_wdg(title, description, image,
                                               behavior)
        td.add(share_wdg)

        # Share
        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Shares"
        image = IconWdg("Shares", IconWdg.SHARE_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Share project with other TACTIC installs.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.ShareWdg';
        spt.tab.set_main_body_tab();
        spt.tab.add_new("shares", "Shares", class_name, kwargs);
        '''
        }
        share_wdg = self.get_small_section_wdg(title, description, image, behavior)
        td.add(share_wdg)
        """

        # Advanced
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Advanced Setup"
        image = IconWdg("Advanced", IconWdg.ADVANCED_32)
        #image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''A set of advanced configuration tools.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.app.ProjectStartWdg';
        spt.tab.set_main_body_tab()
        spt.tab.add_new("project_setup", "Project Setup", class_name)
        '''
        }
        share_wdg = self.get_small_section_wdg(title, description, image,
                                               behavior)
        td.add(share_wdg)
        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
	title = "Documentation"

        description = '''TACTIC Documentation.
        * Project Setup Documentation<br/>
        <br/>
        * End User Documentation<br/>
        <br/>
        * Developer Documentation<br/>
        <br/>
        * System Administrator Documentation<br/>
        <br/>
        '''
        image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.load_alias("main")
        '''
        }
        doc_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(doc_wdg)
        """

        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>")

        from misc_wdg import QuickLinksWdg
        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)

        #td = table.add_cell()
        #totals_wdg = self.get_totals_wdg()
        #td.add(totals_wdg)

        return top
Beispiel #3
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_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
            spt.named_events.fire_event("side_bar|hide", {} );
            '''
        })

        project = Project.get()

        title = TitleWdg(title='Client Home')
        top.add(title)

        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        security = Environment.get_security()
        view_side_bar = security.check_access("builtin",
                                              "view_side_bar",
                                              "allow",
                                              default='allow')
        if view_side_bar:
            button_div = DivWdg()
            shelf.add(button_div)
            button_div.add_style("float: left")
            button_div.add_style("margin-top: -3px")

            button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
            button_div.add(button)
            shelf.add("Toggle Side Bar")
            button.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })

            shelf.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })
            shelf.add_class("hand")
        else:
            shelf.add("&nbsp;")

        search_wdg = DivWdg()
        search_wdg.add_class("spt_main_top")
        top.add(search_wdg)
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 10px auto")
        search_wdg.add_style("width: 430px")
        search_wdg.add("Search: ")
        search_wdg.add("&nbsp;" * 3)

        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'table',
                    'keywords': keywords,
                    'simple_search_view': 'simple_search',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''

        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk)
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")
        search_wdg.add(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")

        button = ActionButtonWdg(title="Search")
        #search_wdg.add(button)
        button.add_style("float: right")
        #button.add_style("margin-top: -28px")

        icon_div = DivWdg()
        search_wdg.add(icon_div)
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 3px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        icon_div.add_style("float: right")
        icon_div.add_style("margin-top: -5px")
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior({
            'type':
            'mouseover',
            'color':
            over_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        })
        icon_div.add_behavior({
            'type':
            'mouseout',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click_up',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'table',
                'keywords': keywords,
                'simple_search_view': 'simple_search',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        })

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")

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

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "My Approvals"
        description = '''View all pending items for approval<br/><br/>
        '''
        #image = "<img src='/context/images/getting_started_pipeline.png'/>"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
            search_type: 'sthpw/sobject_list',
            view: 'client_approval',
            show_shelf: false,
            show_select: false,
            element_names: ['preview', 'name', 'description', 'task_pipeline_vertical','notes'],
            is_editable: false,
            //expression: "@SOBJECT(sthpw/task['project_code','fickle3'].fickle3/cars.sthpw/sobject_list)"
        };
        spt.tab.add_new("approvals", "Approvals", class_name, kwargs);
        '''
        }
        config_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(config_wdg)

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "My Dashboard"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.'''

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

        #element_name = "my_dashboard"
        element_name = "my_dashboard"
        attrs = config.get_element_attributes(element_name)
        dashboard_data = {}
        kwargs = config.get_display_options(element_name)
        class_name = kwargs.get('class_name')

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

        behavior = {
            'type':
            'click_up',
            'dashboard':
            dashboard_data,
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("my_dashboard", "My Dashboard", bvr.dashboard.class_name, bvr.dashboard.kwargs);
        '''
        }
        pipeline_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(pipeline_wdg)

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "My Reports"
        image = "<img src='/context/icons/64x64/report_64.png'/>"
        description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("reports", "Reports", class_name, kwargs);
        //spt.panel.load_popup("Reports", class_name, kwargs);
        '''
        }

        side_bar_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(side_bar_wdg)
        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
	title = "Documentation"

        description = '''TACTIC Documentation.
        <br/><br/>
        * Project Setup Documentation<br/>
        <br/>
        * End User Documentation<br/>
        <br/>
        * Developer Documentation<br/>
        <br/>
        * System Administrator Documentation<br/>
        <br/>
        '''
        image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.load_alias("main")
        '''
        }
        doc_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(doc_wdg)
        """

        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>" * 2)

        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)

        return top
Beispiel #4
0
    def get_display(self):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        #top.add_behavior( {
        #    'type': 'load',
        #    'cbjs_action': '''
        #    spt.named_events.fire_event("side_bar|hide_now", {} );
        #    '''
        #} )


        project = Project.get()

        title = TitleWdg(title='Tools')
        top.add(title)


        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        button_div = DivWdg()
        shelf.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -3px")



        search_wdg = DivWdg()
        search_wdg.add_class("spt_main_top")
        top.add(search_wdg)
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 10px auto")
        search_wdg.add_style("width: 430px")
        search_wdg.add("<div style='float: left; margin: 8px 10px;'>Search: </div>")

        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'table',
                    'keywords': keywords,
                    'simple_search_view': 'simple_search',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''


        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk, height="42px")
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")
        search_wdg.add(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")
        text.add_style("float: left")


        #search_wdg.add(button)
        #button.add_style("margin-top: -28px")

        icon_div = DivWdg()
        search_wdg.add(icon_div)
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 3px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        icon_div.add_style("float: right")
        icon_div.add_style("margin-top: 4px")
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior( {
            'type': 'mouseover',
            'color': over_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        } )
        icon_div.add_behavior( {
            'type': 'mouseout',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click_up',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )





        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'table',
                'keywords': keywords,
                'simple_search_view': 'simple_search',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        } )

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")


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



        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Themes"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Themes define the look and feel of a project.'''

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.themes_wdg.ThemesWdg';
        var kwargs = {
            help_alias: 'project-startup-dashboards'
            };
        spt.tab.set_main_body_tab();
        spt.tab.add_new("themes", "Themes", class_name, kwargs);
        '''
        }
        dashboard_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(dashboard_wdg)





        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Dashboards"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.'''


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



        # FIXME: this bypasses the link security 
        #element_name = "dashboards"
        #attrs = config.get_element_attributes(element_name)
        #dashboard_data = {}
        #kwargs = config.get_display_options(element_name)
        #class_name = kwargs.get('class_name')

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg';
        var kwargs = {
            help_alias: 'project-startup-dashboards'
            };
        spt.tab.set_main_body_tab();
        spt.tab.add_new("dashboards", "Dashboards", class_name, kwargs);
        '''
        }
        dashboard_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(dashboard_wdg)





        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Reports"
        image = "<img src='/context/icons/64x64/report_64.png'/>"
        description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.'''


        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("reports", "Reports", class_name, kwargs);
        //spt.panel.load_popup("Reports", class_name, kwargs);
        '''
        }

        side_bar_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(side_bar_wdg)








        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Lists of Items"
        description = '''View all of the lists items for this project<br/><br/>
        '''
        image = "<img src='/context/icons/48x48/search_type_48.png'/>"
        #image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.HomeWdg';
        var kwargs = {};
        spt.tab.add_new("lists", "Lists", class_name, kwargs);
        '''
        }
        config_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(config_wdg)




        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>"*2)


        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)


        return top
Beispiel #5
0
    def get_collection_wdg(my):

        div = DivWdg()
        div.add_style("margin: 15px 0px")

        title_div = DivWdg("Collection Manager") 
        div.add(title_div)
        div.add_class("spt_collection_left")
        title_div.add_style("font-size: 1.2em")
        title_div.add_style("font-weight: bold")

        div.add("<hr/>")

        # Shelf
        shelf_div = DivWdg()
        div.add(shelf_div)
        shelf_div.add_style("float: right")
        shelf_div.add_style("margin-bottom: 15px")


        #button = IconButtonWdg(title='Delete Selected Collection', icon="BS_TRASH")
        #shelf_div.add(button)
        #button.add_style("display: inline-block")
        #button.add_style("width: auto")

        button = IconButtonWdg(title='Add New Collection', icon="BS_PLUS")
        shelf_div.add(button)
        button.add_style("display: inline-block")
        button.add_style("vertical-align: top")

        insert_view = "edit_collection"

        button.add_behavior( {
            'type': 'click_up',
            'insert_view': insert_view,
            'search_type': my.search_type,
            'cbjs_action': '''
                kwargs = {
                  search_type: bvr.search_type,
                  mode: 'insert',
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  num_columns: 2,
                  default: {
                    _is_collection: true
                  }
                };
                var popup = spt.panel.load_popup('Add New Collection', 'tactic.ui.panel.EditWdg', kwargs);
            '''
        } )
        text_div = DivWdg()
        shelf_div.add(text_div)

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_collection_left");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");

            var num_result = 0;
            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].attributes[0].value.toLowerCase();

                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, display all
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "block";
                }
            }

        '''

        filters = []
        filters.append(("_is_collection",True))
        filters.append(("status","Verified"))
        text = LookAheadTextInputWdg(
            search_type = "workflow/asset",
            column="name",
            width="100%",
            hint_text="Enter terms to filter collections...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True
        )
        text.add_class("spt_main_search")

        text_div.add(text)
        text_div.add_style("width: 270px")
        text_div.add_style("display: inline-block")

        # Asset Library folder access
        div.add("<br clear='all'/>")
        asset_lib_div = DivWdg()
        div.add(asset_lib_div)
        folder_icon = IconWdg(icon="FOLDER_2", width='30px')

        asset_lib_div.add(folder_icon)
        asset_lib_div.add_style("margin: 5px 0px 5px -5px")
        asset_lib_div.add_style("height: 20px")
        asset_lib_div.add_style("padding-top: 5px")
        asset_lib_div.add_style("padding-bottom: 5px")
        asset_lib_div.add_style("font-weight: bold")

        asset_lib_div.add("Asset Library")
        asset_lib_div.add_class("tactic_hover")
        asset_lib_div.add_class("hand")
        asset_lib_div.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_collection_top");
                var content = top.getElements(".spt_collection_content");

                spt.panel.refresh(top);
                '''
            } )


        # collection
        search = Search(my.search_type)
        search.add_filter("_is_collection", True)
        collections = search.get_sobjects()

        collections_div = DivWdg()
        collections_div.add_class("spt_collection_list")
        div.add(collections_div)
        collections_div.add_style("margin: 5px 0px 5px -5px")

        from tactic.ui.panel import ThumbWdg2


        parts = my.search_type.split("/")
        collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])


        collections_div.add_relay_behavior( {
            'type': 'mouseup',
            'search_type': my.search_type,
            'collection_type': collection_type,
            'bvr_match_class': 'spt_collection_item',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_collection_top");
            var content = top.getElement(".spt_collection_content");

            
            var list = bvr.src_el.getParent(".spt_collection_list");
            var items = list.getElements(".spt_collection_item");
            for (var i = 0; i < items.length; i++) {
                items[i].setStyle("background", "");
                items[i].setStyle("box-shadow", "");
            }
            bvr.src_el.setStyle("background", "#EEE");
            var collection_key = bvr.src_el.getAttribute("spt_collection_key");
            var collection_code = bvr.src_el.getAttribute("spt_collection_code");
            var collection_path = bvr.src_el.getAttribute("spt_collection_path");

            var expr = "@SEARCH("+bvr.collection_type+"['parent_code','"+collection_code+"']."+bvr.search_type+")";

            var parent_dict = {};
            var parent_collection = bvr.src_el.getParent(".spt_subcollection_wdg");
            var path = collection_path.substring(0, collection_path.lastIndexOf("/"));
            if (parent_collection) {
                for (var i = 0; i < collection_path.split("/").length - 1; i++) {
                    var n = path.lastIndexOf("/");
                    var collection_name = path.substring(n+1);                
                    path = path.substring(0, n);

                    var parent_key = parent_collection.getAttribute("spt_parent_key");
                    parent_dict[collection_name] = parent_key;
                    parent_collection = parent_collection.getParent(".spt_subcollection_wdg");
                    
                }
            }            

            var cls = "tactic.ui.panel.CollectionContentWdg";
            var kwargs = {
                collection_key: collection_key,
                path: collection_path,
                search_type: bvr.search_type,
                show_shelf: false,
                show_search_limit: true,
                expression: expr,
                parent_dict: parent_dict
            }
            spt.panel.load(content, cls, kwargs);

            bvr.src_el.setStyle("box-shadow", "0px 0px 3px rgba(0,0,0,0.5)");

            // hide the bottom show_search_limit when clicking into a collection
            var panel = bvr.src_el.getParent(".spt_panel");
            var search_limit_div = panel.getElements(".spt_search_limit_top");
            if (search_limit_div.length == 2){
                search_limit_div[1].setStyle("visibility", "hidden");
            }
            '''
        } )


        collections_div.add_relay_behavior( {
            'type': 'mouseup',
            'search_type': my.search_type,
            'bvr_match_class': 'spt_collection_open',
            'cbjs_action': '''
            var item = bvr.src_el.getParent(".spt_collection_div_top");
            var next = item.getNext();

            if (bvr.src_el.hasClass("spt_open")) {
                next.innerHTML = "";
                bvr.src_el.setStyle("opacity", 1.0);
                bvr.src_el.removeClass("spt_open");
            }
            else {
                var collection_key = bvr.src_el.getAttribute("spt_collection_key");
                var collection_path = bvr.src_el.getAttribute("spt_collection_path");

                var cls = "tactic.ui.panel.CollectionListWdg";
                var kwargs = {
                    parent_key: collection_key,
                    path: collection_path,
                }
                spt.panel.load(next, cls, kwargs, null, {show_loading: false});

                bvr.src_el.setStyle("opacity", 0.3);
                bvr.src_el.addClass("spt_open");

                evt.stopPropagation();
            }



            '''
        } )



        for collection in collections:

            collection_wdg = CollectionItemWdg(collection=collection, path=collection.get_value("name"))
            collections_div.add(collection_wdg)
            collection_wdg.add_class("spt_collection_div")

            subcollection_wdg = DivWdg()
            collections_div.add(subcollection_wdg)
            subcollection_wdg.add_class("spt_subcollection_wdg")
            subcollection_wdg.add_style("padding-left: 15px")


        return div
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        #top.add_behavior( {
        #    'type': 'load',
        #    'cbjs_action': '''
        #    spt.named_events.fire_event("side_bar|hide_now", {} );
        #    '''
        #} )

        project = Project.get()

        title = TitleWdg(title='Tools')
        top.add(title)

        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        button_div = DivWdg()
        shelf.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -3px")

        search_wdg = DivWdg()
        search_wdg.add_class("spt_main_top")
        top.add(search_wdg)
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 10px auto")
        search_wdg.add_style("width: 430px")
        search_wdg.add(
            "<div style='float: left; margin: 8px 10px;'>Search: </div>")

        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'table',
                    'keywords': keywords,
                    'simple_search_view': 'simple_search',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''

        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search",
                                     custom_cbk=custom_cbk,
                                     height="42px")
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")
        search_wdg.add(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")
        text.add_style("float: left")

        #search_wdg.add(button)
        #button.add_style("margin-top: -28px")

        icon_div = DivWdg()
        search_wdg.add(icon_div)
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 3px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        icon_div.add_style("float: right")
        icon_div.add_style("margin-top: 4px")
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior({
            'type':
            'mouseover',
            'color':
            over_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        })
        icon_div.add_behavior({
            'type':
            'mouseout',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click_up',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'table',
                'keywords': keywords,
                'simple_search_view': 'simple_search',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        })

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")

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

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Themes"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Themes define the look and feel of a project.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.themes_wdg.ThemesWdg';
        var kwargs = {
            help_alias: 'project-startup-dashboards'
            };
        spt.tab.set_main_body_tab();
        spt.tab.add_new("themes", "Themes", class_name, kwargs);
        '''
        }
        dashboard_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(dashboard_wdg)

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Dashboards"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.'''

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

        # FIXME: this bypasses the link security
        #element_name = "dashboards"
        #attrs = config.get_element_attributes(element_name)
        #dashboard_data = {}
        #kwargs = config.get_display_options(element_name)
        #class_name = kwargs.get('class_name')

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg';
        var kwargs = {
            help_alias: 'project-startup-dashboards'
            };
        spt.tab.set_main_body_tab();
        spt.tab.add_new("dashboards", "Dashboards", class_name, kwargs);
        '''
        }
        dashboard_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(dashboard_wdg)

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Reports"
        image = "<img src='/context/icons/64x64/report_64.png'/>"
        description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("reports", "Reports", class_name, kwargs);
        //spt.panel.load_popup("Reports", class_name, kwargs);
        '''
        }

        side_bar_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(side_bar_wdg)

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Lists of Items"
        description = '''View all of the lists items for this project<br/><br/>
        '''
        image = "<img src='/context/icons/48x48/search_type_48.png'/>"
        #image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.HomeWdg';
        var kwargs = {};
        spt.tab.add_new("lists", "Lists", class_name, kwargs);
        '''
        }
        config_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(config_wdg)

        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>" * 2)

        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)

        return top
Beispiel #7
0
    def get_collection_wdg(my):

        div = DivWdg()
        div.add_style("margin: 15px 0px")

        title_div = DivWdg("Collection Manager") 
        div.add(title_div)
        div.add_class("spt_collection_left")
        title_div.add_style("font-size: 1.2em")
        title_div.add_style("font-weight: bold")

        div.add("<hr/>")

        # Shelf
        shelf_div = DivWdg()
        div.add(shelf_div)
        shelf_div.add_style("float: right")
        shelf_div.add_style("margin-bottom: 15px")


        #button = IconButtonWdg(title='Delete Selected Collection', icon="BS_TRASH")
        #shelf_div.add(button)
        #button.add_style("display: inline-block")
        #button.add_style("width: auto")

        button = IconButtonWdg(title='Add New Collection', icon="BS_PLUS")
        shelf_div.add(button)
        button.add_style("display: inline-block")
        button.add_style("vertical-align: top")

        insert_view = "edit_collection"

        button.add_behavior( {
            'type': 'click_up',
            'insert_view': insert_view,
            'search_type': my.search_type,
            'cbjs_action': '''
                kwargs = {
                  search_type: bvr.search_type,
                  mode: 'insert',
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  num_columns: 2,
                  default: {
                    _is_collection: true
                  }
                };
                var popup = spt.panel.load_popup('Add New Collection', 'tactic.ui.panel.EditWdg', kwargs);
            '''
        } )
        text_div = DivWdg()
        shelf_div.add(text_div)

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_collection_left");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");

            var num_result = 0;
            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].attributes[0].value.toLowerCase();

                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, display all
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "block";
                }
            }

        '''

        filters = []
        filters.append(("_is_collection",True))
        filters.append(("status","Verified"))
        text = LookAheadTextInputWdg(
            search_type = "workflow/asset",
            column="name",
            width="100%",
            height="30px",
            hint_text="Enter terms to filter collections...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True
        )
        text.add_class("spt_main_search")

        text_div.add(text)
        text_div.add_style("width: 270px")
        text_div.add_style("display: inline-block")

        # Asset Library folder access
        div.add("<br clear='all'/>")
        asset_lib_div = DivWdg()
        div.add(asset_lib_div)
        folder_icon = IconWdg(icon="FOLDER_2", width='30px')

        asset_lib_div.add(folder_icon)
        asset_lib_div.add_style("margin: 5px 0px 5px -5px")
        asset_lib_div.add_style("height: 20px")
        asset_lib_div.add_style("padding-top: 5px")
        asset_lib_div.add_style("padding-bottom: 5px")
        asset_lib_div.add_style("font-weight: bold")

        asset_lib_div.add("Asset Library")
        asset_lib_div.add_class("tactic_hover")
        asset_lib_div.add_class("hand")
        asset_lib_div.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_collection_top");             
                var view_panel = top.getParent('.spt_view_panel');
               
                spt.panel.refresh(view_panel);
                '''
            } )

        # Collections folder structure in the left panel
        search_type = my.kwargs.get('search_type')
        collections_div = CollectionFolderWdg(search_type=search_type)
        div.add(collections_div)

        return div
Beispiel #8
0
    def get_display(my):
        search_type = my.kwargs.get("search_type")

        search = Search(search_type)
        if not search.column_exists("_is_collection"):
            return my.top

        search.add_filter("_is_collection", True)
        collections = search.get_sobjects()

        top = my.top
        top.add_class("spt_dialog")
        button = IconButtonWdg(title='Add to Collection', icon="BS_TH_LARGE", show_arrow=True)
        top.add(button)

        detail_wdg = DivWdg()
        top.add(detail_wdg)

        dialog = DialogWdg()
        top.add(dialog)
        
        dialog.set_as_activator(button, offset={'x':-25,'y': 0})
        dialog.add_title("Collections")

        dialog.add("<div style='margin: 10px'><b>Add selected items to a collection</b></div>")

        add_div = DivWdg()
        dialog.add(add_div)
        icon = IconWdg(name="Add new collection", icon="BS_PLUS")
        icon.add_style("opacity: 0.6")
        icon.add_style("padding-right: 3px")
        add_div.add(icon)
        add_div.add("Create new Collection")
        add_div.add_style("text-align: center")
        add_div.add_style("background-color: #EEEEEE")
        add_div.add_style("padding: 5px")
        add_div.add_style("height: 20px")
        add_div.add_class("hand")


        insert_view = "edit_collection"

        add_div.add_behavior( {
            'type': 'click_up',
            'insert_view': insert_view,
            'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_table_top");
                var table = top.getElement(".spt_table");
                var search_type = top.getAttribute("spt_search_type");
                
                // Hide the dialog when popup loads.
                var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
                dialog_top.style.visibility = "hidden";

                kwargs = {
                  search_type: search_type,
                  mode: "insert",
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  'num_columns': 2,
                  default: {
                    _is_collection: true
                  }
                };
                spt.panel.load_popup("Add New Collection", "tactic.ui.panel.EditWdg", kwargs);
            '''
        } )

        content_div = DivWdg()
        dialog.add(content_div)
        content_div.add_style("width: 270px")
        content_div.add_style("padding: 5px")
        content_div.add_style("padding-bottom: 0px")

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_dialog");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");
            var num_result = 0;
            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].attributes[0].value.toLowerCase();

                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, display all
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "block";
                }
            }

        '''
        filters = []
        filters.append(("_is_collection",True))
        filters.append(("status","Verified"))
        text = LookAheadTextInputWdg(
            search_type = "workflow/asset",
            column="name",
            icon="BS_SEARCH",
            icon_pos="right",
            width="100%",
            hint_text="'Enter' to search for Colllection...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True
        )
        text.add_class("spt_main_search")

        content_div.add(text)
        # set minimum if there is at least one collection
        if len(collections) > 0:
            content_div.add_style("min-height: 300")
        content_div.add_style("max-height: 300")
        content_div.add_style("overflow-y: auto")

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

        for collection in collections:

            search_type = collection.get_base_search_type()
            parts = search_type.split("/")
            collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])
            search = Search(collection_type)
            search.add_filter("parent_code", collection.get_code())
            num_items = search.get_count()


            collection_div = DivWdg()
            collection_div.add_class("spt_collection_div")
            content_div.add(collection_div)
            collection_div.add_style("margin: 3px 5px 0px 5px")

            go_wdg = DivWdg()
            collection_div.add(go_wdg)
            go_wdg.add_style("float: right")

            icon = IconWdg(name="View Collection", icon="BS_CHEVRON_RIGHT")
            go_wdg.add(icon)
            #go_wdg.add_behavior( {
            #    'type': 'click_upX',
            #    'cbjs_action': '''
            #    alert("Not Implemented");
            #    '''
            #} )


            name = collection.get_value("name")
            # Adding Collection title (without the number count) as an attribute
            collection_div.set_attr("collection_name", name)

            if not name:
                name = collection.get_value("code")

            check_div = DivWdg()
            collection_div.add(check_div)

            check = CheckboxWdg("collection_key")
            check.add_class("spt_collection_checkbox")
            check_div.add(check)
            check_div.add_style("float: left")
            check_div.add_style("margin-right: 5px")
            check_div.add_style("margin-top: -3px")

            check.add_attr("collection_key", collection.get_search_key() )

            info_div = DivWdg()
            collection_div.add(info_div)
            info_div.add(name)

            if num_items:
                info_div.add(" (%s)" % num_items)

            collection_div.add("<hr/>")


        add_button = DivWdg()
        add_button.add("Add")
        add_button.add_style("margin: 0px 10px 10px 10px")
        add_button.add_style("width: 50px")
        add_button.add_class("btn btn-primary")
        dialog.add(add_button)

        add_button.add_behavior( {
            'type': 'click',
            'cbjs_action': '''
            var search_keys = spt.table.get_selected_search_keys(false);

            if (search_keys.length == 0) {
                spt.notify.show_message("No assets selected.");
                return;
            }

            var top = bvr.src_el.getParent(".spt_dialog");
            var checkboxes = top.getElements(".spt_collection_checkbox");
            var cmd = "tactic.ui.panel.CollectionAddCmd";
            var server = TacticServerStub.get();
            var is_checked = false;

            var dialog_top = bvr.src_el.getParent(".spt_dialog_top");

            for (i = 0; i < checkboxes.length; i++) {
                var checked_collection_attr = checkboxes[i].attributes;
                var collection_key = checked_collection_attr[3].value;
                // Preventing a collection being added to itself, check if search_keys contain collection_key.
                if (search_keys.indexOf(collection_key) != -1) {
                    spt.notify.show_message("Collection cannot be added to itself.");
                    return;
                }

                if (checkboxes[i].checked == true) {
                    // if there is at least one checkbox selected, set is_checked to 'true'
                    is_checked = true;

                    var search_keys = spt.table.get_selected_search_keys(false);
                    var kwargs = {
                        collection_key: collection_key,
                        search_keys: search_keys
                    }
                    server.execute_cmd(cmd, kwargs);
                }
            }

            if (is_checked == false) {
                spt.notify.show_message("No collection selected.");
                return;
            }
            else {
                spt.notify.show_message("Assets added to Collection.");
                // refresh dialog_top, so users can see the number change in Collections
                spt.panel.refresh(dialog_top);
            }
            
            '''
        } )
        

        return top
Beispiel #9
0
    def get_display(my):

        search_type = my.kwargs.get("search_type")

        search = Search(search_type)
        if not search.column_exists("_is_collection"):
            return my.top

        search.add_filter("_is_collection", True)
        collections = search.get_sobjects()

        dialog = DivWdg()
        my.set_as_panel(dialog)
        dialog.add_class('spt_col_dialog_top')

        title_div = DivWdg()
        title_div.add_style('margin: 10px')
        title_div.add(HtmlElement.b("Add selected items to collection(s)"))
        dialog.add(title_div)

        add_div = DivWdg()
        dialog.add(add_div)
        icon = IconWdg(name="Add new collection", icon="BS_PLUS")
        icon.add_style("opacity: 0.6")
        icon.add_style("padding-right: 3px")
        add_div.add(icon)
        add_div.add("Create new Collection")
        add_div.add_style("text-align: center")
        add_div.add_style("background-color: #EEEEEE")
        add_div.add_style("padding: 5px")
        add_div.add_style("height: 20px")
        add_div.add_class("hand")

        insert_view = "edit_collection"

        add_div.add_behavior({
            'type':
            'listen',
            'event_name':
            'refresh_col_dialog',
            'cbjs_action':
            '''
                var dialog_content = bvr.src_el.getParent('.spt_col_dialog_top');
                spt.panel.refresh(dialog_content);
            '''
        })

        add_div.add_behavior({
            'type':
            'click_up',
            'insert_view':
            insert_view,
            'event_name':
            'refresh_col_dialog',
            'cbjs_action':
            '''
                var top = bvr.src_el.getParent(".spt_table_top");
                var table = top.getElement(".spt_table");
                var search_type = top.getAttribute("spt_search_type");
                
                // Hide the dialog when popup loads.
                var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
                dialog_top.style.visibility = "hidden";

                kwargs = {
                  search_type: search_type,
                  mode: "insert",
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  'num_columns': 2,
                  default: {
                    _is_collection: true
                  }
                };
                spt.panel.load_popup("Create New Collection", "tactic.ui.panel.EditWdg", kwargs);
            '''
        })

        content_div = DivWdg()
        dialog.add(content_div)
        content_div.add_style("width: 270px")
        content_div.add_style("padding: 5px")
        content_div.add_style("padding-bottom: 0px")

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_dialog");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");
            var num_result = 0;
            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].attributes[0].value.toLowerCase();

                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, display all
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "block";
                }
            }

        '''
        filters = []
        filters.append(("_is_collection", True))
        filters.append(("status", "Verified"))
        text = LookAheadTextInputWdg(
            search_type="workflow/asset",
            column="name",
            icon="BS_SEARCH",
            icon_pos="right",
            width="100%",
            height="30px",
            hint_text="'Enter' to search for Colllection...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True)
        text.add_class("spt_main_search")

        content_div.add(text)
        # set minimum if there is at least one collection
        if len(collections) > 0:
            content_div.add_style("min-height: 300")
        content_div.add_style("max-height: 300")
        content_div.add_style("overflow-y: auto")

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

        for collection in collections:

            search_type = collection.get_base_search_type()
            parts = search_type.split("/")
            collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])
            search = Search(collection_type)
            search.add_filter("parent_code", collection.get_code())
            num_items = search.get_count()

            collection_div = DivWdg()
            collection_div.add_class("spt_collection_div")
            content_div.add(collection_div)
            collection_div.add_style("margin: 3px 5px 0px 5px")

            go_wdg = DivWdg()
            collection_div.add(go_wdg)
            go_wdg.add_style("float: right")

            #TODO: add some interaction with this arrow
            # icon = IconWdg(name="View Collection", icon="BS_CHEVRON_RIGHT")
            # go_wdg.add(icon)
            #go_wdg.add_behavior( {
            #    'type': 'click_upX',
            #    'cbjs_action': '''
            #    alert("Not Implemented");
            #    '''
            #} )

            name = collection.get_value("name")
            # Adding Collection title (without the number count) as an attribute
            #collection_div.set_attr("collection_name", name)

            if not name:
                name = collection.get_value("code")

            check_div = DivWdg()
            collection_div.add(check_div)

            check = CheckboxWdg("collection_key")
            check.add_class("spt_collection_checkbox")
            check_div.add(check)
            check_div.add_style("float: left")
            check_div.add_style("margin-right: 5px")
            check_div.add_style("margin-top: -3px")

            check.add_attr("collection_key", collection.get_search_key())

            check.add_attr("collection_name", collection.get_name())

            info_div = DivWdg()
            collection_div.add(info_div)
            info_div.add(name)

            if num_items:
                info_div.add(" (%s)" % num_items)

            collection_div.add("<hr/>")

        add_button = DivWdg()
        add_button.add("Add")
        add_button.add_style("margin: 0px 10px 10px 10px")
        add_button.add_style("width: 50px")
        add_button.add_class("btn btn-primary")
        dialog.add(add_button)

        add_button.add_behavior({
            'type':
            'click',
            'cbjs_action':
            '''
            var search_keys = spt.table.get_selected_search_keys(false);

            if (search_keys.length == 0) {
                spt.notify.show_message("No items selected.");
                return;
            }

            var top = bvr.src_el.getParent(".spt_dialog");
            var checkboxes = top.getElements(".spt_collection_checkbox");
            var cmd = "tactic.ui.panel.CollectionAddCmd";
            var server = TacticServerStub.get();
            var is_checked = false;
            var added = [];
            var collection_keys = [];
            
            var dialog_top = bvr.src_el.getParent(".spt_col_dialog_top");
            
            for (i = 0; i < checkboxes.length; i++) {

                if (checkboxes[i].checked == true) {
                    var collection_key = checkboxes[i].getAttribute('collection_key');
                    var collection_name = checkboxes[i].getAttribute('collection_name');
                    
                    
                    // Preventing a collection being added to itself, check if search_keys contain collection_key.
                    if (search_keys.indexOf(collection_key) != -1) {
                        spt.notify.show_message("Collection [" + collection_name + " ] cannot be added to itself.");
                        return;
                    }
                    // if there is at least one checkbox selected, set is_checked to 'true'
                    is_checked = true;

                    // If the collection is not being added to itself, append to the list of collection keys
                    collection_keys.push(collection_key);
                }
            }

            if (is_checked == false) {
                spt.notify.show_message("No collection selected.");
            }
            else {
                var kwargs = {
                    collection_keys: collection_keys,
                    search_keys: search_keys
                }
                var rtn = server.execute_cmd(cmd, kwargs);
                var rtn_message = rtn.info.message;

                if (rtn_message['circular'] == 'True') {
                    var parent_collection_names = rtn_message['parent_collection_names'].join(", ");
                    spt.notify.show_message("Collection [" + collection_name + " ] is a child of the source [" + parent_collection_names + "]");
                    
                    return;
                }
                for (var collection_name in rtn_message) {
                    if (rtn_message[collection_name] != 'No insert')
                        added.push(collection_name);
                }

                if (added.length == 0)
                    spt.notify.show_message("Items already added to Collection.");
                else 
                    spt.notify.show_message("Items added to Collection [ " + added.join(', ') + " ].");
                // refresh dialog_top, so users can see the number change in Collections
                spt.panel.refresh(dialog_top);
            }
            
            '''
        })

        return dialog
Beispiel #10
0
    def get_collection_wdg(my):

        div = DivWdg()
        div.add_style("margin: 15px 0px")

        title_div = DivWdg("Collection Manager")
        div.add(title_div)
        div.add_class("spt_collection_left")
        title_div.add_style("font-size: 1.2em")
        title_div.add_style("font-weight: bold")

        div.add("<hr/>")

        # Shelf
        shelf_div = DivWdg()
        div.add(shelf_div)
        shelf_div.add_style("float: right")
        shelf_div.add_style("margin-bottom: 15px")

        #button = IconButtonWdg(title='Delete Selected Collection', icon="BS_TRASH")
        #shelf_div.add(button)
        #button.add_style("display: inline-block")
        #button.add_style("width: auto")

        button = IconButtonWdg(title='Add New Collection', icon="BS_PLUS")
        shelf_div.add(button)
        button.add_style("display: inline-block")
        button.add_style("vertical-align: top")

        insert_view = "edit_collection"

        button.add_behavior({
            'type':
            'click_up',
            'insert_view':
            insert_view,
            'search_type':
            my.search_type,
            'cbjs_action':
            '''
                kwargs = {
                  search_type: bvr.search_type,
                  mode: 'insert',
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  num_columns: 2,
                  default: {
                    _is_collection: true
                  }
                };
                var popup = spt.panel.load_popup('Add New Collection', 'tactic.ui.panel.EditWdg', kwargs);
            '''
        })
        text_div = DivWdg()
        shelf_div.add(text_div)

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_collection_left");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");

            var num_result = 0;
            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].attributes[0].value.toLowerCase();

                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, display all
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "block";
                }
            }

        '''

        filters = []
        filters.append(("_is_collection", True))
        filters.append(("status", "Verified"))
        text = LookAheadTextInputWdg(
            search_type="workflow/asset",
            column="name",
            width="100%",
            height="30px",
            hint_text="Enter terms to filter collections...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True)
        text.add_class("spt_main_search")

        text_div.add(text)
        text_div.add_style("width: 270px")
        text_div.add_style("display: inline-block")

        # Asset Library folder access
        div.add("<br clear='all'/>")
        asset_lib_div = DivWdg()
        div.add(asset_lib_div)
        folder_icon = IconWdg(icon="FOLDER_2", width='30px')

        asset_lib_div.add(folder_icon)
        asset_lib_div.add_style("margin: 5px 0px 5px -5px")
        asset_lib_div.add_style("height: 20px")
        asset_lib_div.add_style("padding-top: 5px")
        asset_lib_div.add_style("padding-bottom: 5px")
        asset_lib_div.add_style("font-weight: bold")

        asset_lib_div.add("Asset Library")
        asset_lib_div.add_class("tactic_hover")
        asset_lib_div.add_class("hand")
        asset_lib_div.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
                var top = bvr.src_el.getParent(".spt_collection_top");             
                var view_panel = top.getParent('.spt_view_panel');
               
                spt.panel.refresh(view_panel);
                '''
        })

        # Collections folder structure in the left panel
        search_type = my.kwargs.get('search_type')
        collections_div = CollectionFolderWdg(search_type=search_type)
        div.add(collections_div)

        return div
Beispiel #11
0
    def get_collection_wdg(my):

        div = DivWdg()
        div.add_style("margin: 15px 0px")

        title_div = DivWdg("Collection Manager")
        div.add(title_div)
        div.add_class("spt_collection_left")
        title_div.add_style("font-size: 1.2em")
        title_div.add_style("font-weight: bold")

        div.add("<hr/>")

        # Shelf
        shelf_div = DivWdg()
        div.add(shelf_div)
        shelf_div.add_style("float: right")
        shelf_div.add_style("margin-bottom: 15px")

        #button = IconButtonWdg(title='Delete Selected Collection', icon="BS_TRASH")
        #shelf_div.add(button)
        #button.add_style("display: inline-block")
        #button.add_style("width: auto")

        button = IconButtonWdg(title='Add New Collection', icon="BS_PLUS")
        shelf_div.add(button)
        button.add_style("display: inline-block")
        button.add_style("vertical-align: top")

        insert_view = "edit_collection"

        button.add_behavior({
            'type':
            'click_up',
            'insert_view':
            insert_view,
            'search_type':
            my.search_type,
            'cbjs_action':
            '''
                kwargs = {
                  search_type: bvr.search_type,
                  mode: 'insert',
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  num_columns: 2,
                  default: {
                    _is_collection: true
                  }
                };
                var popup = spt.panel.load_popup('Add New Collection', 'tactic.ui.panel.EditWdg', kwargs);
            '''
        })
        text_div = DivWdg()
        shelf_div.add(text_div)

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_collection_left");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");

            var num_result = 0;
            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].attributes[0].value.toLowerCase();

                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, display all
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "block";
                }
            }

        '''

        filters = []
        filters.append(("_is_collection", True))
        filters.append(("status", "Verified"))
        text = LookAheadTextInputWdg(
            search_type="workflow/asset",
            column="name",
            width="100%",
            hint_text="Enter terms to filter collections...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True)
        text.add_class("spt_main_search")

        text_div.add(text)
        text_div.add_style("width: 270px")
        text_div.add_style("display: inline-block")

        # Asset Library folder access
        div.add("<br clear='all'/>")
        asset_lib_div = DivWdg()
        div.add(asset_lib_div)
        folder_icon = IconWdg(icon="FOLDER_2", width='30px')

        asset_lib_div.add(folder_icon)
        asset_lib_div.add_style("margin: 5px 0px 5px -5px")
        asset_lib_div.add_style("height: 20px")
        asset_lib_div.add_style("padding-top: 5px")
        asset_lib_div.add_style("padding-bottom: 5px")
        asset_lib_div.add_style("font-weight: bold")

        asset_lib_div.add("Asset Library")
        asset_lib_div.add_class("tactic_hover")
        asset_lib_div.add_class("hand")
        asset_lib_div.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
                var top = bvr.src_el.getParent(".spt_collection_top");
                var content = top.getElements(".spt_collection_content");

                spt.panel.refresh(top);
                '''
        })

        # collection
        search = Search(my.search_type)
        search.add_filter("_is_collection", True)
        collections = search.get_sobjects()

        collections_div = DivWdg()
        collections_div.add_class("spt_collection_list")
        div.add(collections_div)
        collections_div.add_style("margin: 5px 0px 5px -5px")

        from tactic.ui.panel import ThumbWdg2

        parts = my.search_type.split("/")
        collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])

        collections_div.add_relay_behavior({
            'type':
            'mouseup',
            'search_type':
            my.search_type,
            'collection_type':
            collection_type,
            'bvr_match_class':
            'spt_collection_item',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_collection_top");
            var content = top.getElement(".spt_collection_content");

            
            var list = bvr.src_el.getParent(".spt_collection_list");
            var items = list.getElements(".spt_collection_item");
            for (var i = 0; i < items.length; i++) {
                items[i].setStyle("background", "");
                items[i].setStyle("box-shadow", "");
            }
            bvr.src_el.setStyle("background", "#EEE");
            var collection_key = bvr.src_el.getAttribute("spt_collection_key");
            var collection_code = bvr.src_el.getAttribute("spt_collection_code");
            var collection_path = bvr.src_el.getAttribute("spt_collection_path");

            var expr = "@SEARCH("+bvr.collection_type+"['parent_code','"+collection_code+"']."+bvr.search_type+")";

            var parent_dict = {};
            var parent_collection = bvr.src_el.getParent(".spt_subcollection_wdg");
            var path = collection_path.substring(0, collection_path.lastIndexOf("/"));
            if (parent_collection) {
                for (var i = 0; i < collection_path.split("/").length - 1; i++) {
                    var n = path.lastIndexOf("/");
                    var collection_name = path.substring(n+1);                
                    path = path.substring(0, n);

                    var parent_key = parent_collection.getAttribute("spt_parent_key");
                    parent_dict[collection_name] = parent_key;
                    parent_collection = parent_collection.getParent(".spt_subcollection_wdg");
                    
                }
            }            

            var cls = "tactic.ui.panel.CollectionContentWdg";
            var kwargs = {
                collection_key: collection_key,
                path: collection_path,
                search_type: bvr.search_type,
                show_shelf: false,
                show_search_limit: true,
                expression: expr,
                parent_dict: parent_dict
            }
            spt.panel.load(content, cls, kwargs);

            bvr.src_el.setStyle("box-shadow", "0px 0px 3px rgba(0,0,0,0.5)");

            // hide the bottom show_search_limit when clicking into a collection
            var panel = bvr.src_el.getParent(".spt_panel");
            var search_limit_div = panel.getElements(".spt_search_limit_top");
            if (search_limit_div.length == 2){
                search_limit_div[1].setStyle("visibility", "hidden");
            }
            '''
        })

        collections_div.add_relay_behavior({
            'type':
            'mouseup',
            'search_type':
            my.search_type,
            'bvr_match_class':
            'spt_collection_open',
            'cbjs_action':
            '''
            var item = bvr.src_el.getParent(".spt_collection_div_top");
            var next = item.getNext();

            if (bvr.src_el.hasClass("spt_open")) {
                next.innerHTML = "";
                bvr.src_el.setStyle("opacity", 1.0);
                bvr.src_el.removeClass("spt_open");
            }
            else {
                var collection_key = bvr.src_el.getAttribute("spt_collection_key");
                var collection_path = bvr.src_el.getAttribute("spt_collection_path");

                var cls = "tactic.ui.panel.CollectionListWdg";
                var kwargs = {
                    parent_key: collection_key,
                    path: collection_path,
                }
                spt.panel.load(next, cls, kwargs, null, {show_loading: false});

                bvr.src_el.setStyle("opacity", 0.3);
                bvr.src_el.addClass("spt_open");

                evt.stopPropagation();
            }



            '''
        })

        for collection in collections:

            collection_wdg = CollectionItemWdg(
                collection=collection, path=collection.get_value("name"))
            collections_div.add(collection_wdg)
            collection_wdg.add_class("spt_collection_div")

            subcollection_wdg = DivWdg()
            collections_div.add(subcollection_wdg)
            subcollection_wdg.add_class("spt_subcollection_wdg")
            subcollection_wdg.add_style("padding-left: 15px")

        return div
Beispiel #12
0
    def get_display(self):
       
        search_type = self.kwargs.get("search_type")

        search = Search(search_type)
        if not search.column_exists("_is_collection"):
            return self.top

        search.add_filter("_is_collection", True)
        collections = search.get_sobjects()

        
        dialog = DivWdg()
        self.set_as_panel(dialog)
        dialog.add_class('spt_col_dialog_top')

        title_div = DivWdg()
        title_div.add_style('margin: 10px')
        title_div.add(HtmlElement.b("Add selected items to collection(s)"))
        dialog.add(title_div)

        add_div = DivWdg()
        dialog.add(add_div)
        icon = IconWdg(name="Add new collection", icon="BS_PLUS")
        icon.add_style("opacity: 0.6")
        icon.add_style("padding-right: 3px")
        add_div.add(icon)
        add_div.add("Create new Collection")
        add_div.add_style("text-align: center")
        add_div.add_style("background-color: #EEEEEE")
        add_div.add_style("padding: 5px")
        add_div.add_style("height: 20px")
        add_div.add_class("hand")


        insert_view = "edit_collection"

        add_div.add_behavior( {
            'type': 'listen',
            'event_name': 'refresh_col_dialog',
            'cbjs_action': '''
                var dialog_content = bvr.src_el.getParent('.spt_col_dialog_top');
                spt.panel.refresh(dialog_content);
            '''})

        add_div.add_behavior( {
            'type': 'click_up',
            'insert_view': insert_view,
            'event_name': 'refresh_col_dialog',
            'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_table_top");
                var table = top.getElement(".spt_table");
                var search_type = top.getAttribute("spt_search_type");
                
                // Hide the dialog when popup loads.
                var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
                dialog_top.style.visibility = "hidden";

                kwargs = {
                  search_type: search_type,
                  mode: "insert",
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  'num_columns': 2,
                  default: {
                    _is_collection: true
                  }
                };
                spt.panel.load_popup("Create New Collection", "tactic.ui.panel.EditWdg", kwargs);
            '''
        } )

        content_div = DivWdg()
        dialog.add(content_div)
        content_div.add_style("width: 270px")
        content_div.add_style("padding: 5px")
        content_div.add_style("padding-bottom: 0px")

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_dialog");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");

            var num_result = 0;
            var no_results_el = top.getElement(".spt_no_results");

            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].getElement(".spt_collection_checkbox").getAttribute("collection_name").toLowerCase();
                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, show "no_results_el"
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "none";
                }
                no_results_el.style.display = "block";
            }
            else {
                no_results_el.style.display = "none";
            }

        '''
        filters = []
        filters.append(("_is_collection",True))
        filters.append(("status","Verified"))
        text = LookAheadTextInputWdg(
            search_type = "workflow/asset",
            column="name",
            icon_pos="right",
            width="100%",
            height="30px",
            hint_text="Filter collections...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True,
            validate='false'
        )
        text.add_class("spt_main_search")

        content_div.add(text)
        # set minimum if there is at least one collection
        if len(collections) > 0:
            content_div.add_style("min-height: 300")
        content_div.add_style("max-height: 300")
        content_div.add_style("overflow-y: auto")

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

        no_results_div = DivWdg()
        content_div.add(no_results_div)

        no_results_div.add_color("color", "color", 50)
        no_results_div.add_style("font: normal bold 1.1em arial,serif")
        no_results_div.add("No collections found.")
        no_results_div.add_style("display: none")
        no_results_div.add_style("margin: 10px 0px 0px 10px")
        no_results_div.add_class("spt_no_results")

        for collection in collections:

            search_type = collection.get_base_search_type()
            parts = search_type.split("/")
            collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])
            search = Search(collection_type)
            search.add_filter("parent_code", collection.get_code())
            num_items = search.get_count()


            collection_div = DivWdg()
            collection_div.add_class("spt_collection_div")
            content_div.add(collection_div)
            collection_div.add_style("margin: 3px 5px 0px 5px")

            go_wdg = DivWdg()
            collection_div.add(go_wdg)
            go_wdg.add_style("float: right")
        
            #TODO: add some interaction with this arrow
            # icon = IconWdg(name="View Collection", icon="BS_CHEVRON_RIGHT")
            # go_wdg.add(icon)
            #go_wdg.add_behavior( {
            #    'type': 'click_upX',
            #    'cbjs_action': '''
            #    alert("Not Implemented");
            #    '''
            #} )


            name = collection.get_value("name")
            # Adding Collection title (without the number count) as an attribute
            #collection_div.set_attr("collection_name", name)

            if not name:
                name = collection.get_value("code")

            check_div = DivWdg()
            collection_div.add(check_div)

            check = CheckboxWdg("collection_key")
            check.add_class("spt_collection_checkbox")
            check_div.add(check)
            check_div.add_style("float: left")
            check_div.add_style("margin-right: 5px")
            check_div.add_style("margin-top: -3px")

            check.add_attr("collection_key", collection.get_search_key() )
            
            check.add_attr("collection_name", collection.get_name() )

            info_div = DivWdg()
            collection_div.add(info_div)
            info_div.add(name)

            if num_items:
                info_div.add(" (%s)" % num_items)

            collection_div.add("<hr/>")


        add_button = DivWdg()
        add_button.add("Add")
        add_button.add_style("margin: 0px 10px 10px 10px")
        add_button.add_style("width: 50px")
        add_button.add_class("btn btn-primary")
        dialog.add(add_button)

        add_button.add_behavior( {
            'type': 'click',
            'cbjs_action': '''
            var search_keys = spt.table.get_selected_search_keys(false);

            if (search_keys.length == 0) {
                spt.notify.show_message("No items selected.");
                return;
            }

            var top = bvr.src_el.getParent(".spt_dialog");
            var checkboxes = top.getElements(".spt_collection_checkbox");
            var cmd = "tactic.ui.panel.CollectionAddCmd";
            var server = TacticServerStub.get();
            var is_checked = false;
            var added = [];
            var collection_keys = [];
            
            var dialog_top = bvr.src_el.getParent(".spt_col_dialog_top");
            
            for (i = 0; i < checkboxes.length; i++) {

                if (checkboxes[i].checked == true) {
                    var collection_key = checkboxes[i].getAttribute('collection_key');
                    var collection_name = checkboxes[i].getAttribute('collection_name');
                    
                    
                    // Preventing a collection being added to itself, check if search_keys contain collection_key.
                    if (search_keys.indexOf(collection_key) != -1) {
                        spt.notify.show_message("Collection [" + collection_name + " ] cannot be added to itself.");
                        return;
                    }
                    // if there is at least one checkbox selected, set is_checked to 'true'
                    is_checked = true;

                    // If the collection is not being added to itself, append to the list of collection keys
                    collection_keys.push(collection_key);
                }
            }

            if (is_checked == false) {
                spt.notify.show_message("No collection selected.");
            }
            else {
                var kwargs = {
                    collection_keys: collection_keys,
                    search_keys: search_keys
                }
                var rtn = server.execute_cmd(cmd, kwargs);
                var rtn_message = rtn.info.message;

                if (rtn_message['circular'] == 'True') {
                    var parent_collection_names = rtn_message['parent_collection_names'].join(", ");
                    spt.notify.show_message("Collection [" + collection_name + " ] is a child of the source [" + parent_collection_names + "]");
                    
                    return;
                }
                for (var collection_name in rtn_message) {
                    if (rtn_message[collection_name] != 'No insert')
                        added.push(collection_name);
                }

                if (added.length == 0)
                    spt.notify.show_message("Items already added to Collection.");
                else 
                    spt.notify.show_message("Items added to Collection [ " + added.join(', ') + " ].");
                // refresh dialog_top, so users can see the number change in Collections
                spt.panel.refresh(dialog_top);
            }
            
            '''
        } )
        

        return dialog
Beispiel #13
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_behavior( {
            'type': 'load',
            'cbjs_action': '''
            spt.named_events.fire_event("side_bar|hide", {} );
            '''
        } )


        project = Project.get()

        title = TitleWdg(title='Client Home')
        top.add(title)


        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        security = Environment.get_security()
        view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow')
        if view_side_bar:
            button_div = DivWdg()
            shelf.add(button_div)
            button_div.add_style("float: left")
            button_div.add_style("margin-top: -3px")

            button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
            button_div.add(button)
            shelf.add("Toggle Side Bar")
            button.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            } )

            shelf.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            } )
            shelf.add_class("hand")
        else:
            shelf.add("&nbsp;")


        search_wdg = DivWdg()
        search_wdg.add_class("spt_main_top")
        top.add(search_wdg)
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 10px auto")
        search_wdg.add_style("width: 430px")
        search_wdg.add("Search: ")
        search_wdg.add("&nbsp;"*3)





        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'table',
                    'keywords': keywords,
                    'simple_search_view': 'simple_search',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''


        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk)
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")
        search_wdg.add(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")


        button = ActionButtonWdg(title="Search")
        #search_wdg.add(button)
        button.add_style("float: right")
        #button.add_style("margin-top: -28px")

        icon_div = DivWdg()
        search_wdg.add(icon_div)
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 3px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        icon_div.add_style("float: right")
        icon_div.add_style("margin-top: -5px")
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior( {
            'type': 'mouseover',
            'color': over_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        } )
        icon_div.add_behavior( {
            'type': 'mouseout',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        } )
        icon_div.add_behavior( {
            'type': 'click_up',
            'color': out_color,
            'cbjs_action': '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        } )





        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'table',
                'keywords': keywords,
                'simple_search_view': 'simple_search',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        } )

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")


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


        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "My Approvals"
        description = '''View all pending items for approval<br/><br/>
        '''
        #image = "<img src='/context/images/getting_started_pipeline.png'/>"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
            search_type: 'sthpw/sobject_list',
            view: 'client_approval',
            show_shelf: false,
            show_select: false,
            element_names: ['preview', 'name', 'description', 'task_pipeline_vertical','notes'],
            is_editable: false,
            //expression: "@SOBJECT(sthpw/task['project_code','fickle3'].fickle3/cars.sthpw/sobject_list)"
        };
        spt.tab.add_new("approvals", "Approvals", class_name, kwargs);
        '''
        }
        config_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(config_wdg)



        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "My Dashboard"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.'''




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

        #element_name = "my_dashboard"
        element_name = "my_dashboard"
        attrs = config.get_element_attributes(element_name)
        dashboard_data = {}
        kwargs = config.get_display_options(element_name)
        class_name = kwargs.get('class_name')

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

        behavior = {
        'type': 'click_up',
        'dashboard': dashboard_data,
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("my_dashboard", "My Dashboard", bvr.dashboard.class_name, bvr.dashboard.kwargs);
        '''
        }
        pipeline_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(pipeline_wdg)




        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "My Reports"
        image = "<img src='/context/icons/64x64/report_64.png'/>"
        description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.'''


        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("reports", "Reports", class_name, kwargs);
        //spt.panel.load_popup("Reports", class_name, kwargs);
        '''
        }

        side_bar_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(side_bar_wdg)


        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
	title = "Documentation"

        description = '''TACTIC Documentation.
        <br/><br/>
        * Project Setup Documentation<br/>
        <br/>
        * End User Documentation<br/>
        <br/>
        * Developer Documentation<br/>
        <br/>
        * System Administrator Documentation<br/>
        <br/>
        '''
        image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.load_alias("main")
        '''
        }
        doc_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(doc_wdg)
        """





        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>"*2)


        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)


        return top