Ejemplo n.º 1
0
    def get_link_wdg(self, element_name, config, options):
        attributes = config.get_element_attributes(element_name)
        title = self._get_title(config, element_name)

        default_access = "view"
        path = options.get('path')
        security = Environment.get_security()
        if not security.check_access(
                "side_bar", element_name, "view", default=default_access):
            return

        # backwards compatibility??
        #if not security.check_access("url", path, "view"):
        #    return

        link_wdg = DivWdg(css="hand")
        link_wdg.add_style("padding-top: 4px")

        link_wdg.add_attr("spt_title", title)
        link_wdg.add_attr("spt_icon", attributes.get("icon"))
        link_wdg.add_class("spt_side_bar_link")
        link_wdg.add_attr("spt_view", config.get_view())
        link_wdg.add_attr("spt_element_name", element_name)
        link_wdg.add_attr("spt_path", options['path'])

        # add the mouseover color change
        link_wdg.add_style("color: #292929")
        link_wdg.add_class("SPT_DTS")
        hover = link_wdg.get_color("background3", -10)
        link_wdg.add_event("onmouseover", "this.style.background='%s'" % hover)
        link_wdg.add_event("onmouseout", "this.style.background=''")
        link_wdg.add_class("spt_side_bar_element")

        link_wdg.add_looks("fnt_text")

        link_wdg.add_attr("spt_view", config.get_view())

        # add an invisible drop widget
        drop_wdg = self.get_drop_wdg()
        drop_wdg.add_style("margin-top: -3px")
        link_wdg.add(drop_wdg)

        span = SpanWdg()
        span.add_class("spt_side_bar_title")

        # add an icon
        icon = attributes.get("icon")
        if icon:
            icon = icon.upper()
            from pyasm.widget import IconWdg
            try:
                span.add(IconWdg(title, eval("IconWdg.%s" % icon)))
            except:
                pass

        span.add(title)
        link_wdg.add(span)

        return link_wdg
Ejemplo n.º 2
0
 def get_drop_wdg(my):
     if my.mode == 'view':
         return SpanWdg()
     hr = DivWdg()
     hr.set_attr("SPT_ACCEPT_DROP", "manageSideBar")
     hr.add_style("height: 5px")
     hr.add_style("width: 150px")
     #hr.add_style("border: solid 1px black")
     hr.add_style("position: absolute")
     hr.add_event("onmouseover", "this.getChildren()[0].style.display=''")
     hr.add_event("onmouseout", "this.getChildren()[0].style.display='none'")
     hr.add("<hr style='margin-top: 2px; size: 1px; color: #222; display: none'/>")
     return hr
Ejemplo n.º 3
0
 def get_drop_wdg(self):
     if self.mode == 'view':
         return SpanWdg()
     hr = DivWdg()
     hr.set_attr("SPT_ACCEPT_DROP", "manageSideBar")
     hr.add_style("height: 5px")
     hr.add_style("width: 150px")
     #hr.add_style("border: solid 1px black")
     hr.add_style("position: absolute")
     hr.add_event("onmouseover", "this.getChildren()[0].style.display=''")
     hr.add_event("onmouseout",
                  "this.getChildren()[0].style.display='none'")
     hr.add(
         "<hr style='margin-top: 2px; size: 1px; color: #222; display: none'/>"
     )
     return hr
Ejemplo n.º 4
0
    def get_script_wdg(my):

        search = Search("config/custom_script")
        #search.add_user_filter()
        search.add_order_by("folder")
        search.add_order_by("title")
        scripts = search.get_sobjects()

        widget = DivWdg()
        widget.add_style("width: 100%")

        from pyasm.web.palette import Palette
        palette = Palette.get()
        bg_color = palette.color("background3")
        hover_color = palette.color("background3", 20)
        widget.add_color("background", bg_color)

        '''
        # Try the table layout widget
        from tactic.ui.panel import TableLayoutWdg
        table = TableLayoutWdg(id='js_edit_list',search_type="config/custom_script", view='simple')
        table.set_sobjects(scripts)
        widget.add(table)
        '''

        title = DivWdg()
        title.add("Saved Scripts")
        title.add_style("font-size: 14px")
        title.add_color("color", "color")
        title.add_style("padding: 8px 3px")
        title.add_style("margin: 0 0 0 -1")
        title.add_color("background", "background", -5)
        title.add_border()
        widget.add(title)


        script_div = DivWdg()
        script_div.add_border()
        script_div.add_color("background", "background3")
        script_div.add_color("color", "color3")
        script_div.add_style("padding: 8px")
        script_div.add_style("overflow-x: hidden")
        script_div.add_style("overflow-y: auto")
        script_div.add_style("height: 100%")
        script_div.add_style("min-width: 100px")
        script_div.add_style("width: 220px")
        script_div.add_style("margin: -1px 0px 0px -1px")
        script_div.add_class("spt_resizable")

        inner = DivWdg()
        script_div.add(inner)
        inner.add_style("height: 100%")
        inner.add_style("width: 800px")

        last_folder = ''
        for script in scripts:
            title = script.get_value("title")
            folder = script.get_value("folder")
            language = script.get_value("language", no_exception=True)
            if not language:
                language = 'javascript'

            if folder != last_folder:
                div = DivWdg()
                icon = IconWdg("Script", IconWdg.FOLDER)
                div.add(icon)
                div.add(" %s" % folder)
                inner.add(div)


            last_folder = folder

            div = DivWdg()
            inner.add(div)
            div.add_class('hand')
            icon = IconWdg("Script", IconWdg.TOGGLE_ON)
            icon.add_style("margin-left: 10px")
            div.add(icon)
            div.add("%s" %title)

            span = SpanWdg()
            span.add_style("font-size: 9px")
            span.add_style("opacity: 0.2")
            span.add(" <i>(%s)</i>" % language)
            div.add(span)

            div.add_event("onmou8eover", "this.style.background='%s'" % hover_color)
            div.add_event("onmouseout", "this.style.background='%s'" % bg_color)


            behavior = {
                'type': 'click_up',
                'editor_id': my.editor_id, 
                'cbjs_action': 'spt.script_editor.display_script_cbk(evt, bvr)',
                'code': script.get_code()
            }
            div.add_behavior(behavior)



        widget.add(script_div)

        return widget
Ejemplo n.º 5
0
    def get_display(self):
        web = WebContainer.get_web()
        key = web.get_form_value('name')

        top = DivWdg()
        top.add_class('ad_search_wdg_top')
        self.set_as_panel(top)

        text = TextWdg("name")
        text.set_value(key)

        close_wdg = SpanWdg()
        close_wdg.add( IconWdg("Close", IconWdg.POPUP_WIN_CLOSE) )
        close_wdg.add_style("float: right")
        close_wdg.add_class("hand")

        # NOTE: the div we are looking for to hide on 'close' is outside of the this widget and
        #       is part of the parent widget
        close_wdg.add_behavior({
            'type': 'click_up',
            'cbjs_action': '''
                var ad_input_content = bvr.src_el.getParent(".ad_input_content");
                spt.toggle_show_hide(ad_input_content);
            '''
        })

        top.add( close_wdg )
        top.add("Active Directory Search:<br clear='all'/> ")

        table = Table()
        table.add_row()
        table.add_cell(text)
        td = table.add_cell(self.get_search_wdg())
        td.add_style("display", "")
        top.add(table)



        results_div = DivWdg()
        top.add(results_div)
        results_div.add_style("border: solid 1px #444")
        results_div.add_style("margin: 10px")
        results_div.add_style("padding: 5px")
        #results_div.add_style("max-height: 400px")
        results_div.add_style("overflow: auto")

        if not key:
            results_div.add("Please enter search criteria")
            return top


        results_div.add("Results Found ...")
        users = self.find_users(key)

        max_num_users = 20
        if len(users) > max_num_users:
            display_users = users[:max_num_users]
        else:
            display_users = users

        for user in display_users:
            user_div = DivWdg()
            user_div.add_style("margin: 5px")
            user_div.add_class("hand")
            user_div.add_event("onmouseover", "$(this).setStyle('background','#444')")
            user_div.add_event("onmouseout", "$(this).setStyle('background','#222')")

            checkbox = CheckboxWdg()
            user_div.add(checkbox)

            display_name = user.get('display_name')
            if not display_name:
                display_name = "%s %s" % (user.get('first_name'), user.get('last_name'))
            email = user.get('email')
            login = user.get('login')
            phone_number = user.get('phone_number')

            user_div.add(display_name)
            if email:
                user_div.add(" (%s) " % email)


            self.cbjs_action = self.kwargs.get('cbjs_action')
            if self.cbjs_action:
                user_behavior = {
                    'type': 'click_up',
                    'cbjs_action': self.cbjs_action
                }
                user_div.add_behavior( user_behavior )
            else:
                user_behavior = {
                    'type': 'click_up',
                    'cbjs_action': 'alert("Not implemented")'
                }
                user_div.add_behavior( user_behavior )

            user_div.add_attr("spt_input_value", login)
            user_div.add_attr("spt_display_value", display_name)
            user_div.add_attr("spt_phone_number", phone_number)
            user_div.add_attr("spt_email", email)

            results_div.add(user_div)


        num_users = len(users)
        if num_users > max_num_users:

            results_div.add("... and %s more results matched" % (num_users-max_num_users))

            results_div.add("<br/>Please narrow your search")
            #nav_div = DivWdg()
            #num_categories = num_users / max_num_users + 1
            #if num_categories > 10:
            #    nav_div.add("<br/>Please narrow your search")
            #else:
            #    for i in range(0, num_categories):
            #        span = SpanWdg()
            #        span.add(i)
            #        span.add("&nbsp;&nbsp;")
            #        nav_div.add(span)
            #results_div.add(nav_div)


        if not users:
            user_div = DivWdg()
            user_div.add_style("margin: 5px")
            user_div.add("No Results")
            results_div.add(user_div)
        return top
Ejemplo n.º 6
0
    def get_display(self):

        top = DivWdg()
        top.add_class("spt_sample_chart_top")

        table = Table()
        table.add_row()
        left = table.add_cell()

        # add the chart
        chart_div = DivWdg()
        chart_div.add_class("spt_sample_chart")
        left.add(chart_div)
        chart_div.add_style("width: 600")
        chart_div.add_style("height: 400")
        chart_div.add_style("padding: 10px")

        data_file = 'bar-2.txt'
        chart = ChartWdg(data_file=data_file)
        chart_div.add(chart)

        # add navigator
        right = table.add_cell()
        right.add_style("text-align: top")

        top.add(table)

        base_dir = "%s/src" % Environment.get_install_dir()
        rel_dir = 'context/spt_js/ofc/data-files'

        files_div = DivWdg()
        files_div.add_style("height: 400")
        files_div.add_style("overflow: auto")
        files_div.add_style("padding: 3px")
        right.add(files_div)

        files = os.listdir("%s/%s" % (base_dir, rel_dir))
        for file in files:
            if not file.endswith(".txt"):
                continue

            explore_div = DivWdg()
            link = "/%s/%s" % (rel_dir, file)
            explore_div.add(
                "<a target='_blank' href='%s'>(+)</a>&nbsp;&nbsp;" % link)
            explore_div.add_style("float: left")
            files_div.add(explore_div)

            file_div = DivWdg()
            file_div.add_style("padding: 2px")
            file_div.add_class("hand")
            file_div.add_event("onmouseover",
                               "this.style.background='#696969'")
            file_div.add_event("onmouseout", "this.style.background='#444'")
            file_div.add(file)
            files_div.add(file_div)

            file_div.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                var value = bvr.src_el.innerHTML;
                var top = bvr.src_el.getParent(".spt_sample_chart_top");
                var chart = top.getElement(".spt_sample_chart");
                spt.panel.load(chart, 'tactic.ui.chart.ChartWdg', {data_file:value});
                '''
            })

        return top
Ejemplo n.º 7
0
    def get_display(self):
        web = WebContainer.get_web()
        key = web.get_form_value('name')

        top = DivWdg()
        top.add_class('ad_search_wdg_top')
        self.set_as_panel(top)

        text = TextWdg("name")
        text.set_value(key)

        close_wdg = SpanWdg()
        close_wdg.add(IconWdg("Close", IconWdg.POPUP_WIN_CLOSE))
        close_wdg.add_style("float: right")
        close_wdg.add_class("hand")

        # NOTE: the div we are looking for to hide on 'close' is outside of the this widget and
        #       is part of the parent widget
        close_wdg.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
                var ad_input_content = bvr.src_el.getParent(".ad_input_content");
                spt.toggle_show_hide(ad_input_content);
            '''
        })

        top.add(close_wdg)
        top.add("Active Directory Search:<br clear='all'/> ")

        table = Table()
        table.add_row()
        table.add_cell(text)
        td = table.add_cell(self.get_search_wdg())
        td.add_style("display", "")
        top.add(table)

        results_div = DivWdg()
        top.add(results_div)
        results_div.add_style("border: solid 1px #444")
        results_div.add_style("margin: 10px")
        results_div.add_style("padding: 5px")
        #results_div.add_style("max-height: 400px")
        results_div.add_style("overflow: auto")

        if not key:
            results_div.add("Please enter search criteria")
            return top

        results_div.add("Results Found ...")
        users = self.find_users(key)

        max_num_users = 20
        if len(users) > max_num_users:
            display_users = users[:max_num_users]
        else:
            display_users = users

        for user in display_users:
            user_div = DivWdg()
            user_div.add_style("margin: 5px")
            user_div.add_class("hand")
            user_div.add_event("onmouseover",
                               "$(this).setStyle('background','#444')")
            user_div.add_event("onmouseout",
                               "$(this).setStyle('background','#222')")

            checkbox = CheckboxWdg()
            user_div.add(checkbox)

            display_name = user.get('display_name')
            if not display_name:
                display_name = "%s %s" % (user.get('first_name'),
                                          user.get('last_name'))
            email = user.get('email')
            login = user.get('login')
            phone_number = user.get('phone_number')

            user_div.add(display_name)
            if email:
                user_div.add(" (%s) " % email)

            self.cbjs_action = self.kwargs.get('cbjs_action')
            if self.cbjs_action:
                user_behavior = {
                    'type': 'click_up',
                    'cbjs_action': self.cbjs_action
                }
                user_div.add_behavior(user_behavior)
            else:
                user_behavior = {
                    'type': 'click_up',
                    'cbjs_action': 'alert("Not implemented")'
                }
                user_div.add_behavior(user_behavior)

            user_div.add_attr("spt_input_value", login)
            user_div.add_attr("spt_display_value", display_name)
            user_div.add_attr("spt_phone_number", phone_number)
            user_div.add_attr("spt_email", email)

            results_div.add(user_div)

        num_users = len(users)
        if num_users > max_num_users:

            results_div.add("... and %s more results matched" %
                            (num_users - max_num_users))

            results_div.add("<br/>Please narrow your search")
            #nav_div = DivWdg()
            #num_categories = num_users / max_num_users + 1
            #if num_categories > 10:
            #    nav_div.add("<br/>Please narrow your search")
            #else:
            #    for i in range(0, num_categories):
            #        span = SpanWdg()
            #        span.add(i)
            #        span.add("&nbsp;&nbsp;")
            #        nav_div.add(span)
            #results_div.add(nav_div)

        if not users:
            user_div = DivWdg()
            user_div.add_style("margin: 5px")
            user_div.add("No Results")
            results_div.add(user_div)
        return top
Ejemplo n.º 8
0
    def get_display(my):
        # if no filters are defined, then display nothing
        if not my.filters:
            return Widget()

        #filter_top = DivWdg(css="maq_search_bar")
        filter_top = DivWdg()
        filter_top.add_color("color", "color")
        filter_top.add_color("background", "background", -5)
        filter_top.add_style("padding: 5px")
        filter_top.add_style("min-width: 700px")
        filter_top.add_border()
        my.set_as_panel(filter_top)


        # TEST link to help for search widget
        help_button = ActionButtonWdg(title="?", tip="Search Documentation", size='small')
        filter_top.add(help_button)
        help_button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.help.set_top();
            spt.help.load_alias("search-quickstart|what-is-searching|search-interface|search-compound|search-expressions");
            '''
        } )
        help_button.add_style("float: right")


        # this id should be removed
        filter_top.set_id("%s_search" % my.prefix)
        filter_top.add_class("spt_search")


        for name, value in my.kwargs.items():
            filter_top.set_attr("spt_%s" % name, value)

        #filter_top.add(my.statement)
        popup = my.get_retrieve_wdg()
        filter_top.add(popup)
        popup = my.get_save_wdg()
        filter_top.add(popup)

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

        # Add a number of filters indicator
        div = DivWdg()
        div.add_class("spt_search_num_filters")
        div.add_style("float: right")
        div.add_style("font-size: 0.9em")
        div.add_style("margin: 0 10 0 10")
        #search_summary.add(div)
        filter_top.add(div)

        if my.num_filters_enabled:
            msg = "[%s] filter/s" % my.num_filters_enabled
            icon = IconWdg(msg, IconWdg.DOT_GREEN)
            div.add(icon)
            div.add("%s" % msg)


        filter_div = DivWdg()
        filter_div.set_id("search_filters")
        filter_div.add_class("spt_search_filters")


        # TODO: disabling for now
        # add the action buttons
        #action_wdg =  my.get_action_wdg()
        #action_wdg.add_style("text-align: right")
        #filter_div.add( action_wdg )
        # add the top
        display_str = 'block'
        if not display:
            display_str = 'none'
        filter_div.add_style("display: %s" % display_str)

        search_wdg = my.get_search_wdg()

        prefix = "filter_mode"
        if my.prefix_namespace:
            prefix = '%s_%s' %(my.prefix_namespace, prefix)
        hidden = HiddenWdg("prefix", prefix)

        match_div = DivWdg()
        match_div.add(hidden)
        match_div.add_class('spt_search_filter') 

        palette =  match_div.get_palette()
        bg_color = palette.color('background')
        light_bg_color =  palette.color('background', modifier=+10)
        

        select = SelectWdg("filter_mode")
        select.add_class("spt_search_filter_mode")
        select.set_persist_on_submit(prefix)
        select.remove_empty_option() 
        # for Local search, leave out compound search for now
        if my.kwargs.get('prefix_namespace'):
            select.set_option("labels", "Match all|Match any")
            select.set_option("values", "and|or")
        else:
            select.set_option("labels", "Match all|Match any|Compound search")
            select.set_option("values", "and|or|custom")
        #select.set_option("labels", "all|any")
        #select.set_option("values", "and|or")

        select.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var display = bvr.src_el.value == 'custom';;

        var top = bvr.src_el.getParent(".spt_search");
        var ops = top.getElements(".spt_op");
        for (var i = 0; i < ops.length; i++) {
            var op = ops[i];
            var element = op.getElement(".spt_op_display");
            var value = op.getAttribute("spt_op");
            if (display) {
                element.innerHTML = value;
                var level = op.getAttribute("spt_level");
                if (level == 1) {
                    element.setStyle("background", "%s")
                    element.setStyle("padding", "4px")
                }
            } else {
                element.innerHTML = '&nbsp;';
                element.setStyle("background", "%s")
                element.setStyle("padding", "1px")
            }
        }
        ''' %(light_bg_color, bg_color)
        } )

        match_div.add(select)
        match_div.add_color("color", "color2")
        match_div.add(" on the following")
        hint = HintWdg( "An 'AND' operation is always applied to each category below. " \
                        "This controls only the filters within each category." )
        match_div.add(hint)
        match_div.add('<br/>')

        match_div.add_style("padding-top: 5px")

        filter_div.add( search_wdg)
        search_wdg.add_style("float: left")
        filter_div.add( match_div)


        filter_div.add(HtmlElement.br())

        filters_div = DivWdg()
        filters_div.add_style("margin: 0 -6 0 -6")

        security = Environment.get_security()

        # add all the filters
        for filter in my.filters:
            element_name = filter.get_name()

            if not security.check_access("search", element_name, "view"):
                continue

            # no need to create it again    
            #filter = my.config.get_display_widget(element_name)
            div = DivWdg()
            filters_div.add(div)

            div.add_class("hand")
            class_suffix = element_name.replace(' ', '_')
            cbjs_action = 'var el=spt.get_cousin(bvr.src_el,".spt_search",".spt_filter_%s");spt.simple_display_toggle(el);' % class_suffix
            div.add_behavior( {
                'type': 'click_up',
                'cbjs_action': cbjs_action
            } )
            div.add_color("color", "color", +5)
            div.add_gradient("background", "background", -5, -5)
            div.add_style("margin-top: -1px")

            div.add_border()
            div.add_style("padding: 3px")
            div.add_style("whitespace: nowrap")

            
            if element_name in ["Parent", 'Children']:
                swap = SwapDisplayWdg.get_triangle_wdg()
            else:
                swap = SwapDisplayWdg.get_triangle_wdg()
                swap.set_off()
            swap.add_action_script(cbjs_action)


            div.add_event("onclick", swap.get_swap_script() )
            div.add(swap)
            div.add_class("SPT_DTS")
            div.add(element_name)

            div = DivWdg()
            div.add_class("spt_filter_%s" % class_suffix)

            if element_name in ["Parent", 'Children']:
                div.add_style("display: none")
            else:
                div.add_style("display: block")

            #div.add_style("background-color: #333")
            div.add_color("background", "background")
            div.add_border()
            div.add_style("padding: 5px 3px 5px 3px")
            div.add_style("margin-top: -1px")
            #div.add_style("margin-left: 20px")
            #div.add_style("width: 660")
            div.add(filter)
            filters_div.add(div)

        filter_div.add(filters_div)

        buttons_div = DivWdg()
        buttons_div.add_style("margin-top: 7px")
        buttons_div.add_style("margin-bottom: 7px")
        buttons_div.add(my.get_search_wdg() )
        filter_div.add(buttons_div)


        filter_top.add(filter_div)

        return filter_top
Ejemplo n.º 9
0
    def get_link_wdg(my, element_name, config, options):
        attributes = config.get_element_attributes(element_name)
        title = my._get_title(config, element_name)

        default_access = "view"
        path = options.get('path')
        security = Environment.get_security()
        if not security.check_access("side_bar", element_name, "view", default=default_access):
            return

        # backwards compatibility??
        #if not security.check_access("url", path, "view"):
        #    return


        link_wdg = DivWdg(css="hand")
        link_wdg.add_style( "padding-top: 4px" )

        link_wdg.add_attr("spt_title", title)
        link_wdg.add_attr("spt_icon", attributes.get("icon"))
        link_wdg.add_class("spt_side_bar_link")
        link_wdg.add_attr("spt_view", config.get_view() )
        link_wdg.add_attr("spt_element_name", element_name)
        link_wdg.add_attr("spt_path", options['path'])
       

        # add the mouseover color change
        link_wdg.add_style("color: #292929")
        link_wdg.add_class("SPT_DTS")
        hover = link_wdg.get_color("background3", -10)
        link_wdg.add_event("onmouseover", "this.style.background='%s'" % hover)
        link_wdg.add_event("onmouseout", "this.style.background=''")
        link_wdg.add_class("spt_side_bar_element")

        link_wdg.add_looks("fnt_text")

        link_wdg.add_attr("spt_view", config.get_view() )



        # add an invisible drop widget
        drop_wdg = my.get_drop_wdg()
        drop_wdg.add_style("margin-top: -3px")
        link_wdg.add(drop_wdg)

        span = SpanWdg()
        span.add_class("spt_side_bar_title")

        # add an icon
        icon = attributes.get("icon")
        if icon:
            icon = icon.upper()
            from pyasm.widget import IconWdg
            try:
                span.add( IconWdg(title, eval("IconWdg.%s" % icon) ) )
            except:
                pass


        span.add(title)
        link_wdg.add(span)


        return link_wdg
Ejemplo n.º 10
0
    def _get_bar(my, percent, proc_count, task):
        '''get a vertical bar indicating the progress of a task '''
        sobject = my.get_current_sobject()
        bar = DivWdg()
        if my.desc_checkbox_value == "on":
            bar.add_style('margin-right: 20px')
        else:
            bar.add_style('width: 10px')
        bar.add_style('float: left')
        cur_percent = 100.0
        increment = 100.0 / proc_count
        
        # get some task info
        assigned = 'unassigned'
        process = task.get_value('process')
        if task.get_value('assigned').strip():
            assigned = task.get_value('assigned')
            
        task_desc = task.get_value('description')
        if not task_desc:
            task_desc = 'n/a'

        start_date = task.get_value("bid_start_date")
        end_date = task.get_value("bid_end_date")
        if start_date:
            start_date = Date(db_date=start_date, show_warning=False).get_display_date()
        else:
            start_date = "?"
        if end_date:
            end_date = Date(db_date=end_date, show_warning=False).get_display_date()
        else:
            end_date = "?"

        # remove some spacing characters
        task_desc = re.sub('(\n|\r|\t)', ' ', task_desc)
        task_desc = re.sub('"', "'", task_desc)
        task_status = task.get_value('status')

        display_percent = percent
        if percent < 0:
            task_status = "%s <font color=red>(obsolete)</font>" % task_status
            display_percent = 0
      
        msg =  '<b>%s</b><br/><hr>%s<br/><span style=padding-left:1em>desc: %s</span><br/>' \
            '<span style=padding-left:1em>status:%s (%s%%)</span><br/>'\
            '<span style=padding-left:1em>%s - %s</span>'\
            % (process, assigned, task_desc, task_status, display_percent, start_date, end_date)
       
        if WebContainer.get_web().get_browser() == "IE":
            bar.add_event('onmouseover', "hint_bubble.show(event, '%s')" %msg)
        else:
            bar.add_tip(msg)



        from pyasm.widget import IconWdg
        end_date = task.get_value("bid_end_date")
        end_date = Date(db_date=end_date, show_warning=False)
        now_date = Date(show_warning=False)
        if now_date.get_utc() > end_date.get_utc() and percent != 100:
            alert_color = "#f00"
        else:
            alert_color = None


        for x in xrange(proc_count):
            cur_percent -= increment
            div = DivWdg()
            content = '&nbsp;'
            # unidentified status probably
            if percent < 0:
                content = '&mdash;'
                div.add_style('text-decoration: blink')
        
            div.add(content)
            div.add_style('width: 10px')
            if cur_percent < percent or cur_percent == 0:
                if alert_color:
                    div.add_style("background-color: %s" % alert_color)
                else:
                    div.add_style("background-color: %s" % my._get_color_code(percent))


            bar_height = my.get_option("bar_height")
            if not bar_height:
                bar_height = my.bar_select_value
            if not bar_height:
                bar_height = '3'
            div.add_style("height: %spx" % bar_height)
            # IE needs to set the font size to reduce the overall size
            div.add_style("font-size: %spx" % bar_height )
            if sobject.is_retired():
                div.add_class('task_status_bar_retired')
            else:
                if my.label_select_value == "abbr":
                    div.add_style("margin: -1px")

                #div.add_class("task_status_bar")
                #div.add_style("margin-top: 2px")
                div.add_border()
           
            
            bar.add(div)

        if my.desc_checkbox_value == "on":
            span = SpanWdg(task_desc)
            span.add_style('font-size: 0.8em')
            bar.add( span )
       
        return bar
Ejemplo n.º 11
0
    def get_content_wdg(my):
        div = DivWdg()
        div.add_class("spt_tile_layout_top")
        if my.top_styles:
            div.add_styles(my.top_styles)
        inner = DivWdg()
        div.add(inner)


        
        menus_in = {}
        # set up the context menus
        if my.show_context_menu == True:
            menus_in['DG_HEADER_CTX'] = [ my.get_smart_header_context_menu_data() ]
            menus_in['DG_DROW_SMENU_CTX'] = [ my.get_data_row_smart_context_menu_details() ]
        elif my.show_context_menu == 'none':
            div.add_event('oncontextmenu', 'return false;')
        if menus_in:
            SmartMenu.attach_smart_context_menu( inner, menus_in, False )
 




        

        temp = my.kwargs.get("temp")
        has_loading = False

        
        inner.add_style("margin-left: 20px")
       

        inner.add_attr("ondragenter", "spt.thumb.background_enter(event, this) ")
        inner.add_attr("ondragleave", "spt.thumb.background_leave(event, this) ")
        inner.add_attr("ondragover", "return false")
        inner.add_attr("ondrop", "spt.thumb.background_drop(event, this)")

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

        if my.sobjects:
            inner.add( my.get_scale_wdg() )

            for row, sobject in enumerate(my.sobjects):

                if False and not temp and row > 4: 
                    tile_wdg = DivWdg()
                    inner.add(tile_wdg)
                    tile_wdg.add_style("width: 120px")
                    tile_wdg.add_style("height: 120px")
                    tile_wdg.add_style("float: left")
                    tile_wdg.add_style("padding: 20px")
                    tile_wdg.add_style("text-align: center")
                    tile_wdg.add('<img src="/context/icons/common/indicator_snake.gif" border="0"/>')
                    tile_wdg.add(" Loading ...")
                    tile_wdg.add_attr("spt_search_key", sobject.get_search_key())
                    tile_wdg.add_class("spt_loading")
                    has_loading = True
                    continue


                kwargs = my.kwargs.copy()
                tile = my.get_tile_wdg(sobject)
                inner.add(tile)
        else:
            table = Table()
            inner.add(table)
            my.handle_no_results(table)


        chunk_size = 5
        if has_loading:
            inner.add_behavior( {
            'type': 'load',
            'chunk': chunk_size,
            'cbjs_action': '''
            var layout = bvr.src_el.getParent(".spt_layout");
            spt.table.set_layout(layout);
            var rows = layout.getElements(".spt_loading");

            var jobs = [];
            var count = 0;
            var chunk = bvr.chunk;
            while (true) {
                var job_item = rows.slice(count, count+chunk);
                if (job_item.length == 0) {
                    break;
                }
                jobs.push(job_item);
                count += chunk;
            }

            var count = -1;
            var func = function() {
                count += 1;
                var rows = jobs[count];
                if (! rows || rows.length == 0) {
                    return;
                }
                for (var i = 0; i < rows.length; i++) {
                    rows[i].removeClass("spt_loading");
                }
                spt.table.refresh_rows(rows, null, null, {on_complete: func});
            }
            func();

            '''
            } )





        inner.add("<br clear='all'/>")
        return div
Ejemplo n.º 12
0
    def get_display(my):
        # if no filters are defined, then display nothing
        if not my.filters:
            return Widget()

        #filter_top = DivWdg(css="maq_search_bar")
        filter_top = DivWdg()
        filter_top.add_color("color", "color")
        filter_top.add_color("background", "background", -5)
        filter_top.add_style("padding: 5px")
        filter_top.add_style("min-width: 800px")
        filter_top.add_border()
        my.set_as_panel(filter_top)

        # TEST link to help for search widget
        help_button = ActionButtonWdg(title="?",
                                      tip="Search Documentation",
                                      size='small')
        filter_top.add(help_button)
        help_button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.help.set_top();
            spt.help.load_alias("search-quickstart|what-is-searching|search-interface|search-compound|search-expressions");
            '''
        })
        help_button.add_style("float: right")

        # this id should be removed
        filter_top.set_id("%s_search" % my.prefix)
        filter_top.add_class("spt_search")

        for name, value in my.kwargs.items():
            filter_top.set_attr("spt_%s" % name, value)

        #filter_top.add(my.statement)
        popup = my.get_retrieve_wdg()
        filter_top.add(popup)
        popup = my.get_save_wdg()
        filter_top.add(popup)

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

        # Add a number of filters indicator
        div = DivWdg()
        div.add_class("spt_search_num_filters")
        div.add_style("float: right")
        div.add_style("font-size: 0.9em")
        div.add_style("margin: 0 10 0 10")
        #search_summary.add(div)
        filter_top.add(div)

        if my.num_filters_enabled:
            msg = "[%s] filter/s" % my.num_filters_enabled
            icon = IconWdg(msg, IconWdg.DOT_GREEN)
            div.add(icon)
            div.add("%s" % msg)

        filter_div = DivWdg()
        filter_div.set_id("search_filters")
        filter_div.add_class("spt_search_filters")

        # TODO: disabling for now
        # add the action buttons
        #action_wdg =  my.get_action_wdg()
        #action_wdg.add_style("text-align: right")
        #filter_div.add( action_wdg )
        # add the top
        display_str = 'block'
        if not display:
            display_str = 'none'
        filter_div.add_style("display: %s" % display_str)

        search_wdg = my.get_search_wdg()

        prefix = "filter_mode"
        if my.prefix_namespace:
            prefix = '%s_%s' % (my.prefix_namespace, prefix)
        hidden = HiddenWdg("prefix", prefix)

        match_div = DivWdg()
        match_div.add(hidden)
        match_div.add_class('spt_search_filter')

        palette = match_div.get_palette()
        bg_color = palette.color('background')
        light_bg_color = palette.color('background', modifier=+10)

        select = SelectWdg("filter_mode")
        select.add_style("width: 110px")

        select.add_class("spt_search_filter_mode")
        select.set_persist_on_submit(prefix)
        select.remove_empty_option()
        # for Local search, leave out compound search for now
        if my.kwargs.get('prefix_namespace'):
            select.set_option("labels", "Match all|Match any")
            select.set_option("values", "and|or")
        else:
            select.set_option("labels", "Match all|Match any|Compound")
            select.set_option("values", "and|or|custom")
        #select.set_option("labels", "all|any")
        #select.set_option("values", "and|or")

        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
        var display = bvr.src_el.value == 'custom';;

        var top = bvr.src_el.getParent(".spt_search");
        var ops = top.getElements(".spt_op");
        for (var i = 0; i < ops.length; i++) {
            var op = ops[i];
            var element = op.getElement(".spt_op_display");
            var value = op.getAttribute("spt_op");
            if (display) {
                element.innerHTML = value;
                var level = op.getAttribute("spt_level");
                if (level == 1) {
                    element.setStyle("background", "%s")
                    element.setStyle("padding", "4px")
                }
            } else {
                element.innerHTML = '&nbsp;';
                element.setStyle("background", "%s")
                element.setStyle("padding", "1px")
            }
        }
        ''' % (light_bg_color, bg_color)
        })

        match_div.add(select)
        match_div.add_color("color", "color2")
        #match_div.add(" on the following")
        #hint = HintWdg( "An 'AND' operation is always applied to each category below. " \
        #                "This controls only the filters within each category." )
        #match_div.add(hint)
        #match_div.add('<br/>')
        #match_div.add_style("padding-top: 5px")

        filter_div.add(search_wdg)
        search_wdg.add_style("float: left")
        filter_div.add(match_div)

        filter_div.add(HtmlElement.br())

        filters_div = DivWdg()
        filters_div.add_style("margin: 0 -6 0 -6")

        security = Environment.get_security()

        # add all the filters
        for filter in my.filters:
            element_name = filter.get_name()

            if not security.check_access("search", element_name, "view"):
                continue

            # no need to create it again
            #filter = my.config.get_display_widget(element_name)
            div = DivWdg()
            filters_div.add(div)

            div.add_class("hand")
            class_suffix = element_name.replace(' ', '_')
            cbjs_action = 'var el=spt.get_cousin(bvr.src_el,".spt_search",".spt_filter_%s");spt.simple_display_toggle(el);' % class_suffix
            div.add_behavior({'type': 'click_up', 'cbjs_action': cbjs_action})
            div.add_color("color", "color", +5)
            #div.add_gradient("background", "background", -5, -5)
            div.add_style("margin-top: -1px")
            div.add_style("height: 18px")

            div.add_border()
            div.add_style("padding: 8px 5px")
            div.add_style("whitespace: nowrap")

            if element_name in ["Parent", 'Children']:
                swap = SwapDisplayWdg.get_triangle_wdg()
            else:
                swap = SwapDisplayWdg.get_triangle_wdg()
                swap.set_off()
            swap.add_action_script(cbjs_action)

            div.add_event("onclick", swap.get_swap_script())
            div.add(swap)
            div.add_class("SPT_DTS")
            div.add(element_name)

            div = DivWdg()
            div.add_class("spt_filter_%s" % class_suffix)

            if element_name in ["Parent", 'Children']:
                div.add_style("display: none")
            else:
                div.add_style("display: block")

            #div.add_style("background-color: #333")
            div.add_color("background", "background")
            div.add_border()
            div.add_style("padding: 10px 8px")
            div.add_style("margin-top: -1px")
            #div.add_style("margin-left: 20px")
            #div.add_style("width: 660")
            div.add(filter)
            filters_div.add(div)

        filter_div.add(filters_div)

        buttons_div = DivWdg()
        buttons_div.add_style("margin-top: 7px")
        buttons_div.add_style("margin-bottom: 7px")
        search_wdg = my.get_search_wdg()
        search_wdg.add_style("margin: 15px auto")
        buttons_div.add(search_wdg)
        filter_div.add(buttons_div)

        filter_top.add(filter_div)

        return filter_top
Ejemplo n.º 13
0
    def _get_bar(self, percent, proc_count, task):
        '''get a vertical bar indicating the progress of a task '''
        sobject = self.get_current_sobject()
        bar = DivWdg()
        if self.desc_checkbox_value == "on":
            bar.add_style('margin-right: 20px')
        else:
            bar.add_style('width: 10px')
        bar.add_style('float: left')
        cur_percent = 100.0
        increment = 100.0 / proc_count

        # get some task info
        assigned = 'unassigned'
        process = task.get_value('process')
        if task.get_value('assigned').strip():
            assigned = task.get_value('assigned')

        task_desc = task.get_value('description')
        if not task_desc:
            task_desc = 'n/a'

        start_date = task.get_value("bid_start_date")
        end_date = task.get_value("bid_end_date")
        if start_date:
            start_date = Date(db_date=start_date,
                              show_warning=False).get_display_date()
        else:
            start_date = "?"
        if end_date:
            end_date = Date(db_date=end_date,
                            show_warning=False).get_display_date()
        else:
            end_date = "?"

        # remove some spacing characters
        task_desc = re.sub('(\n|\r|\t)', ' ', task_desc)
        task_desc = re.sub('"', "'", task_desc)
        task_status = task.get_value('status')

        display_percent = percent
        if percent < 0:
            task_status = "%s <font color=red>(obsolete)</font>" % task_status
            display_percent = 0

        msg =  '<b>%s</b><br/><hr>%s<br/><span style=padding-left:1em>desc: %s</span><br/>' \
            '<span style=padding-left:1em>status:%s (%s%%)</span><br/>'\
            '<span style=padding-left:1em>%s - %s</span>'\
            % (process, assigned, task_desc, task_status, display_percent, start_date, end_date)

        if WebContainer.get_web().get_browser() == "IE":
            bar.add_event('onmouseover', "hint_bubble.show(event, '%s')" % msg)
        else:
            bar.add_tip(msg)

        from pyasm.widget import IconWdg
        end_date = task.get_value("bid_end_date")
        end_date = Date(db_date=end_date, show_warning=False)
        now_date = Date(show_warning=False)
        if now_date.get_utc() > end_date.get_utc() and percent != 100:
            alert_color = "#f00"
        else:
            alert_color = None

        for x in xrange(proc_count):
            cur_percent -= increment
            div = DivWdg()
            content = '&nbsp;'
            # unidentified status probably
            if percent < 0:
                content = '&mdash;'
                div.add_style('text-decoration: blink')

            div.add(content)
            div.add_style('width: 10px')
            if cur_percent < percent or cur_percent == 0:
                if alert_color:
                    div.add_style("background-color: %s" % alert_color)
                else:
                    div.add_style("background-color: %s" %
                                  self._get_color_code(percent))

            bar_height = self.get_option("bar_height")
            if not bar_height:
                bar_height = self.bar_select_value
            if not bar_height:
                bar_height = '3'
            div.add_style("height: %spx" % bar_height)
            # IE needs to set the font size to reduce the overall size
            div.add_style("font-size: %spx" % bar_height)
            if sobject.is_retired():
                div.add_class('task_status_bar_retired')
            else:
                if self.label_select_value == "abbr":
                    div.add_style("margin: -1px")

                #div.add_class("task_status_bar")
                #div.add_style("margin-top: 2px")
                div.add_border()

            bar.add(div)

        if self.desc_checkbox_value == "on":
            span = SpanWdg(task_desc)
            span.add_style('font-size: 0.8em')
            bar.add(span)

        return bar
Ejemplo n.º 14
0
    def get_display(my):

        top = DivWdg()
        top.add_class("spt_sample_chart_top")

        table = Table()
        table.add_row()
        left = table.add_cell()

        # add the chart
        chart_div = DivWdg()
        chart_div.add_class("spt_sample_chart")
        left.add(chart_div)
        chart_div.add_style("width: 600")
        chart_div.add_style("height: 400")
        chart_div.add_style("padding: 10px")

        data_file = 'bar-2.txt'
        chart = ChartWdg(data_file=data_file)
        chart_div.add(chart)


        # add navigator
        right = table.add_cell()
        right.add_style("text-align: top")

        top.add(table)

        base_dir = "%s/src" % Environment.get_install_dir()
        rel_dir = 'context/spt_js/ofc/data-files'

        files_div = DivWdg()
        files_div.add_style("height: 400")
        files_div.add_style("overflow: auto")
        files_div.add_style("padding: 3px")
        right.add(files_div)

        files = os.listdir("%s/%s" % (base_dir, rel_dir))
        for file in files:
            if not file.endswith(".txt"):
                continue


            explore_div = DivWdg()
            link = "/%s/%s" % (rel_dir, file)
            explore_div.add("<a target='_blank' href='%s'>(+)</a>&nbsp;&nbsp;" % link)
            explore_div.add_style("float: left")
            files_div.add(explore_div)


            file_div = DivWdg()
            file_div.add_style("padding: 2px")
            file_div.add_class("hand")
            file_div.add_event("onmouseover", "this.style.background='#696969'")
            file_div.add_event("onmouseout", "this.style.background='#444'")
            file_div.add(file)
            files_div.add(file_div)

            file_div.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                var value = bvr.src_el.innerHTML;
                var top = bvr.src_el.getParent(".spt_sample_chart_top");
                var chart = top.getElement(".spt_sample_chart");
                spt.panel.load(chart, 'tactic.ui.chart.ChartWdg', {data_file:value});
                '''
            } )


        return top
Ejemplo n.º 15
0
    def get_content_wdg(my):
        div = DivWdg()
        div.add_class("spt_tile_layout_top")
        if my.top_styles:
            div.add_styles(my.top_styles)
        inner = DivWdg()
        div.add(inner)


        
        menus_in = {}
        # set up the context menus
        if my.show_context_menu == True:
            menus_in['DG_HEADER_CTX'] = [ my.get_smart_header_context_menu_data() ]
            menus_in['DG_DROW_SMENU_CTX'] = [ my.get_data_row_smart_context_menu_details() ]
        elif my.show_context_menu == 'none':
            div.add_event('oncontextmenu', 'return false;')
        if menus_in:
            SmartMenu.attach_smart_context_menu( inner, menus_in, False )
 




        

        temp = my.kwargs.get("temp")
        has_loading = False

        
        inner.add_style("margin-left: 20px")
       

        inner.add_attr("ondragenter", "return false")
        inner.add_attr("ondragover", "return false")
        inner.add_attr("ondrop", "spt.thumb.background_drop(event, this)")

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

        if my.sobjects:
            inner.add( my.get_scale_wdg() )

            for row, sobject in enumerate(my.sobjects):

                if False and not temp and row > 4: 
                    tile_wdg = DivWdg()
                    inner.add(tile_wdg)
                    tile_wdg.add_style("width: 120px")
                    tile_wdg.add_style("height: 120px")
                    tile_wdg.add_style("float: left")
                    tile_wdg.add_style("padding: 20px")
                    tile_wdg.add_style("text-align: center")
                    tile_wdg.add('<img src="/context/icons/common/indicator_snake.gif" border="0"/>')
                    tile_wdg.add(" Loading ...")
                    tile_wdg.add_attr("spt_search_key", sobject.get_search_key())
                    tile_wdg.add_class("spt_loading")
                    has_loading = True
                    continue


                kwargs = my.kwargs.copy()
                tile = my.get_tile_wdg(sobject)
                inner.add(tile)
        else:
            table = Table()
            inner.add(table)
            my.handle_no_results(table)


        chunk_size = 5
        if has_loading:
            inner.add_behavior( {
            'type': 'load',
            'chunk': chunk_size,
            'cbjs_action': '''
            var layout = bvr.src_el.getParent(".spt_layout");
            spt.table.set_layout(layout);
            var rows = layout.getElements(".spt_loading");

            var jobs = [];
            var count = 0;
            var chunk = bvr.chunk;
            while (true) {
                var job_item = rows.slice(count, count+chunk);
                if (job_item.length == 0) {
                    break;
                }
                jobs.push(job_item);
                count += chunk;
            }

            var count = -1;
            var func = function() {
                count += 1;
                var rows = jobs[count];
                if (! rows || rows.length == 0) {
                    return;
                }
                for (var i = 0; i < rows.length; i++) {
                    rows[i].removeClass("spt_loading");
                }
                spt.table.refresh_rows(rows, null, null, {on_complete: func});
            }
            func();

            '''
            } )





        inner.add("<br clear='all'/>")
        return div
Ejemplo n.º 16
0
    def get_day_wdg(my, month, day):

        # find the day of the week
        wday = day.strftime("%w")
        # if it's the first day ...
        if wday == "0":
            my.current_week += 1

        sobjects_week_index = my.sobjects_week_index[my.current_week]
        my.handler.set_sobjects_index( sobjects_week_index )
        my.handler.set_current_week(my.current_week)

        sobjects = my.date_sobjects.get(str(day))
        div = DivWdg()
       
        div.add_style("vertical-align: top")
        div.add_class("spt_calendar_day")
        div.add_class("hand")
        if my.custom_layout:
            my.custom_layout.kwargs['day_obj'] = day
            my.custom_layout.kwargs['day'] = str(day)
            if sobjects:
                # this causes mako processing error complaining about timestamp
                # send in just the search_keys for the day for now

                #sobject_dict_list = [ x.get_sobject_dict() for x in sobjects]
                #my.custom_layout.kwargs['search_objects'] = sobject_dict_list 
                sobject_keys = [ x.get_search_key() for x in sobjects]
                my.custom_layout.kwargs['search_keys'] = sobject_keys
            wdg = my.custom_layout.get_buffer_display()
            my.custom_layout.kwargs['search_keys'] = []
            div.add(wdg)
            return div


        day_div = DivWdg()
        div.add( day_div )
        day_div.add(day.day)
        day_div.add_style("float: right")
        day_div.add_style("margin: 2px")
        div.add("<br clear='all'/>")


        """
        mode = my.kwargs.get("mode")
        if mode in ["line","square"]:
            day_div.add_style("font-size: 0.6em")
            day_div.add_style("padding: 1px 0px 2px 2px")
        else:
            day_div.add_style("font-size: 1.2em")
            day_div.add_style("padding: 3px 0 3px 5px")
        """

        if my.width:
            div.add_style("width: %s" % my.width);
        div.add_style("min-height: %s" % my.height);
        div.add_style("overflow: hidden");
        div.add_style("padding: 2px 0 2px 0")

        div.add_color("color", "color")
        div.add_style("vertical-align: top")

        
        st_title = SearchType.get(my.search_type).get_value('title')
        if sobjects:
            #ids = "".join( [ "['id','%s']" % x.get_id() for x in sobjects ])
            ids = [ str(x.get_id()) for x in sobjects ]
            ids_filter = "['id' ,'in', '%s']" %'|'.join(ids) 
            expression = "@SOBJECT(%s%s)" % (my.search_type, ids_filter)
            div.add_behavior( {
                'type': "click_up",
                'cbjs_action': '''
                var class_name = 'tactic.ui.panel.TableLayoutWdg';
                var title = '%s: %s';
                var kwargs = {
                    'search_type': '%s',
                    'view': 'table',
                    'show_insert': 'false',
                    'expression': "%s"
                };
                spt.app_busy.show("Loading...")
                setTimeout(function() {
                    //spt.panel.load_popup( title, class_name, kwargs );
                    spt.tab.set_main_body_tab();
                    spt.tab.add_new(title, title, class_name, kwargs);
                    spt.app_busy.hide();
                }, 200)

                ''' % (st_title, str(day),my.search_type, expression ),
            } )


            content = DivWdg()
            content.add_style("vertical-align: top")
            content.add_class("spt_calendar_day_content")

            content.add_style("height: 100%")
            #content.add_style("width: 400px")
            content.add_style("min-height: %s" % my.height);

            my.handler.set_sobjects(sobjects)
        else:
            content = DivWdg()
            content.add_style("vertical-align: top")
            content.add_style("height: 100%")
            #content.add_style("width: 400px")
            content.add_style("min-height: %s" % my.height);

            my.handler.set_sobjects([])

        # force it to be 120px for now
        if my.width:
            content.add_style("width: %spx" % my.width)

        my.handler.set_date(day)

        content.add( my.handler.get_buffer_display() )

        div.add(content)



        today = datetime.today()
       

        # store date like the database does YYYY-MM-DD
        date_str = "%04d-%02d-%02d" % (day.year, day.month, day.day)
        div.add_attr('spt_date', date_str)
        div.add_class('spt_date_day')


        color1 = div.get_color("background")
        color2 = div.get_color("background", -10)


        # put a different color for days that are not in the current month
        if day.month != month:
            div.add_style("color: #c22")
            div.add_style("opacity: 0.7")

            #div.add_style("background-image", "linear-gradient(135deg, #ccc 0%, #ccc 25%, #bbb 25%, #bbb 50%, #ccc 50%, #ccc 75%, #bbb 75%);");
            div.add_style("background-size", "15px 15px")
            div.add_style("background-color", "")
            div.add_style("background-image", "linear-gradient(135deg, rgba(0, 0, 0, 0.06) 25%, rgba(0, 0, 0, 0) 25%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.06) 50%, rgba(0, 0, 0, 0.06) 75%, rgba(0, 0, 0, 0) 75%, rgba(0, 0, 0, 0));")




        elif day.year == today.year and day.month == today.month and day.day == today.day:
            div.add_color("background", "background", [-10, -10, 20])
            color1 = div.get_color("background", [-10, -10, 20])




        div.add_event("onmouseover", "$(this).setStyle('background-color','%s')" % color2)
        div.add_event("onmouseout", "$(this).setStyle('background-color','%s')" % color1)

        return div
Ejemplo n.º 17
0
    def get_script_wdg(my):

        search = Search("config/custom_script")
        #search.add_user_filter()
        search.add_order_by("folder")
        search.add_order_by("title")
        scripts = search.get_sobjects()

        widget = DivWdg()
        widget.add_style("width: 100%")

        from pyasm.web.palette import Palette
        palette = Palette.get()
        bg_color = palette.color("background3")
        hover_color = palette.color("background3", 20)
        widget.add_color("background", bg_color)
        '''
        # Try the table layout widget
        from tactic.ui.panel import TableLayoutWdg
        table = TableLayoutWdg(id='js_edit_list',search_type="config/custom_script", view='simple')
        table.set_sobjects(scripts)
        widget.add(table)
        '''

        title = DivWdg()
        title.add("Saved Scripts")
        title.add_style("font-size: 14px")
        title.add_color("color", "color")
        title.add_style("padding: 3px")
        title.add_style("margin: 0 0 0 -1")
        title.add_gradient("background", "background")
        title.add_border()
        widget.add(title)

        script_div = DivWdg()
        script_div.add_border()
        script_div.add_color("background", "background3")
        script_div.add_color("color", "color3")
        script_div.add_style("padding: 8px")
        script_div.add_style("overflow-x: hidden")
        script_div.add_style("overflow-y: auto")
        script_div.add_style("height: 100%")
        script_div.add_style("min-width: 100px")
        script_div.add_style("width: 220px")
        script_div.add_style("margin: -1px 0px 0px -1px")
        script_div.add_class("spt_resizable")

        inner = DivWdg()
        script_div.add(inner)
        inner.add_style("height: 100%")
        inner.add_style("width: 800px")

        last_folder = ''
        for script in scripts:
            title = script.get_value("title")
            folder = script.get_value("folder")
            language = script.get_value("language", no_exception=True)
            if not language:
                language = 'javascript'

            if folder != last_folder:
                div = DivWdg()
                icon = IconWdg("Script", IconWdg.FOLDER)
                div.add(icon)
                div.add(" %s" % folder)
                inner.add(div)

            last_folder = folder

            div = DivWdg()
            inner.add(div)
            div.add_class('hand')
            icon = IconWdg("Script", IconWdg.TOGGLE_ON)
            icon.add_style("margin-left: 10px")
            div.add(icon)
            div.add("%s" % title)

            span = SpanWdg()
            span.add_style("font-size: 9px")
            span.add_style("opacity: 0.2")
            span.add(" <i>(%s)</i>" % language)
            div.add(span)

            div.add_event("onmouseover",
                          "this.style.background='%s'" % hover_color)
            div.add_event("onmouseout",
                          "this.style.background='%s'" % bg_color)

            behavior = {
                'type': 'click_up',
                'editor_id': my.editor_id,
                'cbjs_action':
                'spt.script_editor.display_script_cbk(evt, bvr)',
                'code': script.get_code()
            }
            div.add_behavior(behavior)

        widget.add(script_div)

        return widget