Beispiel #1
0
    def get_display(my):
        my.display_expr = my.kwargs.get('display_expr')
        my.values = []

        instance_type = my.get_option("instance_type")
        accepted_type = my.get_option("accepted_drop_type")

        div = DivWdg()
        div.add_class("spt_drop_element_top")
        div.add_style("width: 100%")
        div.add_style("height: 100%")
        div.add_style("min-width: 100px")
        div.add_style("max-height: 300px")
        div.add_style("overflow-y: auto")

        my.value_wdg = HiddenWdg(my.get_name())
        my.value_wdg.add_class("spt_drop_element_value")
        div.add(my.value_wdg)

        version = my.parent_wdg.get_layout_version()
        if version != "2":
            my.add_drop_behavior(div, accepted_type)

        # add the hidden div which holds containers info for the sobject
        template_div = DivWdg()
        template_div.add_style("display: none")
        template_item = my.get_item_div(None)

        # float left for the new icon beside it
        item_div = template_item.get_widget('item_div')
        item_div.add_style('float: left')

        template_item.add_class("spt_drop_template")
        #template_item.add_style('float: left')
        new_icon = IconWdg("New", IconWdg.NEW)
        new_icon.add_style('padding-left', '3px')
        #TODO: insert the new_icon at add(new_icon, index=0) and make sure
        # the js-side sobject_drop_action cloning align the template div properly
        #template_item.add(" - ")
        template_item.add(new_icon)
        template_div.add(template_item)
        div.add(template_div)

        # list out the relationships
        #sobject = my.get_current_sobject()
        #search_type = sobject.get_base_search_type()

        content_div = DivWdg()
        div.add(content_div)
        # shrink wrapping for FF
        content_div.add_style('float: left')
        content_div.add_class("spt_drop_content")

        if instance_type:
            instance_wdg = my.get_instance_wdg(instance_type)
            content_div.add(instance_wdg)

        return div
Beispiel #2
0
    def get_header_wdg(my):
        div = DivWdg()

        div.add("<hr/>")

        dots_div = DivWdg()
        dots_div.add_style("margin-top: -12px")
        div.add(dots_div)

        left = 50
        width = 60
        for i, widget in enumerate(my.widgets):
            on_dot = IconWdg("", IconWdg.DOT_GREEN)
            on_dot.add_class("spt_wizard_on_dot")
            off_dot = IconWdg("", IconWdg.DOT_GREY)
            off_dot.add_class("spt_wizard_off_dot")
            if i == 0:
                off_dot.add_style("display: none")
            else:
                on_dot.add_style("display: none")

            dot_div = DivWdg()
            dots_div.add(dot_div)
            dot_div.add(on_dot)
            dot_div.add(off_dot)
            dot_div.add_style("width: %spx" % width)
            dot_div.add_style("float: left")
            dot_div.add_style("margin-left: %spx" % left)
            dot_div.add_style("text-align: center")

            if (i+1) < len(my.widgets):
                arrow_div = DivWdg()
                dots_div.add(arrow_div)
                arrow_div.add_style("float: left")
                arrow_div.add_style("position: absolute")
                arrow_div.add_style("margin-left: %spx" % ((width+left)*(i+1.2)))
                arrow_div.add_style("margin-top: -3px")
                arrow_div.add_style("text-align: center")
                icon = IconWdg("", IconWdg.ARROWHEAD_DARK_RIGHT)
                arrow_div.add(icon)



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


        for widget in my.widgets:
            name_div = DivWdg()
            div.add(name_div)
            name_div.add_style("float: left")
            name_div.add_style("margin-left: %spx" % left)
            name = widget.get_name()
            name_div.add(name)
            name_div.add_style("width: %spx" % width)
            name_div.add_style("text-align: center")

        div.add("<br clear='all'/>")
        return div
Beispiel #3
0
    def get_display(self):
        self.display_expr = self.kwargs.get('display_expr')
        self.values = []

        instance_type = self.get_option("instance_type")
        accepted_type = self.get_option("accepted_drop_type")

        div = DivWdg()
        div.add_class("spt_drop_element_top")
        div.add_style("width: 100%")
        div.add_style("min-height: 70px")
        div.add_style("height: auto")
        div.add_style("min-width: 100px")
        div.add_style("max-height: 300px")
        div.add_style("overflow-y: auto")
        div.add_style("overflow-x: hidden")

        self.value_wdg = HiddenWdg(self.get_name())
        self.value_wdg.add_class("spt_drop_element_value")
        div.add( self.value_wdg )



        version = self.parent_wdg.get_layout_version()
        #if version != "2":
        self.add_drop_behavior(div, accepted_type)



        # add the hidden div which holds containers info for the sobject
        template_div = DivWdg()
        template_div.add_style("display: none")
        template_item = self.get_item_div(None)

        # float left for the new icon beside it
        item_div = template_item.get_widget('item_div')
        #item_div.add_style('float: left')

        template_item.add_class("spt_drop_template")
        new_icon = IconWdg("New", IconWdg.NEW)
        new_icon.add_style('padding-left','3px')
        #TODO: insert the new_icon at add(new_icon, index=0) and make sure
        # the js-side sobject_drop_action cloning align the template div properly
        #template_item.add(new_icon)
        template_div.add(template_item)
        div.add(template_div)


        content_div = DivWdg()
        div.add(content_div)
        content_div.add_class("spt_drop_content")

        if instance_type:
            instance_wdg = self.get_instance_wdg(instance_type)
            content_div.add(instance_wdg)
            
        return div
Beispiel #4
0
    def get_item_div(self, sobject):
        ''' get the item div the sobject'''
        top = DivWdg()
        top.add_style("padding: 3px 2px")
        top.add_class("spt_drop_item")
        top.add_class("SPT_DROP_ITEM")


        item_div = DivWdg()
        top.add(item_div, "item_div")
        item_div.add_style("text-overflow: ellipsis")
        item_div.add_style("white-space: nowrap")
        item_div.add_style("width: 80%")
        item_div.add_attr('title','Click to remove')
        item_div.add_style("display", "inline-block")
        item_div.add_style("vertical-align", "top")
        item_div.add_style("overflow", "hidden")


        icon_div = DivWdg()
        top.add(icon_div)
        icon = IconWdg(icon="BS_REMOVE")
        icon_div.add(icon)
        icon_div.add_behavior( {
            'type': 'click_up',
            #'cbjs_action': '''spt.dg_table_action.sobject_drop_remove(evt,bvr)'''
            'cbjs_action': '''spt.drop.sobject_drop_remove(evt,bvr)'''
        } )
        icon.add_style("opacity: 0.3")
        icon_div.add_class("hand")
        icon_div.add_style("display", "inline-block")
        icon_div.add_style("vertical-align", "top")
        #icon_div.add_border()


        #self.menu.set_over(item_div, event="mousein")
        #self.menu.set_out(top, event="mouseleave")


        # set this as the place for the display value to go
        item_div.add_class("spt_drop_display_value")

        add_icon = True
        ExpressionParser.clear_cache()
        if sobject:
            if add_icon:
                self._add_icon(sobject, item_div)

            if self.display_expr:
                display_value = Search.eval(self.display_expr, sobjects = sobject, single=True)
            else:
                display_value = sobject.get_display_value()
            if isinstance(display_value, list):
                display_value = display_value[0]
            item_div.add( display_value )
            self.values.append( SearchKey.get_by_sobject(sobject) )
        return top
Beispiel #5
0
    def get_item_div(my, sobject):
        ''' get the item div the sobject'''
        top = DivWdg()
        top.add_style("padding: 3px 2px")
        top.add_class("spt_drop_item")
        top.add_class("SPT_DROP_ITEM")

        item_div = DivWdg()
        top.add(item_div, "item_div")
        item_div.add_style("text-overflow: ellipsis")
        item_div.add_style("white-space: nowrap")
        item_div.add_style("width: 80%")
        item_div.add_attr('title', 'Click to remove')
        item_div.add_style("display", "inline-block")
        item_div.add_style("vertical-align", "top")
        item_div.add_style("overflow", "hidden")

        icon_div = DivWdg()
        top.add(icon_div)
        icon = IconWdg(icon="BS_REMOVE")
        icon_div.add(icon)
        icon_div.add_behavior({
            'type':
            'click_up',
            #'cbjs_action': '''spt.dg_table_action.sobject_drop_remove(evt,bvr)'''
            'cbjs_action':
            '''spt.drop.sobject_drop_remove(evt,bvr)'''
        })
        icon.add_style("opacity: 0.3")
        icon_div.add_class("hand")
        icon_div.add_style("display", "inline-block")
        icon_div.add_style("vertical-align", "top")
        #icon_div.add_border()

        #my.menu.set_over(item_div, event="mousein")
        #my.menu.set_out(top, event="mouseleave")

        # set this as the place for the display value to go
        item_div.add_class("spt_drop_display_value")

        add_icon = True
        ExpressionParser.clear_cache()
        if sobject:
            if add_icon:
                my._add_icon(sobject, item_div)

            if my.display_expr:
                display_value = Search.eval(my.display_expr,
                                            sobjects=sobject,
                                            single=True)
            else:
                display_value = sobject.get_display_value()
            if isinstance(display_value, list):
                display_value = display_value[0]
            item_div.add(display_value)
            my.values.append(SearchKey.get_by_sobject(sobject))
        return top
Beispiel #6
0
    def get_header_wdg(my):
        div = DivWdg()

        div.add("<hr/>")

        dots_div = DivWdg()
        dots_div.add_style("margin-top: -12px")
        div.add(dots_div)

        left = 50
        width = 60
        for i, widget in enumerate(my.widgets):
            on_dot = IconWdg("", IconWdg.DOT_GREEN)
            on_dot.add_class("spt_wizard_on_dot")
            off_dot = IconWdg("", IconWdg.DOT_GREY)
            off_dot.add_class("spt_wizard_off_dot")
            if i == 0:
                off_dot.add_style("display: none")
            else:
                on_dot.add_style("display: none")

            dot_div = DivWdg()
            dots_div.add(dot_div)
            dot_div.add(on_dot)
            dot_div.add(off_dot)
            dot_div.add_style("width: %spx" % width)
            dot_div.add_style("float: left")
            dot_div.add_style("margin-left: %spx" % left)
            dot_div.add_style("text-align: center")

            if (i + 1) < len(my.widgets):
                arrow_div = DivWdg()
                dots_div.add(arrow_div)
                arrow_div.add_style("float: left")
                arrow_div.add_style("position: absolute")
                arrow_div.add_style("margin-left: %spx" % ((width + left) *
                                                           (i + 1.2)))
                arrow_div.add_style("margin-top: -3px")
                arrow_div.add_style("text-align: center")
                icon = IconWdg("", IconWdg.ARROWHEAD_DARK_RIGHT)
                arrow_div.add(icon)

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

        for widget in my.widgets:
            name_div = DivWdg()
            div.add(name_div)
            name_div.add_style("float: left")
            name_div.add_style("margin-left: %spx" % left)
            name = widget.get_name()
            name_div.add(name)
            name_div.add_style("width: %spx" % width)
            name_div.add_style("text-align: center")

        div.add("<br clear='all'/>")
        return div
Beispiel #7
0
    def get_display(self):
        self.display_expr = self.kwargs.get('display_expr')
        self.values = []

        instance_type = self.get_option("instance_type")
        accepted_type = self.get_option("accepted_drop_type")

        div = DivWdg()
        div.add_class("spt_drop_element_top")
        div.add_style("width: 100%")
        div.add_style("min-height: 70px")
        div.add_style("height: auto")
        div.add_style("min-width: 100px")
        div.add_style("max-height: 300px")
        div.add_style("overflow-y: auto")
        div.add_style("overflow-x: hidden")

        self.value_wdg = HiddenWdg(self.get_name())
        self.value_wdg.add_class("spt_drop_element_value")
        div.add(self.value_wdg)

        version = self.parent_wdg.get_layout_version()
        #if version != "2":
        self.add_drop_behavior(div, accepted_type)

        # add the hidden div which holds containers info for the sobject
        template_div = DivWdg()
        template_div.add_style("display: none")
        template_item = self.get_item_div(None)

        # float left for the new icon beside it
        item_div = template_item.get_widget('item_div')
        #item_div.add_style('float: left')

        template_item.add_class("spt_drop_template")
        new_icon = IconWdg("New", IconWdg.NEW)
        new_icon.add_style('padding-left', '3px')
        #TODO: insert the new_icon at add(new_icon, index=0) and make sure
        # the js-side sobject_drop_action cloning align the template div properly
        #template_item.add(new_icon)
        template_div.add(template_item)
        div.add(template_div)

        content_div = DivWdg()
        div.add(content_div)
        content_div.add_class("spt_drop_content")

        if instance_type:
            instance_wdg = self.get_instance_wdg(instance_type)
            content_div.add(instance_wdg)

        return div
Beispiel #8
0
    def get_display(self):

        msg = self.kwargs.get("message")

        arrow_div = DivWdg()
        icon = IconWdg(msg, IconWdg.ARROW_UP_LEFT_32)
        icon.add_style("margin-top: -20")
        icon.add_style("margin-left: -15")
        icon.add_style("position: absolute")
        arrow_div.add(icon)
        arrow_div.add("&nbsp;" * 5)
        arrow_div.add("<b>%s</b>" % msg)
        arrow_div.add_style("position: relative")
        arrow_div.add_style("margin-top: 5px")
        arrow_div.add_style("margin-left: 20px")
        arrow_div.add_style("float: left")
        arrow_div.add_style("padding: 25px")
        arrow_div.set_box_shadow("1px 1px 2px 2px")
        arrow_div.set_round_corners(30)
        arrow_div.add_color("background", "background")
        return arrow_div
Beispiel #9
0
    def get_display(my):

        msg = my.kwargs.get("message")

        arrow_div = DivWdg()
        icon = IconWdg(msg, IconWdg.ARROW_UP_LEFT_32)
        icon.add_style("margin-top: -20")
        icon.add_style("margin-left: -15")
        icon.add_style("position: absolute")
        arrow_div.add(icon)
        arrow_div.add("&nbsp;"*5)
        arrow_div.add("<b>%s</b>" % msg)
        arrow_div.add_style("position: relative")
        arrow_div.add_style("margin-top: 5px")
        arrow_div.add_style("margin-left: 20px")
        arrow_div.add_style("float: left")
        arrow_div.add_style("padding: 25px")
        arrow_div.set_box_shadow("1px 1px 2px 2px")
        arrow_div.set_round_corners(30)
        arrow_div.add_color("background", "background")
        return arrow_div
Beispiel #10
0
    def get_display(my):

        widget = my.widget
        widget.set_box_shadow()

        widget.add_class("spt_dialog_top")
        widget.add_class("spt_popup")

        z_index = my.kwargs.get("z_index")
        if not z_index:
            z_index = "500"
        widget.add_style("z-index: %s" % z_index)

        web = WebContainer.get_web()

        widget.set_id(my.name)
        widget.add_attr("spt_dialog_id", my.name)
        if my.kwargs.get("display") not in [True, "true"]:
            widget.add_style("display: none")

        widget.add_style("position: absolute")

        widget.add_behavior({
            'type': 'listen',
            'event_name': '%s|dialog_close' % my.name,
            'cbjs_action': my.get_cancel_script()
        })

        offset = my.kwargs.get("offset")
        if not offset:
            offset = my.offset

        show_header = True
        show_resize = False

        drag_div = DivWdg()
        if show_header:
            widget.add(drag_div)

        show_pointer = my.kwargs.get("show_pointer")
        if show_pointer not in [False, 'false']:
            from tactic.ui.container import ArrowWdg
            offset_x = 15 - offset.get('x')
            offset_y = offset.get("y")
            arrow = ArrowWdg(offset_x=offset_x,
                             offset_y=offset_y,
                             color=widget.get_color("background", -10))
            arrow.add_class("spt_popup_pointer")
            arrow.add_style("z-index: 10")
            widget.add(arrow)

        # create the 'close' button ...
        close_wdg = SpanWdg()
        close_wdg.add(IconWdg("Close", "BS_REMOVE"))
        close_wdg.add_style("float: right")
        close_wdg.add_class("hand")
        close_wdg.add_style("margin: 3px 1px 3px 1px")

        close_wdg.add_behavior({
            'type': 'click_up',
            'cbjs_action': my.get_cancel_script()
        })

        drag_div.add(close_wdg)

        anchor_wdg = SpanWdg()
        drag_div.add(anchor_wdg)
        anchor_wdg.add_style("margin: 5px 5px 3px 1px")
        anchor_wdg.add(IconWdg("Anchor Dialog", "BS_PUSHPIN"))
        anchor_wdg.add_style("float: right")
        anchor_wdg.add_class("hand")

        anchor_wdg.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_dialog_top");
            var position = top.getStyle("position");
            if (position == 'fixed') {
                top.setStyle("position", "absolute");
                bvr.src_el.setStyle("opacity", "1.0");
            }
            else {
                top.setStyle("position", "fixed");
                bvr.src_el.setStyle("opacity", "0.5");
            }
            '''
        })

        width = my.kwargs.get("width")
        if not width:
            width = "100px"
        if width:
            drag_div.add_style("min-width: %s" % width)

        # style
        #drag_div.add_looks("popup")

        drag_div.add_style("text-align: left")
        drag_div.add_class("spt_popup_width")
        drag_div.add_style("border-style: solid")
        drag_div.add_color("border-color", "border")
        drag_div.add_style("border-size: 0 0 1 0")

        drag_handle_div = DivWdg(id='%s_title' % my.name)
        drag_div.add(drag_handle_div)
        drag_handle_div.add_style("padding: 3px;")
        #drag_handle_div.add_gradient("background", "background", +10)
        drag_handle_div.add_color("background", "background", -10)
        drag_handle_div.add_color("color", "color")
        drag_handle_div.add_style("padding: 8px 5px 8px 8px")

        drag_handle_div.add_behavior({
            'type': 'double_click',
            'cbjs_action': my.get_cancel_script()
        })

        # add the drag capability
        drag_handle_div.add_behavior({
            'type':
            'smart_drag',
            'drag_el':
            'spt.popup.get_popup(@);',
            'options': {
                'z_sort': 'bring_forward'
            },
            'ignore_default_motion':
            'false',
            'cbjs_setup':
            '''
            var pointer = bvr.drag_el.getElement(".spt_popup_pointer");
            if (pointer) {
                spt.hide(pointer);
            }
        '''
        })

        # add the content
        content_div = DivWdg()

        title_wdg = my.title_wdg
        if not title_wdg:
            title_wdg = "No Title"
            # if the title is empty, just don't show
        if my.kwargs.get("show_title") in [False, 'false']:
            drag_div.add_style("display: none")
        #else:
        #    content_div.add_style("margin-top: -1px")

        drag_handle_div.add(title_wdg)
        drag_handle_div.add_class("spt_popup_title")
        drag_handle_div.add_style("font-weight: bold")

        widget.add(content_div)
        content_div.add_color("color", "color2")
        content_div.add_gradient("background", "background2")

        content_div.set_id("%s_content" % my.name)
        content_div.add_class("spt_popup_content")
        content_div.add_class("spt_dialog_content")
        content_div.add_style("overflow: hidden")
        content_div.add_style("display: block")
        #content_div.add_style("padding: 5px")

        view = my.kwargs.get("view")
        if view:
            from tactic.ui.panel import CustomLayoutWdg
            my.add(CustomLayoutWdg(view=view))

        if not my.content_wdg:
            my.content_wdg = "No Content"

        content_div.add(my.content_wdg)

        # add the resize icon
        if show_resize:
            icon = IconWdg("Resize", IconWdg.RESIZE_CORNER)
            icon.add_style("cursor: nw-resize")
            icon.add_style("z-index: 1000")
            icon.add_class("spt_popup_resize")
            icon.add_style("float: right")
            icon.add_style("margin-top: -25px")
            icon.add_style("margin-right: 5px")
            icon.add_behavior({
                'type': 'drag',
                "drag_el": '@',
                "cb_set_prefix": 'spt.popup.resize_drag'
            })
            widget.add(icon)

        return widget
Beispiel #11
0
    def get_display(my):
        web = WebContainer.get_web()

        top = my.top
        top.add_class("spt_ace_editor_top")

        script = my.kwargs.get("custom_script")
        if script:
            language = script.get_value("language")
        else:
            language = my.kwargs.get("language")
            if not language:
                language = 'javascript'

        code = my.kwargs.get("code")
        if not code:
            code = ""


        show_options = my.kwargs.get("show_options")
        if show_options in ['false', False]:
            show_options = False
        else:
            show_options = True

        options_div = DivWdg()
        top.add(options_div)
        if not show_options:
            options_div.add_style("display: none")
        options_div.add_color("background", "background3")
        options_div.add_border()
        options_div.add_style("text-align: center")
        options_div.add_style("padding: 2px")



        select = SelectWdg("language")
        select.add_style("width: 100px")
        select.add_style("display: inline")
        options_div.add(select)
        select.add_class("spt_language")
        select.set_option("values", "javascript|python|expression|xml")
        select.add_behavior( {
            'type': 'change',
            'editor_id': my.get_editor_id(),
            'cbjs_action': '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var value = bvr.src_el.value;
            spt.ace_editor.set_language(value);

            //register_change(bvr);

            '''
        } )
 
        select = SelectWdg("font_size")
        select.add_style("width: 100px")
        select.add_style("display: inline")
        options_div.add(select)
        select.set_option("labels", "8 pt|9 pt|10 pt|11 pt|12 pt|14 pt|16 pt")
        select.set_option("values", "8 pt|9pt|10pt|11pt|12pt|14pt|16pt")
        select.set_value("10pt")
        select.add_behavior( {
            'type': 'click_up',
            'editor_id': my.get_editor_id(),
            'cbjs_action': '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var editor = spt.ace_editor.editor;
            var editor_id = spt.ace_editor.editor_id;

            var value = bvr.src_el.value;
            $(editor_id).setStyle("font-size", value)
            //editor.resize();
            '''
        } )



        select = SelectWdg("keybinding")
        select.add_style("width: 100px")
        #options_div.add(select)
        select.set_option("labels", "Ace|Vim|Emacs")
        select.set_option("values", "ace|vim|emacs")
        select.set_value("10pt")
        select.add_behavior( {
            'type': 'change',
            'editor_id': my.get_editor_id(),
            'cbjs_action': '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var editor = spt.ace_editor.editor;
            var editor_id = spt.ace_editor.editor_id;

            var vim = require("ace/keyboard/keybinding/vim").Vim;
            editor.setKeyboardHandler(vim)
            '''
        } )


        editor_div = DivWdg()
        top.add(editor_div)


        if code:
            load_div = DivWdg()
            top.add(load_div)
            readonly = my.kwargs.get("readonly")
            if readonly in ['true', True]:
                readonly = True
            else:
                readonly = False

            load_div.add_behavior( {
                'type': 'load',
                'code': code,
                'language': language,
                'editor_id': my.get_editor_id(),
                'readonly': readonly,
                'cbjs_action': '''
                spt.ace_editor.set_editor(bvr.editor_id);
                var func = function() {
                    var editor = spt.ace_editor.editor;
                    var document = editor.getSession().getDocument();
                    if (bvr.code) {
                        spt.ace_editor.set_value(bvr.code);
                    }
                    spt.ace_editor.set_language(bvr.language);
                    editor.setReadOnly(bvr.readonly);


                    var session = editor.getSession();
                    //session.setUseWrapMode(true);
                    //session.setWrapLimitRange(120, 120);
                };

                var editor = spt.ace_editor.editor;
                if (!editor) {
                    setTimeout( func, 1000);
                }
                else {
                    func();
                }

                '''
            } )




        # theme
        select = SelectWdg("theme")
        select.add_style("width: 100px")
        select.add_style("display: inline")
        options_div.add(select)
        select.set_option("labels", "Eclipse|Twilight|TextMate|Vibrant Ink|Merbivore|Clouds")
        select.set_option("values", "eclipse|twilight|textmate|vibrant_ink|merbivore|clouds")
        select.set_value("twilight")
        select.add_behavior( {
            'type': 'change',
            'editor_id': my.get_editor_id(),
            'cbjs_action': '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var editor = spt.ace_editor.editor;
            var editor_id = spt.ace_editor.editor_id;
            value = bvr.src_el.value;

            editor.setTheme("ace/theme/" + value);
            '''
        } )


        editor_div = DivWdg()
        top.add(editor_div)




        my.text_area.add_style("margin-top: -1px")
        my.text_area.add_style("margin-bottom: 0px")
        my.text_area.add_color("background", "background")
        my.text_area.add_style("font-family: courier new")
        my.text_area.add_border()
        editor_div.add(my.text_area)
        my.text_area.add_style("position: relative")
        #text_area.add_style("margin: 20px")


        size = web.get_form_value("size")
        if size:
            width, height = size.split(",")
        else:
            width = my.kwargs.get("width")
            if not width:
                width = "650px"
            height = my.kwargs.get("height")
            if not height:
                height = "450px"
        my.text_area.add_style("width: %s" % width)
        my.text_area.add_style("height: %s" % height)



        bottom_div = DivWdg()
        top.add(bottom_div)
        bottom_div.add_color("background", "background3")
        bottom_div.add_border()
        bottom_div.add_style("text-align: center")
        bottom_div.add_style("padding: 2px")
        bottom_div.add_style("height: 20px")

        bottom_title = "Script Editor"
        bottom_div.add(bottom_title)

        icon = IconWdg("Resize Editor", IconWdg.RESIZE_CORNER)
        bottom_div.add(icon)
        icon.add_style("float: right")
        icon.add_style("margin-right: -4px")
        icon.add_style("cursor: se-resize")
        icon.add_behavior( {
            'type': 'drag',
            "cb_set_prefix": 'spt.ace_editor.drag_resize',
        } )


        #hidden = HiddenWdg("size")
        hidden = TextWdg("size")
        bottom_div.add(hidden)
        hidden.add_style("width: 85px")
        hidden.add_style("text-align: center")
        hidden.add_style("float: right")
        hidden.add_class("spt_size")
        hidden.set_value("%s,%s" % (width, height))

        theme = top.get_theme()
        if theme == 'dark':
            theme = 'twilight'
        else:
            theme = 'eclipse'

        print "theme: ", theme

        top.add_behavior( {
            'type': 'load',
            'unique_id': my.unique_id,
            'theme': theme,
            'cbjs_action': '''

if (typeof(ace) == 'undefined') {

// fist time loading
spt.ace_editor = {}
spt.ace_editor.editor = null;
spt.ace_editor.editor_id = bvr.unique_id;
spt.ace_editor.theme = bvr.theme;


spt.ace_editor.set_editor = function(editor_id) {
    spt.ace_editor.editor_id = editor_id;
    spt.ace_editor.editor = $(editor_id).editor;
}

spt.ace_editor.set_editor_top = function(top_el) {
    if (!top_el.hasClass("spt_ace_editor")) {
        top_el = top_el.getElement(".spt_ace_editor");
    }

    var editor_id = top_el.getAttribute("id");
    spt.ace_editor.set_editor(editor_id);
}




spt.ace_editor.get_editor = function() {
    return spt.ace_editor.editor;

}



spt.ace_editor.clear_selection = function() {
    var editor = spt.ace_editor.editor;
    editor.clearSelection();

}



spt.ace_editor.get_selection = function() {
    var editor = spt.ace_editor.editor;
    //return editor.getSelection();
    return editor.getCopyText();
}





spt.ace_editor.get_value = function() {
    var editor = spt.ace_editor.editor;
    var document = editor.getSession().getDocument()
    var value = document.getValue();
    return value;
}



spt.ace_editor.set_value = function(value) {
    var editor = spt.ace_editor.editor;
    var document = editor.getSession().getDocument()
    document.setValue(value);
    editor.gotoLine(2);
    editor.resize();
    editor.focus();
}

spt.ace_editor.goto_line = function(number) {
    var editor = spt.ace_editor.editor;
    var document = editor.getSession().getDocument()
    editor.gotoLine(2);
    editor.resize();
    editor.focus();
 

}


spt.ace_editor.insert = function(value) {
    var editor = spt.ace_editor.editor;
    var position = editor.getCursorPosition();
    var doc = editor.getSession().getDocument()
    doc.insertInLine(position, value);
}

 
spt.ace_editor.insert_lines = function(values) {
    var editor = spt.ace_editor.editor;
    var position = editor.getCursorPosition();
    var doc = editor.getSession().getDocument()
    doc.insertLines(position.row, values);
}



spt.ace_editor.get_document = function() {
    var document = spt.ace_editor.editor.getSession().getDocument()
    return document;

}




spt.ace_editor.set_language = function(value) {
    if (!value) {
        value = 'javascript';
    }

    var editor = spt.ace_editor.editor;
    var top = $(spt.ace_editor.editor_id).getParent(".spt_ace_editor_top");
    var lang_el = top.getElement(".spt_language");

    for ( var i = 0; i < lang_el.options.length; i++ ) {
        if ( lang_el.options[i].value == value ) {
            lang_el.options[i].selected = true;
            break;
        }
    }



    var session = editor.getSession();
    var mode;
    if (value == 'python') {
        mode = require("ace/mode/python").Mode;
    }
    else if (value == 'xml') {
        mode = require("ace/mode/xml").Mode;
    }
    else if (value == 'expression') {
        mode = require("ace/mode/xml").Mode;
    }
    else {
        mode = require("ace/mode/javascript").Mode;
    }
    session.setMode( new mode() );
}

spt.ace_editor.drag_start_x;
spt.ace_editor.drag_start_y;
spt.ace_editor.drag_size;
spt.ace_editor.drag_editor_el;
spt.ace_editor.drag_size_el;
spt.ace_editor.drag_resize_setup = function(evt, bvr, mouse_411)
{
    var editor = spt.ace_editor.editor;
    var editor_id = spt.ace_editor.editor_id;

    spt.ace_editor.drag_start_x = mouse_411.curr_x;
    spt.ace_editor.drag_start_y = mouse_411.curr_y;

    var editor_el = $(editor_id);
    spt.ace_editor.drag_editor_el = editor_el;
    spt.ace_editor.drag_size = editor_el.getSize();

    var top = bvr.src_el.getParent(".spt_ace_editor_top");
    spt.ace_editor.drag_size_el = top.getElement(".spt_size");
}


spt.ace_editor.drag_resize_motion = function(evt, bvr, mouse_411)
{
    var diff_x = parseFloat(mouse_411.curr_x - spt.ace_editor.drag_start_x);
    var diff_y = parseFloat(mouse_411.curr_y - spt.ace_editor.drag_start_y);

    var size = spt.ace_editor.drag_size;


    var editor_el = spt.ace_editor.drag_editor_el;

    var width = size.x + diff_x
    if (width < 300) {
        width = 300;
    }
    var height = size.y + diff_y
    if (height < 200) {
        height = 200;
    }

    editor_el.setStyle("width", width);
    editor_el.setStyle("height", height);

    spt.ace_editor.drag_size_el.value = width + "," + height;

    var editor = spt.ace_editor.editor;
    editor.resize();

}
    var js_files = [
        "ace/ace-0.2.0/src/ace.js",
        //"ace/ace-0.2.0/src/ace-uncompressed.js",
    ];


   

    var ace_setup =  function() {
        var editor = ace.edit(bvr.unique_id);
        spt.ace_editor.editor = editor;

        // put the editor into the dom
        spt.ace_editor.editor_id = bvr.unique_id;
        $(bvr.unique_id).editor = editor;

        editor.setTheme("ace/theme/" + spt.ace_editor.theme);
        var JavaScriptMode = require("ace/mode/javascript").Mode;
        editor.getSession().setMode(new JavaScriptMode())
    }

    


    spt.dom.load_js(js_files, function() { 
    
        ace; require; define; 

        var core_js_files = [
        "ace/ace-0.2.0/src/mode-javascript.js",
         "ace/ace-0.2.0/src/mode-xml.js",
            "ace/ace-0.2.0/src/mode-python.js",
             "ace/ace-0.2.0/src/theme-twilight.js",
               
            "ace/ace-0.2.0/src/theme-textmate.js",
            "ace/ace-0.2.0/src/theme-vibrant_ink.js",
            "ace/ace-0.2.0/src/theme-merbivore.js",
            "ace/ace-0.2.0/src/theme-clouds.js",
            "ace/ace-0.2.0/src/theme-eclipse.js"
        ];
        //var supp_js_files = [];
           
         
        

        spt.dom.load_js(core_js_files, ace_setup);
        //spt.dom.load_js(supp_js_files);      
        });
   

    





}
else {
    var editor = ace.edit(bvr.unique_id);
    editor.setTheme("ace/theme/" +  bvr.theme);
    var JavaScriptMode = require("ace/mode/javascript").Mode;
   
    editor.getSession().setMode(new JavaScriptMode())

    spt.ace_editor.editor_id = bvr.unique_id;
    spt.ace_editor.editor = editor;
    $(bvr.unique_id).editor = editor;

}
            '''
        } )


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

        element_data_dict = {}

        config = self.get_config()
        element_names = config.get_element_names()

        content_wdg = DivWdg()
        content_wdg.add_class("spt_simple_search_top")

        onload_js = DivWdg()
        content_wdg.add(onload_js)
        onload_js.add_behavior( {
            'type': 'load',
            'cbjs_action': self.get_onload_js()
        } )




        if not element_names:
            element_names = ['keywords']

        self.set_content(content_wdg)

        
        # this is somewhat duplicated logic from alter_search, but since this is called 
        # in ViewPanelWdg, it's a diff instance and needs to retrieve again
        filter_data = FilterData.get()

        filter_view = self.kwargs.get("filter_view")
        if filter_view:
            search = Search("config/widget_config")
            search.add_filter("view", filter_view)
            search.add_filter("category", "search_filter")
            search.add_filter("search_type", self.search_type)
            filter_config = search.get_sobject()
            if filter_config:
                filter_xml = filter_config.get_xml_value("config")
                filter_value = filter_xml.get_value("config/filter/values")
                if filter_value:
                    data_list = jsonloads(filter_value)

        else:
            data_list = filter_data.get_values_by_prefix(self.prefix)



        for data in data_list:
            handler = data.get("handler")
            element_name = data.get("element_name")
            if not element_name:
                continue

            element_data_dict[element_name] = data

        elements_wdg = DivWdg()
        content_wdg.add(elements_wdg)
        elements_wdg.add_color("color", "color")
        elements_wdg.add_style("padding-top: 10px")
        elements_wdg.add_style("padding-bottom: 15px")

        #elements_wdg.add_color("background", "background3", 0)
        elements_wdg.add_color("background", "background", -3)
        elements_wdg.add_border()



        if len(element_names) == 1:
            elements_wdg.add_style("border-width: 0px 0px 0px 0px" )
            elements_wdg.add_style("padding-right: 50px" )
        else:
            elements_wdg.add_style("border-width: 0px 0px 0px 0px" )

        table = Table()
        table.add_color("color", "color")
        elements_wdg.add(table)
        table.add_class("spt_simple_search_table")
        
        columns = self.kwargs.get("columns")
        if not columns:
            columns = 2
        else:
            columns = int(columns) 
       
        num_rows = int(len(element_names)/columns)+1
        tot_rows = int(len(element_names)/columns)+1
        project_code = Project.get_project_code()
        # self.search_type could be the same as self.base_search_type
        full_search_type = SearchType.build_search_type(self.search_type, project_code)


        visible_rows = self.kwargs.get("visible_rows")
        if visible_rows:
            visible_rows = int(visible_rows)
            num_rows = visible_rows
        else:
            visible_rows = 0

        titles = config.get_element_titles() 
        row_count = 0
        for i, element_name in enumerate(element_names):
            attrs = config.get_element_attributes(element_name)
            if i % columns == 0:

                if visible_rows and row_count == visible_rows:
                    tr, td = table.add_row_cell("+ more ...")
                    td.add_class("hand")
                    td.add_class("SPT_DTS")
                    td.add_class("spt_toggle")
                    td.add_style("padding-left: 10px")

                    td.add_behavior( {
                        'type': 'click_up',
                        'visible_rows': visible_rows,
                        'cbjs_action': '''
                        var top = bvr.src_el.getParent(".spt_simple_search_table");
                        var expand = true;
                        var rows = top.getElements(".spt_simple_search_row");
                        for (var i = 0; i < rows.length; i++) {
                            var row = rows[i];
                            if (row.getStyle("display") == "none") {
                                row.setStyle("display", "");
                            }
                            else {
                                row.setStyle("display", "none");
                                expand = false;
                            }
                        }
                        var spacer = top.getElements(".spt_spacer");
                        var cell = top.getElement(".spt_toggle");
                        if (expand) {
                            spacer.setStyle("height", (rows.length+bvr.visible_rows)*20);
                            cell.innerHTML = "- less ...";
                        }
                        else {
                            spacer.setStyle("height", bvr.visible_rows*20);
                            cell.innerHTML = "+ more ...";
                        }

                        '''
                    } )


                tr = table.add_row()
                if visible_rows and row_count >= visible_rows:

                    tr.add_class("spt_simple_search_row")
                    tr.add_style("display: none")
                    tr.add_style("height: 0px")

                row_count += 1

            icon_td = table.add_cell()
            title_td = table.add_cell()
            element_td = table.add_cell()

            # need to add these to all the elements because it is all separated
            # by table tds
            icon_td.add_class("spt_element_item")
            icon_td.add_attr("spt_element_name", element_name)
            title_td.add_class("spt_element_item")
            title_td.add_attr("spt_element_name", element_name)
            element_td.add_class("spt_element_item")
            element_td.add_attr("spt_element_name", element_name)

            # show the title
            title_td.add_style("text-align: left")
            title_td.add_style("padding-right: 5px")
            title_td.add_style("min-width: 60px")



            element_wdg = DivWdg()
            if attrs.get('view') == 'false':
                element_wdg.add_style('display: none')
            element_td.add(element_wdg)



            if i >= 0  and i < columns -1 and len(element_names) > 1:
                spacer = DivWdg()
                spacer.add_class("spt_spacer")
                spacer.add_style("border-style: solid")
                spacer.add_style("border-width: 0 0 0 0")
                #spacer.add_style("height: %spx" % (num_rows*20))
                spacer.add_style("height: %spx" % (num_rows*10))
                spacer.add_style("width: 10px")
                spacer.add_style("border-color: %s" % spacer.get_color("border") )
                spacer.add("&nbsp;")
                td = table.add_cell(spacer)
                td.add_attr("rowspan", tot_rows)

            element_wdg.add_style("padding: 4px 10px 4px 5px")
            element_wdg.add_class("spt_table_search")
            element_wdg.add_style("margin: 1px")
            element_wdg.add_style("min-height: 20px")
            element_wdg.add_style("min-width: 250px")

            # this is done at get_top()
            #element_wdg.add_class("spt_search")
            element_wdg.add( HiddenWdg("prefix", self.prefix))

            display_handler = config.get_display_handler(element_name)
            element_wdg.add( HiddenWdg("handler", display_handler))


            element_wdg.add( HiddenWdg("element_name", element_name))
        

            from pyasm.widget import ExceptionWdg
            try:
                widget = config.get_display_widget(element_name)
                if widget:
                    widget.set_title(titles[i])

            except Exception as e:
                element_wdg.add(ExceptionWdg(e))
                continue


            if not widget:
                # the default for KeywordFilterElementWdg is mode=keyword
                if not self.column_choice:
                    self.column_choice = self.get_search_col(self.search_type)
                widget = KeywordFilterElementWdg(column=self.column_choice)
                widget.set_name(element_name)
                


            from pyasm.widget import IconWdg
            icon_div = DivWdg()
            icon_td.add(icon_div)
            icon_div.add_style("width: 20px")
            icon_div.add_style("margin-top: -2px")
            icon_div.add_style("padding-left: 6px")
            icon_div.add_class("spt_filter_top")


            widget.set_show_title(False)
            #element_wdg.add("%s: " % title)
            data = element_data_dict.get(element_name)

			
            view_panel_keywords = self.kwargs.get("keywords")
            #user data takes precedence over view_panel_keywords
            if isinstance(widget, KeywordFilterElementWdg):
                if view_panel_keywords:
                    widget.set_value("value", view_panel_keywords)
            if data:
                widget.set_values(data)

                
           
			    
                    

            if isinstance(widget, KeywordFilterElementWdg) and not full_search_type.startswith('sthpw/sobject_list'):
                widget.set_option('filter_search_type', full_search_type)
            try:
                if attrs.get('view') != 'false':
                    title_td.add(widget.get_title_wdg())

                element_wdg.add(widget.get_buffer_display())
            except Exception as e:
                element_wdg.add(ExceptionWdg(e))
                continue
                


            icon = IconWdg("Filter Set", "BS_ASTERISK")
            #icon.add_style("color", "#393")
            icon_div.add(icon)
            icon.add_class("spt_filter_set")
            icon.add_class("hand")
            icon.add_attr("spt_element_name", element_name)

            icon.add_behavior( {
                'type': 'click',
                'cbjs_action': '''
                var element_name = bvr.src_el.getAttribute("spt_element_name");
                spt.simple_search.clear_element(element_name);
                '''

            } )

            if not widget.is_set():
                icon.add_style("display: none")

            else:
                color = icon_div.get_color("background", -10)
                icon_td.add_style("background-color", color)
                title_td.add_style("background-color", color)
                element_td.add_style("background-color", color)



        #elements_wdg.add("<br clear='all'/>")
        top = self.get_top()
        return top
Beispiel #13
0
    def get_display(my):


        top = DivWdg()
        title = DivWdg()

        top.add(title)
        top.add_color("background", "background")
        top.add_style("margin: 0px 10px 15px 10px")
        top.set_box_shadow()

        title.add("More Information")
        title.add_style("font-size: 16px")
        title.add_style("padding: 5px")
        title.add_gradient("background", "background")
        title.add_border()
        title.set_round_corners(corners=['TL','TR'])

        content_wdg = DivWdg()
        top.add(content_wdg)
        content_wdg.add_border()
        content_wdg.add_style("padding: 20px")

        content_wdg.add("<div style='font-size: 12px'>The following links will help you find out more information on how to set-up or use TACTIC.</div>")
        content_wdg.add("<hr/>")

        hover = title.get_color("background", -10)


        links_div = DivWdg()
        links_div.add_style("padding: 10px")
        content_wdg.add(links_div)


        # documentation linke
        link_div = DivWdg()
        link_div.add_style("padding-left: 10px")
        links_div.add(link_div)


        icon = IconWdg("Documentation", IconWdg.DOCUMENTATION)

        icon.set_box_shadow("2px 2px 5px")
        icon.add_border()
        icon.add_style("padding: 5px 3px 5px 7px")
        icon.set_round_corners()
        icon.add_color("background", "background3")

        link_div.add(icon)
        link_div.add("&nbsp;"*2)

        link = HtmlElement.href("Documentation", "/doc/", target="_blank")
        link_div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.help.set_top();
            spt.help.load_alias("main");
            '''
        } )

        link_div.add_behavior( {
        'type': 'hover',
        'color': hover,
        'cbjs_action_over': '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
        'cbjs_action_out': '''
        bvr.src_el.setStyle("background", "");
        '''
        } )
        link_div.add(link)
        link.add_color("color", "color")

        links_div.add("<br/>")



        link_div = DivWdg()
        link_div.add_style("padding-left: 10px")
        links_div.add(link_div)

        icon = IconWdg("Community", IconWdg.COMMUNITY)

        icon.set_box_shadow("2px 2px 5px")
        icon.add_border()
        icon.add_style("padding: 5px 3px 5px 7px")
        icon.set_round_corners()
        icon.set_round_corners()
        icon.add_color("background", "background3")

        link_div.add(icon)
        link_div.add("&nbsp;"*2)
        link = HtmlElement.href("Community", "http://community.southpawtech.com", target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link_div.add_behavior( {
        'type': 'hover',
        'color': hover,
        'cbjs_action_over': '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
        'cbjs_action_out': '''
        bvr.src_el.setStyle("background", "");
        '''
        } )

        links_div.add("<br/>")

        # documentation link
        link_div = DivWdg()
        link_div.add_style("padding-left: 10px")
        links_div.add(link_div)

        icon = IconWdg("Support", IconWdg.WEBSITE)

        icon.set_box_shadow("2px 2px 5px")
        icon.add_border()
        icon.add_style("padding: 5px 3px 5px 7px")
        icon.set_round_corners()
        icon.add_color("background", "background3")


        link_div.add(icon)
        link_div.add("&nbsp;"*2)

        link = HtmlElement.href("Support", "http://www.southpawtech.com", target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link_div.add_behavior( {
        'type': 'hover',
        'color': hover,
        'cbjs_action_over': '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
        'cbjs_action_out': '''
        bvr.src_el.setStyle("background", "");
        '''
        } )



        return top
Beispiel #14
0
    def get_display(self):
        top = DivWdg()

        search_type = self.kwargs.get("search_type")
        view = self.kwargs.get("view")
        element_name = self.kwargs.get("element_name")

        config_view = WidgetConfigView.get_by_search_type(search_type, view)

        #inner_div = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10")
        inner_div = RoundedCornerDivWdg(hex_color_code="272727",
                                        corner_size="10")
        inner_div.set_dimensions(width_str='400px', content_height_str='600px')
        top.add(inner_div)

        # add the save button
        buttons_list = []
        buttons_list.append({
            'label': 'Save as View',
            'tip': 'Save as View',
            'bvr': {
                'cbjs_action': "alert('Not Implemented')"
            }
        })
        buttons_list.append({
            'label': 'Save as Def',
            'tip': 'Save as Definition',
            'bvr': {
                'cbjs_action': "alert('Not Implemented')"
            }
        })

        buttons = TextBtnSetWdg(float="right",
                                buttons=buttons_list,
                                spacing=6,
                                size='small',
                                side_padding=4)

        inner_div.add(buttons)

        title_div = DivWdg()
        title_div.add_style("margin-bottom: 10px")
        title_div.add_class("maq_search_bar")
        title_div.add("Element Definition")
        inner_div.add(title_div)

        test = SimpleElementDefinitionWdg(config_view=config_view,
                                          element_name=element_name)
        inner_div.add(test)

        config_title_wdg = DivWdg()
        inner_div.add(config_title_wdg)
        config_title_wdg.add("<b>Definitions in config</b>")
        config_title_wdg.add_style("margin: 15px 0px 5px 0px")

        for config in config_view.get_configs():
            view = config.get_view()
            xml = config.get_element_xml(element_name)

            config_div = DivWdg()
            inner_div.add(config_div)

            # add the title
            from pyasm.widget import SwapDisplayWdg, IconWdg

            view_div = DivWdg()
            view_div.add_class("spt_view")
            config_div.add(view_div)

            if not xml:
                icon_wdg = IconWdg("Nothing defined", IconWdg.DOT_RED)
                icon_wdg.add_style("float: right")
                view_div.add(icon_wdg)
            else:
                icon_wdg = IconWdg("Is defined", IconWdg.DOT_GREEN)
                icon_wdg.add_style("float: right")
                view_div.add(icon_wdg)

            swap = SwapDisplayWdg()
            view_div.add(swap)
            swap.add_action_script('''
                var info_wdg = bvr.src_el.getParent('.spt_view').getElement('.spt_info');
                spt.toggle_show_hide(info_wdg);
            ''')

            mode = "predefined"
            file_path = config.get_file_path()
            if not file_path:
                mode = "database"
            elif file_path == 'generated':
                mode = 'generated'

            # display the title
            view_div.add("%s" % view)
            view_div.add(" - [%s]" % mode)

            info_div = DivWdg()
            info_div.add_class("spt_info")
            info_div.add_style("margin-left: 20px")
            info_div.add_style("display: none")
            #if not xml:
            #    info_div.add_style("display: none")
            #else:
            #    swap.set_off()
            view_div.add(info_div)

            path_div = DivWdg()
            if not file_path:
                file_path = mode
            path_div.add("Defined in: %s" % file_path)
            info_div.add(path_div)

            text_wdg = TextAreaWdg()
            text_wdg.set_option("rows", 15)
            text_wdg.set_option("cols", 80)
            text_wdg.set_value(xml)
            info_div.add(text_wdg)

            #view_div.add("<hr/>")

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

        element_data_dict = {}

        config = self.get_config()
        element_names = config.get_element_names()

        content_wdg = DivWdg()
        content_wdg.add_class("spt_simple_search_top")

        onload_js = DivWdg()
        content_wdg.add(onload_js)
        onload_js.add_behavior({
            'type': 'load',
            'cbjs_action': self.get_onload_js()
        })

        if not element_names:
            element_names = ['keywords']

        self.set_content(content_wdg)

        # this is somewhat duplicated logic from alter_search, but since this is called
        # in ViewPanelWdg, it's a diff instance and needs to retrieve again
        filter_data = FilterData.get()

        filter_view = self.kwargs.get("filter_view")
        if filter_view:
            search = Search("config/widget_config")
            search.add_filter("view", filter_view)
            search.add_filter("category", "search_filter")
            search.add_filter("search_type", self.search_type)
            filter_config = search.get_sobject()
            if filter_config:
                filter_xml = filter_config.get_xml_value("config")
                filter_value = filter_xml.get_value("config/filter/values")
                if filter_value:
                    data_list = jsonloads(filter_value)

        else:
            data_list = filter_data.get_values_by_prefix(self.prefix)

        for data in data_list:
            handler = data.get("handler")
            element_name = data.get("element_name")
            if not element_name:
                continue

            element_data_dict[element_name] = data

        elements_wdg = DivWdg()
        content_wdg.add(elements_wdg)
        elements_wdg.add_color("color", "color")
        elements_wdg.add_style("padding-top: 10px")
        elements_wdg.add_style("padding-bottom: 15px")

        #elements_wdg.add_color("background", "background3", 0)
        elements_wdg.add_color("background", "background", -3)
        elements_wdg.add_border()

        if len(element_names) == 1:
            elements_wdg.add_style("border-width: 0px 0px 0px 0px")
            elements_wdg.add_style("padding-right: 50px")
        else:
            elements_wdg.add_style("border-width: 0px 0px 0px 0px")

        table = Table()
        table.add_color("color", "color")
        elements_wdg.add(table)
        table.add_class("spt_simple_search_table")

        columns = self.kwargs.get("columns")
        if not columns:
            columns = 2
        else:
            columns = int(columns)

        num_rows = int(len(element_names) / columns) + 1
        tot_rows = int(len(element_names) / columns) + 1
        project_code = Project.get_project_code()
        # self.search_type could be the same as self.base_search_type
        full_search_type = SearchType.build_search_type(
            self.search_type, project_code)

        visible_rows = self.kwargs.get("visible_rows")
        if visible_rows:
            visible_rows = int(visible_rows)
            num_rows = visible_rows
        else:
            visible_rows = 0

        titles = config.get_element_titles()
        row_count = 0
        for i, element_name in enumerate(element_names):
            attrs = config.get_element_attributes(element_name)
            if i % columns == 0:

                if visible_rows and row_count == visible_rows:
                    tr, td = table.add_row_cell("+ more ...")
                    td.add_class("hand")
                    td.add_class("SPT_DTS")
                    td.add_class("spt_toggle")
                    td.add_style("padding-left: 10px")

                    td.add_behavior({
                        'type':
                        'click_up',
                        'visible_rows':
                        visible_rows,
                        'cbjs_action':
                        '''
                        var top = bvr.src_el.getParent(".spt_simple_search_table");
                        var expand = true;
                        var rows = top.getElements(".spt_simple_search_row");
                        for (var i = 0; i < rows.length; i++) {
                            var row = rows[i];
                            if (row.getStyle("display") == "none") {
                                row.setStyle("display", "");
                            }
                            else {
                                row.setStyle("display", "none");
                                expand = false;
                            }
                        }
                        var spacer = top.getElements(".spt_spacer");
                        var cell = top.getElement(".spt_toggle");
                        if (expand) {
                            spacer.setStyle("height", (rows.length+bvr.visible_rows)*20);
                            cell.innerHTML = "- less ...";
                        }
                        else {
                            spacer.setStyle("height", bvr.visible_rows*20);
                            cell.innerHTML = "+ more ...";
                        }

                        '''
                    })

                tr = table.add_row()
                if visible_rows and row_count >= visible_rows:

                    tr.add_class("spt_simple_search_row")
                    tr.add_style("display: none")
                    tr.add_style("height: 0px")

                row_count += 1

            icon_td = table.add_cell()
            title_td = table.add_cell()
            element_td = table.add_cell()

            # need to add these to all the elements because it is all separated
            # by table tds
            icon_td.add_class("spt_element_item")
            icon_td.add_attr("spt_element_name", element_name)
            title_td.add_class("spt_element_item")
            title_td.add_attr("spt_element_name", element_name)
            element_td.add_class("spt_element_item")
            element_td.add_attr("spt_element_name", element_name)

            # show the title
            title_td.add_style("text-align: left")
            title_td.add_style("padding-right: 5px")
            title_td.add_style("min-width: 60px")

            element_wdg = DivWdg()
            if attrs.get('view') == 'false':
                element_wdg.add_style('display: none')
            element_td.add(element_wdg)

            if i >= 0 and i < columns - 1 and len(element_names) > 1:
                spacer = DivWdg()
                spacer.add_class("spt_spacer")
                spacer.add_style("border-style: solid")
                spacer.add_style("border-width: 0 0 0 0")
                #spacer.add_style("height: %spx" % (num_rows*20))
                spacer.add_style("height: %spx" % (num_rows * 10))
                spacer.add_style("width: 10px")
                spacer.add_style("border-color: %s" %
                                 spacer.get_color("border"))
                spacer.add("&nbsp;")
                td = table.add_cell(spacer)
                td.add_attr("rowspan", tot_rows)

            element_wdg.add_style("padding: 4px 10px 4px 5px")
            element_wdg.add_class("spt_table_search")
            element_wdg.add_style("margin: 1px")
            element_wdg.add_style("min-height: 20px")
            element_wdg.add_style("min-width: 250px")

            # this is done at get_top()
            #element_wdg.add_class("spt_search")
            element_wdg.add(HiddenWdg("prefix", self.prefix))

            display_handler = config.get_display_handler(element_name)
            element_wdg.add(HiddenWdg("handler", display_handler))

            element_wdg.add(HiddenWdg("element_name", element_name))

            from pyasm.widget import ExceptionWdg
            try:
                widget = config.get_display_widget(element_name)
                if widget:
                    widget.set_title(titles[i])

            except Exception as e:
                element_wdg.add(ExceptionWdg(e))
                continue

            if not widget:
                # the default for KeywordFilterElementWdg is mode=keyword
                if not self.column_choice:
                    self.column_choice = self.get_search_col(self.search_type)
                widget = KeywordFilterElementWdg(column=self.column_choice)
                widget.set_name(element_name)

            from pyasm.widget import IconWdg
            icon_div = DivWdg()
            icon_td.add(icon_div)
            icon_div.add_style("width: 20px")
            icon_div.add_style("margin-top: -2px")
            icon_div.add_style("padding-left: 6px")
            icon_div.add_class("spt_filter_top")

            widget.set_show_title(False)
            #element_wdg.add("%s: " % title)
            data = element_data_dict.get(element_name)

            view_panel_keywords = self.kwargs.get("keywords")
            #user data takes precedence over view_panel_keywords
            if isinstance(widget, KeywordFilterElementWdg):
                if view_panel_keywords:
                    widget.set_value("value", view_panel_keywords)
            if data:
                widget.set_values(data)

            if isinstance(
                    widget, KeywordFilterElementWdg
            ) and not full_search_type.startswith('sthpw/sobject_list'):
                widget.set_option('filter_search_type', full_search_type)
            try:
                if attrs.get('view') != 'false':
                    title_td.add(widget.get_title_wdg())

                element_wdg.add(widget.get_buffer_display())
            except Exception as e:
                element_wdg.add(ExceptionWdg(e))
                continue

            icon = IconWdg("Filter Set", "BS_ASTERISK")
            #icon.add_style("color", "#393")
            icon_div.add(icon)
            icon.add_class("spt_filter_set")
            icon.add_class("hand")
            icon.add_attr("spt_element_name", element_name)

            icon.add_behavior({
                'type':
                'click',
                'cbjs_action':
                '''
                var element_name = bvr.src_el.getAttribute("spt_element_name");
                spt.simple_search.clear_element(element_name);
                '''
            })

            if not widget.is_set():
                icon.add_style("display: none")

            else:
                color = icon_div.get_color("background", -10)
                icon_td.add_style("background-color", color)
                title_td.add_style("background-color", color)
                element_td.add_style("background-color", color)

        #elements_wdg.add("<br clear='all'/>")
        top = self.get_top()
        return top
Beispiel #16
0
    def get_display(my):
        web = WebContainer.get_web()

        top = my.top
        top.add_class("spt_ace_editor_top")

        script = my.kwargs.get("custom_script")
        if script:
            language = script.get_value("language")
        else:
            language = my.kwargs.get("language")
            if not language:
                language = 'javascript'

        code = my.kwargs.get("code")
        if not code:
            code = ""


        show_options = my.kwargs.get("show_options")
        if show_options in ['false', False]:
            show_options = False
        else:
            show_options = True

        options_div = DivWdg()
        top.add(options_div)
        if not show_options:
            options_div.add_style("display: none")
        options_div.add_color("background", "background3")
        options_div.add_border()
        options_div.add_style("text-align: center")
        options_div.add_style("padding: 2px")



        select = SelectWdg("language")
        select.add_style("width: 100px")
        select.add_style("display: inline")
        options_div.add(select)
        select.add_class("spt_language")
        select.set_option("values", "javascript|server_js|python|expression|xml")
        select.add_behavior( {
            'type': 'change',
            'editor_id': my.get_editor_id(),
            'cbjs_action': '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var value = bvr.src_el.value;
            spt.ace_editor.set_language(value);

            //register_change(bvr);

            '''
        } )
 
        select = SelectWdg("font_size")
        select.add_style("width: 100px")
        select.add_style("display: inline")
        options_div.add(select)
        select.set_option("labels", "8 pt|9 pt|10 pt|11 pt|12 pt|14 pt|16 pt")
        select.set_option("values", "8 pt|9pt|10pt|11pt|12pt|14pt|16pt")
        select.set_value("10pt")
        select.add_behavior( {
            'type': 'click_up',
            'editor_id': my.get_editor_id(),
            'cbjs_action': '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var editor = spt.ace_editor.editor;
            var editor_id = spt.ace_editor.editor_id;

            var value = bvr.src_el.value;
            $(editor_id).setStyle("font-size", value)
            //editor.resize();
            '''
        } )



        select = SelectWdg("keybinding")
        select.add_style("width: 100px")
        #options_div.add(select)
        select.set_option("labels", "Ace|Vim|Emacs")
        select.set_option("values", "ace|vim|emacs")
        select.set_value("10pt")
        select.add_behavior( {
            'type': 'change',
            'editor_id': my.get_editor_id(),
            'cbjs_action': '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var editor = spt.ace_editor.editor;
            var editor_id = spt.ace_editor.editor_id;

            var vim = require("ace/keyboard/keybinding/vim").Vim;
            editor.setKeyboardHandler(vim)
            '''
        } )


        editor_div = DivWdg()
        top.add(editor_div)


        if code:
            load_div = DivWdg()
            top.add(load_div)
            readonly = my.kwargs.get("readonly")
            if readonly in ['true', True]:
                readonly = True
            else:
                readonly = False

            load_div.add_behavior( {
                'type': 'load',
                'code': code,
                'language': language,
                'editor_id': my.get_editor_id(),
                'readonly': readonly,
                'cbjs_action': '''
                spt.ace_editor.set_editor(bvr.editor_id);
                var func = function() {
                    var editor = spt.ace_editor.editor;
                    var document = editor.getSession().getDocument();
                    if (bvr.code) {
                        spt.ace_editor.set_value(bvr.code);
                    }
                    spt.ace_editor.set_language(bvr.language);
                    editor.setReadOnly(bvr.readonly);


                    var session = editor.getSession();
                    //session.setUseWrapMode(true);
                    //session.setWrapLimitRange(120, 120);
                };

                var editor = spt.ace_editor.editor;
                if (!editor) {
                    setTimeout( func, 1000);
                }
                else {
                    func();
                }

                '''
            } )




        # theme
        select = SelectWdg("theme")
        select.add_style("width: 100px")
        select.add_style("display: inline")
        options_div.add(select)
        select.set_option("labels", "Eclipse|Twilight|TextMate|Vibrant Ink|Merbivore|Clouds")
        select.set_option("values", "eclipse|twilight|textmate|vibrant_ink|merbivore|clouds")
        select.set_value("twilight")
        select.add_behavior( {
            'type': 'change',
            'editor_id': my.get_editor_id(),
            'cbjs_action': '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var editor = spt.ace_editor.editor;
            var editor_id = spt.ace_editor.editor_id;
            value = bvr.src_el.value;

            editor.setTheme("ace/theme/" + value);
            '''
        } )


        editor_div = DivWdg()
        top.add(editor_div)




        my.text_area.add_style("margin-top: -1px")
        my.text_area.add_style("margin-bottom: 0px")
        my.text_area.add_color("background", "background")
        my.text_area.add_style("font-family: courier new")
        my.text_area.add_border()
        editor_div.add(my.text_area)
        my.text_area.add_style("position: relative")
        #text_area.add_style("margin: 20px")


        size = web.get_form_value("size")
        if size:
            width, height = size.split(",")
        else:
            width = my.kwargs.get("width")
            if not width:
                width = "650px"
            height = my.kwargs.get("height")
            if not height:
                height = "450px"
        my.text_area.add_style("width: %s" % width)
        my.text_area.add_style("height: %s" % height)



        bottom_div = DivWdg()
        top.add(bottom_div)
        bottom_div.add_color("background", "background3")
        bottom_div.add_border()
        bottom_div.add_style("text-align: center")
        bottom_div.add_style("padding: 2px")
        bottom_div.add_style("height: 20px")

        bottom_title = "Script Editor"
        bottom_div.add(bottom_title)

        icon = IconWdg("Resize Editor", IconWdg.RESIZE_CORNER)
        bottom_div.add(icon)
        icon.add_style("float: right")
        icon.add_style("margin-right: -4px")
        icon.add_style("cursor: se-resize")
        icon.add_behavior( {
            'type': 'drag',
            "cb_set_prefix": 'spt.ace_editor.drag_resize',
        } )


        #hidden = HiddenWdg("size")
        hidden = TextWdg("size")
        bottom_div.add(hidden)
        hidden.add_style("width: 85px")
        hidden.add_style("text-align: center")
        hidden.add_style("float: right")
        hidden.add_class("spt_size")
        hidden.set_value("%s,%s" % (width, height))

        theme = top.get_theme()
        if theme == 'dark':
            theme = 'twilight'
        else:
            theme = 'eclipse'

        print "theme: ", theme

        top.add_behavior( {
            'type': 'load',
            'unique_id': my.unique_id,
            'theme': theme,
            'cbjs_action': '''

if (typeof(ace) == 'undefined') {

// fist time loading
spt.ace_editor = {}
spt.ace_editor.editor = null;
spt.ace_editor.editor_id = bvr.unique_id;
spt.ace_editor.theme = bvr.theme;


spt.ace_editor.set_editor = function(editor_id) {
    spt.ace_editor.editor_id = editor_id;
    spt.ace_editor.editor = $(editor_id).editor;
}

spt.ace_editor.set_editor_top = function(top_el) {
    if (!top_el.hasClass("spt_ace_editor")) {
        top_el = top_el.getElement(".spt_ace_editor");
    }

    var editor_id = top_el.getAttribute("id");
    spt.ace_editor.set_editor(editor_id);
}




spt.ace_editor.get_editor = function() {
    return spt.ace_editor.editor;

}



spt.ace_editor.clear_selection = function() {
    var editor = spt.ace_editor.editor;
    editor.clearSelection();

}



spt.ace_editor.get_selection = function() {
    var editor = spt.ace_editor.editor;
    //return editor.getSelection();
    return editor.getCopyText();
}





spt.ace_editor.get_value = function() {
    var editor = spt.ace_editor.editor;
    var document = editor.getSession().getDocument()
    var value = document.getValue();
    return value;
}



spt.ace_editor.set_value = function(value) {
    var editor = spt.ace_editor.editor;
    var document = editor.getSession().getDocument()
    document.setValue(value);
    editor.gotoLine(2);
    editor.resize();
    editor.focus();
}

spt.ace_editor.goto_line = function(number) {
    var editor = spt.ace_editor.editor;
    var document = editor.getSession().getDocument()
    editor.gotoLine(2);
    editor.resize();
    editor.focus();
 

}


spt.ace_editor.insert = function(value) {
    var editor = spt.ace_editor.editor;
    var position = editor.getCursorPosition();
    var doc = editor.getSession().getDocument()
    doc.insertInLine(position, value);
}

 
spt.ace_editor.insert_lines = function(values) {
    var editor = spt.ace_editor.editor;
    var position = editor.getCursorPosition();
    var doc = editor.getSession().getDocument()
    doc.insertLines(position.row, values);
}



spt.ace_editor.get_document = function() {
    var document = spt.ace_editor.editor.getSession().getDocument()
    return document;

}




spt.ace_editor.set_language = function(value) {
    if (!value) {
        value = 'javascript';
    }

    var editor = spt.ace_editor.editor;
    var top = $(spt.ace_editor.editor_id).getParent(".spt_ace_editor_top");
    var lang_el = top.getElement(".spt_language");

    for ( var i = 0; i < lang_el.options.length; i++ ) {
        if ( lang_el.options[i].value == value ) {
            lang_el.options[i].selected = true;
            break;
        }
    }



    var session = editor.getSession();
    var mode;
    if (value == 'python') {
        mode = require("ace/mode/python").Mode;
    }
    else if (value == 'xml') {
        mode = require("ace/mode/xml").Mode;
    }
    else if (value == 'expression') {
        mode = require("ace/mode/xml").Mode;
    }
    else {
        mode = require("ace/mode/javascript").Mode;
    }
    session.setMode( new mode() );
}

spt.ace_editor.drag_start_x;
spt.ace_editor.drag_start_y;
spt.ace_editor.drag_size;
spt.ace_editor.drag_editor_el;
spt.ace_editor.drag_size_el;
spt.ace_editor.drag_resize_setup = function(evt, bvr, mouse_411)
{
    var editor = spt.ace_editor.editor;
    var editor_id = spt.ace_editor.editor_id;

    spt.ace_editor.drag_start_x = mouse_411.curr_x;
    spt.ace_editor.drag_start_y = mouse_411.curr_y;

    var editor_el = $(editor_id);
    spt.ace_editor.drag_editor_el = editor_el;
    spt.ace_editor.drag_size = editor_el.getSize();

    var top = bvr.src_el.getParent(".spt_ace_editor_top");
    spt.ace_editor.drag_size_el = top.getElement(".spt_size");
}


spt.ace_editor.drag_resize_motion = function(evt, bvr, mouse_411)
{
    var diff_x = parseFloat(mouse_411.curr_x - spt.ace_editor.drag_start_x);
    var diff_y = parseFloat(mouse_411.curr_y - spt.ace_editor.drag_start_y);

    var size = spt.ace_editor.drag_size;


    var editor_el = spt.ace_editor.drag_editor_el;

    var width = size.x + diff_x
    if (width < 300) {
        width = 300;
    }
    var height = size.y + diff_y
    if (height < 200) {
        height = 200;
    }

    editor_el.setStyle("width", width);
    editor_el.setStyle("height", height);

    spt.ace_editor.drag_size_el.value = width + "," + height;

    var editor = spt.ace_editor.editor;
    editor.resize();

}
    var js_files = [
        "ace/ace-0.2.0/src/ace.js",
        //"ace/ace-0.2.0/src/ace-uncompressed.js",
    ];


   

    var ace_setup =  function() {
        var editor = ace.edit(bvr.unique_id);
        spt.ace_editor.editor = editor;

        // put the editor into the dom
        spt.ace_editor.editor_id = bvr.unique_id;
        $(bvr.unique_id).editor = editor;

        editor.setTheme("ace/theme/" + spt.ace_editor.theme);
        var JavaScriptMode = require("ace/mode/javascript").Mode;
        editor.getSession().setMode(new JavaScriptMode())
    }

    


    spt.dom.load_js(js_files, function() { 
    
        ace; require; define; 

        var core_js_files = [
        "ace/ace-0.2.0/src/mode-javascript.js",
         "ace/ace-0.2.0/src/mode-xml.js",
            "ace/ace-0.2.0/src/mode-python.js",
             "ace/ace-0.2.0/src/theme-twilight.js",
               
            "ace/ace-0.2.0/src/theme-textmate.js",
            "ace/ace-0.2.0/src/theme-vibrant_ink.js",
            "ace/ace-0.2.0/src/theme-merbivore.js",
            "ace/ace-0.2.0/src/theme-clouds.js",
            "ace/ace-0.2.0/src/theme-eclipse.js"
        ];
        //var supp_js_files = [];
           
         
        

        spt.dom.load_js(core_js_files, ace_setup);
        //spt.dom.load_js(supp_js_files);      
        });
   

    





}
else {
    var editor = ace.edit(bvr.unique_id);
    editor.setTheme("ace/theme/" +  bvr.theme);
    var JavaScriptMode = require("ace/mode/javascript").Mode;
   
    editor.getSession().setMode(new JavaScriptMode())

    spt.ace_editor.editor_id = bvr.unique_id;
    spt.ace_editor.editor = editor;
    $(bvr.unique_id).editor = editor;

}
            '''
        } )


        return top
Beispiel #17
0
    def get_display(self):
        top = self.top
        self.set_as_panel(top)
        top.add_class("spt_delete_top")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_border()
        top.add_style("width: 400px")
        top.add_border()

        search_key = self.kwargs.get("search_key")
        search_keys = self.kwargs.get("search_keys")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            sobjects = [sobject]
            search_keys = [search_key]
        elif search_keys:
            sobjects = Search.get_by_search_keys(search_keys)
            sobject = sobjects[0]

        if not sobjects or not sobject:
            msg = "%s not found" % search_key
            return msg
        search_type = sobject.get_base_search_type()

        if search_type in ['sthpw/project', 'sthpw/search_object']:
            msg = 'You cannot delete these items with this tool'
            return msg

        self.search_keys = search_keys

        title = DivWdg()
        top.add(title)

        icon = IconWdg("WARNING", IconWdg.WARNING)
        icon.add_style("float: left")
        title.add(icon)

        if len(self.search_keys) > 1:
            title.add("Delete %s Items" % len(self.search_keys))
        else:
            title.add("Delete Item [%s]" % (sobject.get_code()))
        title.add_style("font-size: 20px")
        title.add_style("font-weight: bold")
        title.add_style("padding: 10px")

        title.add("<hr/>")

        content = DivWdg()
        top.add(content)
        content.add_style("margin: 5px 10px 20px 10px")

        content.add(
            "The item to be deleted has a number of dependencies as described below:<br/>",
            'heading')

        # find all the relationships
        related_types = SearchType.get_related_types(search_type,
                                                     direction='children')

        items_div = DivWdg()
        content.add(items_div)
        items_div.add_style("padding: 10px")
        valid_related_ctr = 0
        for related_type in related_types:
            if related_type == "*":
                print("WARNING: related_type is *")
                continue
            if related_type == search_type:
                continue
            if related_type in ['sthpw/search_object', 'sthpw/search_type']:
                continue

            item_div = self.get_item_div(sobjects, related_type)
            if item_div:
                items_div.add(item_div)
                valid_related_ctr += 1

        if valid_related_ctr > 0:
            #icon = IconWdg("Note", "BS_NOTE")
            #icon.add_style("float: left")
            #content.add( icon )
            content.add(
                "<div><b>By selecting the above, the corresponding related items will be deleted as well.</b></div>"
            )
            content.add("<br/>" * 2)
        else:
            # changed the heading to say no dependencies
            content.add("The item to be deleted has no dependencies.<br/>",
                        'heading')

        num_items = len(self.search_keys)
        if num_items == 1:
            verb = "is 1 item"
        else:
            verb = "are %s items" % num_items
        content.add("There %s to be deleted" % verb)
        content.add("<br/>" * 2)

        content.add("Do you wish to continue deleting?")
        content.add("<br/>" * 3)

        button_div = DivWdg()
        button_div.add_class("spt_buttons")
        content.add(button_div)
        button_div.add_style('text-align: center')

        button = ActionButtonWdg(title="Delete", width=100, color="danger")
        button_div.add(button)
        button.add_style("display: inline-block")

        deleting_div = DivWdg()
        content.add(deleting_div)
        deleting_div.add(
            "<img src='/context/icons/common/indicator_snake.gif'/>")
        deleting_div.add_class("spt_delete_msg")
        deleting_div.add(" Deleting ...")
        deleting_div.add_style("text-align: center")
        deleting_div.add_style("font-size: 16px")
        deleting_div.add_style("margin: 20px")
        deleting_div.add_style("display: none")

        on_complete = self.kwargs.get("on_complete")

        button.add_behavior({
            'type':
            'click_up',
            'search_keys':
            self.search_keys,
            'on_complete':
            on_complete,
            'cbjs_action':
            '''
        spt.app_busy.show("Deleting");
        //spt.notify.show_message("Deleting ...");

        //var button_el = bvr.src_el.getParent(".spt_buttons");
        //button_el.setStyle("display", "none");

        var top = bvr.src_el.getParent(".spt_delete_top");
        var values = spt.api.Utility.get_input_values(top);

        var class_name = "tactic.ui.tools.DeleteCmd";
        var kwargs = {
            'search_keys': bvr.search_keys,
            'values': values
        };

        var del_trigger = function() {
            
            // for fast table
            var tmps = spt.split_search_key(bvr.search_keys[0])
            var tmps2 = tmps[0].split('?');
            var del_st_event = "delete|" + tmps2[0];
            var bvr_fire = {};
            var input = {'search_keys': bvr.search_keys};
            bvr_fire.options = input;
            spt.named_events.fire_event(del_st_event, bvr_fire);
        }

        var server = TacticServerStub.get();

        server.execute_cmd(class_name, kwargs, null, {
            on_complete: function() {
                //spt.notify.show_message("Finshed deleting ...");

                // run the post delete and destroy the popup
                var popup = bvr.src_el.getParent(".spt_popup");
                if (popup.spt_on_post_delete) {
                    popup.spt_on_post_delete();
                }

                del_trigger();

                spt.popup.destroy(popup);


                if (bvr.on_complete) {
                   on_complete = function() {
                       eval(bvr.on_complete);
                   }
                   on_complete();
                }

                spt.app_busy.hide();
            },
            on_error: function(e) {
                spt.notify.show_message("Error on delete");
                spt.alert(spt.exception.handler(e));
                spt.app_busy.hide();
            }
        } );

        '''
        })

        button = ActionButtonWdg(title="Cancel", width=100)
        button_div.add(button)
        button.add_style("display: inline-block")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        })

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

        return top
Beispiel #18
0
    def get_import_wdg(self):
        div = DivWdg()

        if self.data:

            div.add("<br/>"*2)
            div.add("The following TACTIC share was found: ")
            div.add("<br/>"*2)

            data_input = TextAreaWdg("data")
            data_input.add_style("display: none")
            div.add(data_input)

            #print "xxxx: ", self.data
            data_str = jsondumps(self.data)
            #data_str = data_str.replace('"', "'")
            print "data: ", data_str
            data_input.set_value(data_str)




            table = Table()
            div.add(table)
            table.set_max_width()
            table.add_style("margin-left: 20px")
            table.add_style("margin-right: 20px")

            for name, value in self.data.items():
                name = Common.get_display_title(name)
                table.add_row()
                table.add_cell(name)
                table.add_cell(value)



            div.add("<br/>"*2)

            div.add( self.get_versions_wdg() )

            div.add("<br/>"*2)

            # check to see if the project exists
            project_code = self.data.get("project_code")
            project_code = self.data.get("projects")
            project = Project.get_by_code(project_code)
            #if project:
            if False:
                msg_div = DivWdg()
                div.add(msg_div)
                msg_div.add_style("padding: 20px")
                msg_div.add_color("background", "background3")
                msg_div.add_color("color", "color")
                msg_div.add_border()

                icon = IconWdg("WARNING", IconWdg.WARNING)
                msg_div.add(icon)
                icon.add_style("float: left")

                msg_div.add("The project with code [%s] already exists.  You must remove the installed project before trying to import this one." % project_code)
                return div





            if self.data.get("is_encrypted") == "true":
                div.add("The transactions in this share is encrypted.  Please provide an encryption key to decrypt the transactions<br/><br/>")
                div.add("Encryption Key: ")
                text = TextWdg("encryption_key")
                div.add(text)
                div.add("<br/>"*2)

            button = ActionButtonWdg(title="Import >>")
            button.add_style("float: right")
            div.add(button)
            div.add("<br/>"*2)
            button.add_behavior( {
                'type': 'click_up',
                'project_code': project_code,
                'cbjs_action': '''
                spt.app_busy.show("Importing Project "+bvr.project_code+"...");
                var top = bvr.src_el.getParent(".spt_sync_import_top");
                var values = spt.api.Utility.get_input_values(top, null, false);
                var cmd = "tactic.ui.sync.SyncImportCmd";
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, values, {}, {use_transaction: false});
                spt.notify.show_message("Finished importing project");
                spt.app_busy.hide();
                document.location = '/tactic/'+bvr.project_code;
                '''
            } )



        return div
Beispiel #19
0
    def get_display(self):
        top = self.top
        self.set_as_panel(top)
        top.add_class("spt_sync_import_top")
        top.add_style("width: 500px")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("padding: 20px")

        inner = DivWdg()
        top.add(inner)

        inner.add(self.get_base_dir_wdg())

        is_refresh = self.kwargs.get("is_refresh") == 'true'


        base_dir = self.kwargs.get("base_dir")
        if base_dir:
            data = self.kwargs.get("data")
            if data:
                self.data = jsonloads(data)
            else:
                if not os.path.exists(base_dir):
                    msg_div = DivWdg()

                    inner.add("<br/>"*2)
                    inner.add(msg_div)

                    msg_div.add_style("padding: 20px 20px 30px 20px")
                    msg_div.add_color("background", "background3")
                    msg_div.add_color("color", "color")
                    msg_div.add_border()

                    icon = IconWdg("WARNING", IconWdg.WARNING)
                    msg_div.add(icon)
                    icon.add_style("float: left")

                    msg_div.add("<br/>")

                    msg_div.add("Base folder [%s] does not exist on server" % base_dir)
                    if is_refresh:
                        return inner
                    else:
                        return top


                manifest_path = "%s/tactic.txt" % base_dir
                f = open(manifest_path)
                data = f.read()
                self.data = jsonloads(data)

                inner.add( self.get_import_wdg() )

        else:
            self.data = {}

            msg_div = DivWdg()
            inner.add(msg_div)
            icon = IconWdg("", IconWdg.ARROW_UP)
            msg_div.add(icon)
            msg_div.add("Please browse or enter in a sync location")
            msg_div.add_style("padding: 20px")
            msg_div.add_style("margin: 30px")
            msg_div.add_style("text-align: center")
            msg_div.add_border()
            msg_div.add_color("background", "background3")
            msg_div.add_color("color", "color3")


        if self.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
Beispiel #20
0
    def get_content_wdg(self):

        div = DivWdg()
        div.add_class("spt_tool_top")

        #table = Table()
        from tactic.ui.container import ResizableTableWdg
        from table_layout_wdg import FastTableLayoutWdg

        #table = ResizableTableWdg()
        table = Table()
        table.add_style("table-layout", "fixed")
        table.add_style("width: 100%")
        div.add(table)
        table.add_row()

        td = table.add_cell()
        #td.add_style("width: 30%")


        kwargs = self.kwargs.copy()


        td.add_style("vertical-align: top")
        layout_div = DivWdg()
        layout_div.add_style("min-height: 500px")
        layout_div.add_style("height: auto")
        td.add(layout_div)
        #td.add_style("overflow: hidden")
        kwargs['height'] = 500

        kwargs['show_shelf'] = False
        kwargs['show_search_limit'] = False
        kwargs['expand_on_load'] = True

        layout = FastTableLayoutWdg(**kwargs)
        layout_div.add(layout)
        layout.set_sobjects(self.sobjects)
        #from tactic.ui.panel import TileLayoutWdg
        #layout = TileLayoutWdg(**self.kwargs)
        #layout_div.add(layout)


        td = table.add_cell()
        td.add_border(color="#EEE")
        td.add_style("vertical-align: top")

        content = DivWdg()
        td.add(content)
        content.add_class("spt_tool_content")
        content.add_border(color="#EEE")
        content.add_style("margin: -1px")
        content.add_style("height: auto")
        #content.add_style("padding: 0px 20px")



        no_content_wdg = DivWdg()
        content.add(no_content_wdg)
        no_content_wdg.add("<br/>"*3)

        '''
        The no content message displays tool icons
        and a message in format:
                         <tools>
                          <msg>
        '''
        tool_icons = self.kwargs.get('tool_icon')
        if isinstance(tool_icons, basestring):
            tool_icon_lst = tool_icons.split("|")
        else:
            tool_icon_lst = None

        if tool_icon_lst:
            for icon in tool_icon_lst:
                icon = IconWdg(icon=icon) 
                icon.add_style("padding", "5px")
                no_content_wdg.add(icon)
            no_content_wdg.add("</br></br>")
       
        tool_msg = self.kwargs.get('tool_msg')
        if tool_msg:
            no_content_wdg.add("<p>%s<p>" % tool_msg)
        else:
            no_content_wdg.add("Click the tool(s) to modify settings.") 
       
        #no_content_wdg.add_style("opacity: 0.5")
        no_content_wdg.add_style("margin: 30px auto")
        no_content_wdg.add_color("color", "color3")
        no_content_wdg.add_color("background", "background3")
        no_content_wdg.add_style("text-align", "center")
        no_content_wdg.add_style("padding-top: 20px")
        no_content_wdg.add_style("padding-bottom: 20px")
        no_content_wdg.add_style("width: 350px")
        no_content_wdg.add_style("height: 110px")
        no_content_wdg.add_style("margin: 30px auto")
        no_content_wdg.add_border()


        return div
Beispiel #21
0
    def get_display(self):

        menu_div = DivWdg()
        menu_div.set_attr( "id", self.menu_id )
        menu_div.add_class( "SPT_CTX_MENU" )
        menu_div.add_class( "SPT_PUW" )  # make it a Page Utility Widget (now processed client side)

        menu_div.set_z_start( 300 )
        menu_div.add_looks( "menu border curs_default" )

        m_width = self.width - 2
        menu_div.add_style( ("width: %spx" % m_width) )

        menu_table = Table()
        menu_table.add_styles( "text-align: left; text-indent: 3px; border-collapse: collapse;" )

        options = self.opt_spec_list
        for opt in options:

            tbody = menu_table.add_tbody()
            tbody.add_style("display","table-row-group")

            tr = menu_table.add_row()
            tr.add_looks( "menu" )
            tr.add_class( "SPT_CTX_MENU_%s" % opt['type'].upper() )
            disabled = False

            if opt.has_key( 'disabled' ) and opt['disabled']:
                disabled = True

            if not disabled:
                if opt['type'] in [ 'action', 'toggle' ]:
                    tr.add_behavior( {'type':'hover',
                                      'cbfn_over': 'spt.ctx_menu.entry_over',
                                      'cbfn_out': 'spt.ctx_menu.entry_out',
                                      'hover_class':'look_menu_hover'} )

                if opt['type'] == 'action':
                    if opt.has_key('bvr_cb') and type(opt['bvr_cb']) == dict:
                        bvr = opt['bvr_cb']
                        bvr['cbjs_preaction'] = 'spt.ctx_menu.clear();'
                        # bvr['cbfn_preaction'] = 'spt.ctx_menu.clear'
                        bvr.update( { 'type': 'click', 'mouse_btn': 'LMB' } )
                        tr.add_behavior( bvr )

                if opt['type'] == 'submenu':
                    bvr = { 'type': 'hover',
                            'cbfn_over': 'spt.ctx_menu.submenu_entry_over',
                            'cbfn_out': 'spt.ctx_menu.submenu_entry_out',
                            'hover_class':'look_menu_hover',
                            'options': { 'menu_id': opt['submenu_id'] } }
                    tr.add_behavior( bvr )
                    # now trap click on submenu, so that it doesn't make the current menu disappear ...
                    tr.add_behavior( { 'type': 'click', 'cbjs_action': ';', 'activator_type': 'ctx_menu' } )

            tr.add_looks( "curs_default" )

            icon_width = 16
            icon_col_width = 0

            # Left icon cell ...
            if self.allow_icons:
                td = menu_table.add_cell()
                icon_col_width = icon_width + 2
                td.add_styles("text-align: center; vertical-align: middle; width: %spx;" % icon_col_width)
                td.add_looks("menu_icon_column")

                if opt.has_key( 'icon' ):
                    icon_wdg = IconWdg("", opt['icon'])
                    td.add( icon_wdg )
                    if disabled:
                        icon_wdg.add_style( "opacity: .4" )
                        icon_wdg.add_style( "filter: alpha(opacity=40)" )

            # Menu option label cell ...
            td = menu_table.add_cell()
            w = m_width - icon_col_width - icon_width
            td.add_style("width", ("%spx" % w))
            td.add_style("height", ("%spx" % icon_col_width))
            td.add_style( "padding-left: 4px" )
            td.add_style( "padding-top: 2px" )
            td.add_style( "cursor: default" )

            label_str = ''
            if opt.has_key( 'label' ):
                label_str = opt.get('label')
            elif opt.get('type') == 'separator':
                label_str = '<HR>'

            td.add_looks("fnt_text")
            if opt.get('type') == 'title':
                td.add_looks("fnt_bold")

            td.add(label_str)

            if disabled:
                td.add_style( "opacity: .2" )
                td.add_style( "filter: alpha(opacity=20)" )

            # Submenu arrow icon cell ...
            td = menu_table.add_cell()
            td.add_style("width", ("%spx" % icon_width))

            if opt['type'] == 'submenu':
                icon_wdg = IconWdg("", IconWdg.ARROWHEAD_DARK_RIGHT)
                td.add(icon_wdg)

            if disabled:
                td.add_style( "opacity: .4" )
                td.add_style( "filter: alpha(opacity=40)" )

        menu_div.add( menu_table )
        menu_div.add_style( "display: none" )
        menu_div.add_style( "position: absolute" )
        return menu_div
Beispiel #22
0
    def get_display(my):

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

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

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

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

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

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

        insert_view = "edit_collection"

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

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

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

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

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

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

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

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

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

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

        for collection in collections:

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

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

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

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

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

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

            check_div = DivWdg()
            collection_div.add(check_div)

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

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

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

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

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

            collection_div.add("<hr/>")

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

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

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

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

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

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

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

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

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

        return dialog
Beispiel #23
0
    def get_display(my):

        collection = my.kwargs.get("collection")
        path = my.kwargs.get("path")

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

        search = Search(collection_type)
        search.add_filter("parent_code", collection.get_value("code"))
        search.add_column("search_code")
        items = search.get_sobjects()
        codes = [x.get_value("search_code") for x in items]

        count = search.get_count()

        # find the children that are actually collections
        search = Search(search_type)
        search.add_filter("_is_collection", True)
        search.add_filters("code", codes)
        has_child_collections = search.get_count() > 0

        top = my.top
        collection_top = top
        collection_top.add_class("spt_collection_div_top")
        collection_div = DivWdg()

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

        collection_top.add(collection_div)
        collection_top.add_class("tactic_hover")
        collection_top.add_class("hand")

        collection_div.add_class("spt_collection_item")
        collection_div.add_attr("spt_collection_key",
                                collection.get_search_key())
        collection_div.add_attr("spt_collection_code", collection.get_code())
        collection_div.add_attr("spt_collection_path", path)

        # This is for Drag and Drop from a tile widget
        collection_div.add_class("spt_tile_top")
        collection_div.add_attr("spt_search_key", collection.get_search_key())
        collection_div.add_attr("spt_search_code", collection.get_code())
        collection_div.add_attr("spt_name", name)

        collection_div.add_style("height: 20px")
        collection_div.add_style("padding-top: 10px")

        if has_child_collections:
            icon_div = DivWdg()
            icon = IconWdg(name="View Collection", icon="BS_CHEVRON_DOWN")
            icon_div.add(icon)
            icon.add_style("float: right")
            icon.add_style("margin-top: -20px")
            collection_top.add(icon_div)
            icon_div.add_class("spt_collection_open")
            icon_div.add_attr("spt_collection_key",
                              collection.get_search_key())
            icon_div.add_attr("spt_collection_path", path)

        from tactic.ui.panel import ThumbWdg2
        thumb_wdg = ThumbWdg2()
        thumb_wdg.set_sobject(collection)
        collection_div.add(thumb_wdg)
        thumb_wdg.add_style("width: 45px")
        thumb_wdg.add_style("float: left")
        thumb_wdg.add_style("margin-top: -10px")

        if count:
            count_div = DivWdg()
            collection_div.add(count_div)
            #count_div.add_style("margin-top: -10px")
            #count_div.add_style("margin-left: -10px")

            count_div.add_style("width: 15px")
            count_div.add_style("height: 15px")
            count_div.add_style("font-size: 0.8em")
            count_div.add_style("border-radius: 10px")
            count_div.add_style("background: #DDD")
            count_div.add_style("position: absolute")
            count_div.add_style("text-align: center")
            count_div.add_style("margin-left: 23px")
            count_div.add_style("margin-top: -8px")
            count_div.add_style("box-shadow: 0px 0px 3px rgba(0,0,0,0.5)")

            expression = "@COUNT(%s['parent_code','%s'])" % (
                collection_type, collection.get_code())
            count_div.add(count)
            count_div.add_update({
                #'expr_key': collection.get_search_key(),
                'expression': expression,
                'interval': 2
            })

        name = collection.get_value("name")
        collection_div.add(name)

        return top
Beispiel #24
0
    def get_display(my):
        top = my.top
        my.set_as_panel(top)
        top.add_class("spt_delete_top")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_border()
        top.add_style("width: 300px")
        top.add_border()

        search_key = my.kwargs.get("search_key")
        search_keys = my.kwargs.get("search_keys")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            sobjects = [sobject]
            search_keys = [search_key]
        elif search_keys:
            sobjects = Search.get_by_search_keys(search_keys)
            sobject = sobjects[0]

        if not sobjects:
            msg = "%s not found" % search_key
            return msg
        search_type = sobject.get_base_search_type()

        if search_type in ['sthpw/project', 'sthpw/search_object']:
            msg = 'You cannot delete these items with this tool'
            return msg

        my.search_keys = search_keys

        title = DivWdg()
        top.add(title)
        title.add_color("background", "background", -10)
        if my.search_keys:
            title.add("Delete %s Items" % len(my.search_keys))
        else:
            title.add("Delete Item [%s]" % (sobject.get_code()))
        title.add_style("font-size: 14px")
        title.add_style("font-weight: bold")
        title.add_style("padding: 10px")

        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")

        content.add(
            "The item to be deleted has a number of dependencies as described below:<br/>",
            'heading')

        # find all the relationships
        related_types = SearchType.get_related_types(search_type,
                                                     direction='children')

        items_div = DivWdg()
        content.add(items_div)
        items_div.add_style("padding: 10px")
        valid_related_ctr = 0
        for related_type in related_types:
            if related_type == "*":
                print "WARNING: related_type is *"
                continue
            if related_type == search_type:
                continue
            if related_type in ['sthpw/search_object', 'sthpw/search_type']:
                continue

            item_div = my.get_item_div(sobjects, related_type)
            if item_div:
                items_div.add(item_div)
                valid_related_ctr += 1

        if valid_related_ctr > 0:
            icon = IconWdg("WARNING", IconWdg.WARNING)
            icon.add_style("float: left")
            content.add(icon)
            content.add(
                "<div><b>WARNING: By selecting the related items above, you can delete them as well when deleting this sObject.</b></div>"
            )
            content.add("<br/>" * 2)
        else:
            # changed the heading to say no dependencies
            content.add("The item to be deleted has no dependencies.<br/>",
                        'heading')

        content.add("There are %s items to be deleted" % len(my.search_keys))
        content.add("<br/>" * 2)

        content.add("Do you wish to continue deleting?")
        content.add("<br/>" * 2)

        button_div = DivWdg()
        button_div.add_styles('width: 300px; height: 75px')
        button = ActionButtonWdg(title="Delete")
        button_div.add(button)
        content.add(button_div)
        button.add_style("float: left")

        button.add_behavior({
            'type':
            'click_up',
            'search_keys':
            my.search_keys,
            'cbjs_action':
            '''
        spt.app_busy.show("Deleting");

        var top = bvr.src_el.getParent(".spt_delete_top");
        var values = spt.api.Utility.get_input_values(top);

        var class_name = "tactic.ui.tools.DeleteCmd";
        var kwargs = {
            'search_keys': bvr.search_keys,
            'values': values
        };

        var del_trigger = function() {
            
            // for fast table
            var tmps = spt.split_search_key(bvr.search_keys[0])
            var tmps2 = tmps[0].split('?');
            var del_st_event = "delete|" + tmps2[0];
            var bvr_fire = {};
            var input = {'search_keys': bvr.search_keys};
            bvr_fire.options = input;
            spt.named_events.fire_event(del_st_event, bvr_fire);
        }

        var server = TacticServerStub.get();
        try {
            server.start({'title': 'Delete sObject', 'description': 'Delete sObject [' + bvr.search_keys + ']'});
            server.execute_cmd(class_name, kwargs);
            server.finish();

            // run the post delete and destroy the popup
            var popup = bvr.src_el.getParent(".spt_popup");
            if (popup.spt_on_post_delete) {
                popup.spt_on_post_delete();
            }

            del_trigger();

            spt.popup.destroy(popup);


        }
        catch(e) {
            spt.alert(spt.exception.handler(e));
        }

        spt.app_busy.hide();
       
        '''
        })

        button = ActionButtonWdg(title="Cancel")
        button.add_style("float: left")
        button_div.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        })

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

        return top
    def handle_dir_or_item(my, item_div, dirname, basename):
        spath = "%s/%s" % (dirname, basename)
        fspath = "%s/%s" % (dirname, File.get_filesystem_name(basename))

        md5 = my.md5s.get(fspath)
        changed = False
        context = None
        error_msg = None
        snapshot = None
        file_obj = my.checked_in_paths.get(fspath)
        if not file_obj:
            if fspath.startswith(my.base_dir):
                rel = fspath.replace("%s/" % my.base_dir, "")
                file_obj = my.checked_in_paths.get(rel)


        if file_obj != None:

            snapshot_code = file_obj.get_value("snapshot_code")
            snapshot = my.snapshots_dict.get(snapshot_code)
            if not snapshot:
                # last resort
                snapshot = file_obj.get_parent()

            if snapshot:
                context = snapshot.get_value("context")
                item_div.add_attr("spt_snapshot_code", snapshot.get_code())

                snapshot_md5 = file_obj.get_value("md5")
                item_div.add_attr("spt_md5", snapshot_md5)
                item_div.add_attr("title", "Checked-in as: %s" % file_obj.get_value("file_name"))

                if md5 and md5 != snapshot_md5:
                    item_div.add_class("spt_changed")
                    changed = True
            else:
                error_msg = 'snapshot not found'

            


        status = None
        if file_obj != None:
            if changed:
                check = IconWdg( "Checked-In", IconWdg.ERROR, width=12 )
                status = "changed"
            else:
                check = IconWdg( "Checked-In", IconWdg.CHECK, width=12 )
                status = "same"
            item_div.add_color("color", "color", [0, 0, 50])

        else:
            check = None
            item_div.add_style("opacity: 0.8")
            status = "unversioned"



        if check:
            item_div.add(check)
            check.add_style("float: left")
            check.add_style("margin-left: -16px")
            check.add_style("margin-top: 4px")


        # add the file name
        filename_div = DivWdg()
        item_div.add(filename_div)
        filename_div.add(basename)
        file_info_div = None
        if snapshot and status != 'unversioned':
            file_info_div = SpanWdg()
            filename_div.add(file_info_div)

        if error_msg:
            filename_div.add(' (%s)'%error_msg)
        filename_div.add_style("float: left")
        filename_div.add_style("overflow: hidden")
        filename_div.add_style("width: 65%")


        # DEPRECATED
        from pyasm.widget import CheckboxWdg, TextWdg, SelectWdg, HiddenWdg
        checkbox = CheckboxWdg("check")
      

        checkbox.add_style("display: none")
        checkbox.add_class("spt_select")
        checkbox.add_style("float: right")
        checkbox.add_style("margin-top: 1px")
        item_div.add(checkbox)

        subcontext_val = ''
        cat_input = None
        is_select = True
        if my.context_options:
            context_sel = SelectWdg("context")
            context_sel.add_attr('title', 'context')
            context_sel.set_option("show_missing", False)
            context_sel.set_option("values", my.context_options)
            item_div.add_attr("spt_context", my.context_options[0]) 
            cat_input = context_sel
            input_cls = 'spt_context'

    
        else:
            if my.subcontext_options in [['(main)'], ['(auto)'] , []]:
                is_select = False
                #subcontext = TextWdg("subcontext")
                subcontext = HiddenWdg("subcontext")
                subcontext.add_class("spt_subcontext")

            elif my.subcontext_options == ['(text)']:
                is_select = False
                subcontext = TextWdg("subcontext")
                subcontext.add_class("spt_subcontext")

            else:
                is_select = True


                subcontext = SelectWdg("subcontext")
                subcontext.set_option("show_missing", False)
                subcontext.set_option("values", my.subcontext_options)
                #subcontext.add_empty_option("----")


            cat_input = subcontext
            input_cls = 'spt_subcontext'
            
          


            if my.subcontext_options == ['(main)'] or my.subcontext_options == ['(auto)']:
                subcontext_val = my.subcontext_options[0]
                subcontext.set_value(subcontext_val)
                item_div.add_attr("spt_subcontext", subcontext_val)
            elif context:
                parts = context.split("/")
                if len(parts) > 1:

                    # get the actual subcontext value
                    subcontext_val = "/".join(parts[1:])

                    # identify a previous "auto" check-in and preselect the item in the select
                    if is_select and subcontext_val not in my.subcontext_options:
                        subcontext_val = '(auto)'

                    elif isinstance(cat_input,  HiddenWdg):
                        subcontext_val =  ''
                    # the Text field will adopt the subcontext value of the last check-in
                    subcontext.set_value(subcontext_val)
                    item_div.add_attr("spt_subcontext", subcontext_val)

            else:
                if is_select:
                    if my.subcontext_options:
                        subcontext_val = my.subcontext_options[0]
                    #subcontext_val = '(auto)'
                    cat_input.set_value(subcontext_val)
                else:
                    subcontext_val = ''
                item_div.add_attr("spt_subcontext", subcontext_val)
        item_div.add(cat_input)


        cat_input.add_behavior( {
                'type': 'click_up',
                'propagate_evt': False,
                'cbjs_action': '''
                bvr.src_el.focus();
                '''
            } )

        cat_input.add_style("display: none") 
        cat_input.add_class("spt_subcontext")
        cat_input.add_style("float: right")
        cat_input.add_style("width: 50px")
        cat_input.add_style("margin-top: -1px")
        cat_input.add_style("font-size: 10px")
        cat_input.add_style("height: 16px")


        # we depend on the attribute cuz sometimes we go by the initialized value 
        # since they are not drawn
        cat_input.add_behavior( {
            'type': 'change',
            'cbjs_action': '''
            var el = bvr.src_el.getParent('.spt_dir_list_item');
            el.setAttribute("%s", bvr.src_el.value);
            ''' %input_cls
        } )


       


        if file_info_div:
            if subcontext_val in ['(auto)','(main)', '']:
                file_info_div.add(" <i style='font-size: 9px; opacity: 0.6'>(v%s)</i>" % snapshot.get_value("version") )
            else:
                file_info_div.add(" <i style='font-size: 9px; opacity: 0.6'>(v%s - %s)</i>" % (snapshot.get_value("version"), subcontext_val) )
Beispiel #26
0
    def get_display(my):

        div = DivWdg()

        if not Container.get_dict("JSLibraries", "spt_popup"):
            div.add_style("position: fixed")
            div.add_style("top: 0px")
            div.add_style("left: 0px")
            div.add_style("opacity: 0.4")
            div.add_style("background", "#000")
            div.add_style("padding: 100px")
            div.add_style("height: 100%")
            div.add_style("width: 100%")
            div.add_class("spt_popup_background")
            div.add_style("display: none")
            div.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.hide(bvr.src_el);
                '''
            })

        Container.put("PopupWdg:background", True)

        # This is the absolute outside of a popup, including the drop shadow
        widget = DivWdg()
        div.add(widget)
        widget.add_class("spt_popup")

        if not Container.get_dict("JSLibraries", "spt_popup"):
            widget.add_behavior({
                'type': 'load',
                'cbjs_action': my.get_onload_js()
            })

        width = my.kwargs.get("width")
        if not width:
            width = 10

        #widget.add_behavior( {
        #    'type': 'load',
        #    'cbjs_action': 'bvr.src_el.makeResizable({handle:bvr.src_el.getElement(".spt_popup_resize")})'
        #} )

        web = WebContainer.get_web()

        widget.set_id(my.name)
        if my.kwargs.get("display") == "true":
            pass
        else:
            widget.add_style("display: none")

        widget.add_style("position: absolute")
        widget.add_style("left: 400px")
        widget.add_style("top: 100px")

        widget.add_border()
        widget.add_color("background", "background")

        #widget.set_box_shadow(color="#000")
        widget.set_box_shadow()

        table = Table()
        table.add_behavior({
            'type':
            'load',
            'width':
            width,
            'cbjs_action':
            '''
        bvr.src_el.setStyle("width", bvr.width)

        var popup = bvr.src_el.getParent(".spt_popup");
        var window_size = $(window).getSize();
        var size = bvr.src_el.getSize();
        var left = window_size.x/2 - size.x/2;
        var top = window_size.y/2 - size.y/2;
        popup.setStyle("left", left);
        //popup.setStyle("top", top);

        '''
        })

        table.add_row()
        """
        # Qt doesn't support shadows very well
        if web.get_browser() == 'Qtx':
            # dynamically add css files

            table.add_class("css_shadow_table")
            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_top_left SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_top SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_top_right SPT_POPUP_SHADOW")


            # Middle (Content) Row of Shadow table ...
            table.add_row()

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_left SPT_POPUP_SHADOW")
        """

        content_td = table.add_cell()
        content_td.add_class("css_shadow_td")
        """
        if web.get_browser() == 'Qtx':
            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_right SPT_POPUP_SHADOW")


            # Bottom Row of Shadow table ...
            table.add_row()

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_bottom_left SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_bottom SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_bottom_right SPT_POPUP_SHADOW")
        """

        drag_div = DivWdg()

        #from tactic.ui.container import ArrowWdg
        #arrow = ArrowWdg()
        #drag_div.add(arrow)

        # FIXME: for some reason, this causes popups to stop functioning after
        # close a couple of times
        my.add_header_context_menu(drag_div)

        # create the 'close' button ...
        if my.allow_close:
            close_wdg = SpanWdg()
            #close_wdg.add( IconWdg("Close", IconWdg.POPUP_WIN_CLOSE) )
            close_wdg.add(IconWdg("Close", "BS_REMOVE"))
            close_wdg.add_style("margin: 5px 1px 3px 1px")
            close_wdg.add_style("float: right")
            close_wdg.add_class("hand")

            close_wdg.add_behavior({
                'type': 'click_up',
                'cbjs_action': my.get_cancel_script()
            })

            drag_div.add(close_wdg)

            # create the 'minimize' button ...
            minimize_wdg = SpanWdg()
            minimize_wdg.add_style("margin: 5px 1px 3px 1px")
            #minimize_wdg.add( IconWdg("Minimize", IconWdg.POPUP_WIN_MINIMIZE) )
            minimize_wdg.add(IconWdg("Minimize", "BS_MINUS"))
            minimize_wdg.add_style("float: right")
            minimize_wdg.add_class("hand")
            behavior = {
                'type': 'click_up',
                'cbjs_action': "spt.popup.toggle_minimize( bvr.src_el );"
            }
            minimize_wdg.add_behavior(behavior)
            drag_div.add(minimize_wdg)

        #-- TO ADD SOON -- create the 'refresh' button ...
        #   refresh_wdg = SpanWdg()
        #   refresh_wdg.add( IconWdg("Refresh Popup", IconWdg.POPUP_WIN_REFRESH) )
        #   refresh_wdg.add_style("float: right")
        #   refresh_wdg.add_class("hand")
        #   behavior = {
        #       'type': 'click_up',
        #       'cbjs_action': "spt.popup.toggle_minimize( bvr.src_el );"
        #   }
        #   refresh_wdg.add_behavior( behavior );
        #   drag_div.add(refresh_wdg)

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

        # style
        drag_div.add_style("font-size: 1.1em")

        drag_div.add_style("text-align: left")
        drag_div.add_class("spt_popup_width")

        drag_handle_div = DivWdg(id='%s_title' % my.name)
        drag_handle_div.add_style("padding: 12px;")
        #drag_handle_div.add_gradient("background", "background", +10)
        drag_handle_div.add_color("background", "background", -5)
        drag_handle_div.add_color("color", "color")
        drag_handle_div.add_style("font-weight", "bold")
        drag_handle_div.add_style("font-size", "12px")

        # add the drag capability.
        # NOTE: need to use getParent because spt.popup has not yet been
        # initialized when this is processed
        shadow_color = drag_div.get_color("shadow")
        drag_div.add_behavior({
            'type': 'smart_drag',
            'shadow_color': shadow_color,
            'drag_el': "@.getParent('.spt_popup')",
            'bvr_match_class': 'spt_popup_title',
            'options': {
                'z_sort': 'bring_forward'
            },
            'ignore_default_motion': 'true',
            "cbjs_setup": '''
              if (spt.popup.is_background_visible) {
                  spt.popup.offset_x = document.body.scrollLeft;
                  spt.popup.offset_y = document.body.scrollTop;
                  spt.popup.hide_background();
                  var parent = bvr.src_el.getParent(".spt_popup");
                  parent.setStyle("box-shadow","0px 0px 20px " + bvr.shadow_color);
              }
              else {
                  spt.popup.offset_x = 0;
                  spt.popup.offset_y = 0;
              }
            ''',
            "cbjs_motion": '''
              mouse_411.curr_x += spt.popup.offset_x;
              mouse_411.curr_y += spt.popup.offset_y;
              spt.mouse.default_drag_motion(evt, bvr, mouse_411);
            ''',
            "cbjs_action": ''
        })

        title_wdg = my.title_wdg
        if not title_wdg:
            title_wdg = "No Title"
        #else:
        #    title_wdg = title_wdg

        drag_handle_div.add_behavior({
            'type': 'double_click',
            'cbjs_action': my.get_cancel_script()
        })

        drag_handle_div.add(title_wdg)
        drag_handle_div.add_class("spt_popup_title")

        # add a context menu
        from tactic.ui.container.smart_menu_wdg import SmartMenu
        SmartMenu.assign_as_local_activator(drag_handle_div, 'HEADER_CTX')
        drag_handle_div.add_attr("spt_element_name", "Test Dock")

        # add the content
        content_div = DivWdg()
        content_div.add_color("color", "color2")
        #content_div.add_color("background", "background2")
        from pyasm.web.palette import Palette
        palette = Palette.get()
        content_div.add_color("color", "color2")
        content_div.add_color("background", "background2")

        content_div.add_style("margin", "0px, -1px -0px -1px")

        content_div.set_id("%s_content" % my.name)
        content_div.add_class("spt_popup_content")
        content_div.add_style("overflow: hidden")
        content_div.add_style("display: block")
        #content_div.add_style("padding: 10px")
        if not my.content_wdg:
            my.content_wdg = "No Content"

        content_div.add(my.content_wdg)

        drag_div.add(drag_handle_div)
        my.position_aux_div(drag_div, content_div)
        content_td.add(drag_div)
        widget.add(table)

        # ALWAYS make the Popup a Page Utility Widget (now processed client side)
        widget.add_class("SPT_PUW")

        if my.z_start:
            widget.set_z_start(my.z_start)
            widget.add_style("z-index: %s" % my.z_start)
        else:
            widget.add_style("z-index: 102")

        # add the resize icon
        icon = IconWdg("Resize", IconWdg.RESIZE_CORNER)
        icon.add_style("cursor: nw-resize")
        icon.add_style("z-index: 1000")
        icon.add_class("spt_popup_resize")
        icon.add_style("float: right")
        icon.add_style("margin-top: -15px")
        icon.add_behavior({
            'type': 'drag',
            "drag_el": '@',
            "cb_set_prefix": 'spt.popup.resize_drag'
        })
        content_td.add(icon)

        #return widget
        return div
Beispiel #27
0
    def get_display(my):

        search_key = my.kwargs.get("search_key")
        msg = None
        base_search_type = SearchKey.extract_search_type(search_key)
        sobject = SearchKey.get_by_search_key(search_key)
        process_div = DivWdg()
        process_div.add_style('padding-top: 10px')

        if base_search_type  in ['sthpw/task', 'sthpw/note']:
            my.process = sobject.get_value('process')
            my.context = sobject.get_value('context')
            if not my.process:
                my.process = ''

            parent = sobject.get_parent()
            if parent:
                search_key = SearchKey.get_by_sobject(parent)
            else:
                msg = "Parent for [%s] not found"%search_key
            
        else:
            my.process = my.kwargs.get('process')

        
        top = my.top
        top.add_class('spt_simple_checkin')
        top.add_color("background", "background")
        top.add_styles("position: relative")

        content = DivWdg(msg)
        top.add(content)
        #content.add_border()
        #content.add_color("background", "background3")
        #content.add_color("color", "background3")
        content.add_style("width: 600px")
        content.add_styles("margin-left: auto; margin-right: auto;")
        content.add_style("height: 200px")

        from tactic.ui.widget import CheckinWdg
        content.add_behavior( {
            'type': 'load',
            'cbjs_action': CheckinWdg.get_onload_js()
        } )


        button_div = DivWdg()
        
        content.add(process_div)

        content.add(button_div)
        button = IconWdg(title="Check-In", icon=IconWdg.CHECK_IN_3D_LG)

        title = Common.get_display_title(my.checkin_action)
        button.add_attr('title', title)


        button_div.add(button)
        button_div.set_box_shadow("1px 1px 1px 1px")
        button_div.add_style("width: 60px")
        button_div.add_style("height: 60px")
        button_div.add_style("float: left")
        button_div.add_style("background: white")
        button_div.add_class("hand")

        button_div.add_style("padding: 2px 3px 0 0")
        button_div.add_style("margin: 20px 60px 20px 200px")
        button_div.add_style("text-align: center")

        button_div.add("Check-in")

        # to be consistent with Check-in New File
        if my.process:
            checkin_process = my.process
        else:
            # Dont' specify, the user can choose later in check-in widget
            checkin_process = ''
        button.add_behavior( {
            'type': 'click_up',
            'search_key': search_key,
            'process': checkin_process,
            'context': my.context,
            'cbjs_action': '''
            var class_name = 'tactic.ui.widget.CheckinWdg';
            var applet = spt.Applet.get();


            spt.app_busy.show("Choose file(s) to check in")


            var current_dir = null;
            var is_sandbox = false;
            var refresh = false
            var values = spt.checkin.browse_folder(current_dir, is_sandbox, refresh);
            if (!values) {
                spt.app_busy.hide();
                return;
            }

            var file_paths = values.file_paths;
            if (file_paths.length == 0) {
                spt.alert("You need to select files(s) to check in.");
                spt.app_busy.hide();
                return;
            }

            spt.app_busy.hide();

            var args = {
                'search_key': bvr.search_key,
                'show_links': false,
                'show_history': false,
                'close_on_publish': true
            }
            if (bvr.process) args.process = bvr.process;
            if (bvr.context) args.context = bvr.context;

            var kwargs = {};
            kwargs.values = values;
            spt.panel.load_popup("Check-in", class_name, args, kwargs);

            /*
            var options=  {
                title: "Check-in Widget",
                class_name: 'tactic.ui.widget.CheckinWdg',
                popup_id: 'checkin_widget'
            };
            var bvr2 = {};
            bvr2.options = options;
            bvr2.values = values;
            bvr2.args = args;
            spt.popup.get_widget({}, bvr2)

            */

            '''
        } )


        button_div = DivWdg()
        content.add(button_div)
        button = IconWdg(title="Check-Out", icon=IconWdg.CHECK_OUT_3D_LG)
        button_div.add(button)
        button_div.set_box_shadow("1px 1px 1px 1px")
        button_div.add_style("width: 60px")
        button_div.add_style("height: 60px")
        button_div.add_style("float: left")
        button_div.add_style("margin: 20px")
        button_div.add_style("padding: 2px 3px 0 0")
        button_div.add_style("background: white")
        button_div.add_class("hand")

        button_div.add_style("text-align: center")
        button_div.add("Check-out")

       
        sobject = SearchKey.get_by_search_key(search_key)

        # snapshot is retrieved for getting the process informatoin, they are not being used
        # for loading as real_time snapshot query option is used. 
        search = Search("sthpw/snapshot")
        search.add_sobject_filter(sobject)
        if my.process:
            search.add_filter("process", my.process)
        search.add_filter("is_latest", True)
        snapshot = search.get_sobject()

        if not my.process and snapshot:
            my.process = snapshot.get_value('process')
            # for old process-less snapshots
            if not my.process:
                my.process = snapshot.get_value('context')

        process_wdg = DivWdg(HtmlElement.b(checkin_process))
        if checkin_process:
            width = len(checkin_process)*10
        else:
            width = 10
        process_wdg.add_styles('margin-left: auto; margin-right: auto; text-align: center; width: %s'%width)
        process_div.add(process_wdg)
        # DO NOT pass in snapshot_code, get it in real time

        snapshot_codes = []
   
        show_status = True
        if my.checkout_action == 'latest':
            cbjs_action = CheckinSandboxListWdg.get_checkout_cbjs_action(my.process, show_status)
            bvr = {'snapshot_codes': snapshot_codes,
                    'real_time': True,
                    'file_types': ['main'],
                    'filename_mode': 'repo',
                    'cbjs_action': cbjs_action}

        elif my.checkout_action == 'latest (version_omitted)':
            cbjs_action = CheckinSandboxListWdg.get_checkout_cbjs_action(my.process, show_status)
            bvr = {'snapshot_codes':snapshot_codes,
                    'real_time': True,
                    'file_types': ['main'],
                    'filename_mode': 'versionless',
                    'cbjs_action': cbjs_action}

        elif my.checkout_action == 'latest versionless':
            cbjs_action = CheckinSandboxListWdg.get_checkout_cbjs_action(my.process, show_status)
            bvr = {'snapshot_codes':snapshot_codes,
                    'real_time': True,
                    'versionless': True,
                    'file_types': ['main'],
                    'filename_mode': 'versionless',
                    'cbjs_action': cbjs_action}
       
        elif my.checkout_action == 'open file browser':
            bvr =  {
           
            'cbjs_action': '''
            var class_name = 'tactic.ui.checkin.SObjectDirListWdg';
            var kwargs = {
                search_keys: [bvr.search_key],
                process: '%s' 
            };
            spt.panel.load_popup("Check-out", class_name, kwargs);
            '''%my.process
            }
        bvr.update({ 'type': 'click_up', 'search_key': search_key})
        button.add_behavior(bvr)
        title = Common.get_display_title(my.checkout_action)
        button.add_attr('title', title)


        
        #TODO: remove these margin-top which is used to compensate all the ButtonNewWdg top extra white space
        
        content.add("<br clear='all'/>")
        status_div = DivWdg()
        status_div.add_style('margin: 20px 0 0 10px')
        status_div.add_style('width: 100%')
        text_info = FloatDivWdg()
        text_info.add_styles('padding: 4px; width: 500px')
        text_info.add_style('margin-top: 8px')
        text_info.add_attr('title','Displays the last checked out file path')

        text_info.add_border()
        text_info.set_round_corners()

        text_content = DivWdg()
        text_content.add('&nbsp;')
        text_content.add_class('spt_status_area')

        text_info.add(text_content)
        label = FloatDivWdg('path:')
        label.add_style('margin: 12px 6px 0 6px')

        # button
        button = ButtonNewWdg(title="Explore", icon=IconWdg.FOLDER_GO)
        button.add_style('padding-bottom: 15px')
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
            var applet = spt.Applet.get();
            var status_div = bvr.src_el.getParent('.spt_simple_checkin').getElement('.spt_status_area');
            var value = status_div.get('text');

            var dir_name = spt.path.get_dirname(value);
            if (dir_name)
                applet.open_explorer(dir_name);
        '''
        } )

        status_div.add(label)
        status_div.add(text_info)
        content.add(status_div)
        content.add(button)
    

        content.add_behavior({'type':'load',
            'cbjs_action': ''' 
            
            if (!spt.Applet.applet) {
                spt.api.app_busy_show('Initializing Java', 'Please wait...');
                var exec = function() {var applet = spt.Applet.get()};
                spt.api.app_busy_hide(exec);
            }'''})
        
        return top
Beispiel #28
0
    def get_displayxx(my):

        show_menu = my.kwargs.get("show_menu")
        is_disabled = my.kwargs.get("is_disabled")

        show_title = my.kwargs.get("show_title")
        show_title = show_title in ['True', True]

        width = 35 
        if show_title:
            height = 26
        else:
            height = 20
        height = 30

        top = my.top
        top.add_class("spt_button_top")
        top.add_style("overflow: hidden")


        #border = top.get_color("border")
        #top.add_border(-20)
        top.add_gradient("background", "background", 20, -35)
        top.add_style("border-width: 1px 0 1px 0")
        top.add_style("border-style: solid")
        top.add_style("border-color: %s" % top.get_color('border'))
        #top.add_style("margin-left: -1px")

        inner = my.inner
        top.add(inner)
        inner.add_color("color", "color3")
        inner.add_style("padding-top: 3px")
        inner.add_style("overflow: hidden")

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

        inner.add_class("hand")
        inner.add_style("z-index: 20")
        #inner.add_style("overflow: hidden")
        #inner.add_style("opacity: 0.5")
        inner.add_attr("title", title)

        my.button.add_style("margin-top: 5px")
        inner.add(my.button)
        icon_str = my.kwargs.get("icon")
        icon = IconWdg(title, icon_str)
        my.button.add(icon)
        icon.add_class("spt_button_icon")

        my.show_arrow = my.kwargs.get("show_arrow") in [True, 'true']
        if my.show_arrow or my.dialog:
            arrow = IconWdg(title, IconWdg.ARROW_MORE_INFO)
            inner.add(arrow)
            arrow.add_style("position: absolute")
            arrow.add_style("float: left")
            arrow.add_style("margin-left: 2px")
            arrow.add_style("margin-top: -10px")




        inner.add_style("font-size: 8px")
        inner.add_style("height: %spx" % height)
        inner.add_style("width: %spx" % width)
        inner.add_style("text-align: center")

        show_title = False
        if show_title:
            title_div = DivWdg()
            title_div.add(title)
            inner.add(title_div)



        inner.add_behavior( {
        'type': 'click',
        'width': width,
        'cbjs_action': '''
            var button = bvr.src_el;
            button.setStyle("border-style", "ridge");
            button.setStyle("width", bvr.width-2);
        '''
        } )


        inner.add_behavior( {
        'type': 'click_up',
        'width': width,
        'cbjs_action': '''
            var button = bvr.src_el;
            button.setStyle("border-style", "none");
            button.setStyle("width", bvr.width);
        '''
        } )


        inner.add_behavior( {
        'type': 'hover',
        'width': width,
        'cbjs_action_over': '''
            var button = bvr.src_el;
            var icon = button.getElement(".spt_button_icon");
            icon.setStyle('opacity', '1');
        ''',
        'cbjs_action_out': '''
            var button = bvr.src_el;
            button.setStyle("border-style", "none");
            var icon = button.getElement(".spt_button_icon");
            icon.setStyle('opacity', '0.5');

            button.setStyle("width", bvr.width);

        '''
 
        } )


        if show_menu in ['true', True]:
            inner.add_style("float: left")
            arrow_div = DivWdg()
            top.add(arrow_div)
            arrow_div.add_style("opacity: 0.5")
            arrow_div.add_style("z-index: 100")
            arrow_div.add_style("height: %spx" % height)
            arrow_div.add_style("border-left: dotted 1px %s" % arrow_div.get_color("border") )
            #arrow_div.add_style("margin-left: -15px")
            arrow_div.add_style("float: left")

            arrow = DivWdg(IconWdg("More Options", IconWdg.ARROW_MORE_INFO))
            arrow.add_style("margin-top: 8px")
            arrow_div.add(arrow)
            arrow_div.add_style("position: relative")


            arrow_div.add_behavior( {
            'type': 'hover',
            'cbjs_action_over': '''
                var button = bvr.src_el;
                var height = parseInt(button.getStyle("height").replace("px",""));
                var width = parseInt(button.getStyle("width").replace("px",""));
                button.setStyle('opacity', '1');
                button.setStyle('border', 'solid 1px red');
                button.setStyle("height", height-2);
                button.setStyle("width", width-2);
            ''',
            'cbjs_action_out': '''
                var button = bvr.src_el;

                var height = parseInt(button.getStyle("height").replace("px",""));
                var width = parseInt(button.getStyle("width").replace("px",""));

                button.setStyle('opacity', '0.5');
                button.setStyle('border', '');
                button.setStyle("height", height+2);
                button.setStyle("width", width+2);
            '''
     
            } )

            my.add_menu_wdg(arrow_div)



        if is_disabled in ['true', True]:
            disabled_div = DivWdg()
            disabled_div.add_class("spt_save_button_disabled")
            disabled_div.set_attr("title", "%s (Disabled)" % title)
            disabled_div.add_style("position: relative")
            disabled_div.add_style("height: %spx" % (height+3))
            disabled_div.add_style("width: %spx" % width)
            #disabled_div.add_style("margin-left: -%spx" % width)
            disabled_div.add_style("margin-top: -%spx" % (height+3))
            disabled_div.add_style("opacity", "0.6")
            disabled_div.add_style("background", "#AAA")
            inner.add_style("opacity", "1")
            top.add(disabled_div)



        if my.dialog:
            top.add(my.dialog)
            dialog_id = my.dialog.get_id()
            inner.add_behavior( {
            'type': 'load',
            'height': height,
            'dialog_id': dialog_id,
            'cbjs_action': '''
            var pos = bvr.src_el.getPosition();
            var el = $(bvr.dialog_id);
            el.setStyle("left", pos.x);
            el.setStyle("top", pos.y+bvr.height+13);
            '''
            } )

            my.inner.add_behavior( {
            'type': 'click_up',
            'dialog_id': dialog_id,
            'cbjs_action': '''
            var dialog = $(bvr.dialog_id);
            spt.toggle_show_hide(dialog);
            '''
            } )


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

        top = DivWdg()
        title = DivWdg()

        top.add(title)
        top.add_color("background", "background")
        top.add_style("margin: 0px 10px 15px 10px")
        #top.set_box_shadow()

        title.add("More Information")
        title.add_style("font-size: 16px")
        title.add_style("padding: 5px")
        title.add_color("background", "background", -5)
        title.add_border()
        #title.set_round_corners(corners=['TL','TR'])

        content_wdg = DivWdg()
        top.add(content_wdg)
        content_wdg.add_border()
        content_wdg.add_style("padding: 20px")

        content_wdg.add(
            "<div style='font-size: 12px'>The following links will help you find out more information on how to set-up or use TACTIC.</div>"
        )
        content_wdg.add("<hr/>")

        hover = title.get_color("background", -10)

        links_div = DivWdg()
        links_div.add_style("padding: 10px")
        content_wdg.add(links_div)

        # documentation linke
        link_div = DivWdg()
        link_div.add_style("padding-left: 10px")
        links_div.add(link_div)

        icon = IconWdg("Documentation", IconWdg.DOCUMENTATION)

        icon.set_box_shadow("2px 2px 5px")
        icon.add_border()
        icon.add_style("padding: 5px 3px 5px 7px")
        icon.set_round_corners()
        icon.add_color("background", "background3")

        link_div.add(icon)
        link_div.add("&nbsp;" * 2)

        link = HtmlElement.href("Documentation", "/doc/", target="_blank")
        link_div.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.help.set_top();
            spt.help.load_alias("main");
            '''
        })

        link_div.add_behavior({
            'type':
            'hover',
            'color':
            hover,
            'cbjs_action_over':
            '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
            'cbjs_action_out':
            '''
        bvr.src_el.setStyle("background", "");
        '''
        })
        link_div.add(link)
        link.add_color("color", "color")

        links_div.add("<br/>")

        link_div = DivWdg()
        link_div.add_style("padding-left: 10px")
        links_div.add(link_div)

        icon = IconWdg("Community", IconWdg.COMMUNITY)

        icon.set_box_shadow("2px 2px 5px")
        icon.add_border()
        icon.add_style("padding: 5px 3px 5px 7px")
        icon.set_round_corners()
        icon.set_round_corners()
        icon.add_color("background", "background3")

        link_div.add(icon)
        link_div.add("&nbsp;" * 2)
        link = HtmlElement.href("Community",
                                "http://community.southpawtech.com",
                                target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link_div.add_behavior({
            'type':
            'hover',
            'color':
            hover,
            'cbjs_action_over':
            '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
            'cbjs_action_out':
            '''
        bvr.src_el.setStyle("background", "");
        '''
        })

        links_div.add("<br/>")

        # documentation link
        link_div = DivWdg()
        link_div.add_style("padding-left: 10px")
        links_div.add(link_div)

        icon = IconWdg("Support", IconWdg.WEBSITE)

        icon.set_box_shadow("2px 2px 5px")
        icon.add_border()
        icon.add_style("padding: 5px 3px 5px 7px")
        icon.set_round_corners()
        icon.add_color("background", "background3")

        link_div.add(icon)
        link_div.add("&nbsp;" * 2)

        link = HtmlElement.href("Support",
                                "http://www.southpawtech.com",
                                target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link_div.add_behavior({
            'type':
            'hover',
            'color':
            hover,
            'cbjs_action_over':
            '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
            'cbjs_action_out':
            '''
        bvr.src_el.setStyle("background", "");
        '''
        })

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

        div = DivWdg()

        if not Container.get_dict("JSLibraries", "spt_popup"):
            div.add_style("position: fixed")
            div.add_style("top: 0px")
            div.add_style("left: 0px")
            div.add_style("opacity: 0.4")
            div.add_style("background", "#000")
            div.add_style("padding: 100px")
            div.add_style("height: 100%")
            div.add_style("width: 100%")
            div.add_class("spt_popup_background")
            div.add_style("display: none")
            div.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.hide(bvr.src_el);
                '''
            } ) 

        Container.put("PopupWdg:background", True)



        # This is the absolute outside of a popup, including the drop shadow
        widget = DivWdg()
        div.add(widget)
        widget.add_class("spt_popup")



        if not Container.get_dict("JSLibraries", "spt_popup"):
            widget.add_behavior( {
                'type': 'load',
                'cbjs_action': my.get_onload_js()
            } )


        width = my.kwargs.get("width")
        if not width:
            width = 10

        #widget.add_behavior( {
        #    'type': 'load',
        #    'cbjs_action': 'bvr.src_el.makeResizable({handle:bvr.src_el.getElement(".spt_popup_resize")})'
        #} )


        web = WebContainer.get_web()


        widget.set_id(my.name)
        if my.kwargs.get("display") == "true":
            pass
        else:
            widget.add_style("display: none")

        widget.add_style("position: absolute")
        widget.add_style("left: 400px")
        widget.add_style("top: 100px")

        widget.add_border()
        widget.add_color("background", "background")

        #widget.set_box_shadow(color="#000")
        widget.set_box_shadow()


        table = Table()
        table.add_behavior( {
        'type': 'load',
        'width': width,
        'cbjs_action': '''
        bvr.src_el.setStyle("width", bvr.width)

        var popup = bvr.src_el.getParent(".spt_popup");
        var window_size = $(window).getSize();
        var size = bvr.src_el.getSize();
        var left = window_size.x/2 - size.x/2;
        var top = window_size.y/2 - size.y/2;
        popup.setStyle("left", left);
        //popup.setStyle("top", top);

        '''
        } )



        table.add_row()

        """
        # Qt doesn't support shadows very well
        if web.get_browser() == 'Qtx':
            # dynamically add css files

            table.add_class("css_shadow_table")
            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_top_left SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_top SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_top_right SPT_POPUP_SHADOW")


            # Middle (Content) Row of Shadow table ...
            table.add_row()

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_left SPT_POPUP_SHADOW")
        """

        content_td = table.add_cell()
        content_td.add_class("css_shadow_td")

        """
        if web.get_browser() == 'Qtx':
            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_right SPT_POPUP_SHADOW")


            # Bottom Row of Shadow table ...
            table.add_row()

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_bottom_left SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_bottom SPT_POPUP_SHADOW")

            td = table.add_cell()
            td.add_class("css_shadow_td css_shadow_bottom_right SPT_POPUP_SHADOW")
        """


        drag_div = DivWdg()

        #from tactic.ui.container import ArrowWdg
        #arrow = ArrowWdg()
        #drag_div.add(arrow)


        # FIXME: for some reason, this causes popups to stop functioning after
        # close a couple of times
        my.add_header_context_menu(drag_div)


        # create the 'close' button ...
        if my.allow_close:
            close_wdg = SpanWdg(css='spt_popup_close')
            #close_wdg.add( IconWdg("Close", IconWdg.POPUP_WIN_CLOSE) )
            close_wdg.add( IconWdg("Close", "BS_REMOVE") )
            close_wdg.add_style("margin: 5px 1px 3px 1px")
            close_wdg.add_style("float: right")
            close_wdg.add_class("hand")

            close_wdg.add_behavior({
                'type': 'click_up',
                'cbjs_action': my.get_cancel_script()
            })

            drag_div.add(close_wdg)


            # create the 'minimize' button ...
            minimize_wdg = SpanWdg(css='spt_popup_min')
            minimize_wdg.add_style("margin: 5px 1px 3px 1px")
            #minimize_wdg.add( IconWdg("Minimize", IconWdg.POPUP_WIN_MINIMIZE) )
            minimize_wdg.add( IconWdg("Minimize", "BS_MINUS") )
            minimize_wdg.add_style("float: right")
            minimize_wdg.add_class("hand")
            behavior = {
                'type': 'click_up',
                'cbjs_action': "spt.popup.toggle_minimize( bvr.src_el );"
            }
            minimize_wdg.add_behavior( behavior );
            drag_div.add(minimize_wdg)

        #-- TO ADD SOON -- create the 'refresh' button ...
        #   refresh_wdg = SpanWdg()
        #   refresh_wdg.add( IconWdg("Refresh Popup", IconWdg.POPUP_WIN_REFRESH) )
        #   refresh_wdg.add_style("float: right")
        #   refresh_wdg.add_class("hand")
        #   behavior = {
        #       'type': 'click_up',
        #       'cbjs_action': "spt.popup.toggle_minimize( bvr.src_el );"
        #   }
        #   refresh_wdg.add_behavior( behavior );
        #   drag_div.add(refresh_wdg)

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

        # style
        drag_div.add_style("font-size: 1.1em")

        drag_div.add_style("text-align: left")
        drag_div.add_class("spt_popup_width")

        drag_handle_div = DivWdg(id='%s_title' %my.name)
        drag_handle_div.add_style("padding: 12px;")
        #drag_handle_div.add_gradient("background", "background", +10)
        drag_handle_div.add_color("background", "background", -5)
        drag_handle_div.add_color("color", "color")
        drag_handle_div.add_style("font-weight", "bold")
        drag_handle_div.add_style("font-size", "12px")


        # add the drag capability.
        # NOTE: need to use getParent because spt.popup has not yet been
        # initialized when this is processed
        shadow_color = drag_div.get_color("shadow")
        drag_div.add_behavior( {
            'type':'smart_drag',
            'shadow_color': shadow_color,
            'drag_el': "@.getParent('.spt_popup')",
            'bvr_match_class': 'spt_popup_title',
            'options': {'z_sort': 'bring_forward'},
            'ignore_default_motion': 'true',
            "cbjs_setup": '''
              if (spt.popup.is_background_visible) {
                  spt.popup.offset_x = document.body.scrollLeft;
                  spt.popup.offset_y = document.body.scrollTop;
                  spt.popup.hide_background();
                  var parent = bvr.src_el.getParent(".spt_popup");
                  parent.setStyle("box-shadow","0px 0px 20px " + bvr.shadow_color);
              }
              else {
                  spt.popup.offset_x = 0;
                  spt.popup.offset_y = 0;
              }
            ''',
            "cbjs_motion": '''
              mouse_411.curr_x += spt.popup.offset_x;
              mouse_411.curr_y += spt.popup.offset_y;
              spt.mouse.default_drag_motion(evt, bvr, mouse_411);
            ''',
            "cbjs_action": ''
        } )


        
        title_wdg = my.title_wdg
        if not title_wdg:
            title_wdg = "No Title"
        #else:
        #    title_wdg = title_wdg

        drag_handle_div.add_behavior({
            'type': 'double_click',
            'cbjs_action': my.get_cancel_script()
        })


        drag_handle_div.add(title_wdg)
        drag_handle_div.add_class("spt_popup_title")


        # add a context menu
        from tactic.ui.container.smart_menu_wdg import SmartMenu
        SmartMenu.assign_as_local_activator( drag_handle_div, 'HEADER_CTX' )
        drag_handle_div.add_attr("spt_element_name", "Test Dock")



        # add the content
        content_div = DivWdg()
        content_div.add_color("color", "color2")
        #content_div.add_color("background", "background2")
        from pyasm.web.palette import Palette
        palette = Palette.get()
        content_div.add_color("color", "color2")
        content_div.add_color("background", "background2")

        content_div.add_style("margin", "0px, -1px -0px -1px")

        content_div.set_id("%s_content" % my.name)
        content_div.add_class("spt_popup_content")
        content_div.add_style("overflow: hidden")
        content_div.add_style("display: block")
        #content_div.add_style("padding: 10px")
        if not my.content_wdg:
            my.content_wdg = "No Content"

        content_div.add(my.content_wdg)

        drag_div.add( drag_handle_div )
        my.position_aux_div(drag_div, content_div)
        content_td.add(drag_div)
        widget.add(table)

        # ALWAYS make the Popup a Page Utility Widget (now processed client side)
        widget.add_class( "SPT_PUW" )

        if my.z_start:
            widget.set_z_start( my.z_start )
            widget.add_style("z-index: %s" % my.z_start)
        else:
            widget.add_style("z-index: 102")


        # add the resize icon
        icon = IconWdg( "Resize", IconWdg.RESIZE_CORNER )
        icon.add_style("cursor: nw-resize")
        icon.add_style("z-index: 1000")
        icon.add_class("spt_popup_resize")
        icon.add_style("float: right")
        icon.add_style("margin-top: -15px")
        icon.add_behavior( {
        'type': 'drag',
        "drag_el": '@',
        "cb_set_prefix": 'spt.popup.resize_drag'
        } )
        content_td.add(icon)

        #return widget
        return div
Beispiel #31
0
    def get_display(my):
        top = my.top
        my.set_as_panel(top)
        top.add_class("spt_delete_top")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_border()
        top.add_style("width: 300px")
        top.add_border()


        search_key = my.kwargs.get("search_key")
        search_keys = my.kwargs.get("search_keys")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            sobjects = [sobject]
            search_keys = [search_key]
        elif search_keys:
            sobjects = Search.get_by_search_keys(search_keys)
            sobject = sobjects[0]

        if not sobjects:
            msg =  "%s not found" %search_key
            return msg
        search_type = sobject.get_base_search_type()

        if search_type in ['sthpw/project', 'sthpw/search_object']:
            msg = 'You cannot delete these items with this tool'
            return msg


        my.search_keys = search_keys


        title = DivWdg()
        top.add(title)
        title.add_color("background", "background", -10)
        if my.search_keys:
            title.add("Delete %s Items" % len(my.search_keys))
        else:
            title.add("Delete Item [%s]" % (sobject.get_code()))
        title.add_style("font-size: 14px")
        title.add_style("font-weight: bold")
        title.add_style("padding: 10px")

        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")


        content.add("The item to be deleted has a number of dependencies as described below:<br/>", 'heading')

        # find all the relationships
        related_types = SearchType.get_related_types(search_type, direction='children') 
       
        items_div = DivWdg()
        content.add( items_div )
        items_div.add_style("padding: 10px")
        valid_related_ctr = 0
        for related_type in related_types:
            if related_type == "*":
                print "WARNING: related_type is *"
                continue
            if related_type == search_type:
                continue
            if related_type in ['sthpw/search_object','sthpw/search_type']:
                continue

            item_div = my.get_item_div(sobjects, related_type)
            if item_div:
                items_div.add(item_div)
                valid_related_ctr += 1


        

        if valid_related_ctr > 0:
            icon = IconWdg("WARNING", IconWdg.WARNING)
            icon.add_style("float: left")
            content.add( icon )
            content.add("<div><b>WARNING: By selecting the related items above, you can delete them as well when deleting this sObject.</b></div>")
            content.add("<br/>"*2)
        else:
            # changed the heading to say no dependencies
            content.add("The item to be deleted has no dependencies.<br/>", 'heading')


        content.add("There are %s items to be deleted" % len(my.search_keys))
        content.add("<br/>"*2)

        content.add("Do you wish to continue deleting?")
        content.add("<br/>"*2)

        button_div = DivWdg()
        button_div.add_styles('width: 300px; height: 75px')
        button = ActionButtonWdg(title="Delete")
        button_div.add(button)
        content.add(button_div)
        button.add_style("float: left")

        button.add_behavior( {
        'type': 'click_up',
        'search_keys': my.search_keys,
        'cbjs_action': '''
        spt.app_busy.show("Deleting");

        var top = bvr.src_el.getParent(".spt_delete_top");
        var values = spt.api.Utility.get_input_values(top);

        var class_name = "tactic.ui.tools.DeleteCmd";
        var kwargs = {
            'search_keys': bvr.search_keys,
            'values': values
        };

        var del_trigger = function() {
            
            // for fast table
            var tmps = spt.split_search_key(bvr.search_keys[0])
            var tmps2 = tmps[0].split('?');
            var del_st_event = "delete|" + tmps2[0];
            var bvr_fire = {};
            var input = {'search_keys': bvr.search_keys};
            bvr_fire.options = input;
            spt.named_events.fire_event(del_st_event, bvr_fire);
        }

        var server = TacticServerStub.get();
        try {
            server.start({'title': 'Delete sObject', 'description': 'Delete sObject [' + bvr.search_keys + ']'});
            server.execute_cmd(class_name, kwargs);
            server.finish();

            // run the post delete and destroy the popup
            var popup = bvr.src_el.getParent(".spt_popup");
            if (popup.spt_on_post_delete) {
                popup.spt_on_post_delete();
            }

            del_trigger();

            spt.popup.destroy(popup);


        }
        catch(e) {
            spt.alert(spt.exception.handler(e));
        }

        spt.app_busy.hide();
       
        '''
        } )



        button = ActionButtonWdg(title="Cancel")
        button.add_style("float: left")
        button_div.add(button)
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        } )


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


        return top
Beispiel #32
0
    def get_display(my):
        top = my.top
        top.add_class("spt_subscription_bar_top")
        my.set_as_panel(top)

        top.add_style("width: 40px")
        top.add_style("height: 20px")

        #top.add_class("hand")




        interval = my.kwargs.get("interval")
        if not interval:
            interval = 10 * 1000
        else:
            interval = int(interval) * 1000

        inner = DivWdg()
        top.add(inner)

        my.set_refresh(inner,interval,panel_cls='spt_subscription_bar_top')

        mode = my.kwargs.get("mode")
        if not mode:
            mode = "tab"

        dialog_open = my.kwargs.get("dialog_open")
        if dialog_open in [True, 'true']:
            dialog_open = True
        else:
            dialog_open = False


        mode = "dialog"
        if mode == "dialog":

            from tactic.ui.container import DialogWdg
            dialog = DialogWdg(display=dialog_open, show_title=False)
            inner.add(dialog)
            dialog.set_as_activator(inner)
            subscription_wdg = SubscriptionWdg()
            dialog.add(subscription_wdg)
            subscription_wdg.add_style("width: %spx"%(my.WIDTH+50))
            subscription_wdg.add_color("background", "background")
            subscription_wdg.add_style("height: 500px")

        elif mode == "popup":
            top.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                var class_name = 'tactic.ui.app.SubscriptionWdg';
                var kwargs = {};
                spt.panel.load_popup("Subscriptions", class_name, kwargs);
                '''
            } )
        else:
            top.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.tab.set_main_body_tab();
                var class_name = 'tactic.ui.app.SubscriptionWdg';
                var kwargs = {};
                spt.tab.add_new("Subscriptions", "Subscriptions", class_name, kwargs);
                '''
            } )


        color = inner.get_color("border") 
        inner.add_style("border-style: solid")
        inner.add_style("border-size: 1px")
        inner.add_style("border-color: transparent")
        inner.set_round_corners(5)
        inner.add_style("padding: 2px")

        inner.add_behavior( {
            'type': 'mouseenter',
            'color': color,
            'cbjs_action': '''
            bvr.src_el.setStyle("border", "solid 1px "+bvr.color);
            '''
        } )
        inner.add_behavior( {
            'type': 'mouseleave',
            'cbjs_action': '''
            bvr.src_el.setStyle("border-color", "transparent");
            '''
        } )


        category = None
        subscriptions = my.get_subscriptions(category)


        #if not subscriptions:
        #    inner.add_style("display: none")


        num = len(subscriptions)
        # the word message takes up too much space
        """
        if num <= 1:
            msg = "%s message" % num
        else:
            msg = "%s messages" % num
        """
        if num > 0:
            msg = num
        else:
            msg = ''
        icon = IconWdg(msg, IconWdg.STAR)
        icon.add_style('float: left')
        inner.add(icon)
        msg_div = DivWdg(msg)
        msg_div.add_style('padding-top: 1px')
        #msg_div.add_style('border-width: 1px')
        #msg_div.add_styles('border-radius: 50%; width: 18px; height: 18px; background: white')
        inner.add(msg_div)

        if my.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
Beispiel #33
0
    def get_display(my):
        my.display_expr = my.kwargs.get('display_expr')
        my.values = []

        instance_type = my.get_option("instance_type")
        accepted_type = my.get_option("accepted_drop_type")

        div = DivWdg()
        div.add_class("spt_drop_element_top")
        div.add_style("width: 100%")
        div.add_style("height: 100%")
        div.add_style("min-width: 100px")
        div.add_style("max-height: 300px")
        div.add_style("overflow-y: auto")

        my.value_wdg = HiddenWdg(my.get_name())
        my.value_wdg.add_class("spt_drop_element_value")
        div.add( my.value_wdg )



        version = my.parent_wdg.get_layout_version()
        #if version != "2":
        my.add_drop_behavior(div, accepted_type)



        # add the hidden div which holds containers info for the sobject
        template_div = DivWdg()
        template_div.add_style("display: none")
        template_item = my.get_item_div(None)

        # float left for the new icon beside it
        item_div = template_item.get_widget('item_div')
        item_div.add_style('float: left')

        template_item.add_class("spt_drop_template")
        #template_item.add_style('float: left')
        new_icon = IconWdg("New", IconWdg.NEW)
        new_icon.add_style('padding-left','3px')
        #TODO: insert the new_icon at add(new_icon, index=0) and make sure
        # the js-side sobject_drop_action cloning align the template div properly
        #template_item.add(" - ")
        template_item.add(new_icon)
        template_div.add(template_item)
        div.add(template_div)


        # list out the relationships
        #sobject = my.get_current_sobject()
        #search_type = sobject.get_base_search_type()

 
        content_div = DivWdg()
        div.add(content_div)
        # shrink wrapping for FF
        content_div.add_style('float: left')
        content_div.add_class("spt_drop_content")

        if instance_type:
            instance_wdg = my.get_instance_wdg(instance_type)
            content_div.add(instance_wdg)
            
        return div
Beispiel #34
0
    def get_display(self):

        self.sobject_data = {}

        top = self.top
        top.add_style
        top.add_class("spt_gallery_top")

        inner = DivWdg()
        top.add(inner)

        # make the whole Gallery unselectable
        inner.add_class('unselectable')
        inner.add_style("position: fixed")
        inner.add_style("top: 0px")
        inner.add_style("left: 0px")
        inner.add_style("width: 100%")
        #inner.add_style("height: 100%")
        inner.add_style("bottom: 0px")
        inner.add_style("padding-bottom: 40px")

        #inner.add_style("background: rgba(0,0,0,0.5)")
        inner.add_style("background: rgba(0,0,0,1)")
        inner.add_style("z-index: 2000")


        width = self.kwargs.get("width")
        height = self.kwargs.get("height")
        
        # default to top.
        align = self.kwargs.get("align")
        if not align:
            align = "top"


        if not width:
            width = 1300
        else:
            width = int(width)


        paths = self.get_paths(file_type='main')
        # icon type may be too small
        thumb_paths = self.get_paths(file_type='web')
        
        descriptions = []
        for path in paths:
            sobject = self.sobject_data.get(path)
            if not sobject:
                descriptions.append("")
            else:
                description = sobject.get("description")
                if not description:
                    description = ""
                descriptions.append(description)

        total_width = width * len(paths)
        inner.add_behavior( {
        'type': 'load',
        'width': width,
        'total_width': total_width,
        'descriptions': descriptions,
        'cbjs_action': '''
        spt.gallery = {};
        // 1250 is defined also in the css styles
        spt.gallery.portrait = window.innerWidth < 1250;
        spt.gallery.portrait = false

        
        spt.gallery.top = bvr.src_el;
        spt.gallery.content = spt.gallery.top.getElement(".spt_gallery_content");
        spt.gallery.content.setStyle('opacity','0.1')
        spt.gallery.desc_el = spt.gallery.top.getElement(".spt_gallery_description");
        
        //window.addEvent('domready', function() {
        setTimeout(function() {
		// set the img h or w directly
		var items = bvr.src_el.getElements('.spt_gallery_item img');
		// fade in
        spt.gallery.content.set('tween', {duration: 250}).fade('in');

        /*
		for (var k=0; k < items.length; k++) {
		    var sizes = items[k].getSize();
		    var item_h = sizes.y;
		    var item_w = sizes.x;
		    if (item_h >= item_w){
			    //items[k].setStyle('width', 'auto');
			    //items[k].setStyle('height', '100%');
		    }
		    else {
			    //items[k].setStyle('width','auto');
			    //items[k].setStyle('height','100%');
		    }
		    
		}
        */


        }, 50)

        spt.gallery.width = bvr.width;
        spt.gallery.descriptions = bvr.descriptions;
        spt.gallery.index = 0;
        spt.gallery.total = bvr.descriptions.length;
        spt.gallery.left_arrow = bvr.src_el.getElement('.spt_left_arrow');
        spt.gallery.right_arrow = bvr.src_el.getElement('.spt_right_arrow');
        spt.gallery.videos = {};
       

        spt.gallery.init = function() {
            
        }

        spt.gallery.stack = [];

        spt.gallery.push_stack = function(key) {
            spt.gallery.stack.push(key);
        }


        spt.gallery.show_next = function(src_el) {
            if (!src_el)
                src_el = spt.gallery.right_arrow;
           
            if (spt.gallery.index >= spt.gallery.total-2) {
                spt.hide(src_el);
            }
            if (spt.gallery.index == spt.gallery.total-1) {
                return;
            }
            spt.gallery.index += 1;
            spt.gallery.show_index(spt.gallery.index);
        }

        spt.gallery.show_prev = function(src_el) {
            if (!src_el)
                src_el = spt.gallery.left_arrow;
            if (spt.gallery.index <= 1) {
                spt.hide(src_el);
            
            }
            if (spt.gallery.index == 0) {
                return;
            }
            
            spt.gallery.index -= 1;
            spt.gallery.show_index(spt.gallery.index);
        }


        spt.gallery.show_index = function(index) {

          
            // stop all videos
            var videos = spt.gallery.top.getElements(".video-js");
            for (var i = 0; i < videos.length; i++) {
                try {
                    var video = videos[i];
                    var video_id = video.get("id");
                    var video_obj = videojs(video_id,  {"nativeControlsForTouch": false});
                    video_obj.pause();

                }
                catch(e) {
                }
            }


            // can't tween percentage with this library???
            var width = spt.gallery.width;
            var margin = - width * index;
            var content = spt.gallery.content;
            //content.setStyle("margin-left", margin + "px");
            new Fx.Tween(content,{duration: 250}).start("margin-left", margin);
 


            spt.gallery.index = index;
            var total = spt.gallery.total;
            
           
            if (index == 0) {
                spt.hide(spt.gallery.left_arrow);
                spt.show(spt.gallery.right_arrow);
            }
            else if (index == total - 1) {
                spt.show(spt.gallery.left_arrow);
                spt.hide(spt.gallery.right_arrow);
            }
            else {
                spt.show(spt.gallery.left_arrow);
                spt.show(spt.gallery.right_arrow);
            }
                

            
            var description = spt.gallery.descriptions[index];
            if (!description) {
                description = (index+1)+" of "+total;
            }
            else {
                description = (index+1)+" of "+total+" - " + description;
            }
            spt.gallery.set_description(description);
        }


        spt.gallery.close = function() {
            var content = spt.gallery.content;
            var top = content.getParent(".spt_gallery_top");
            spt.behavior.destroy_element(top);
        }


        spt.gallery.set_description = function(desc) {
            var desc_el = spt.gallery.desc_el;
            desc_el.innerHTML = desc;
        }

        '''
        } )




        scroll = DivWdg(css='spt_gallery_scroll')
        inner.add(scroll)
        scroll.set_box_shadow()
        scroll.add_style("width: %s" % width)
        if height:
            scroll.add_style("height: %s" % height)
        scroll.add_style("overflow-x: hidden")
        scroll.add_style("overflow-y: hidden")
        scroll.add_style("background: #000")

        #scroll.add_style("position: absolute")
        scroll.add_style("margin-left: auto")
        scroll.add_style("margin-right: auto")



        

        content = DivWdg()
        top.add_attr('tabindex','-1')

        scroll.add(content)
        content.add_class("spt_gallery_content")

        # make the items vertically align to bottom (flex-emd)
        # on a regular monitor, align to top (flex-start) is better
        if align == 'bottom':
            align_items = 'flex-end'
        else:
            align_items = 'flex-start'
        content.add_styles("display: flex; flex-flow: row nowrap; align-items: %s; justify-content: center;"%align_items)

        content.add_style("width: %s" % total_width)

        top.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            bvr.src_el.focus();
            '''
        } )
 
        top.add_behavior( {
            'type': 'mouseenter',
            'cbjs_action': '''
            bvr.src_el.focus();
            '''
        } )
        top.add_behavior( {
            'type': 'mouseleave',
            'cbjs_action': '''
            bvr.src_el.blur();
            '''
        } )


        """
        input = TextWdg("keydown")
        content.add(input)
        input.add_style("position: absolute")
        input.add_style("left: -5000px")
        """
        top.add_behavior( {
            'type': 'keydown',
            'cbjs_action': '''
            var key = evt.key;
            
            if (key == "left") {
                spt.gallery.push_stack(key);
                spt.gallery.show_prev();
            }
            else if (key == "right") {
                spt.gallery.push_stack(key);
                spt.gallery.show_next();
            }
            else if (key == "esc" || key == "enter") {
                
                var top = bvr.src_el
                spt.behavior.destroy_element(top);
            }



            '''
        } )



        curr_index = 0
        for i, path in enumerate(paths):
            path_div = DivWdg(css='spt_gallery_item')
            content.add(path_div)
            #path_div.add_style("float: left")
            path_div.add_style("display: inline-block")
            path_div.add_style("vertical-align: middle")

            if path == self.curr_path:
                curr_index = i

            try:
                thumb_path = thumb_paths[i]
            except IndexError:
                print "Cannot find the thumb_path [%s] "%i 
                thumb_path = ''

            #path_div.add_style("width: %s" % width)
            #if height:
            #    path_div.add_style("height: %s" % height)
            path_div.add_style("width: 100%")
            path_div.add_style("height: 100%")
            path_div.add_style("overflow-x: hidden")
            path_div.add_style("overflow-y: hidden")

            from tactic.ui.widget import EmbedWdg
            embed = EmbedWdg(src=path, click=False, thumb_path=thumb_path, index=i, controls="true")
            path_div.add(embed)




        content.add_behavior({
            'type': 'load',
            'index': curr_index,
            'cbjs_action': '''
            if (!bvr.index) bvr.index = 0;
            spt.gallery.show_index(bvr.index);
            '''
        } )



        #icon = IconWdg(title="Close", icon="/plugins/remington/pos/icons/close.png")
        icon = IconWdg(title="Close", icon="/context/icons/glyphs/close.png", width="40px")
        inner.add(icon)
        icon.add_style("position: absolute")
        icon.add_style("cursor: pointer")
        icon.add_style("top: 30px")
        icon.add_style("right: 38px")
        icon.add_style("opacity: 0.5")
        icon.add_behavior( {
            'type': 'click_up' ,
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_gallery_top");
            spt.behavior.destroy_element(top);
            '''
        } )
        icon.add_style("background", "rgba(48,48,48,0.7)")
        icon.add_style("border-radius", "5px")


        icon = IconWdg(title="Previous", icon="/context/icons/glyphs/chevron_left.png")
        inner.add(icon)
        icon.add_class('spt_left_arrow')
        icon.add_style("cursor: pointer")
        icon.add_style("position: absolute")
        icon.add_style("top: 40%")
        icon.add_style("left: 0px")
        icon.add_style("opacity: 0.5")
        icon.add_behavior( {
            'type': 'click_up' ,
            'cbjs_action': '''
            var arrow = bvr.src_el;
            spt.gallery.show_prev(arrow); 
            '''
        } )
        icon.add_style("background", "rgba(48,48,48,0.7)")
        icon.add_style("border-radius", "5px")


        icon = IconWdg(title="Next", icon="/context/icons/glyphs/chevron_right.png")
        inner.add(icon)
        icon.add_class('spt_right_arrow')
        icon.add_style("position: absolute")
        icon.add_style("cursor: pointer")
        icon.add_style("top: 40%")
        icon.add_style("right: 0px")
        icon.add_style("opacity: 0.5")
        icon.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var arrow = bvr.src_el;
            spt.gallery.show_next(arrow); 
            '''
        } )
        icon.add_style("background", "rgba(48,48,48,0.7)")
        icon.add_style("border-radius", "5px")




        desc_div = DivWdg()
        desc_div.add_class("spt_gallery_description")
        desc_div.add_style("height: 30px")
        desc_div.add_style("width: %s" % width)
        desc_div.add_style("text-align: center")
        desc_div.add_style("background: rgba(0,0,0,1)")
        desc_div.add_style("color: #bbb")
        desc_div.add_style("font-weight: bold")
        desc_div.add_style("font-size: 16px")
        desc_div.add_style("padding-top: 10px")
        desc_div.add_style("margin-left: -%s" % (width/2))
        desc_div.add_style("z-index: 1000")
        desc_div.add("")

        desc_outer_div = DivWdg()
        inner.add(desc_outer_div)
        desc_outer_div.add_style("position: fixed")
        desc_outer_div.add(desc_div)
        desc_outer_div.add_style("bottom: 0px")
        desc_outer_div.add_style("left: 50%")



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

        my.sobject_data = {}

        top = my.top
        top.add_style
        top.add_class("spt_gallery_top")

        inner = DivWdg()
        top.add(inner)
        inner.add_style("position: fixed")
        inner.add_style("top: 0")
        inner.add_style("left: 0")
        inner.add_style("width: 100%")
        #inner.add_style("height: 100%")
        inner.add_style("bottom: 0px")
        inner.add_style("padding-bottom: 40px")

        #inner.add_style("background: rgba(0,0,0,0.5)")
        inner.add_style("background: rgba(0,0,0,1)")
        inner.add_style("z-index: 1000")

        width = my.kwargs.get("width")
        height = my.kwargs.get("height")
        if not width:
            width = 1300
        else:
            width = int(width)

        paths = my.get_paths(file_type='main')
        # icon type may be too small
        thumb_paths = my.get_paths(file_type='web')

        descriptions = []
        for path in paths:
            sobject = my.sobject_data.get(path)
            if not sobject:
                descriptions.append("")
            else:
                description = sobject.get("description")
                if not description:
                    description = ""
                descriptions.append(description)

        total_width = width * len(paths)
        inner.add_behavior({
            'type':
            'load',
            'width':
            width,
            'total_width':
            total_width,
            'descriptions':
            descriptions,
            'cbjs_action':
            '''
        spt.gallery = {};
        // 1250 is defined also in the css styles
        spt.gallery.portrait = window.innerWidth < 1250;

       
        
        spt.gallery.top = bvr.src_el;
        spt.gallery.content = spt.gallery.top.getElement(".spt_gallery_content");
        spt.gallery.content.setStyle('opacity','0.1')
        spt.gallery.desc_el = spt.gallery.top.getElement(".spt_gallery_description");
        
        var height_factor = '100%'; 
        if (spt.gallery.portrait) {
            bvr.width = bvr.width * 0.8;
            var scroll = bvr.src_el.getElement('.spt_gallery_scroll');
            scroll.setStyle('width', bvr.width);
            scroll.setStyle('height', '80%');
            scroll.setStyle('position', 'relative');
            scroll.setStyle('top', '500px');
            
            var items = bvr.src_el.getElements('.spt_gallery_item');
            for (var k=0; k < items.length; k++) {
                items[k].setStyle('width', bvr.width);
                items[k].setStyle('height', '80%');
            }
            var left = bvr.src_el.getElement('.spt_left_arrow');
            var right = bvr.src_el.getElement('.spt_right_arrow');
            left.setStyle('top','88%')
            left.setStyle('left','35%')
            right.setStyle('top','88%')
            
            right.setStyle('right','35%')
            
            height_factor = '70%';
            
        }
        //window.addEvent('domready', function() {
        setTimeout(function() {
		// set the img h or w directly
		var items = bvr.src_el.getElements('.spt_gallery_item img');
		// fade in
        spt.gallery.content.set('tween', {duration: 250}).fade('in');

		for (var k=0; k < items.length; k++) {
		    var sizes = items[k].getSize();
		    var item_h = sizes.y;
		    var item_w = sizes.x;
		    if (item_h >= item_w){
			    items[k].setStyle('width', '');
			    items[k].setStyle('height', height_factor);
		    }
		    else {
			    items[k].setStyle('width','100%');
			    items[k].setStyle('height','');
		    }
		    
		}
        }, 50)
        spt.gallery.width = bvr.width;
        spt.gallery.descriptions = bvr.descriptions;
        spt.gallery.index = 0;
        spt.gallery.total = bvr.descriptions.length;
        spt.gallery.left_arrow = bvr.src_el.getElement('.spt_left_arrow');
        spt.gallery.right_arrow = bvr.src_el.getElement('.spt_right_arrow');
        spt.gallery.videos = {};
       

        spt.gallery.init = function() {
            
        }

        spt.gallery.stack = [];

        spt.gallery.push_stack = function(key) {
            spt.gallery.stack.push(key);
        }


        spt.gallery.show_next = function(src_el) {
            if (!src_el)
                src_el = spt.gallery.right_arrow;
           
            if (spt.gallery.index >= spt.gallery.total-2) {
                spt.hide(src_el);
            }
            if (spt.gallery.index == spt.gallery.total-1) {
                return;
            }
            spt.gallery.index += 1;
            spt.gallery.show_index(spt.gallery.index);
        }

        spt.gallery.show_prev = function(src_el) {
            if (!src_el)
                src_el = spt.gallery.left_arrow;
            if (spt.gallery.index <= 1) {
                spt.hide(src_el);
            
            }
            if (spt.gallery.index == 0) {
                return;
            }
            
            spt.gallery.index -= 1;
            spt.gallery.show_index(spt.gallery.index);
        }


        spt.gallery.show_index = function(index) {

          
            // stop all videos
            var videos = spt.gallery.top.getElements(".video-js");
            for (var i = 0; i < videos.length; i++) {
                try {
                    var video = videos[i];
                    var video_id = video.get("id");
                    var video_obj = videojs(video_id,  {"nativeControlsForTouch": false});
                    video_obj.pause();

                }
                catch(e) {
                }
            }
            var width = spt.gallery.width;
            var margin = - width * index;
            var content = spt.gallery.content;
            //content.setStyle("margin-left", margin + "px");
            new Fx.Tween(content,{duration: 250}).start("margin-left", margin);

            spt.gallery.index = index;
            var total = spt.gallery.total;
            
           
            if (index == 0) {
                spt.hide(spt.gallery.left_arrow);
                spt.show(spt.gallery.right_arrow);
            }
            else if (index == total - 1) {
                spt.show(spt.gallery.left_arrow);
                spt.hide(spt.gallery.right_arrow);
            }
            else {
                spt.show(spt.gallery.left_arrow);
                spt.show(spt.gallery.right_arrow);
            }
                

            
            var description = spt.gallery.descriptions[index];
            if (!description) {
                description = (index+1)+" of "+total;
            }
            else {
                description = (index+1)+" of "+total+" - " + description;
            }
            spt.gallery.set_description(description);
        }


        spt.gallery.close = function() {
            var content = spt.gallery.content;
            var top = content.getParent(".spt_gallery_top");
            spt.behavior.destroy_element(top);
        }


        spt.gallery.set_description = function(desc) {
            var desc_el = spt.gallery.desc_el;
            desc_el.innerHTML = desc;
        }

        '''
        })

        scroll = DivWdg(css='spt_gallery_scroll')
        inner.add(scroll)
        scroll.set_box_shadow()

        scroll.add_style("width: %s" % width)
        if height:
            scroll.add_style("height: %s" % height)
        scroll.add_style("overflow-x: hidden")
        scroll.add_style("overflow-y: hidden")
        scroll.add_style("background: #000")

        #scroll.add_style("position: absolute")
        scroll.add_style("margin-left: auto")
        scroll.add_style("margin-right: auto")

        content = DivWdg()
        top.add_attr('tabindex', '-1')

        scroll.add(content)
        content.add_class("spt_gallery_content")
        # make the itesm vertically align to bottom
        content.add_styles(
            "display: flex; flex-flow: row nowrap; align-items: flex-end;")
        content.add_style("width: %s" % total_width)

        top.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
            bvr.src_el.focus();
            '''
        })

        top.add_behavior({
            'type':
            'mouseenter',
            'cbjs_action':
            '''
            bvr.src_el.focus();
            '''
        })
        top.add_behavior({
            'type':
            'mouseleave',
            'cbjs_action':
            '''
            bvr.src_el.blur();
            '''
        })
        """
        input = TextWdg("keydown")
        content.add(input)
        input.add_style("position: absolute")
        input.add_style("left: -5000px")
        """
        top.add_behavior({
            'type':
            'keydown',
            'cbjs_action':
            '''
            var key = evt.key;
            
            if (key == "left") {
                spt.gallery.push_stack(key);
                spt.gallery.show_prev();
            }
            else if (key == "right") {
                spt.gallery.push_stack(key);
                spt.gallery.show_next();
            }
            else if (key == "esc" || key == "enter") {
                
                var top = bvr.src_el
                spt.behavior.destroy_element(top);
            }



            '''
        })

        curr_index = 0
        for i, path in enumerate(paths):
            path_div = DivWdg(css='spt_gallery_item')
            content.add(path_div)
            path_div.add_style("float: left")

            if path == my.curr_path:
                curr_index = i

            try:
                thumb_path = thumb_paths[i]
            except IndexError:
                print "Cannot find the thumb_path [%s] " % i
                thumb_path = ''

            path_div.add_style("width: %s" % width)
            if height:
                path_div.add_style("height: %s" % height)

            from tactic.ui.widget import EmbedWdg
            embed = EmbedWdg(src=path,
                             click=False,
                             thumb_path=thumb_path,
                             index=i)
            path_div.add(embed)

            #img = HtmlElement.img(path)
            #path_div.add(img)
            #img.add_style("width: 100%")

        content.add_behavior({
            'type':
            'load',
            'index':
            curr_index,
            'cbjs_action':
            '''
            if (!bvr.index) bvr.index = 0;
            spt.gallery.show_index(bvr.index);
            '''
        })

        #icon = IconWdg(title="Close", icon="/plugins/remington/pos/icons/close.png")
        icon = IconWdg(title="Close",
                       icon="/context/icons/glyphs/close.png",
                       width="40px")
        inner.add(icon)
        #icon = DivWdg()
        #icon.add("X")
        #icon.add_style("font-size: 42px")
        #icon.add_style("color: #ddd")
        #icon.add_style("width: 48px")
        #icon.add_style("height: 48px")
        #icon.add_style("text-align: center")
        #icon.add_style("border-radius: 30px")
        #icon.add_style("border: solid 3px #ddd")
        icon.add_style("position: absolute")
        icon.add_style("cursor: pointer")
        icon.add_style("bottom: 80px")
        icon.add_style("left: 38px")
        icon.add_style("opacity: 0.5")
        icon.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_gallery_top");
            spt.behavior.destroy_element(top);
            '''
        })

        icon = IconWdg(title="Previous",
                       icon="/context/icons/glyphs/chevron_left.png")
        inner.add(icon)
        icon.add_class('spt_left_arrow')
        icon.add_style("cursor: pointer")
        icon.add_style("position: absolute")
        icon.add_style("top: 40%")
        icon.add_style("left: 0px")
        icon.add_style("opacity: 0.5")
        icon.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var arrow = bvr.src_el;
            spt.gallery.show_prev(arrow); 
            '''
        })

        icon = IconWdg(title="Next",
                       icon="/context/icons/glyphs/chevron_right.png")
        inner.add(icon)
        icon.add_class('spt_right_arrow')
        icon.add_style("position: absolute")
        icon.add_style("cursor: pointer")
        icon.add_style("top: 40%")
        icon.add_style("right: 0px")
        icon.add_style("opacity: 0.5")
        icon.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var arrow = bvr.src_el;
            spt.gallery.show_next(arrow); 
            '''
        })

        desc_div = DivWdg()
        desc_div.add_class("spt_gallery_description")
        desc_div.add_style("height: 30px")
        desc_div.add_style("width: %s" % width)
        desc_div.add_style("text-align: center")
        desc_div.add_style("background: rgba(0,0,0,1)")
        desc_div.add_style("color: #bbb")
        desc_div.add_style("font-weight: bold")
        desc_div.add_style("font-size: 16px")
        desc_div.add_style("padding-top: 10px")
        desc_div.add_style("margin-left: -%s" % (width / 2))
        desc_div.add_style("z-index: 1000")
        desc_div.add("")

        desc_outer_div = DivWdg()
        inner.add(desc_outer_div)
        desc_outer_div.add_style("position: fixed")
        desc_outer_div.add(desc_div)
        desc_outer_div.add_style("bottom: 0px")
        desc_outer_div.add_style("left: 50%")

        return top
Beispiel #36
0
    def get_display(my):
        top = DivWdg()
        top.add_class("spt_top")

        dialog = DialogWdg()
        dialog_id = dialog.get_id()

        # create the button
        button = DivWdg()
        button.add_style("padding: 5px")
        button.add_style("width: 30px")
        button.add_style("text-align: center")
        button.add_style("float: left")
        button.add_gradient("background", "background")
        button.add_border()
        top.add(button)
        icon = IconWdg("Press Me", IconWdg.ZOOM)
        icon.add_style("float: left")
        button.add(icon)
        icon = IconWdg("Press Me", IconWdg.INFO_OPEN_SMALL)
        icon.add_style("margin-left: -9px")
        button.add(icon)
        button.add_behavior( {
        'type': 'click_up',
        'dialog_id': dialog_id,
        'cbjs_action': '''
        var pos = bvr.src_el.getPosition();
        var el = $(bvr.dialog_id);
        el.setStyle("left", pos.x+1);
        el.setStyle("top", pos.y+32);
        el.setStyle("display", "");
        '''
        } )

        # defined the dialog
        top.add(dialog)
        dialog.add_title("Search Limit")

        table = Table()
        table.add_color("color", "color2")
        dialog.add(table)
        table.add_row()
        td = table.add_cell()
        td.add("Search Limit: ")

        td = table.add_cell()
        select = SelectWdg("search_limit")
        select.set_option("values", "5|10|20|50|100|200|Custom")
        td.add(select)

        save_button = ProdIconButtonWdg("Save")
        td.add(save_button)
        cancel_script = dialog.get_cancel_script();
        save_button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
        var values = spt.api.get_input_values(dialog_top);

        var top = spt.get_parent(bvr.src_el, ".spt_top");
        var input = top.getElement(".spt_search_limit");
        input.value = values.search_limit;
        %s
        ''' % cancel_script
        } )


        text = TextWdg("search_limit")
        text.add_class("spt_search_limit")
        top.add(text)

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

        top = self.top
        top.add_class("spt_subscription_bar_top")
        self.set_as_panel(top)

        top.add_style("width: 40px")
        top.add_style("height: 20px")

        #top.add_class("hand")




        interval = self.kwargs.get("interval")
        if not interval:
            interval = 10 * 1000
        else:
            interval = int(interval) * 1000

        inner = DivWdg()
        top.add(inner)

        self.set_refresh(inner, interval, panel_cls='spt_subscription_bar_top', mode='interval')

        mode = self.kwargs.get("mode")
        if not mode:
            mode = "tab"

        dialog_open = self.kwargs.get("dialog_open")
        if dialog_open in [True, 'true']:
            dialog_open = True
        else:
            dialog_open = False

        subscription_kwargs ={}
        subscription_kwargs_list = ['icon','show_preview','show_message_history','show_unsubscribe','show_timestamp','interval']
        for key in self.kwargs:
            if key in subscription_kwargs_list:
                subscription_kwargs[key]= self.kwargs.get(key)

        mode = "dialog"
        if mode == "dialog":
            from tactic.ui.container import DialogWdg
           
            dialog = DialogWdg(display=dialog_open, show_title=False, show_pointer=False )
            inner.add(dialog)
            dialog.set_as_activator(inner)
            subscription_wdg = SubscriptionWdg(**subscription_kwargs)
            dialog.add(subscription_wdg)
            subscription_wdg.add_style("width: %spx"%(self.WIDTH+50))
            subscription_wdg.add_color("background", "background")
            subscription_wdg.add_style("max-height: 500px")
            subscription_wdg.add_style("min-height: 300px")

        elif mode == "popup":
            top.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                var class_name = 'tactic.ui.app.SubscriptionWdg';
                var kwargs = {};
                spt.panel.load_popup("Subscriptions", class_name, kwargs);
                '''
            } )
        else:
            top.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.tab.set_main_body_tab();
                var class_name = 'tactic.ui.app.SubscriptionWdg';
                var kwargs = {};
                spt.tab.add_new("Subscriptions", "Subscriptions", class_name, kwargs);
                '''
            } )


        color = inner.get_color("border") 
        inner.add_style("border-style: solid")
        inner.add_style("border-size: 1px")
        inner.add_style("border-color: transparent")
        inner.set_round_corners(5)
        inner.add_style("padding: 2px")

        inner.add_behavior( {
            'type': 'mouseenter',
            'color': color,
            'cbjs_action': '''
            bvr.src_el.setStyle("border", "solid 1px "+bvr.color);
            '''
        } )
        inner.add_behavior( {
            'type': 'mouseleave',
            'cbjs_action': '''
            bvr.src_el.setStyle("border-color", "transparent");
            '''
        } )


        category = None
        subscriptions = self.get_subscriptions(category)


        #if not subscriptions:
        #    inner.add_style("display: none")


        num = len(subscriptions)
        # the word message takes up too much space
        """
        if num <= 1:
            msg = "%s message" % num
        else:
            msg = "%s messages" % num
        """
        if num > 0:
            msg = num
        else:
            msg = ''
        try:
            icon_display = self.kwargs.get('icon')
        except:
            icon_display = "STAR"
        if icon_display is None:
            icon_display = "STAR"

        icon = IconWdg(msg, icon_display)
        icon.add_style('float: left')
        inner.add(icon)
        msg_div = DivWdg(msg)
        msg_div.add_style('padding-top: 1px')
        #msg_div.add_style('border-width: 1px')
        #msg_div.add_styles('border-radius: 50%; width: 18px; height: 18px; background: white')
        inner.add(msg_div)

        if self.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
Beispiel #38
0
    def handle_item_div(my, item_div, dirname, basename):


        table = Table()
        item_div.add(table)
        table.add_row()
        table.add_style("width: 100%")



        icon_string = my.get_file_icon(dirname, basename)

        icon_div = DivWdg()
        td = table.add_cell(icon_div)
        td.add_style("width: 15px")

        icon = IconWdg("%s/%s" % (dirname, basename), icon_string)
        icon_div.add(icon)
        icon_div.add_style("float: left")
        icon_div.add_style("margin-top: -1px")



        path = "%s/%s" % (dirname, basename)
        status = my.path_info.get(path)
        margin_left = -16
        if status == 'same':
            check = IconWdg( "No Changes", IconWdg.CHECK, width=12 )
        elif status == 'added':
            check = IconWdg( "Added", IconWdg.NEW, width=16 )
            margin_left = -18
        elif status == 'unversioned':
            check = IconWdg( "Unversioned", IconWdg.HELP, width=12 )
        elif status == 'missing':
            check = IconWdg( "Missing", IconWdg.WARNING, width=12 )
        elif status == 'editable':
            check = IconWdg( "Editable", IconWdg.EDIT, width=12 )
        elif status == 'modified':
            check = IconWdg( "Modified", IconWdg.WARNING, width=12 )
        else:
            check = IconWdg( "Error (unknown status)", IconWdg.ERROR, width=12 )

        if check:
            td = table.add_cell(check)
            td.add_style("width: 3px")
            check.add_style("float: left")
            check.add_style("margin-left: %spx" % margin_left)
            check.add_style("margin-top: 4px")
            item_div.add_color("color", "color", [0, 0, 50])

            if status == 'missing':
                item_div.add_style("opacity: 0.3")

        else:
            item_div.add_style("opacity: 0.8")


        name_div = DivWdg()
        td = table.add_cell(name_div)
        name_div.add(basename)
        name_div.add_style("float: left")

        if status != "same":
            name_div.add(" <i style='opacity: 0.5; font-size: 10px'>(%s)</i>" % status)

        spath = path.replace(" ", "_")


        # add the size of the file
        size_div = DivWdg()
        td = table.add_cell(size_div)
        td.add_style("width: 60px")

        size = my.sizes.get(spath)
        if size is None or size == -1:
            size_div.add("-")
        else:
            size_div.add(FormatValue().get_format_value(size, 'KB'))

        size_div.add_style("margin-right: 5px")
        size_div.add_style('text-align: right')



        # FIXME: this still is needed right now, although really used.
        my.subcontext_options = []
        if not my.subcontext_options:
            subcontext = TextWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.add_class("spt_subcontext")
            subcontext.add_style("float: right")

        else:
            subcontext = SelectWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.set_option("show_missing", False)
            subcontext.set_option("values", my.subcontext_options)
            subcontext.add_empty_option("----")


        subcontext.add_behavior( {
            'type': 'click_up',
            'propagate_evt': False,
            'cbjs_action': '''
            bvr.src_el.focus();
            '''
        } )

        subcontext.add_style("display: none")
        item_div.add(subcontext)
Beispiel #39
0
    def get_display(my):

        top = my.top

        #help_div = DivWdg()
        help_div = top
        #top.add(help_div)
        help_div.add_class("spt_help_top")
        help_div.set_id("spt_help_top")

        show_title = my.kwargs.get("show_title")
        if show_title in [True, 'true']:
            show_title = True
        else:
            show_title = False

        if show_title:
            title_wdg = DivWdg()
            help_div.add(title_wdg)
            title_wdg.add_style("font-size: 12px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_gradient("background", "background", 0, -20)
            title_wdg.add_style("padding: 3px")
            #title_wdg.add_style("margin-top: 8px")
            title_wdg.add_style("margin-bottom: 5px")
            title_wdg.add_style("height: 26px")
            title_wdg.add_style("padding: 6 0 0 6")
            title_wdg.set_round_corners(corners=['TL', 'TR'])

            icon = IconWdg("Close", IconWdg.KILL)
            title_wdg.add(icon)
            icon.add_style("float: right")
            title_wdg.add("Help")

        help_div.set_round_corners()
        help_div.add_color("color", "color2")
        help_div.add_color("background", "background")
        help_div.add_border()

        shelf_div = DivWdg()
        help_div.add(shelf_div)
        shelf_div.add_style("padding: 5px")
        shelf_div.add_gradient("background", "background")
        shelf_div.add_style("height: 25px")

        from tactic.ui.widget import SingleButtonWdg

        button = SingleButtonWdg(title="Documentation Main Page",
                                 icon=IconWdg.HOME)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_alias("main")
        '''
        })

        button = SingleButtonWdg(title="Edit Help", icon=IconWdg.EDIT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.app.HelpEditWdg';

        var element_name = spt.help.get_view();
        if (!element_name) {
          element_name = "default";
        }
        var kwargs = {
          view: element_name
        }

        spt.tab.add_new("help_edit", "Help Edit", class_name, kwargs);
            
        '''
        })

        button = SingleButtonWdg(title="Go Back One Page",
                                 icon=IconWdg.ARROW_LEFT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_prev();
        '''
        })

        button = SingleButtonWdg(title="Go Forward One Page",
                                 icon=IconWdg.ARROW_RIGHT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_next();
        '''
        })

        button = SingleButtonWdg(title="Documentation Downloads",
                                 icon=IconWdg.DOWNLOAD)
        shelf_div.add(button)
        button.add_style("float: right")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_alias("pdf")
        '''
        })

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

        help_div.add_behavior({
            'type': 'load',
            'cbjs_action': my.get_onload_js()
        })

        help_div.add_behavior({
            'type':
            'listen',
            'event_name':
            'tab|select',
            'cbjs_action':
            '''

        var content = bvr.src_el.getElement(".spt_help_content");
        var options = bvr.firing_data;
        var element_name = options.element_name;
        var alias = options.alias;

        if (!alias) {
            alias = options.element_name;
        }

        spt.help.set_top();
        if (spt.help.is_visible()) {
            spt.help.load_alias(alias);
        }
        else {
            spt.help.set_view(alias);
        }
        '''
        })

        help_div.add_behavior({
            'type':
            'listen',
            'event_name':
            'show_help',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_help");
        var content = top.getElement(".spt_help_content");
        var firing_data = bvr.firing_data;
        var class_name = firing_data.class_name;
        if (!class_name) {
            class_name = 'tactic.ui.app.HelpContentWdg';
        }

        if (top.getStyle("display") != 'none') {
            spt.hide(top);
            return;
        }

        spt.help.set_top()

        // get the help view
        var help_view = spt.help.get_view();
        var html = firing_data.html;
        if (html) {
            spt.help.load_html(html);    
        }
        else {
            if (!help_view) {
                help_view = 'default'    
            }
            spt.help.load_alias(help_view);
        }

        var size = $(window).getSize();

        var dialog = bvr.src_el.getParent(".spt_dialog_content");

        dialog.setStyle("height", size.y - 100);
        dialog.setStyle("width", 650);

        var top = bvr.src_el.getParent(".spt_dialog_top");
        top.setStyle("left", size.x - 660);
        top.setStyle("top", 40);

        spt.show(top);
        '''
        })

        content = DivWdg()
        help_div.add(content)
        content.add_class("spt_help_content")
        content.add_style("position: relative")
        content.add_style("overflow_x: auto")
        content.add_style("overflow_y: auto")
        content.add_style("margin-bottom: 10px")
        #content.add_style("border: solid 1px blue")
        content.add_style("height: 98%")

        #key = "schema_editor"
        #search = Search("config/doc")
        #search.add_filter("code", key)
        #doc = search.get_sobject()
        #doc_html = doc.get_value("doc")
        #help_div.add(doc_html)

        return top
Beispiel #40
0
    def handle_item_div(my, item_div, dirname, basename):

        table = Table()
        item_div.add(table)
        table.add_row()
        table.add_style("width: 100%")

        icon_string = my.get_file_icon(dirname, basename)

        icon_div = DivWdg()
        td = table.add_cell(icon_div)
        td.add_style("width: 15px")

        icon = IconWdg("%s/%s" % (dirname, basename), icon_string)
        icon_div.add(icon)
        icon_div.add_style("float: left")
        icon_div.add_style("margin-top: -1px")

        path = "%s/%s" % (dirname, basename)
        status = my.path_info.get(path)
        margin_left = -16
        if status == 'same':
            check = IconWdg("No Changes", IconWdg.CHECK, width=12)
        elif status == 'added':
            check = IconWdg("Added", IconWdg.NEW, width=16)
            margin_left = -18
        elif status == 'unversioned':
            check = IconWdg("Unversioned", IconWdg.HELP, width=12)
        elif status == 'missing':
            check = IconWdg("Missing", IconWdg.WARNING, width=12)
        elif status == 'editable':
            check = IconWdg("Editable", IconWdg.EDIT, width=12)
        elif status == 'modified':
            check = IconWdg("Modified", IconWdg.WARNING, width=12)
        else:
            check = IconWdg("Error (unknown status)", IconWdg.ERROR, width=12)

        if check:
            td = table.add_cell(check)
            td.add_style("width: 3px")
            check.add_style("float: left")
            check.add_style("margin-left: %spx" % margin_left)
            check.add_style("margin-top: 4px")
            item_div.add_color("color", "color", [0, 0, 50])

            if status == 'missing':
                item_div.add_style("opacity: 0.3")

        else:
            item_div.add_style("opacity: 0.8")

        name_div = DivWdg()
        td = table.add_cell(name_div)
        name_div.add(basename)
        name_div.add_style("float: left")

        if status != "same":
            name_div.add(" <i style='opacity: 0.5; font-size: 10px'>(%s)</i>" %
                         status)

        spath = path.replace(" ", "_")

        # add the size of the file
        size_div = DivWdg()
        td = table.add_cell(size_div)
        td.add_style("width: 60px")

        size = my.sizes.get(spath)
        if size is None or size == -1:
            size_div.add("-")
        else:
            size_div.add(FormatValue().get_format_value(size, 'KB'))

        size_div.add_style("margin-right: 5px")
        size_div.add_style('text-align: right')

        # FIXME: this still is needed right now, although really used.
        my.subcontext_options = []
        if not my.subcontext_options:
            subcontext = TextWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.add_class("spt_subcontext")
            subcontext.add_style("float: right")

        else:
            subcontext = SelectWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.set_option("show_missing", False)
            subcontext.set_option("values", my.subcontext_options)
            subcontext.add_empty_option("----")

        subcontext.add_behavior({
            'type':
            'click_up',
            'propagate_evt':
            False,
            'cbjs_action':
            '''
            bvr.src_el.focus();
            '''
        })

        subcontext.add_style("display: none")
        item_div.add(subcontext)
Beispiel #41
0
    def get_import_wdg(my):
        div = DivWdg()

        if my.data:

            div.add("<br/>" * 2)
            div.add("The following TACTIC share was found: ")
            div.add("<br/>" * 2)

            data_input = TextAreaWdg("data")
            data_input.add_style("display: none")
            div.add(data_input)

            #print "xxxx: ", my.data
            data_str = jsondumps(my.data)
            #data_str = data_str.replace('"', "'")
            print "data: ", data_str
            data_input.set_value(data_str)

            table = Table()
            div.add(table)
            table.set_max_width()
            table.add_style("margin-left: 20px")
            table.add_style("margin-right: 20px")

            for name, value in my.data.items():
                name = Common.get_display_title(name)
                table.add_row()
                table.add_cell(name)
                table.add_cell(value)

            div.add("<br/>" * 2)

            div.add(my.get_versions_wdg())

            div.add("<br/>" * 2)

            # check to see if the project exists
            project_code = my.data.get("project_code")
            project_code = my.data.get("projects")
            project = Project.get_by_code(project_code)
            #if project:
            if False:
                msg_div = DivWdg()
                div.add(msg_div)
                msg_div.add_style("padding: 20px")
                msg_div.add_color("background", "background3")
                msg_div.add_color("color", "color")
                msg_div.add_border()

                icon = IconWdg("WARNING", IconWdg.WARNING)
                msg_div.add(icon)
                icon.add_style("float: left")

                msg_div.add(
                    "The project with code [%s] already exists.  You must remove the installed project before trying to import this one."
                    % project_code)
                return div

            if my.data.get("is_encrypted") == "true":
                div.add(
                    "The transactions in this share is encrypted.  Please provide an encryption key to decrypt the transactions<br/><br/>"
                )
                div.add("Encryption Key: ")
                text = TextWdg("encryption_key")
                div.add(text)
                div.add("<br/>" * 2)

            button = ActionButtonWdg(title="Import >>")
            button.add_style("float: right")
            div.add(button)
            div.add("<br/>" * 2)
            button.add_behavior({
                'type':
                'click_up',
                'project_code':
                project_code,
                'cbjs_action':
                '''
                spt.app_busy.show("Importing Project "+bvr.project_code+"...");
                var top = bvr.src_el.getParent(".spt_sync_import_top");
                var values = spt.api.Utility.get_input_values(top, null, false);
                var cmd = "tactic.ui.sync.SyncImportCmd";
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, values, {}, {use_transaction: false});
                spt.notify.show_message("Finished importing project");
                spt.app_busy.hide();
                document.location = '/tactic/'+bvr.project_code;
                '''
            })

        return div
Beispiel #42
0
    def get_display(my):

        widget = my.widget
        widget.set_box_shadow()

        widget.add_class("spt_dialog_top")
        widget.add_class("spt_popup")



        z_index = my.kwargs.get("z_index")
        if not z_index:
            z_index = "500"
        widget.add_style("z-index: %s" % z_index)


        web = WebContainer.get_web()

        widget.set_id(my.name)
        widget.add_attr("spt_dialog_id", my.name);
        if my.kwargs.get("display") not in [True, "true"]:
            widget.add_style("display: none")

        widget.add_style("position: absolute")

        widget.add_behavior( {
        'type': 'listen',
        'event_name': '%s|dialog_close' % my.name,
        'cbjs_action': my.get_cancel_script()
        } )


        offset = my.kwargs.get("offset")
        if not offset:
            offset = my.offset





        show_header = True
        show_resize = False


        drag_div = DivWdg()
        if show_header:
            widget.add(drag_div)



        show_pointer = my.kwargs.get("show_pointer")
        if show_pointer not in [False, 'false']:
            from tactic.ui.container import ArrowWdg
            offset_x = 15 - offset.get('x')
            offset_y = offset.get("y")
            arrow = ArrowWdg(
                    offset_x=offset_x,
                    offset_y=offset_y,
                    color=widget.get_color("background", -10)
            )
            arrow.add_class("spt_popup_pointer")
            arrow.add_style("z-index: 10")
            widget.add(arrow)


        # create the 'close' button ...
        close_wdg = SpanWdg()
        close_wdg.add( IconWdg("Close", "BS_REMOVE") )
        close_wdg.add_style("float: right")
        close_wdg.add_class("hand")
        close_wdg.add_style("margin: 3px 1px 3px 1px")

        close_wdg.add_behavior({
            'type': 'click_up',
            'cbjs_action': my.get_cancel_script()
        })

        drag_div.add(close_wdg)


        anchor_wdg = SpanWdg()
        drag_div.add(anchor_wdg)
        anchor_wdg.add_style("margin: 5px 5px 3px 1px")
        anchor_wdg.add( IconWdg("Anchor Dialog", "BS_PUSHPIN") )
        anchor_wdg.add_style("float: right")
        anchor_wdg.add_class("hand")

        anchor_wdg.add_behavior({
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_dialog_top");
            var position = top.getStyle("position");
            if (position == 'fixed') {
                top.setStyle("position", "absolute");
                bvr.src_el.setStyle("opacity", "1.0");
            }
            else {
                top.setStyle("position", "fixed");
                bvr.src_el.setStyle("opacity", "0.5");
            }
            '''
        })







        width = my.kwargs.get("width")
        if not width:
            width = "100px"
        if width:
            drag_div.add_style("min-width: %s" % width)

        # style
        #drag_div.add_looks("popup")

        drag_div.add_style("text-align: left")
        drag_div.add_class("spt_popup_width")
        drag_div.add_style("border-style: solid")
        drag_div.add_color("border-color", "border")
        drag_div.add_style("border-size: 0 0 1 0")


        drag_handle_div = DivWdg(id='%s_title' %my.name)
        drag_div.add( drag_handle_div )
        drag_handle_div.add_style("padding: 3px;")
        #drag_handle_div.add_gradient("background", "background", +10)
        drag_handle_div.add_color("background", "background", -10)
        drag_handle_div.add_color("color", "color")
        drag_handle_div.add_style("padding: 8px 5px 8px 8px")

        drag_handle_div.add_behavior({
            'type': 'double_click',
            'cbjs_action': my.get_cancel_script()
        })


        # add the drag capability
        drag_handle_div.add_behavior( {
        'type':'smart_drag',
        'drag_el': 'spt.popup.get_popup(@);',
        'options': {'z_sort': 'bring_forward'},
        'ignore_default_motion': 'false',
        'cbjs_setup': '''
            var pointer = bvr.drag_el.getElement(".spt_popup_pointer");
            if (pointer) {
                spt.hide(pointer);
            }
        '''
        } )


        # add the content
        content_div = DivWdg()
        
        title_wdg = my.title_wdg
        if not title_wdg:
            title_wdg = "No Title"
            # if the title is empty, just don't show
        if my.kwargs.get("show_title") in [False, 'false']:
            drag_div.add_style("display: none")
        #else:
        #    content_div.add_style("margin-top: -1px")


        drag_handle_div.add(title_wdg)
        drag_handle_div.add_class("spt_popup_title")
        drag_handle_div.add_style("font-weight: bold")


        widget.add(content_div)
        content_div.add_color("color", "color2")
        content_div.add_gradient( "background", "background2" )

        content_div.set_id("%s_content" % my.name)
        content_div.add_class("spt_popup_content")
        content_div.add_class("spt_dialog_content")
        content_div.add_style("overflow: hidden")
        content_div.add_style("display: block")
        #content_div.add_style("padding: 5px")

        view = my.kwargs.get("view")
        if view:
            from tactic.ui.panel import CustomLayoutWdg
            my.add( CustomLayoutWdg(view=view) )

        if not my.content_wdg:
            my.content_wdg = "No Content"

        content_div.add(my.content_wdg)


        # add the resize icon
        if show_resize:
            icon = IconWdg( "Resize", IconWdg.RESIZE_CORNER )
            icon.add_style("cursor: nw-resize")
            icon.add_style("z-index: 1000")
            icon.add_class("spt_popup_resize")
            icon.add_style("float: right")
            icon.add_style("margin-top: -25px")
            icon.add_style("margin-right: 5px")
            icon.add_behavior( {
            'type': 'drag',
            "drag_el": '@',
            "cb_set_prefix": 'spt.popup.resize_drag'
            } )
            widget.add(icon)




        return widget
Beispiel #43
0
    def get_display(my):
        top = my.top
        my.set_as_panel(top)
        top.add_class("spt_sync_import_top")
        top.add_style("width: 500px")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("padding: 20px")

        inner = DivWdg()
        top.add(inner)

        inner.add(my.get_base_dir_wdg())

        is_refresh = my.kwargs.get("is_refresh") == 'true'

        base_dir = my.kwargs.get("base_dir")
        if base_dir:
            data = my.kwargs.get("data")
            if data:
                my.data = jsonloads(data)
            else:
                if not os.path.exists(base_dir):
                    msg_div = DivWdg()

                    inner.add("<br/>" * 2)
                    inner.add(msg_div)

                    msg_div.add_style("padding: 20px 20px 30px 20px")
                    msg_div.add_color("background", "background3")
                    msg_div.add_color("color", "color")
                    msg_div.add_border()

                    icon = IconWdg("WARNING", IconWdg.WARNING)
                    msg_div.add(icon)
                    icon.add_style("float: left")

                    msg_div.add("<br/>")

                    msg_div.add("Base folder [%s] does not exist on server" %
                                base_dir)
                    if is_refresh:
                        return inner
                    else:
                        return top

                manifest_path = "%s/tactic.txt" % base_dir
                f = open(manifest_path)
                data = f.read()
                my.data = jsonloads(data)

                inner.add(my.get_import_wdg())

        else:
            my.data = {}

            msg_div = DivWdg()
            inner.add(msg_div)
            icon = IconWdg("", IconWdg.ARROW_UP)
            msg_div.add(icon)
            msg_div.add("Please browse or enter in a sync location")
            msg_div.add_style("padding: 20px")
            msg_div.add_style("margin: 30px")
            msg_div.add_style("text-align: center")
            msg_div.add_border()
            msg_div.add_color("background", "background3")
            msg_div.add_color("color", "color3")

        if my.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
Beispiel #44
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
Beispiel #45
0
    def get_display(my):

        top = my.top
        top.add_style("white-space: nowrap")
        #top.add_style("position: relative")

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

        show_menu = my.kwargs.get("show_menu")
        is_disabled = my.kwargs.get("is_disabled")

        button = DivWdg()
        button.add_style("float: left")

        my.inner = button
        top.add(button)
        my.inner.add_class("hand")

        button.add_class("spt_button_top")
        button.add_style("position: relative")

        #img = "<img src='%s/MainButtonSlices_button.png'/>" % base
        #img_div = DivWdg(img)
        #button.add(img_div)
        #img_div.add_style("opacity", ALPHA)

        img_div = DivWdg()
        button.add(img_div)
        img_div.add_style("width: 30px")
        img_div.add_style("height: 35px")

        over_div = DivWdg()
        button.add(over_div)
        over_div.add_class("spt_button_over")
        over_img = "<img src='%s/MainButton_over.png'/>" % base
        over_div.add(over_img)
        over_div.add_style("position: absolute")
        over_div.add_style("top: 0px")
        over_div.add_style("left: 0px")
        over_div.add_style("display: none")

        click_div = DivWdg()

        button.add(click_div)
        click_div.add_class("spt_button_click")
        click_img = "<img src='%s/MainButton_click.png'/>" % base
        click_div.add(click_img)
        click_div.add_style("position: absolute")
        click_div.add_style("top: 0px")
        click_div.add_style("left: 0px")
        click_div.add_style("display: none")

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

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

        icon_div = my.icon_div
        button.add(icon_div)
        #icon_div.add_class("spt_button_click")
        icon_str = my.kwargs.get("icon")
        icon = IconWdg(tip, icon_str, right_margin=0, width=16)
        icon.add_class("spt_button_icon")
        icon_div.add(icon)
        icon_div.add_style("position: absolute")
        #TODO: removed this top attr after we trim the top and bottom whitespace of the over image
        icon_div.add_style("top: 12px")
        icon_div.add_style("left: 6px")

        if my.is_disabled:
            icon_div.add_style("opacity: 0.5")

        my.icon_div = icon_div

        sub_icon = my.kwargs.get("sub_icon")
        if sub_icon:
            sub_icon = IconWdg(icon=sub_icon, size="8")
            button.add(sub_icon)
            sub_icon.add_style("position: absolute")
            sub_icon.add_style("bottom: 4px")
            sub_icon.add_style("right: 0px")

        my.show_arrow = my.kwargs.get("show_arrow") in [True, 'true']
        if my.show_arrow or my.dialog:
            arrow_div = DivWdg()
            button.add(arrow_div)
            arrow_div.add_style("position: absolute")
            arrow_div.add_style("top: 24px")
            arrow_div.add_style("left: 20px")

            arrow = IconWdg(tip, IconWdg.ARROW_MORE_INFO)
            arrow_div.add(arrow)

        web = WebContainer.get_web()
        is_IE = web.is_IE()

        #my.hit_wdg.add_style("height: 100%")
        my.hit_wdg.add_style("width: 100%")
        if is_IE:
            my.hit_wdg.add_style("filter: alpha(opacity=0)")
            my.hit_wdg.add_style("height: 40px")
        else:
            my.hit_wdg.add_style("height: 100%")
            my.hit_wdg.add_style("opacity: 0.0")

        if my.is_disabled:
            my.hit_wdg.add_style("display: none")

        button.add(my.hit_wdg)

        my.hit_wdg.add_style("position: absolute")
        my.hit_wdg.add_style("top: 0px")
        my.hit_wdg.add_style("left: 0px")
        my.hit_wdg.add_attr("title", tip)
        """
        my.hit_wdg.add_behavior( {
        'type': 'hover',
        'cbjs_action_over': '''
            var top = bvr.src_el.getParent(".spt_button_top")
            var over = top.getElement(".spt_button_over");
            var click = top.getElement(".spt_button_click");
            over.setStyle("display", "");
            click.setStyle("display", "none");
        ''',
        'cbjs_action_out': '''
            var top = bvr.src_el.getParent(".spt_button_top")
            var over = top.getElement(".spt_button_over");
            var click = top.getElement(".spt_button_click");
            over.setStyle("display", "none");
            click.setStyle("display", "none");
        '''
        } )
        """

        # add a second arrow widget
        if my.show_arrow_menu:
            my.inner.add(my.arrow_div)
            my.arrow_div.add_attr("title", "More Options")
            my.arrow_div.add_style("position: absolute")
            my.arrow_div.add_style("top: 11px")
            my.arrow_div.add_style("left: 20px")
            my.arrow_div.add(my.arrow_menu)

        if my.dialog:
            top.add(my.dialog)
            dialog_id = my.dialog.get_id()
            my.hit_wdg.add_behavior({
                'type':
                'click_up',
                'dialog_id':
                dialog_id,
                'cbjs_action':
                '''
            var dialog = $(bvr.dialog_id);
            var pos = bvr.src_el.getPosition();
            var size = bvr.src_el.getSize();
            //var dialog = $(bvr.dialog_id);
            dialog.setStyle("left", pos.x);
            dialog.setStyle("top", pos.y+size.y);
            spt.toggle_show_hide(dialog);

            '''
            })

        return top
Beispiel #46
0
    def get_display(my):
        top = my.top
        my.set_as_panel(top)
        top.add_class("spt_delete_top")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_border()
        top.add_style("width: 300px")
        top.add_border()


        search_key = my.kwargs.get("search_key")
        search_keys = my.kwargs.get("search_keys")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            sobjects = [sobject]
            search_keys = [search_key]
        elif search_keys:
            sobjects = Search.get_by_search_keys(search_keys)
            sobject = sobjects[0]

        if not sobjects:
            msg =  "%s not found" %search_key
            return msg
        search_type = sobject.get_base_search_type()

        if search_type in ['sthpw/project', 'sthpw/search_object']:
            msg = 'You cannot delete these items with this tool'
            return msg


        my.search_keys = search_keys


        title = DivWdg()
        top.add(title)
        title.add_color("background", "background", -10)
        if my.search_keys:
            title.add("Delete %s Items" % len(my.search_keys))
        else:
            title.add("Delete Item [%s]" % (sobject.get_code()))
        title.add_style("font-size: 14px")
        title.add_style("font-weight: bold")
        title.add_style("padding: 10px")

        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")


        content.add("The item to be deleted has a number of dependencies as described below:<br/>", 'heading')

        # find all the relationships
        schema = Schema.get()
        related_types = schema.get_related_search_types(search_type, direction="children")
        parent_type = schema.get_parent_type(search_type)
        child_types = schema.get_child_types(search_type)


        # some special considerations
        # FIXME: this needs to be more automatic.  Should only be
        # deletable children (however, that will be defined)
        if search_type in ['sthpw/task','sthpw/note', 'sthpw/snapshot']:
            if "sthpw/project" in related_types:
                related_types.remove("sthpw/project")

            if "sthpw/login" in related_types:
                related_types.remove("sthpw/login")

            if "config/process" in related_types:
                related_types.remove("config/process")



        if parent_type in related_types:
            related_types.remove(parent_type)

        related_types.append('sthpw/note')
        related_types.append('sthpw/task')
        related_types.append('sthpw/snapshot')
        if 'sthpw/work_hour' not in related_types:
            related_types.append('sthpw/work_hour')
       
        items_div = DivWdg()
        content.add( items_div )
        items_div.add_style("padding: 10px")
        valid_related_ctr = 0
        for related_type in related_types:
            if related_type == "*":
                print "WARNING: related_type is *"
                continue
            if related_type == search_type:
                continue
            if related_type in ['sthpw/search_object','sthpw/search_type']:
                continue

            item_div = my.get_item_div(sobjects, related_type)
            if item_div:
                items_div.add(item_div)
                valid_related_ctr += 1


        

        if valid_related_ctr > 0:
            icon = IconWdg("WARNING", IconWdg.WARNING)
            icon.add_style("float: left")
            content.add( icon )
            content.add("<div><b>WARNING: By selecting the related items above, you can delete them as well when deleting this sObject.</b></div>")
            content.add("<br/>"*2)
        else:
            # changed the heading to say no dependencies
            content.add("The item to be deleted has no dependencies.<br/>", 'heading')


        content.add("There are %s items to be deleted" % len(my.search_keys))
        content.add("<br/>"*2)

        content.add("Do you wish to continue deleting?")
        content.add("<br/>"*2)

        button_div = DivWdg()
        button_div.add_styles('width: 300px; height: 50px')
        button = ActionButtonWdg(title="Delete")
        button_div.add(button)
        content.add(button_div)
        button.add_style("float: left")

        button.add_behavior( {
        'type': 'click_up',
        'search_keys': my.search_keys,
        'cbjs_action': '''
        spt.app_busy.show("Deleting");

        var top = bvr.src_el.getParent(".spt_delete_top");
        var values = spt.api.Utility.get_input_values(top);

        var class_name = "tactic.ui.tools.DeleteCmd";
        var kwargs = {
            'search_keys': bvr.search_keys,
            'values': values
        };
        var server = TacticServerStub.get();
        try {
            server.start({'title': 'Delete sObject', 'description': 'Delete sObject [' + bvr.search_keys + ']'});
            server.execute_cmd(class_name, kwargs);
            server.finish();

            // run the post delete and destroy the popup
            var popup = bvr.src_el.getParent(".spt_popup");
            if (popup.spt_on_post_delete) {
                popup.spt_on_post_delete();
            }

            spt.popup.destroy(popup);


        }
        catch(e) {
            spt.alert(spt.exception.handler(e));
        }

        spt.app_busy.hide();
       
        '''
        } )



        button = ActionButtonWdg(title="Cancel")
        button.add_style("float: left")
        button_div.add(button)
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        } )


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


        return top
Beispiel #47
0
    def get_displayxx(my):

        show_menu = my.kwargs.get("show_menu")
        is_disabled = my.kwargs.get("is_disabled")

        show_title = my.kwargs.get("show_title")
        show_title = show_title in ['True', True]

        width = 35
        if show_title:
            height = 26
        else:
            height = 20
        height = 30

        top = my.top
        top.add_class("spt_button_top")
        top.add_style("overflow: hidden")

        #border = top.get_color("border")
        #top.add_border(-20)
        top.add_gradient("background", "background", 20, -35)
        top.add_style("border-width: 1px 0 1px 0")
        top.add_style("border-style: solid")
        top.add_style("border-color: %s" % top.get_color('border'))
        #top.add_style("margin-left: -1px")

        inner = my.inner
        top.add(inner)
        inner.add_color("color", "color3")
        inner.add_style("padding-top: 3px")
        inner.add_style("overflow: hidden")

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

        inner.add_class("hand")
        inner.add_style("z-index: 20")
        #inner.add_style("overflow: hidden")
        #inner.add_style("opacity: 0.5")
        inner.add_attr("title", title)

        my.button.add_style("margin-top: 5px")
        inner.add(my.button)
        icon_str = my.kwargs.get("icon")
        icon = IconWdg(title, icon_str)
        my.button.add(icon)
        icon.add_class("spt_button_icon")

        my.show_arrow = my.kwargs.get("show_arrow") in [True, 'true']
        if my.show_arrow or my.dialog:
            arrow = IconWdg(title, IconWdg.ARROW_MORE_INFO)
            inner.add(arrow)
            arrow.add_style("position: absolute")
            arrow.add_style("float: left")
            arrow.add_style("margin-left: 2px")
            arrow.add_style("margin-top: -10px")

        inner.add_style("font-size: 8px")
        inner.add_style("height: %spx" % height)
        inner.add_style("width: %spx" % width)
        inner.add_style("text-align: center")

        show_title = False
        if show_title:
            title_div = DivWdg()
            title_div.add(title)
            inner.add(title_div)

        inner.add_behavior({
            'type':
            'click',
            'width':
            width,
            'cbjs_action':
            '''
            var button = bvr.src_el;
            button.setStyle("border-style", "ridge");
            button.setStyle("width", bvr.width-2);
        '''
        })

        inner.add_behavior({
            'type':
            'click_up',
            'width':
            width,
            'cbjs_action':
            '''
            var button = bvr.src_el;
            button.setStyle("border-style", "none");
            button.setStyle("width", bvr.width);
        '''
        })

        inner.add_behavior({
            'type':
            'hover',
            'width':
            width,
            'cbjs_action_over':
            '''
            var button = bvr.src_el;
            var icon = button.getElement(".spt_button_icon");
            icon.setStyle('opacity', '1');
        ''',
            'cbjs_action_out':
            '''
            var button = bvr.src_el;
            button.setStyle("border-style", "none");
            var icon = button.getElement(".spt_button_icon");
            icon.setStyle('opacity', '0.5');

            button.setStyle("width", bvr.width);

        '''
        })

        if show_menu in ['true', True]:
            inner.add_style("float: left")
            arrow_div = DivWdg()
            top.add(arrow_div)
            arrow_div.add_style("opacity: 0.5")
            arrow_div.add_style("z-index: 100")
            arrow_div.add_style("height: %spx" % height)
            arrow_div.add_style("border-left: dotted 1px %s" %
                                arrow_div.get_color("border"))
            #arrow_div.add_style("margin-left: -15px")
            arrow_div.add_style("float: left")

            arrow = DivWdg(IconWdg("More Options", IconWdg.ARROW_MORE_INFO))
            arrow.add_style("margin-top: 8px")
            arrow_div.add(arrow)
            arrow_div.add_style("position: relative")

            arrow_div.add_behavior({
                'type':
                'hover',
                'cbjs_action_over':
                '''
                var button = bvr.src_el;
                var height = parseInt(button.getStyle("height").replace("px",""));
                var width = parseInt(button.getStyle("width").replace("px",""));
                button.setStyle('opacity', '1');
                button.setStyle('border', 'solid 1px red');
                button.setStyle("height", height-2);
                button.setStyle("width", width-2);
            ''',
                'cbjs_action_out':
                '''
                var button = bvr.src_el;

                var height = parseInt(button.getStyle("height").replace("px",""));
                var width = parseInt(button.getStyle("width").replace("px",""));

                button.setStyle('opacity', '0.5');
                button.setStyle('border', '');
                button.setStyle("height", height+2);
                button.setStyle("width", width+2);
            '''
            })

            my.add_menu_wdg(arrow_div)

        if is_disabled in ['true', True]:
            disabled_div = DivWdg()
            disabled_div.add_class("spt_save_button_disabled")
            disabled_div.set_attr("title", "%s (Disabled)" % title)
            disabled_div.add_style("position: relative")
            disabled_div.add_style("height: %spx" % (height + 3))
            disabled_div.add_style("width: %spx" % width)
            #disabled_div.add_style("margin-left: -%spx" % width)
            disabled_div.add_style("margin-top: -%spx" % (height + 3))
            disabled_div.add_style("opacity", "0.6")
            disabled_div.add_style("background", "#AAA")
            inner.add_style("opacity", "1")
            top.add(disabled_div)

        if my.dialog:
            top.add(my.dialog)
            dialog_id = my.dialog.get_id()
            inner.add_behavior({
                'type':
                'load',
                'height':
                height,
                'dialog_id':
                dialog_id,
                'cbjs_action':
                '''
            var pos = bvr.src_el.getPosition();
            var el = $(bvr.dialog_id);
            el.setStyle("left", pos.x);
            el.setStyle("top", pos.y+bvr.height+13);
            '''
            })

            my.inner.add_behavior({
                'type':
                'click_up',
                'dialog_id':
                dialog_id,
                'cbjs_action':
                '''
            var dialog = $(bvr.dialog_id);
            spt.toggle_show_hide(dialog);
            '''
            })

        return top
Beispiel #48
0
    def get_display(my):
        top = DivWdg()
        top.add_class("spt_top")

        dialog = DialogWdg()
        dialog_id = dialog.get_id()

        # create the button
        button = DivWdg()
        button.add_style("padding: 5px")
        button.add_style("width: 30px")
        button.add_style("text-align: center")
        button.add_style("float: left")
        button.add_gradient("background", "background")
        button.add_border()
        top.add(button)
        icon = IconWdg("Press Me", IconWdg.ZOOM)
        icon.add_style("float: left")
        button.add(icon)
        icon = IconWdg("Press Me", IconWdg.INFO_OPEN_SMALL)
        icon.add_style("margin-left: -9px")
        button.add(icon)
        button.add_behavior({
            'type':
            'click_up',
            'dialog_id':
            dialog_id,
            'cbjs_action':
            '''
        var pos = bvr.src_el.getPosition();
        var el = $(bvr.dialog_id);
        el.setStyle("left", pos.x+1);
        el.setStyle("top", pos.y+32);
        el.setStyle("display", "");
        '''
        })

        # defined the dialog
        top.add(dialog)
        dialog.add_title("Search Limit")

        table = Table()
        table.add_color("color", "color2")
        dialog.add(table)
        table.add_row()
        td = table.add_cell()
        td.add("Search Limit: ")

        td = table.add_cell()
        select = SelectWdg("search_limit")
        select.set_option("values", "5|10|20|50|100|200|Custom")
        td.add(select)

        save_button = ProdIconButtonWdg("Save")
        td.add(save_button)
        cancel_script = dialog.get_cancel_script()
        save_button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
        var values = spt.api.get_input_values(dialog_top);

        var top = spt.get_parent(bvr.src_el, ".spt_top");
        var input = top.getElement(".spt_search_limit");
        input.value = values.search_limit;
        %s
        ''' % cancel_script
        })

        text = TextWdg("search_limit")
        text.add_class("spt_search_limit")
        top.add(text)

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

        web = WebContainer.get_web()
        show_multi_project = web.get_form_value('show_multi_project')
        project = Project.get()
        search_type_objs = project.get_search_types(include_multi_project=show_multi_project)


        top = my.top
        top.add_class("spt_panel_stype_list_top")
        #top.add_style("min-width: 400px")
        #top.add_style("max-width: 1000px")
        #top.add_style("width: 100%")
        top.center()



        button = SingleButtonWdg(title="Advanced Setup", icon=IconWdg.ADVANCED)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.app.ProjectStartWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("project_setup", "Project Setup", class_name)
            '''
        } )


        button = SingleButtonWdg(title="Add", tip="Add New Searchable Type (sType)", icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.app.SearchTypeCreatorWdg';

            var kwargs = {
            };
            var popup = spt.panel.load_popup("Create New Searchable Type", class_name, kwargs);

            var top = bvr.src_el.getParent(".spt_panel_stype_list_top");
            popup.on_register_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )

        cb = CheckboxWdg('show_multi_project', label=' show multi-project')
        if show_multi_project:
            cb.set_checked()
        cb.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
                var panel = bvr.src_el.getParent('.spt_panel_stype_list_top')
                spt.panel.refresh(panel, {show_multi_project: bvr.src_el.checked});
            '''
            })
        span = SpanWdg(css='small')
        top.add(span)
        top.add(cb)
        top.add("<br clear='all'/>")
        #search_type_objs = []
        if not search_type_objs:
            arrow_div = DivWdg()
            top.add(arrow_div)
            icon = IconWdg("Click to Add", IconWdg.ARROW_UP_LEFT_32)
            icon.add_style("margin-top: -20")
            icon.add_style("margin-left: -15")
            icon.add_style("position: absolute")
            arrow_div.add(icon)
            arrow_div.add("&nbsp;"*5)
            arrow_div.add("<b>Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: 5px")
            arrow_div.add_style("margin-left: 20px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 25px")
            arrow_div.set_box_shadow("0px 5px 20px")
            arrow_div.set_round_corners(30)
            arrow_div.add_color("background", "background")

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("width: 600px")
            div.add_style("margin: 30px auto")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg( "WARNING", IconWdg.WARNING )
            div.add(icon)
            div.add("<b>No Searchable Types have been created</b>")
            div.add("<br/><br/>")
            div.add("Searchables Types contain lists of items that are managed in this project.  Each item will automatically have the ability to have files checked into it, track tasks and status and record work hours.")
            div.add("<br/>"*2)
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias="main")
            div.add(help)
            div.add("<br/>")
            div.add("Click on the 'Add' button above to start adding new types.")
            return top


        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")



        table = Table()
        div.add(table)
        table.add_style("margin-top: 10px")
        table.set_max_width()



        # group mouse over
        table.add_relay_behavior( {
            'type': "mouseover",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        } )
        table.add_relay_behavior( {
            'type': "mouseout",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        } )



        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("")
        th.add_style("text-align: left")
        th = table.add_header("Title")
        th.add_style("text-align: left")
        th = table.add_header("# Items")
        th.add_style("text-align: left")
        th = table.add_header("View")
        th.add_style("text-align: left")
        th = table.add_header("Add")
        th.add_style("text-align: left")
        th = table.add_header("Import")
        th.add_style("text-align: left")
        th = table.add_header("Custom Columns")
        th.add_style("text-align: left")
        th = table.add_header("Workflow")
        th.add_style("text-align: left")
        th = table.add_header("Notifications")
        th.add_style("text-align: left")
        th = table.add_header("Triggers")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")
        #th = table.add_header("Security")
        #th.add_style("text-align: left")



        for i, search_type_obj in enumerate(search_type_objs):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i%2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2 )


            thumb = ThumbWdg()
            thumb.set_sobject(search_type_obj)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)



            search_type = search_type_obj.get_value("search_type")
            title = search_type_obj.get_title()

            table.add_cell(title)

            try:
                search = Search(search_type)
                count = search.get_count()
                if count:
                    table.add_cell("%s item/s" % count)
                else:
                    table.add_cell("&nbsp;")
            except:
                td = table.add_cell("&lt; No table &gt;")
                td.add_style("font-style: italic")
                td.add_style("color: #F00")
                continue



            #search = Search(search_type)
            #search.add_interval_filter("timestamp", "today")
            #created_today = search.get_count()
            #table.add_cell(created_today)



            td = table.add_cell()
            button = IconButtonWdg(title="View", icon=IconWdg.ZOOM)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            button.add_style("float: left")


            arrow_button = IconButtonWdg(tip="More Views", icon=IconWdg.ARROWHEAD_DARK_DOWN)
            arrow_button.add_style("margin-left: 20px")
            td.add(arrow_button)

            cbk = '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = bvr.class_name;
            var layout = bvr.layout;

            var kwargs = {
                search_type: bvr.search_type,
                layout: layout,
                view: bvr.view,
                simple_search_view: 'simple_search',
                element_names: bvr.element_names,
            };

            // use tab
            var top = activator.getParent(".spt_dashboard_top");
            spt.tab.set_tab_top(top);
            spt.tab.add_new('%s', '%s', class_name, kwargs);
            ''' % (title, title)


            from tactic.ui.panel import SwitchLayoutMenu
            SwitchLayoutMenu(search_type=search_type, activator=arrow_button, cbk=cbk, is_refresh=False)

            td = table.add_cell()
            button = IconButtonWdg(title="Add", icon=IconWdg.ADD)
            td.add(button)
            button.add_behavior( {
                'type': 'listen',
                'search_type': search_type,
                'event_name': 'startup_save:' + search_type_obj.get_title(),
                'title': search_type_obj.get_title(),
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
 

                '''
            } )
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': search_type_obj.get_title(),
                'cbjs_action': '''

                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: "insert",
                    save_event: "startup_save:" + bvr.title
                }
                spt.panel.load_popup("Add New Items ("+bvr.title+")", class_name, kwargs);

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                '''
            } )


            """
            td = table.add_cell()
            button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'checkin',
                    element_names: ['preview','code','name','description','history','general_checkin','notes']
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            """





            td = table.add_cell()
            button = IconButtonWdg(title="Import", icon=IconWdg.IMPORT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Import Data",
                'cbjs_action': '''

                var class_name = 'tactic.ui.widget.CsvImportWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };

                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )



            td = table.add_cell()
            button = IconButtonWdg(title="Custom Columns", icon=IconWdg.COLUMNS)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Add Custom Columns",
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.ColumnEditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Workflow", icon=IconWdg.PIPELINE)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/pipeline")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")




            button.add_behavior( {
                'type': 'click_up',
                'title': 'Workflow',
                'search_type': search_type,
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.PipelineEditWdg';
                var kwargs = {
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )
 


            td = table.add_cell()
            button = IconButtonWdg(title="Notifications", icon=IconWdg.MAIL)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/notification")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")






            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )


            td = table.add_cell()
            button = IconButtonWdg(title="Triggers", icon=IconWdg.ARROW_OUT)
            td.add(button)
            button.add_style("float: left")

            search = Search("config/trigger")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")


            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Edit Searchable Type", icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_type_obj.get_search_key(),
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/sobject",
                    view: "edit_startup",
                    search_key: bvr.search_key
                }
                spt.panel.load_popup("Edit Searchable Type", class_name, kwargs);


                '''
            } )


 
            """
            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''
                alert("security");
                '''
            } )
            """


        columns_wdg = DivWdg()
        top.add(columns_wdg)


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

        top = my.top

        #help_div = DivWdg()
        help_div = top
        #top.add(help_div)
        help_div.add_class("spt_help_top")
        help_div.set_id("spt_help_top")

        show_title = my.kwargs.get("show_title")
        if show_title in [True, 'true']:
            show_title = True
        else:
            show_title = False

        if show_title:
            title_wdg = DivWdg()
            help_div.add(title_wdg)
            title_wdg.add_style("font-size: 12px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_color("background", "background", -10)
            title_wdg.add_style("padding: 3px")
            #title_wdg.add_style("margin-top: 8px")
            title_wdg.add_style("margin-bottom: 5px")
            title_wdg.add_style("height: 26px")
            title_wdg.add_style("padding: 6 0 0 6")
            title_wdg.set_round_corners(corners=['TL','TR'])

            icon = IconWdg("Close", IconWdg.KILL)
            title_wdg.add(icon)
            icon.add_style("float: right")
            title_wdg.add("Help")



        help_div.set_round_corners()
        help_div.add_color("color", "color2")
        help_div.add_color("background", "background")
        help_div.add_style("overflow: hidden")
        help_div.add_border()



        shelf_div = DivWdg()
        help_div.add(shelf_div)
        shelf_div.add_style("padding: 10px")
        shelf_div.add_color("background", "background", -10)
        shelf_div.add_style("height: 25px")


        #button = SingleButtonWdg(title="Documentation Main Page", icon=IconWdg.HOME)
        button = IconButtonWdg(title="Documentation Main Page", icon="BS_HOME")
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_style("margin: 0px 10px")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_alias("main")
        '''
        } )




        #button = SingleButtonWdg(title="Edit Help", icon=IconWdg.EDIT)
        if my.show_add_new:
            button = IconButtonWdg(title="Add New Help", icon="BS_EDIT")
            shelf_div.add(button)
            button.add_style("float: left")
            button.add_style("margin: 0px 10px")
            button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.app.HelpEditWdg';

            var element_name = spt.help.get_view();
            if (!element_name) {
              element_name = "default";
            }
            var kwargs = {
              view: element_name
            }

            spt.tab.add_new("help_edit", "Help Edit", class_name, kwargs);
                
            '''
            } )



        #button = SingleButtonWdg(title="Go Back One Page", icon=IconWdg.ARROW_LEFT)
        button = IconButtonWdg(title="Go Back One Page", icon="BS_CIRCLE_ARROW_LEFT")
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_style("margin: 0px 10px")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_prev();
        '''
        } )

        #button = SingleButtonWdg(title="Go Forward One Page", icon=IconWdg.ARROW_RIGHT)
        button = IconButtonWdg(title="Go Forward One Page", icon="BS_CIRCLE_ARROW_RIGHT")
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_style("margin: 0px 10px")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_next();
        '''
        } )



        #button = SingleButtonWdg(title="Documentation Downloads", icon=IconWdg.DOWNLOAD)
        button = IconButtonWdg(title="Documentation Downloads", icon="BS_DOWNLOAD")
        shelf_div.add(button)
        button.add_style("float: right")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_alias("pdf")
        '''
        } )


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



        help_div.add_behavior( {
        'type': 'load',
        'cbjs_action': my.get_onload_js()
        })


        help_div.add_behavior( {
        'type': 'listen',
        'event_name': 'tab|select',
        'cbjs_action': '''

        var content = bvr.src_el.getElement(".spt_help_content");
        var options = bvr.firing_data;
        var element_name = options.element_name;
        var alias = options.alias;

        if (!alias) {
            alias = options.element_name;
        }

        spt.help.set_top();
        if (spt.help.is_visible()) {
            spt.help.load_alias(alias);
        }
        else {
            spt.help.set_view(alias);
        }
        '''

        } )


        help_div.add_behavior( {
        'type': 'listen',
        'event_name': 'show_help',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_help");
        var content = top.getElement(".spt_help_content");
        var firing_data = bvr.firing_data;
        var class_name = firing_data.class_name;
        if (!class_name) {
            class_name = 'tactic.ui.app.HelpContentWdg';
        }

        if (top.getStyle("display") != 'none') {
            spt.hide(top);
            return;
        }

        spt.help.set_top()

        // get the help view
        var help_view = spt.help.get_view();
        var html = firing_data.html;
        if (html) {
            spt.help.load_html(html);    
        }
        else {
            if (!help_view) {
                help_view = 'default'    
            }
            spt.help.load_alias(help_view);
        }

        var size = $(window).getSize();

        var dialog = bvr.src_el.getParent(".spt_dialog_content");

        dialog.setStyle("height", size.y - 100);
        dialog.setStyle("width", 650);

        var top = bvr.src_el.getParent(".spt_dialog_top");
        top.setStyle("left", size.x - 660);
        top.setStyle("top", 40);

        spt.show(top);
        '''
        } )






        content = DivWdg()
        help_div.add(content)
        content.add_class("spt_help_content");
        content.add_style("position: relative")
        content.add_style("overflow_x: auto")
        content.add_style("overflow_y: auto")
        content.add_style("margin-bottom: 10px")
        #content.add_style("border: solid 1px blue")
        content.add_style("height: 98%")


        #key = "schema_editor"
        #search = Search("config/doc")
        #search.add_filter("code", key)
        #doc = search.get_sobject()
        #doc_html = doc.get_value("doc")
        #help_div.add(doc_html)


        return top
Beispiel #51
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
Beispiel #52
0
    def get_display(self):
        top = self.top
        self.set_as_panel(top)
        top.add_class("spt_delete_top")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_border()
        top.add_style("width: 400px")
        top.add_border()


        search_key = self.kwargs.get("search_key")
        search_keys = self.kwargs.get("search_keys")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            sobjects = [sobject]
            search_keys = [search_key]
        elif search_keys:
            sobjects = Search.get_by_search_keys(search_keys)
            sobject = sobjects[0]

        if not sobjects or not sobject:
            msg =  "%s not found" %search_key
            return msg
        search_type = sobject.get_base_search_type()

        if search_type in ['sthpw/project', 'sthpw/search_object']:
            msg = 'You cannot delete these items with this tool'
            return msg


        self.search_keys = search_keys


        title = DivWdg()
        top.add(title)

        icon = IconWdg("WARNING", IconWdg.WARNING)
        icon.add_style("float: left")
        title.add(icon)

        if len(self.search_keys) > 1:
            title.add("Delete %s Items" % len(self.search_keys))
        else:
            title.add("Delete Item [%s]" % (sobject.get_code()))
        title.add_style("font-size: 20px")
        title.add_style("font-weight: bold")
        title.add_style("padding: 10px")

        title.add("<hr/>")

        content = DivWdg()
        top.add(content)
        content.add_style("margin: 5px 10px 20px 10px")


        content.add("The item to be deleted has a number of dependencies as described below:<br/>", 'heading')

        # find all the relationships
        related_types = SearchType.get_related_types(search_type, direction='children') 
       
        items_div = DivWdg()
        content.add( items_div )
        items_div.add_style("padding: 10px")
        valid_related_ctr = 0
        for related_type in related_types:
            if related_type == "*":
                print("WARNING: related_type is *")
                continue
            if related_type == search_type:
                continue
            if related_type in ['sthpw/search_object','sthpw/search_type']:
                continue

            item_div = self.get_item_div(sobjects, related_type)
            if item_div:
                items_div.add(item_div)
                valid_related_ctr += 1


        

        if valid_related_ctr > 0:
            #icon = IconWdg("Note", "BS_NOTE")
            #icon.add_style("float: left")
            #content.add( icon )
            content.add("<div><b>By selecting the above, the corresponding related items will be deleted as well.</b></div>")
            content.add("<br/>"*2)
        else:
            # changed the heading to say no dependencies
            content.add("The item to be deleted has no dependencies.<br/>", 'heading')


        num_items = len(self.search_keys)
        if num_items == 1:
            verb = "is 1 item"
        else:
            verb = "are %s items" % num_items
        content.add("There %s to be deleted" % verb)
        content.add("<br/>"*2)

        content.add("Do you wish to continue deleting?")
        content.add("<br/>"*3)

        button_div = DivWdg()
        button_div.add_class("spt_buttons")
        content.add(button_div)
        button_div.add_style('text-align: center')

        button = ActionButtonWdg(title="Delete", width=100, color="danger")
        button_div.add(button)
        button.add_style("display: inline-block")

        deleting_div = DivWdg()
        content.add(deleting_div)
        deleting_div.add("<img src='/context/icons/common/indicator_snake.gif'/>")
        deleting_div.add_class("spt_delete_msg")
        deleting_div.add(" Deleting ...")
        deleting_div.add_style("text-align: center")
        deleting_div.add_style("font-size: 16px")
        deleting_div.add_style("margin: 20px")
        deleting_div.add_style("display: none")

        on_complete = self.kwargs.get("on_complete")

        button.add_behavior( {
        'type': 'click_up',
        'search_keys': self.search_keys,
        'on_complete': on_complete,
        'cbjs_action': '''
        spt.app_busy.show("Deleting");
        //spt.notify.show_message("Deleting ...");

        //var button_el = bvr.src_el.getParent(".spt_buttons");
        //button_el.setStyle("display", "none");

        var top = bvr.src_el.getParent(".spt_delete_top");
        var values = spt.api.Utility.get_input_values(top);

        var class_name = "tactic.ui.tools.DeleteCmd";
        var kwargs = {
            'search_keys': bvr.search_keys,
            'values': values
        };

        var del_trigger = function() {
            
            // for fast table
            var tmps = spt.split_search_key(bvr.search_keys[0])
            var tmps2 = tmps[0].split('?');
            var del_st_event = "delete|" + tmps2[0];
            var bvr_fire = {};
            var input = {'search_keys': bvr.search_keys};
            bvr_fire.options = input;
            spt.named_events.fire_event(del_st_event, bvr_fire);
        }

        var server = TacticServerStub.get();

        server.execute_cmd(class_name, kwargs, null, {
            on_complete: function() {
                //spt.notify.show_message("Finshed deleting ...");

                // run the post delete and destroy the popup
                var popup = bvr.src_el.getParent(".spt_popup");
                if (popup.spt_on_post_delete) {
                    popup.spt_on_post_delete();
                }

                del_trigger();

                spt.popup.destroy(popup);


                if (bvr.on_complete) {
                   on_complete = function() {
                       eval(bvr.on_complete);
                   }
                   on_complete();
                }

                spt.app_busy.hide();
            },
            on_error: function(e) {
                spt.notify.show_message("Error on delete");
                spt.alert(spt.exception.handler(e));
                spt.app_busy.hide();
            }
        } );

        '''
        } )



        button = ActionButtonWdg(title="Cancel", width=100)
        button_div.add(button)
        button.add_style("display: inline-block")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        } )


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


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

        collection = my.kwargs.get("collection")
        path = my.kwargs.get("path")

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

        search = Search(collection_type)
        search.add_filter("parent_code", collection.get_value("code"))
        search.add_column("search_code")
        items = search.get_sobjects()
        codes = [x.get_value("search_code") for x in items]

        count = search.get_count()


        # find the children that are actually collections
        search = Search(search_type)
        search.add_filter("_is_collection", True)
        search.add_filters("code", codes)
        has_child_collections = search.get_count() > 0


        top = my.top
        collection_top = top
        collection_top.add_class("spt_collection_div_top")
        collection_div = DivWdg()
        
        name = collection.get_value("name")
        # Adding Collection title (without the number count) as an attribute
        collection_top.set_attr("collection_name", name)

        collection_top.add(collection_div)
        collection_top.add_class("tactic_hover")
        collection_top.add_class("hand")

        collection_div.add_class("spt_collection_item")
        collection_div.add_attr("spt_collection_key", collection.get_search_key())
        collection_div.add_attr("spt_collection_code", collection.get_code())
        collection_div.add_attr("spt_collection_path", path)

        # This is for Drag and Drop from a tile widget
        collection_div.add_class("spt_tile_top")
        collection_div.add_attr("spt_search_key", collection.get_search_key())
        collection_div.add_attr("spt_search_code", collection.get_code())

        collection_div.add_style("height: 20px")
        collection_div.add_style("padding-top: 10px")

        
        if has_child_collections:
            icon_div = DivWdg()
            icon = IconWdg(name="View Collection", icon="BS_CHEVRON_DOWN")
            icon_div.add(icon)
            icon.add_style("float: right")
            icon.add_style("margin-top: -20px")
            collection_top.add(icon_div)
            icon_div.add_class("spt_collection_open")
            icon_div.add_attr("spt_collection_key", collection.get_search_key())
            icon_div.add_attr("spt_collection_path", path)

        from tactic.ui.panel import ThumbWdg2
        thumb_wdg = ThumbWdg2()
        thumb_wdg.set_sobject(collection)
        collection_div.add(thumb_wdg)
        thumb_wdg.add_style("width: 45px")
        thumb_wdg.add_style("float: left")
        thumb_wdg.add_style("margin-top: -10px")

        if count:
            count_div = DivWdg()
            collection_div.add(count_div)
            #count_div.add_style("margin-top: -10px")
            #count_div.add_style("margin-left: -10px")

            count_div.add_style("width: 15px")
            count_div.add_style("height: 15px")
            count_div.add_style("font-size: 0.8em")
            count_div.add_style("border-radius: 10px")
            count_div.add_style("background: #DDD")
            count_div.add_style("position: absolute")
            count_div.add_style("text-align: center")
            count_div.add_style("margin-left: 23px")
            count_div.add_style("margin-top: -8px")
            count_div.add_style("box-shadow: 0px 0px 3px rgba(0,0,0,0.5)")

            count_div.add(count)
            #count_div.add_update( {
            #    'parent_key': collection.get_search_key(),
            #    'expression': "@COUNT(%s)" % collection_type,
            #} )


        name = collection.get_value("name")
        collection_div.add(name)



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

        web = WebContainer.get_web()
        show_multi_project = web.get_form_value('show_multi_project')
        project = Project.get()
        search_type_objs = project.get_search_types(include_multi_project=show_multi_project)


        top = my.top
        top.add_class("spt_panel_stype_list_top")
        #top.add_style("min-width: 400px")
        #top.add_style("max-width: 1000px")
        #top.add_style("width: 100%")
        top.center()



        button = SingleButtonWdg(title="Advanced Setup", icon=IconWdg.ADVANCED)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.app.ProjectStartWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("project_setup", "Project Setup", class_name)
            '''
        } )


        button = SingleButtonWdg(title="Add", tip="Add New Searchable Type (sType)", icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.app.SearchTypeCreatorWdg';

            var kwargs = {
            };
            var popup = spt.panel.load_popup("Create New Searchable Type", class_name, kwargs);

            var top = bvr.src_el.getParent(".spt_panel_stype_list_top");
            popup.on_register_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )

        cb = CheckboxWdg('show_multi_project', label=' show multi-project')
        if show_multi_project:
            cb.set_checked()
        cb.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
                var panel = bvr.src_el.getParent('.spt_panel_stype_list_top')
                spt.panel.refresh(panel, {show_multi_project: bvr.src_el.checked});
            '''
            })
        span = SpanWdg(css='small')
        top.add(span)
        top.add(cb)
        top.add("<br clear='all'/>")
        #search_type_objs = []
        if not search_type_objs:
            arrow_div = DivWdg()
            top.add(arrow_div)
            icon = IconWdg("Click to Add", IconWdg.ARROW_UP_LEFT_32)
            icon.add_style("margin-top: -20")
            icon.add_style("margin-left: -15")
            icon.add_style("position: absolute")
            arrow_div.add(icon)
            arrow_div.add("&nbsp;"*5)
            arrow_div.add("<b>Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: 5px")
            arrow_div.add_style("margin-left: 20px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 25px")
            arrow_div.set_box_shadow("0px 5px 20px")
            arrow_div.set_round_corners(30)
            arrow_div.add_color("background", "background")

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("width: 600px")
            div.add_style("margin: 30px auto")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg( "WARNING", IconWdg.WARNING )
            div.add(icon)
            div.add("<b>No Searchable Types have been created</b>")
            div.add("<br/><br/>")
            div.add("Searchables Types contain lists of items that are managed in this project.  Each item will automatically have the ability to have files checked into it, track tasks and status and record work hours.")
            div.add("<br/>"*2)
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias="main")
            div.add(help)
            div.add("<br/>")
            div.add("Click on the 'Add' button above to start adding new types.")
            return top


        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")



        table = Table()
        div.add(table)
        table.add_style("margin-top: 10px")
        table.set_max_width()



        # group mouse over
        table.add_relay_behavior( {
            'type': "mouseover",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        } )
        table.add_relay_behavior( {
            'type': "mouseout",
            'bvr_match_class': 'spt_row',
            'cbjs_action': "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        } )



        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("")
        th.add_style("text-align: left")
        th = table.add_header("Title")
        th.add_style("text-align: left")
        th = table.add_header("# Items")
        th.add_style("text-align: left")
        th = table.add_header("View")
        th.add_style("text-align: left")
        th = table.add_header("Add")
        th.add_style("text-align: left")
        th = table.add_header("Import")
        th.add_style("text-align: left")
        th = table.add_header("Custom Columns")
        th.add_style("text-align: left")
        th = table.add_header("Workflow")
        th.add_style("text-align: left")
        th = table.add_header("Notifications")
        th.add_style("text-align: left")
        th = table.add_header("Triggers")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")
        #th = table.add_header("Security")
        #th.add_style("text-align: left")



        for i, search_type_obj in enumerate(search_type_objs):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i%2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2 )


            thumb = ThumbWdg()
            thumb.set_sobject(search_type_obj)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)



            search_type = search_type_obj.get_value("search_type")
            title = search_type_obj.get_title()

            table.add_cell(title)

            try:
                search = Search(search_type)
                count = search.get_count()
                if count:
                    table.add_cell("%s item/s" % count)
                else:
                    table.add_cell("&nbsp;")
            except:
                td = table.add_cell("&lt; No table &gt;")
                td.add_style("font-style: italic")
                td.add_style("color: #F00")
                continue



            #search = Search(search_type)
            #search.add_interval_filter("timestamp", "today")
            #created_today = search.get_count()
            #table.add_cell(created_today)



            td = table.add_cell()
            button = IconButtonWdg(title="View", icon=IconWdg.ZOOM)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            button.add_style("float: left")


            arrow_button = IconButtonWdg(tip="More Views", icon=IconWdg.ARROWHEAD_DARK_DOWN)
            arrow_button.add_style("margin-left: 20px")
            td.add(arrow_button)

            cbk = '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = bvr.class_name;
            var layout = bvr.layout;

            var kwargs = {
                search_type: bvr.search_type,
                layout: layout,
                view: bvr.view,
                simple_search_view: 'simple_search',
                element_names: bvr.element_names,
            };

            // use tab
            var top = activator.getParent(".spt_dashboard_top");
            spt.tab.set_tab_top(top);
            spt.tab.add_new('%s', '%s', class_name, kwargs);
            ''' % (title, title)


            from tactic.ui.panel import SwitchLayoutMenu
            SwitchLayoutMenu(search_type=search_type, activator=arrow_button, cbk=cbk, is_refresh=False)

            td = table.add_cell()
            button = IconButtonWdg(title="Add", icon=IconWdg.ADD)
            td.add(button)
            button.add_behavior( {
                'type': 'listen',
                'search_type': search_type,
                'event_name': 'startup_save:' + search_type_obj.get_title(),
                'title': search_type_obj.get_title(),
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
 

                '''
            } )
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': search_type_obj.get_title(),
                'cbjs_action': '''

                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: "insert",
                    save_event: "startup_save:" + bvr.title
                }
                spt.panel.load_popup("Add New Items ("+bvr.title+")", class_name, kwargs);

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                '''
            } )


            """
            td = table.add_cell()
            button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'checkin',
                    element_names: ['preview','code','name','description','history','general_checkin','notes']
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            """





            td = table.add_cell()
            button = IconButtonWdg(title="Import", icon=IconWdg.IMPORT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Import Data",
                'cbjs_action': '''

                var class_name = 'tactic.ui.widget.CsvImportWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };

                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )



            td = table.add_cell()
            button = IconButtonWdg(title="Custom Columns", icon=IconWdg.COLUMNS)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': "Add Custom Columns",
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.ColumnEditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Workflow", icon=IconWdg.PIPELINE)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/pipeline")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")




            button.add_behavior( {
                'type': 'click_up',
                'title': 'Workflow',
                'search_type': search_type,
                'cbjs_action': '''
                var class_name = 'tactic.ui.startup.PipelineEditWdg';
                var kwargs = {
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )
 


            td = table.add_cell()
            button = IconButtonWdg(title="Notifications", icon=IconWdg.MAIL)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/notification")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")






            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )


            td = table.add_cell()
            button = IconButtonWdg(title="Triggers", icon=IconWdg.ARROW_OUT)
            td.add(button)
            button.add_style("float: left")

            search = Search("config/trigger")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg( "Has Items", IconWdg.CHECK, width=8 )
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")


            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            } )





            td = table.add_cell()
            button = IconButtonWdg(title="Edit Searchable Type", icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_type_obj.get_search_key(),
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/sobject",
                    view: "edit_startup",
                    search_key: bvr.search_key
                }
                spt.panel.load_popup("Edit Searchable Type", class_name, kwargs);


                '''
            } )


 
            """
            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''
                alert("security");
                '''
            } )
            """


        columns_wdg = DivWdg()
        top.add(columns_wdg)


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

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

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

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

        detail_wdg = DivWdg()
        top.add(detail_wdg)

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

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

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


        insert_view = "edit_collection"

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

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

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

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

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

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

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

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

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

        for collection in collections:

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


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

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

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


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

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

            check_div = DivWdg()
            collection_div.add(check_div)

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

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

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

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

            collection_div.add("<hr/>")


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

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

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

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

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

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

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

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

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

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

        top = my.top
        top.add_style("white-space: nowrap")
        #top.add_style("position: relative")

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


        show_menu = my.kwargs.get("show_menu")
        is_disabled = my.kwargs.get("is_disabled")

        button = DivWdg()
        button.add_style("float: left")
        
        my.inner = button
        top.add(button)
        my.inner.add_class("hand")

        button.add_class("spt_button_top")
        button.add_style("position: relative")

        #img = "<img src='%s/MainButtonSlices_button.png'/>" % base
        #img_div = DivWdg(img)
        #button.add(img_div)
        #img_div.add_style("opacity", ALPHA)

        img_div = DivWdg()
        button.add(img_div)
        img_div.add_style("width: 30px")
        img_div.add_style("height: 35px")
       
       

        over_div = DivWdg()
        button.add(over_div)
        over_div.add_class("spt_button_over")
        over_img = "<img src='%s/MainButton_over.png'/>" % base
        over_div.add(over_img)
        over_div.add_style("position: absolute")
        over_div.add_style("top: 0px")
        over_div.add_style("left: 0px")
        over_div.add_style("display: none")

        click_div = DivWdg()
    
        button.add(click_div)
        click_div.add_class("spt_button_click")
        click_img = "<img src='%s/MainButton_click.png'/>" % base
        click_div.add(click_img)
        click_div.add_style("position: absolute")
        click_div.add_style("top: 0px")
        click_div.add_style("left: 0px")
        click_div.add_style("display: none")


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

        icon_div = my.icon_div
        button.add(icon_div)
        #icon_div.add_class("spt_button_click")
        icon_str = my.kwargs.get("icon")
        icon = IconWdg(tip, icon_str, right_margin=0, width=16)
        icon.add_class("spt_button_icon")
        icon_div.add(icon)
        icon_div.add_style("position: absolute")
        #TODO: removed this top attr after we trim the top and bottom whitespace of the over image
        icon_div.add_style("top: 12px")
        icon_div.add_style("left: 6px")

        if my.is_disabled:
            icon_div.add_style("opacity: 0.5")
        

        my.icon_div = icon_div

        sub_icon = my.kwargs.get("sub_icon")
        if sub_icon:
            sub_icon = IconWdg(icon=sub_icon, size="8")
            button.add(sub_icon)
            sub_icon.add_style("position: absolute")
            sub_icon.add_style("bottom: 4px")
            sub_icon.add_style("right: 0px")
        
       

        my.show_arrow = my.kwargs.get("show_arrow") in [True, 'true']
        if my.show_arrow or my.dialog:
            arrow_div = DivWdg()
            button.add(arrow_div)
            arrow_div.add_style("position: absolute")
            arrow_div.add_style("top: 24px")
            arrow_div.add_style("left: 20px")

            arrow = IconWdg(tip, IconWdg.ARROW_MORE_INFO)
            arrow_div.add(arrow)


        web = WebContainer.get_web()
        is_IE = web.is_IE()

        #my.hit_wdg.add_style("height: 100%")
        my.hit_wdg.add_style("width: 100%")
        if is_IE:
            my.hit_wdg.add_style("filter: alpha(opacity=0)")
            my.hit_wdg.add_style("height: 40px")
        else:
            my.hit_wdg.add_style("height: 100%")
            my.hit_wdg.add_style("opacity: 0.0")

        if my.is_disabled:
            my.hit_wdg.add_style("display: none")

        button.add(my.hit_wdg)


        my.hit_wdg.add_style("position: absolute")
        my.hit_wdg.add_style("top: 0px")
        my.hit_wdg.add_style("left: 0px")
        my.hit_wdg.add_attr("title", tip)


        """
        my.hit_wdg.add_behavior( {
        'type': 'hover',
        'cbjs_action_over': '''
            var top = bvr.src_el.getParent(".spt_button_top")
            var over = top.getElement(".spt_button_over");
            var click = top.getElement(".spt_button_click");
            over.setStyle("display", "");
            click.setStyle("display", "none");
        ''',
        'cbjs_action_out': '''
            var top = bvr.src_el.getParent(".spt_button_top")
            var over = top.getElement(".spt_button_over");
            var click = top.getElement(".spt_button_click");
            over.setStyle("display", "none");
            click.setStyle("display", "none");
        '''
        } )
        """



        # add a second arrow widget
        if my.show_arrow_menu:
            my.inner.add(my.arrow_div)
            my.arrow_div.add_attr("title", "More Options")
            my.arrow_div.add_style("position: absolute")
            my.arrow_div.add_style("top: 11px")
            my.arrow_div.add_style("left: 20px")
            my.arrow_div.add(my.arrow_menu)






        if my.dialog:
            top.add(my.dialog)
            dialog_id = my.dialog.get_id()
            my.hit_wdg.add_behavior( {
            'type': 'click_up',
            'dialog_id': dialog_id,
            'cbjs_action': '''
            var dialog = $(bvr.dialog_id);
            var pos = bvr.src_el.getPosition();
            var size = bvr.src_el.getSize();
            //var dialog = $(bvr.dialog_id);
            dialog.setStyle("left", pos.x);
            dialog.setStyle("top", pos.y+size.y);
            spt.toggle_show_hide(dialog);

            '''
            } )




        return top
Beispiel #57
0
    def handle_dir_or_item(self, item_div, dirname, basename):
        spath = "%s/%s" % (dirname, basename)
        #fspath = "%s/%s" % (dirname, File.get_filesystem_name(basename))
        fspath = "%s/%s" % (dirname, basename)

        md5 = self.md5s.get(fspath)
        changed = False
        context = None
        error_msg = None
        snapshot = None
        file_obj = self.checked_in_paths.get(fspath)
        if not file_obj:
            if fspath.startswith(self.base_dir):
                rel = fspath.replace("%s/" % self.base_dir, "")
                file_obj = self.checked_in_paths.get(rel)

        if file_obj != None:

            snapshot_code = file_obj.get_value("snapshot_code")
            snapshot = self.snapshots_dict.get(snapshot_code)
            if not snapshot:
                # last resort
                snapshot = file_obj.get_parent()

            if snapshot:
                context = snapshot.get_value("context")
                item_div.add_attr("spt_snapshot_code", snapshot.get_code())

                snapshot_md5 = file_obj.get_value("md5")
                item_div.add_attr("spt_md5", snapshot_md5)
                item_div.add_attr(
                    "title",
                    "Checked-in as: %s" % file_obj.get_value("file_name"))

                if md5 and md5 != snapshot_md5:
                    item_div.add_class("spt_changed")
                    changed = True
            else:
                error_msg = 'snapshot not found'

        status = None
        if file_obj != None:
            if changed:
                check = IconWdg("Checked-In", IconWdg.ERROR, width=12)
                status = "changed"
            else:
                check = IconWdg("Checked-In", IconWdg.CHECK, width=12)
                status = "same"
            item_div.add_color("color", "color", [0, 0, 50])

        else:
            check = None
            item_div.add_style("opacity: 0.8")
            status = "unversioned"

        if check:
            item_div.add(check)
            check.add_style("float: left")
            check.add_style("margin-left: -16px")
            check.add_style("margin-top: 4px")

        # add the file name
        filename_div = DivWdg()
        item_div.add(filename_div)
        filename_div.add(basename)
        file_info_div = None
        if snapshot and status != 'unversioned':
            file_info_div = SpanWdg()
            filename_div.add(file_info_div)

        if error_msg:
            filename_div.add(' (%s)' % error_msg)
        filename_div.add_style("float: left")
        filename_div.add_style("overflow: hidden")
        filename_div.add_style("width: 65%")

        # DEPRECATED
        """
        checkbox = CheckboxWdg("check")
        checkbox.add_style("display: none")
        checkbox.add_class("spt_select")
        checkbox.add_style("float: right")
        checkbox.add_style("margin-top: 1px")
        item_div.add(checkbox)
        """

        subcontext_val = ''
        cat_input = None
        is_select = True
        if self.context_options:
            context_sel = SelectWdg("context")
            context_sel.add_attr('title', 'context')
            context_sel.set_option("show_missing", False)
            context_sel.set_option("values", self.context_options)
            item_div.add_attr("spt_context", self.context_options[0])
            cat_input = context_sel
            input_cls = 'spt_context'

        else:
            if self.subcontext_options in [['(main)'], ['(auto)'], []]:
                is_select = False
                #subcontext = TextWdg("subcontext")
                subcontext = HiddenWdg("subcontext")
                subcontext.add_class("spt_subcontext")

            elif self.subcontext_options == ['(text)']:
                is_select = False
                subcontext = TextWdg("subcontext")
                subcontext.add_class("spt_subcontext")

            else:
                is_select = True

                subcontext = SelectWdg("subcontext", bs=False)
                subcontext.set_option("show_missing", False)
                subcontext.set_option("values", self.subcontext_options)
                #subcontext.add_empty_option("----")

            cat_input = subcontext
            input_cls = 'spt_subcontext'

            if self.subcontext_options == [
                    '(main)'
            ] or self.subcontext_options == ['(auto)']:
                subcontext_val = self.subcontext_options[0]
                subcontext.set_value(subcontext_val)
                item_div.add_attr("spt_subcontext", subcontext_val)
            elif context:
                parts = context.split("/")
                if len(parts) > 1:

                    # get the actual subcontext value
                    subcontext_val = "/".join(parts[1:])

                    # identify a previous "auto" check-in and preselect the item in the select
                    if is_select and subcontext_val not in self.subcontext_options:
                        subcontext_val = '(auto)'

                    elif isinstance(cat_input, HiddenWdg):
                        subcontext_val = ''
                    # the Text field will adopt the subcontext value of the last check-in
                    subcontext.set_value(subcontext_val)
                    item_div.add_attr("spt_subcontext", subcontext_val)
                elif self.subcontext_options:
                    # handles file which may have previous strict checkin
                    subcontext_val = self.subcontext_options[0]
                    item_div.add_attr("spt_subcontext", subcontext_val)

            else:
                if is_select:
                    if self.subcontext_options:
                        subcontext_val = self.subcontext_options[0]
                    #subcontext_val = '(auto)'
                    cat_input.set_value(subcontext_val)
                else:
                    subcontext_val = ''
                item_div.add_attr("spt_subcontext", subcontext_val)
        item_div.add(cat_input)

        cat_input.add_behavior({
            'type':
            'click_up',
            'propagate_evt':
            False,
            'cbjs_action':
            '''
                bvr.src_el.focus();
                '''
        })

        # on selecting in the UI, it will be visible again
        cat_input.add_style("display: none")
        cat_input.add_class("spt_subcontext")
        cat_input.add_style("float: right")
        cat_input.add_style("width: 70px")
        cat_input.add_style("margin-top: -1px")
        cat_input.add_style("font-size: 10px")
        # it needs to be 18px at least for selected value  visible
        cat_input.add_style("height: 18px")

        # we depend on the attribute cuz sometimes we go by the initialized value
        # since they are not drawn
        cat_input.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
            var el = bvr.src_el.getParent('.spt_dir_list_item');
            el.setAttribute("%s", bvr.src_el.value);
            ''' % input_cls
        })

        if file_info_div:
            if subcontext_val in ['(auto)', '(main)', '']:
                file_info_div.add(
                    " <i style='font-size: 9px; opacity: 0.6'>(v%s)</i>" %
                    snapshot.get_value("version"))
            else:
                file_info_div.add(
                    " <i style='font-size: 9px; opacity: 0.6'>(v%s - %s)</i>" %
                    (snapshot.get_value("version"), subcontext_val))
Beispiel #58
0
    def get_display(self):

        menu_div = DivWdg()
        menu_div.set_attr("id", self.menu_id)
        menu_div.add_class("SPT_CTX_MENU")
        menu_div.add_class(
            "SPT_PUW"
        )  # make it a Page Utility Widget (now processed client side)

        menu_div.set_z_start(300)
        menu_div.add_looks("menu border curs_default")

        m_width = self.width - 2
        menu_div.add_style(("width: %spx" % m_width))

        menu_table = Table()
        menu_table.add_styles(
            "text-align: left; text-indent: 3px; border-collapse: collapse;")

        options = self.opt_spec_list
        for opt in options:

            tbody = menu_table.add_tbody()
            tbody.add_style("display", "table-row-group")

            tr = menu_table.add_row()
            tr.add_looks("menu")
            tr.add_class("SPT_CTX_MENU_%s" % opt['type'].upper())
            disabled = False

            if opt.has_key('disabled') and opt['disabled']:
                disabled = True

            if not disabled:
                if opt['type'] in ['action', 'toggle']:
                    tr.add_behavior({
                        'type': 'hover',
                        'cbfn_over': 'spt.ctx_menu.entry_over',
                        'cbfn_out': 'spt.ctx_menu.entry_out',
                        'hover_class': 'look_menu_hover'
                    })

                if opt['type'] == 'action':
                    if opt.has_key('bvr_cb') and type(opt['bvr_cb']) == dict:
                        bvr = opt['bvr_cb']
                        bvr['cbjs_preaction'] = 'spt.ctx_menu.clear();'
                        # bvr['cbfn_preaction'] = 'spt.ctx_menu.clear'
                        bvr.update({'type': 'click', 'mouse_btn': 'LMB'})
                        tr.add_behavior(bvr)

                if opt['type'] == 'submenu':
                    bvr = {
                        'type': 'hover',
                        'cbfn_over': 'spt.ctx_menu.submenu_entry_over',
                        'cbfn_out': 'spt.ctx_menu.submenu_entry_out',
                        'hover_class': 'look_menu_hover',
                        'options': {
                            'menu_id': opt['submenu_id']
                        }
                    }
                    tr.add_behavior(bvr)
                    # now trap click on submenu, so that it doesn't make the current menu disappear ...
                    tr.add_behavior({
                        'type': 'click',
                        'cbjs_action': ';',
                        'activator_type': 'ctx_menu'
                    })

            tr.add_looks("curs_default")

            icon_width = 16
            icon_col_width = 0

            # Left icon cell ...
            if self.allow_icons:
                td = menu_table.add_cell()
                icon_col_width = icon_width + 2
                td.add_styles(
                    "text-align: center; vertical-align: middle; width: %spx;"
                    % icon_col_width)
                td.add_looks("menu_icon_column")

                if opt.has_key('icon'):
                    icon_wdg = IconWdg("", opt['icon'])
                    td.add(icon_wdg)
                    if disabled:
                        icon_wdg.add_style("opacity: .4")
                        icon_wdg.add_style("filter: alpha(opacity=40)")

            # Menu option label cell ...
            td = menu_table.add_cell()
            w = m_width - icon_col_width - icon_width
            td.add_style("width", ("%spx" % w))
            td.add_style("height", ("%spx" % icon_col_width))
            td.add_style("padding-left: 4px")
            td.add_style("padding-top: 2px")
            td.add_style("cursor: default")

            label_str = ''
            if opt.has_key('label'):
                label_str = opt.get('label')
            elif opt.get('type') == 'separator':
                label_str = '<HR>'

            td.add_looks("fnt_text")
            if opt.get('type') == 'title':
                td.add_looks("fnt_bold")

            td.add(label_str)

            if disabled:
                td.add_style("opacity: .2")
                td.add_style("filter: alpha(opacity=20)")

            # Submenu arrow icon cell ...
            td = menu_table.add_cell()
            td.add_style("width", ("%spx" % icon_width))

            if opt['type'] == 'submenu':
                icon_wdg = IconWdg("", IconWdg.ARROWHEAD_DARK_RIGHT)
                td.add(icon_wdg)

            if disabled:
                td.add_style("opacity: .4")
                td.add_style("filter: alpha(opacity=40)")

        menu_div.add(menu_table)
        menu_div.add_style("display: none")
        menu_div.add_style("position: absolute")
        return menu_div
Beispiel #59
0
    def get_content_wdg(my):

        div = DivWdg()
        div.add_class("spt_tool_top")

        #table = Table()
        from tactic.ui.container import ResizableTableWdg
        from table_layout_wdg import FastTableLayoutWdg

        table = ResizableTableWdg()
        table.add_style("table-layout", "fixed")
        table.add_style("width: 100%")
        div.add(table)
        table.add_row()

        td = table.add_cell()


        kwargs = my.kwargs.copy()


        td.add_style("vertical-align: top")
        layout_div = DivWdg()
        layout_div.add_style("min-height: 500px")
        layout_div.add_style("height: auto")
        td.add(layout_div)
        td.add_style("overflow: hidden")

        kwargs['show_shelf'] = False
        kwargs['show_search_limit'] = False
        kwargs['expand_on_load'] = False
        layout = FastTableLayoutWdg(**kwargs)
        layout_div.add(layout)
        layout.set_sobjects(my.sobjects)
        #from tactic.ui.panel import TileLayoutWdg
        #layout = TileLayoutWdg(**my.kwargs)
        #layout_div.add(layout)


        td = table.add_cell()
        td.add_border(color="#EEE")
        td.add_style("vertical-align: top")

        content = DivWdg()
        td.add(content)
        content.add_class("spt_tool_content")
        content.add_border(color="#EEE")
        content.add_style("margin: -1px")
        content.add_style("height: 100%")
        #content.add_style("padding: 0px 20px")



        no_content_wdg = DivWdg()
        content.add(no_content_wdg)
        no_content_wdg.add("<br/>"*3)

        '''
        The no content message displays tool icons
        and a message in format:
                         <tools>
                          <msg>
        '''
        tool_icons = my.kwargs.get('tool_icon')
        if isinstance(tool_icons, basestring):
            tool_icon_lst = tool_icons.split("|")
        else:
            tool_icon_lst = None

        if tool_icon_lst:
            for icon in tool_icon_lst:
                icon = IconWdg(icon=icon) 
                icon.add_style("padding", "5px")
                no_content_wdg.add(icon)
            no_content_wdg.add("</br></br>")
       
        tool_msg = my.kwargs.get('tool_msg')
        if tool_msg:
            no_content_wdg.add("<p>%s<p>" % tool_msg)
        else:
            no_content_wdg.add("Click the tool(s) to modify settings.") 
       
        #no_content_wdg.add_style("opacity: 0.5")
        no_content_wdg.add_style("margin: 30px auto")
        no_content_wdg.add_color("color", "color3")
        no_content_wdg.add_color("background", "background3")
        no_content_wdg.add_style("text-align", "center")
        no_content_wdg.add_style("padding-top: 20px")
        no_content_wdg.add_style("padding-bottom: 20px")
        no_content_wdg.add_style("width: 350px")
        no_content_wdg.add_style("height: 110px")
        no_content_wdg.add_style("margin: 30px auto")
        no_content_wdg.add_border()


        return div