Esempio n. 1
0
    def get_save_wdg(self):

        div = DivWdg()
        div.add("Save current search as: ")

        text = TextWdg("save_search_text")
        text.set_id("save_search_text")
        div.add(text)



        save_button = ButtonWdg("Save Search")
        behavior = {
            'cbjs_action':  'spt.table.save_search();'
        }
        save_button.add_behavior( behavior )


        cancel_button = ButtonWdg("Cancel")
        cancel_button.add_event("onclick", "$('save_search_wdg').style.display = 'none'")

        div.add(HtmlElement.hr())
        button_div = DivWdg()
        button_div.add_style("text-align: center")
        button_div.add(save_button)
        button_div.add("  ")
        button_div.add(cancel_button)
        div.add(button_div)

        return div
Esempio n. 2
0
    def get_save_wdg(my):

        # add the popup
        popup = PopupWdg(id='save_search_wdg')
        popup.add("Save Search", "title")

        div = DivWdg()
        div.add("Save current search as: ")

        text = TextWdg("save_search_text")
        text.set_id("save_search_text")
        div.add(text)

        save_button = ButtonWdg("Save Search")
        behavior = {
            'type': 'click',
            'mouse_btn': 'LMB',
            'cbjs_action': 'spt.dg_table.save_search_cbk(evt, bvr);'
        }
        save_button.add_behavior(behavior)

        cancel_button = ButtonWdg("Cancel")
        cancel_button.add_event("onclick",
                                "$('save_search_wdg').style.display = 'none'")

        div.add(HtmlElement.hr())
        button_div = DivWdg()
        button_div.add_style("text-align: center")
        button_div.add(save_button)
        button_div.add("  ")
        button_div.add(cancel_button)
        div.add(button_div)

        popup.add(div, "content")

        return popup
Esempio n. 3
0
class ActionButtonWdg(DivWdg):

    ARGS_KEYS = {
        'title': {
            'description': 'Value to show on actual button',
            'type': 'TextWdg',
            'order': 0,
            'category': 'Options'
        },
        'title2': {
            'description':
            'Alt Value to show on actual button when clicked on',
            'type': 'TextWdg',
            'order': 0,
            'category': 'Options'
        },
        'tip': {
            'description':
            'Tool tip info to show when mouse hovers over button',
            'type': 'TextWdg',
            'order': 1,
            'category': 'Options'
        },
        'action': {
            'description': 'Javascript callback',
            'type': 'TextAreaWdg',
            'order': 1,
            'category': 'Options'
        }
    }

    def __init__(my, **kwargs):
        web = WebContainer.get_web()
        is_Qt_OSX = web.is_Qt_OSX()
        my.browser = web.get_browser()

        #is_Qt_OSX = False
        if is_Qt_OSX:
            my.redirect = ActionButtonWdgOld(**kwargs)
        else:
            my.redirect = None

        #my.top = DivWdg()
        my.kwargs = kwargs
        my.text_wdg = DivWdg()
        my.table = Table()
        my.table.add_row()
        my.table.add_style("color", "#333")
        my.td = my.table.add_cell()
        my.td.add_class("spt_action_button")
        super(ActionButtonWdg, my).__init__()

    def add_behavior(my, behavior):
        if my.redirect:
            return my.redirect.add_behavior(behavior)

        my.td.add_behavior(behavior)

    def add_style(my, name, value=None, override=True):
        if my.redirect:
            return my.redirect.add_style(name, value, override=override)

        super(ActionButtonWdg, my).add_style(name, value, override=override)

    def add_class(my, value):
        if my.redirect:
            return my.redirect.add_class(value)

        super(ActionButtonWdg, my).add_class(value)

    def add_top_behaviors(my, top):
        if my.redirect:
            return my.redirect.add_top_behavior(top)

    def get_display(my):
        if my.redirect:
            return my.redirect.get_display()

        my.add_class("spt_button_top")
        # no need to define top
        #my.add(top)

        my.add_style("margin: 0px 3px", override=False)

        opacity = my.kwargs.get("opacity")
        if not opacity:
            opacity = 1.0
        my.add_style("opacity: %s" % opacity)

        base = "%s/%s" % (BASE, my.get_theme())

        my.add(my.table)
        td = my.td
        td.add_style("text-align: center")

        size = my.kwargs.get("size")
        if not size:
            size = 'medium'
        size = size[:1]

        width = my.kwargs.get("width")
        if width:
            top_width = int(width)
            my.add_style("width: %s" % top_width)
        else:
            top_width = 40
            if size == 'm':
                top_width = 83
                my.add_style("width: %spx" % top_width)
            if size == 'l':
                top_width = 127
                my.add_style("width: %spx" % top_width)
            if size == 'b':
                top_width = "100%"
                my.add_style("width: %spx" % top_width)
                my.table.add_style("width: 100%")

        #request_top_wdg = Container.get("request_top_wdg")
        #if not request_top_wdg:
        #    request_top_wdg = my.table
        request_top_wdg = my.table

        try:
            button_bvr = request_top_wdg.has_class("spt_button_behaviors")
            if not button_bvr:
                my.add_top_behaviors(request_top_wdg)
                request_top_wdg.add_class("spt_button_behaviors")
        except Exception, e:
            print "WARNING: ", e

        title = my.kwargs.get("title")
        if not title:
            title = "No Title"

        # stretch it wider in case the text is longer,
        # don't make it too long though
        if len(title) > 10:
            width = len(title) / 8.0 * 60
            if width < top_width:
                width = top_width
            td.add_style('width', width)
            td.add_style('height', '28px')
        if not title:
            title = "(No title)"

        #title = "Search"
        tip = my.kwargs.get("tip")
        if not tip:
            tip = title
        my.add_attr("title", tip)

        title2 = my.kwargs.get("title2")
        if title2:
            td.add_behavior({
                'type':
                'click_up',
                'title1':
                title,
                'title2':
                title2,
                'cbjs_action':
                '''
            var label_el = bvr.src_el.getElement(".spt_label");
            var label1 = "<b>" + bvr.title1 + "</b>";
            var label2 = "<b>" + bvr.title2 + "</b>";
            if (label_el.innerHTML == label1) {
                label_el.innerHTML = label2;
            }
            else {
                label_el.innerHTML = label1;
            }
            '''
            })

        from pyasm.widget import ButtonWdg
        button = ButtonWdg()
        button.add_style("width: %s" % top_width)
        button.add_class('spt_label')

        icon = my.kwargs.get("icon")
        if icon:
            icon_div = DivWdg()
            icon = IconWdg(title, icon, width=16)
            icon_div.add(icon)
            button.add(icon_div)
            my.table.add_style("position: relative")
            icon_div.add_style("position: absolute")
            icon_div.add_style("left: 5px")
            icon_div.add_style("top: 6px")
            title = " &nbsp; &nbsp; %s" % title
            button.add_style("padding: 2px")

        button.set_name(title)

        td.add(button)
        #button.add_border()
        #button.set_box_shadow("0px 0px 1px", color=button.get_color("shadow"))

        if my.browser == 'Qt' and os.name != 'nt':
            button.add_style("top: 8px")
        else:
            button.add_style("top: 6px")

        # BOOTSTRAP
        color = my.kwargs.get("color")
        button.add_class('btn')
        if color:
            if color.startswith("#"):
                button.add_style("background", color)
            else:
                button.add_class('btn-%s' % color)
        else:
            button.add_class('btn-default')

        if size == 'b':
            button.add_class('btn-block')
        else:
            button.add_class('btn-sm')
        button.add_style("top: 0px")

        button.add_attr('spt_text_label', title)
        td.add_class("spt_action_button_hit")
        button.add_class("hand")

        return super(ActionButtonWdg, my).get_display()
Esempio n. 4
0
            print "WARNING: ", e
            configs = []
        except:
            my.clear_search_data(my.search_type)
            raise
        views = SObject.get_values(configs, "view")

        select = SelectWdg("saved_search")
        select.set_id("saved_search")
        select.add_empty_option("-- Select --")
        #select.set_option("query", "config/widget_config|view|view")
        select.set_option("values", views)
        #select.set_option("query_filter", "\"view\" like 'saved_search:%'")
        div.add(select)

        retrieve_button = ButtonWdg("Retrieve Search")
        behavior = {
            'type': 'click',
            'cbjs_action': 'spt.dg_table.retrieve_search_cbk(evt, bvr);'
        }
        retrieve_button.add_behavior(behavior)

        cancel_button = ButtonWdg("Cancel")
        cancel_button.add_event(
            "onclick", "$('retrieve_search_wdg').style.display = 'none'")

        div.add(HtmlElement.hr())
        button_div = DivWdg()
        button_div.add_style("text-align: center")
        button_div.add(retrieve_button)
        button_div.add("&nbsp;&nbsp;")
Esempio n. 5
0
    def get_display(self):
        if self.redirect:
            return self.redirect.get_display()

        self.add_class("spt_button_top")
        # no need to define top
        #self.add(top)

        self.add_style("margin: 0px 3px", override=False)

        opacity = self.kwargs.get("opacity")
        if not opacity:
            opacity = 1.0
        self.add_style("opacity: %s" % opacity)

        base = "%s/%s" % (BASE, self.get_theme())

        self.add(self.table)
        td = self.td
        td.add_style("text-align: center")

        size = self.kwargs.get("size")
        if not size:
            size = 'medium'
        size = size[:1]

        width = self.kwargs.get("width")
        if width:
            top_width = int(width)
            self.add_style("width: %s" % top_width)
        else:
            top_width = 40
            if size == 'm':
                top_width = 83
                self.add_style("width: %spx" % top_width)
            if size == 'l':
                top_width = 127
                self.add_style("width: %spx" % top_width)
            if size == 'b':
                top_width = "100%"
                self.add_style("width: %spx" % top_width)
                self.table.add_style("width: 100%")

        #request_top_wdg = Container.get("request_top_wdg")
        #if not request_top_wdg:
        #    request_top_wdg = self.table
        request_top_wdg = self.table

        try:
            button_bvr = request_top_wdg.has_class("spt_button_behaviors")
            if not button_bvr:
                self.add_top_behaviors(request_top_wdg)
                request_top_wdg.add_class("spt_button_behaviors")
        except Exception as e:
            print "WARNING: ", e

        title = self.kwargs.get("title")
        if not title:
            title = "No Title"

        # stretch it wider in case the text is longer,
        # don't make it too long though
        if len(title) > 10:
            width = len(title) / 8.0 * 60
            if width < top_width:
                width = top_width
            td.add_style('width', width)
            td.add_style('height', '28px')
        if not title:
            title = "(No title)"

        #title = "Search"
        tip = self.kwargs.get("tip")
        if not tip:
            tip = title
        self.add_attr("title", tip)

        title2 = self.kwargs.get("title2")
        if title2:
            td.add_behavior({
                'type':
                'click_up',
                'title1':
                title,
                'title2':
                title2,
                'cbjs_action':
                '''
            var label_el = bvr.src_el.getElement(".spt_label");
            var label1 = bvr.title1;
            var label2 = bvr.title2;
            if (label_el.value == label1) {
                label_el.value = label2;
            }
            else {
                label_el.value = label1;
            }
            '''
            })

        from pyasm.widget import ButtonWdg
        button = ButtonWdg()
        button.add_style("width: %s" % top_width)
        button.add_class('spt_label')

        icon = self.kwargs.get("icon")
        if icon:
            icon_div = DivWdg()
            icon = IconWdg(title, icon, width=16)
            icon_div.add(icon)
            button.add(icon_div)
            self.table.add_style("position: relative")
            icon_div.add_style("position: absolute")
            icon_div.add_style("left: 5px")
            icon_div.add_style("top: 6px")
            title = " &nbsp; &nbsp; %s" % title
            button.add_style("padding: 2px")

        button.set_name(title)

        td.add(button)
        #button.add_border()
        #button.set_box_shadow("0px 0px 1px", color=button.get_color("shadow"))

        if self.browser == 'Qt' and os.name != 'nt':
            button.add_style("top: 8px")
        else:
            button.add_style("top: 6px")

        # BOOTSTRAP
        color = self.kwargs.get("color")
        button.add_class('btn')
        if color:
            if color.startswith("#"):
                button.add_style("background", color)
            else:
                button.add_class('btn-%s' % color)
        else:
            button.add_class('btn-default')

        if size == 'b':
            button.add_class('btn-block')
        else:
            button.add_class('btn-sm')
        button.add_style("top: 0px")

        button.add_attr('spt_text_label', title)
        td.add_class("spt_action_button_hit")
        button.add_class("hand")

        return super(ActionButtonWdg, self).get_display()