Example #1
0
    def get_display(self):

        top = self.top
        login = self.kwargs.get("login")
        if not login or login == "$LOGIN":
            login = Environment.get_user_name()

        login_sobj = Login.get_by_code(login)

        #top.add_style("margin-top: -2px")
        #top.add_style("margin-left: -2px")

        thumb_div = DivWdg()
        thumb_div.add_style("float: left")
        thumb_div.add_style("margin-right: 5px")
        thumb_div.add_style("margin-bottom: 5px")
        thumb_div.add_style("padding-top: 1px")
        thumb = ThumbWdg()
        thumb.set_sobject(login_sobj)
        thumb_div.add(thumb)
        thumb.set_icon_size(90)
        thumb.set_aspect("height")

        full_name = login_sobj.get_full_name()

        info_wdg = DivWdg()
        top.add(info_wdg)

        name_wdg = DivWdg()
        info_wdg.add(thumb_div)
        info_wdg.add(name_wdg)
        name_wdg.add(" " * 3)
        name_wdg.add(full_name)
        name_wdg.add_style("font-size: 1.5em")
        name_wdg.add_style("font-weight: bold")
        name_wdg.add_style("padding: 5px")
        #name_wdg.add_style("margin-left: -10px")
        name_wdg.add_color("background", "background3")
        name_wdg.add_style("height: 20px")
        name_wdg.add_style("margin-bottom: 0px")
        name_wdg.add_border()

        info_wdg.add("<br/>")

        from tactic.ui.container import TabWdg

        # return if the supplied tab view has a config xml
        if self.tab_view:
            search = Search("config/widget_config")
            search.add_filter("category", "TabWdg")
            search.add_filter("view", self.tab_view)
            config_sobj = search.get_sobject()
            if config_sobj:

                config_xml = config_sobj.get_value('config')
                # replace the variable $login with the login clicked
                if login:
                    config_xml = config_xml.replace('$login', login)

                tab = TabWdg(config_xml=config_xml,
                             view=self.tab_view,
                             show_add=False,
                             show_remove=False)
                top.add(tab)
                return top

        config_xml = []
        config_xml.append('<config>')
        config_xml.append('<tab>')

        config_xml.append('''
        <element name='schedule'>
          <display class='tactic.ui.widget.TaskCalendarWdg'>
            <assigned>%s</assigned>
            <sobject_display_expr>%s</sobject_display_expr>
            <show_header>true</show_header>
            <show_border>false</show_border>
          </display>
        </element> 
        ''' % (login, self.sobject_display_expr))

        config_xml.append('''
        <element name='activity'>
          <display class='tactic.ui.widget.ActivityCalendarWdg'>
            <login>%s</login>
            <cell_width>100px</cell_width>
            <cell_height>50px</cell_height>
            <show_header>true</show_header>
            <show_border>false</show_border>
          </display>
        </element> 
        ''' % login)

        config_xml.append('''
        <element name='tasks'>
          <display class='tactic.ui.panel.FastTableLayoutWdg'>
            <search_type>sthpw/task</search_type>
            <view>table</view>
            <expression>@SOBJECT(sthpw/task['assigned','%s']['@ORDER_BY', 'bid_start_date desc'])</expression>
            <mode>simple</mode>
          </display>
        </element> 
        ''' % login)

        config_xml.append('''
        <element name='work_hours'>
          <display class='tactic.ui.widget.SObjectCalendarWdg'>
            <login>%s</login>
            <!--
            <cell_width>100px</cell_width>
            -->
            <cell_height>50px</cell_height>
            <show_header>true</show_header>
            <show_border>false</show_border>
            <search_type>sthpw/work_hour</search_type>
            <handler>tactic.ui.widget.WorkHourCalendarDayWdg</handler>
            <start_date_col>day</start_date_col>
            <end_date_col>day</end_date_col>
          </display>
        </element> 
        ''' % login)

        config_xml.append('''
         <element name='recent transactions'>
          <display class='tactic.ui.panel.FastTableLayoutWdg'>
            <search_type>sthpw/transaction_log</search_type>
            <view>table</view>
            <expression>@SOBJECT(sthpw/transaction_log['login','%s']['@ORDER_BY','timestamp desc']['@LIMIT','30'])</expression>
            <element_names>code,timestamp,namespace,description,transaction_log_hidden</element_names>
            <show_shelf>false</show_shelf>
            <show_select>false</show_select>
          </display>
        </element> 
        ''' % login)

        config_xml.append('</tab>')
        config_xml.append('</config>')
        config_xml = "".join(config_xml)

        tab = TabWdg(config_xml=config_xml,
                     view='tab',
                     show_add=False,
                     show_remove=False)
        top.add(tab)
        tab.add_style("margin-left: -2px")
        tab.add_style("margin-right: -2px")

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

        top = my.top
        login = my.kwargs.get("login")
        if not login or login == "$LOGIN":
            login = Environment.get_user_name()

        login_sobj = Login.get_by_code(login)

        # top.add_style("margin-top: -2px")
        # top.add_style("margin-left: -2px")

        thumb_div = DivWdg()
        thumb_div.add_style("float: left")
        thumb_div.add_style("margin-right: 5px")
        thumb_div.add_style("margin-bottom: 5px")
        thumb_div.add_style("padding-top: 1px")
        thumb = ThumbWdg()
        thumb.set_sobject(login_sobj)
        thumb_div.add(thumb)
        thumb.set_icon_size(90)
        thumb.set_aspect("height")

        full_name = login_sobj.get_full_name()

        info_wdg = DivWdg()
        top.add(info_wdg)

        name_wdg = DivWdg()
        info_wdg.add(thumb_div)
        info_wdg.add(name_wdg)
        name_wdg.add("&nbsp;" * 3)
        name_wdg.add(full_name)
        name_wdg.add_style("font-size: 1.5em")
        name_wdg.add_style("font-weight: bold")
        name_wdg.add_style("padding: 5px")
        # name_wdg.add_style("margin-left: -10px")
        name_wdg.add_color("background", "background3")
        name_wdg.add_style("height: 20px")
        name_wdg.add_style("margin-bottom: 0px")
        name_wdg.add_border()

        info_wdg.add("<br/>")

        from tactic.ui.container import TabWdg

        # return if the supplied tab view has a config xml
        if my.tab_view:
            search = Search("config/widget_config")
            search.add_filter("category", "TabWdg")
            search.add_filter("view", my.tab_view)
            config_sobj = search.get_sobject()
            if config_sobj:

                config_xml = config_sobj.get_value("config")
                # replace the variable $login with the login clicked
                if login:
                    config_xml = config_xml.replace("$login", login)

                tab = TabWdg(config_xml=config_xml, view=my.tab_view, show_add=False, show_remove=False)
                top.add(tab)
                return top

        config_xml = []
        config_xml.append("<config>")
        config_xml.append("<tab>")

        config_xml.append(
            """
        <element name='activity'>
          <display class='tactic.ui.widget.ActivityCalendarWdg'>
            <login>%s</login>
            <cell_width>100px</cell_width>
            <cell_height>50px</cell_height>
            <show_header>true</show_header>
            <show_border>false</show_border>
          </display>
        </element> 
        """
            % login
        )

        config_xml.append(
            """
        <element name='schedule'>
          <display class='tactic.ui.widget.TaskCalendarWdg'>
            <assigned>%s</assigned>
            <sobject_display_expr>%s</sobject_display_expr>
            <show_header>true</show_header>
            <show_border>false</show_border>
          </display>
        </element> 
        """
            % (login, my.sobject_display_expr)
        )
        config_xml.append(
            """
        <element name='tasks'>
          <display class='tactic.ui.panel.FastTableLayoutWdg'>
            <search_type>sthpw/task</search_type>
            <view>table</view>
            <expression>@SOBJECT(sthpw/task['assigned','%s']['@ORDER_BY', 'bid_start_date desc'])</expression>
            <mode>simple</mode>
          </display>
        </element> 
        """
            % login
        )

        config_xml.append(
            """
        <element name='work_hours'>
          <display class='tactic.ui.widget.SObjectCalendarWdg'>
            <login>%s</login>
            <!--
            <cell_width>100px</cell_width>
            -->
            <cell_height>50px</cell_height>
            <show_header>true</show_header>
            <show_border>false</show_border>
            <search_type>sthpw/work_hour</search_type>
            <handler>tactic.ui.widget.WorkHourCalendarDayWdg</handler>
            <start_date_col>day</start_date_col>
            <end_date_col>day</end_date_col>
          </display>
        </element> 
        """
            % login
        )

        config_xml.append(
            """
         <element name='recent transactions'>
          <display class='tactic.ui.panel.FastTableLayoutWdg'>
            <search_type>sthpw/transaction_log</search_type>
            <view>table</view>
            <expression>@SOBJECT(sthpw/transaction_log['login','%s']['@ORDER_BY','timestamp desc']['@LIMIT','30'])</expression>
            <element_names>code,timestamp,namespace,description,transaction_log_hidden</element_names>
            <show_shelf>false</show_shelf>
            <show_select>false</show_select>
          </display>
        </element> 
        """
            % login
        )

        config_xml.append("</tab>")
        config_xml.append("</config>")
        config_xml = "".join(config_xml)

        tab = TabWdg(config_xml=config_xml, view="tab", show_add=False, show_remove=False)
        top.add(tab)
        tab.add_style("margin-left: -2px")
        tab.add_style("margin-right: -2px")

        return top