Exemple #1
0
    def get_display(my):

        web = WebContainer.get_web()

        
        tactic_header = Table()
        tactic_header.add_row()
        tactic_header.add_color("color", "color2")


        # tactic logo and release info
        skin = web.get_skin()
        src = '/context/skins/' + skin + '/images/tactic_logo.png'
        img = HtmlElement.img(src)
        img.add_class('hand')
        img.add_attr('title', 'Go to home page')
        img.add_behavior({'type': 'click_up', 'cbjs_action': "window.location='/tactic/'"})

        rel_div = DivWdg()
        rel_div.add(" "*3)
        rel_div.add("Release: %s" %Environment.get_release_version() )
        rel_div.add_style("font-size: 9px")
        # Need this to override the above color in add_looks
        rel_div.add_color("color", "color2")

        tactic_wdg = Table()

        tactic_wdg.add_style("width: 180px")
        tactic_wdg.add_row()
        td = tactic_wdg.add_cell( img )
        td.set_style("width:100px")
        tactic_wdg.add_row()
        td = tactic_wdg.add_cell( rel_div )
        td.set_style("text-align: left") 

        td = tactic_header.add_cell( tactic_wdg )
       
        # add the project thumb and title
        project = Project.get()

        if my.show_project:
            thumb_div = DivWdg()
            td = tactic_header.add_cell( thumb_div )
            thumb_div.add_style("height: 28px")
            thumb_div.add_style("overflow: hidden")
            thumb_div.add_border(modifier=-10)
            thumb_div.add_style("-moz-border-radius: 3px")

            thumb = ThumbWdg()
            thumb_div.add(thumb)
            thumb.set_sobject(project)
            thumb.set_icon_size("45")
            td.set_style("vertical-align: top; padding-right:14px;padding-left: 3px")

            td = tactic_header.add_cell( project.get_value("title") )
            #td.add_looks( "fnt_title_1" )
            td.add_style("font-size: 20px")
            td.add_style("white-space: nowrap")
            td.add_style("padding-left: 14px")

            # project selection 
            td = tactic_header.add_cell()
            project_div = DivWdg()
            project_div.add_style("margin-top: -5px")
            project_div.add(ProjectSelectWdg() )
            td.add( project_div )
            td.set_style("padding-left: 14px")
             

            # Global Actions Gear Menu (contains links to Documentation) ...
            action_bar_btn_dd = PageHeaderGearMenuWdg()
            action_div = DivWdg(action_bar_btn_dd)
            action_div.add_style("margin-top: -5px")
            td = tactic_header.add_cell( action_div )

            if PrefSetting.get_value_by_key('subscription_bar') == 'true':
                from message_wdg import SubscriptionBarWdg
                sub = SubscriptionBarWdg(mode='popup')
                tactic_header.add_cell(sub)

        # user login

        # user
        user = Environment.get_login()
        full_name = user.get_full_name()
        user_div = SpanWdg( HtmlElement.b( "%s  " % full_name) , css='hand')       
        user_div.set_style("padding-right:10px")

        # signout
        login = Environment.get_security().get_login()
        search_key = SearchKey.get_by_sobject(login)
        span = SpanWdg()
        span.add( user_div )
        user_div.add_attr('spt_nudge_menu_vert', '20')
       
        td = tactic_header.add_cell(span)       
        td.set_style("width:100%; text-align:right; white-space: nowrap")



        from tactic.ui.widget import SingleButtonWdg
        button = SingleButtonWdg(title='My Account', icon=IconWdg.USER, show_arrow=True)
        button_div = DivWdg(button)
        button_div.add_style("margin-top: -5px")
        button.add_attr('spt_nudge_menu_horiz', '-80')
        button.add_attr('spt_nudge_menu_vert', '10')

        td = tactic_header.add_cell(button_div)
    

        menus = my.get_smart_menu()
        # TODO: this part seems redundant to attach to both
        SmartMenu.add_smart_menu_set(user_div, [menus])
        SmartMenu.assign_as_local_activator(user_div, None, True)

        SmartMenu.add_smart_menu_set(button, [menus])
        SmartMenu.assign_as_local_activator(button, None, True)

   


        td.set_style("width:100%;")
        button = SingleButtonWdg(title='Help', icon=IconWdg.HELP_BUTTON, show_arrow=False)
        #button.add_behavior( {
        #'type': 'click_up',
        #'cbjs_action': '''
        #window.open("/doc/")
        #'''
        #} )

        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.named_events.fire_event("show_help")
        '''
        } )


        from tactic.ui.container import DialogWdg
        help_dialog = DialogWdg(z_index=900, show_pointer=False)
        td.add(help_dialog)
        help_dialog.add_title("Help")
        help_dialog.add_class("spt_help")


        # container for help
        help_div = DivWdg()
        help_dialog.add(help_div)

        from help_wdg import HelpWdg
        help_wdg = HelpWdg()
        help_div.add(help_wdg)


        button_div = DivWdg(button)
        button_div.add_style("margin-top: -5px")
        td = tactic_header.add_cell(button_div)
        td.set_style("width:100%; text-align:right; white-space: nowrap")


        # Layout the Main Header Table
        main_div = DivWdg()

        # TEST: NEW LAYOUT
        if Config.get_value("install", "layout") == "fixed":
            main_div.add_style("position: fixed")
            main_div.add_style("z-index: 100")
            main_div.add_style("width: 100%")

        license = Environment.get_security().get_license()

        if not license.is_licensed():
            from tactic.ui.app import LicenseManagerWdg
            license_manager = LicenseManagerWdg(use_popup=True)
            main_div.add(license_manager)

        

        # create the header table
        tactic_header_div = DivWdg()
        tactic_header_div.add(tactic_header)
        tactic_header_div.add_gradient("background", "background2", 10, -10)

        main_div.add(tactic_header_div)

        main_div.add( my.get_js_popup() )


        """
        main_div.add( HelpPopupWdg() )

        # FIXME: is this even used at all?
        action_bar_popup = PopupWdg( id="ActionBarWdg_popup", allow_page_activity=True, width="636px" )
        action_bar_popup.add_title( "TACTIC™ Action Bar" )
        action_bar_popup.add( ActionBarWdg() )
        main_div.add( action_bar_popup )
        """

        # FIXME(?): does this CommonPopup need to be at z_start=300? By default popups will be at z_start=200
        popup = PopupWdg( id="CommonPopup", allow_page_activity=True, width="600px", z_start=300 )
        popup.add('Tools', 'title')

        main_div.add( popup )

        
        return main_div