コード例 #1
0
    def get_save_wdg(my):

        from tactic.ui.container import DialogWdg
        dialog = DialogWdg(display=False, width=200, offset={'x':0,'y':50}, show_pointer=False)
        dialog_id = dialog.get_id()

        title = 'Save a New View'

        dialog.add_title(title)

        div = DivWdg()
        dialog.add(div)
        div.add_style("padding: 5 5 5 20")
        div.add_color("background", "background")

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


        from tactic.ui.panel import ViewPanelSaveWdg
        save_wdg = ViewPanelSaveWdg(
            search_type=my.kwargs.get("search_type"),
            dialog_id=dialog_id,
            table_id=my.table_id
        )
        div.add(save_wdg)

        return dialog
コード例 #2
0
ファイル: gear_menu_wdg.py プロジェクト: mwx1993/TACTIC
    def get_save_wdg(my):

        from tactic.ui.container import DialogWdg
        dialog = DialogWdg(display=False,
                           width=200,
                           offset={
                               'x': 0,
                               'y': 50
                           },
                           show_pointer=False)
        dialog_id = dialog.get_id()

        title = 'Save a New View'

        dialog.add_title(title)

        div = DivWdg()
        dialog.add(div)
        div.add_style("padding: 5 5 5 20")
        div.add_color("background", "background")

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

        from tactic.ui.panel import ViewPanelSaveWdg
        save_wdg = ViewPanelSaveWdg(search_type=my.kwargs.get("search_type"),
                                    dialog_id=dialog_id,
                                    table_id=my.table_id)
        div.add(save_wdg)

        return dialog
コード例 #3
0
    def get_display(self):

        category = "FreeformWdg"

        search_type = self.get_value("search_type")
        if not search_type:
            search_type = "sthpw/login"

        view = self.get_value("view")
        if not view:
            view = 'freeform'

        search = Search("config/widget_config")
        search.add_filter("search_type", search_type)
        search.add_filter("view", view)
        config_sobj = search.get_sobject()
        if config_sobj:
            config_xml = config_sobj.get_value("config")
        else:
            config_xml = "<config/>"

        top = self.top
        self.set_as_panel(top)
        top.add_class("spt_freeform_top")

        inner = DivWdg()
        top.add(inner)

        table = ResizableTableWdg()
        table.add_color("background", "background")
        inner.add(table)
        table.add_row()
        table.set_max_width()

        td = table.add_cell()
        td.add_attr("colspan", "5")
        td.add_color("background", "background3")
        td.add_color("color", "color")
        td.add_style("padding", "10px")

        td.add("Search Type: ")
        select = SelectWdg("search_type")
        project = Project.get()
        search_types = project.get_search_types()
        values = [x.get_base_key() for x in search_types]
        labels = [
            "%s (%s)" % (x.get_title(), x.get_base_key()) for x in search_types
        ]
        select.set_option("values", values)
        select.set_option("labels", labels)
        if search_type:
            select.set_value(search_type)
        td.add(select)
        td.add("&nbsp;" * 10)
        td.add("View: ")
        text = TextWdg("view")
        td.add(text)
        if view:
            text.set_value(view)

        button = ActionButtonWdg(title="Load")
        button.add_style("float: left")
        td.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.app_busy.show("Loading View");
        var top = bvr.src_el.getParent(".spt_freeform_top");
        spt.panel.refresh(top);
        spt.app_busy.hide();
        '''
        })

        table.add_row()

        left = table.add_cell()
        left.add_style("vertical-align: top")
        left.add_border()
        left.add_color("color", "color")
        left.add_color("background", "background")
        left.add_style("min-width: 150px")

        left_div = DivWdg()
        left.add(left_div)
        left_div.add_style("min-height: 300px")
        left_div.add_style("min-width: 150px")
        left_div.add_style("width: 150px")

        title = DivWdg()
        left_div.add(title)
        title.add_style("font-weight: bold")
        title.add_style("font-size: 14px")
        title.add_style("width: 100%")
        title.add("Elements")
        title.add_gradient("background", "background", -5)
        title.add_style("padding: 10px 5px 5px 5px")
        title.add_style("height: 25px")
        title.add_style("margin-bottom: 10px")

        left.add_behavior({
            'type':
            'smart_click_up',
            'bvr_match_class':
            'SPT_ELEMENT_CLICK',
            'cbjs_action':
            r'''
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var template_top = top.getElement(".spt_freeform_template_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");

        var element_name = bvr.src_el.getAttribute("spt_element_name");

        var template_els = template_top.getElements(".spt_element");
        var els = canvas.getElements(".spt_element");

        // get the highest number
        var number = 0;
        for ( var i = 0; i < els.length; i++) {
            var el = els[i];
            var name = el.getAttribute("spt_element_name");
            var num = name.match(/(\d+)/);
            if (!num)
                continue;
            num = parseInt(num);
            if (num > number) {
                number = num;
            }
        }
        number = number + 1;

        for ( var i = 0; i < template_els.length; i++) {
            var el = template_els[i];
            if (el.getAttribute("spt_element_name") == element_name) {
                var clone = spt.behavior.clone(el);
                canvas.appendChild(clone);
                clone.setStyle("top", "30px");
                clone.setStyle("left", "30px");
                clone.setStyle("position", "absolute");
                var new_name = element_name + number;
                clone.setAttribute("spt_element_name", new_name)
                clone.attrs = {};

                var number = Math.floor(Math.random()*10001)
                clone.setAttribute("spt_element_id", "element"+number);

                spt.freeform.select(clone);


                break;
            }
        }
        '''
        })

        values = [
            'Label', 'Box', 'Text', 'TextArea', 'Button', 'Preview', 'Image',
            'HTML', 'Table', 'Border', 'Custom Layout'
        ]
        names = [
            'label', 'box', 'text', 'textarea', 'button', 'preview', 'image',
            'html', 'table', 'border', 'custom'
        ]
        icons = [IconWdg.VIEW]

        for name, value in zip(names, values):

            element_div = DivWdg()
            left_div.add(element_div)
            element_div.add_style("padding: 3px")
            element_div.add_class("SPT_DTS")
            element_div.add_class("hand")

            icon = IconWdg(name, IconWdg.VIEW)
            element_div.add(icon)

            element_div.add(value)
            element_div.add_class("SPT_ELEMENT_CLICK")
            element_div.add_attr("spt_element_name", name)
            element_div.add_style("padding-left: 10px")

            hover = element_div.get_color("background", -10)
            element_div.add_behavior({
                'type':
                'hover',
                'hover':
                hover,
                'cbjs_action_over':
                '''bvr.src_el.setStyle("background", bvr.hover)''',
                'cbjs_action_out':
                '''bvr.src_el.setStyle("background", "")'''
            })
            element_div.add_class("hand")

            element_div.add_behavior({
                'type':
                'drag',
                "drag_el":
                '@',
                "cb_set_prefix":
                'spt.freeform.create_element_drag'
            })
        """
        button = ActionButtonWdg(title="Save")
        left_div.add(button)
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");
        spt.freeform.init(canvas);
        var xml = spt.freeform.export();
        var search_type = canvas.getAttribute("spt_search_type");
        var view = canvas.getAttribute("spt_view");
        if (!search_type || !view) {
            alert("Cannot find search type or view");
            return;
        }

        var server = TacticServerStub.get();
        var sobject = server.get_unique_sobject("config/widget_config", {search_type: search_type, view: view} );
        server.update(sobject, {config: xml} );

        '''
        } )
        """

        from tactic.ui.container import DialogWdg
        dialog = DialogWdg(display=False, show_pointer=False)
        dialog.add_title("Properties")
        self.dialog_id = dialog.get_id()
        left.add(dialog)
        attr_div = self.get_attr_wdg()
        dialog.add(attr_div)

        template_div = DivWdg()
        left.add(template_div)
        template_div.add_class("spt_freeform_template_top")
        template_div.add_style("display: none")
        template_config_xml = self.get_template_config_xml()
        freeform_layout = FreeFormCanvasWdg(search_type=search_type,
                                            view="freeform",
                                            config_xml=template_config_xml,
                                            dialog_id=self.dialog_id)
        template_div.add(freeform_layout)

        # handle the canvas
        canvas = table.add_cell(resize=False)
        canvas.add(self.get_action_wdg())
        canvas.add_style("overflow: hidden")

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

        canvas_div = DivWdg()
        canvas_div.add_style("margin: 20px")
        canvas_div.add_style("width: 90%")
        canvas_div.add_style("min-width: 300px")
        canvas_div.add_style("padding: 10px")
        canvas_div.add_style("height: 100%")
        canvas_div.add_class("spt_freeform_canvas_top")
        canvas.add(canvas_div)
        freeform_layout = FreeFormCanvasWdg(search_type=search_type,
                                            view=view,
                                            config_xml=config_xml,
                                            dialog_id=self.dialog_id)
        canvas_div.add(freeform_layout)

        table.add_resize_row()

        if self.kwargs.get("is_refresh") in [True, "true"]:
            return inner
        else:
            return top
コード例 #4
0
    def get_display(my):

        category = "FreeformWdg"

        search_type = my.get_value("search_type")
        if not search_type:
            search_type = "sthpw/login"

        view = my.get_value("view")
        if not view:
            view = "freeform"

        search = Search("config/widget_config")
        search.add_filter("search_type", search_type)
        search.add_filter("view", view)
        config_sobj = search.get_sobject()
        if config_sobj:
            config_xml = config_sobj.get_value("config")
        else:
            config_xml = "<config/>"

        top = my.top
        my.set_as_panel(top)
        top.add_class("spt_freeform_top")

        inner = DivWdg()
        top.add(inner)

        table = ResizableTableWdg()
        table.add_color("background", "background")
        inner.add(table)
        table.add_row()
        table.set_max_width()

        td = table.add_cell()
        td.add_attr("colspan", "5")
        td.add_color("background", "background3")
        td.add_color("color", "color")
        td.add_style("padding", "10px")

        td.add("Search Type: ")
        select = SelectWdg("search_type")
        project = Project.get()
        search_types = project.get_search_types()
        values = [x.get_base_key() for x in search_types]
        labels = ["%s (%s)" % (x.get_title(), x.get_base_key()) for x in search_types]
        select.set_option("values", values)
        select.set_option("labels", labels)
        if search_type:
            select.set_value(search_type)
        td.add(select)
        td.add("&nbsp;" * 10)
        td.add("View: ")
        text = TextWdg("view")
        td.add(text)
        if view:
            text.set_value(view)

        button = ActionButtonWdg(title="Load")
        button.add_style("float: left")
        td.add(button)
        button.add_behavior(
            {
                "type": "click_up",
                "cbjs_action": """
        spt.app_busy.show("Loading View");
        var top = bvr.src_el.getParent(".spt_freeform_top");
        spt.panel.refresh(top);
        spt.app_busy.hide();
        """,
            }
        )

        table.add_row()

        left = table.add_cell()
        left.add_style("vertical-align: top")
        left.add_border()
        left.add_color("color", "color")
        left.add_color("background", "background")
        left.add_style("min-width: 150px")

        left_div = DivWdg()
        left.add(left_div)
        left_div.add_style("min-height: 300px")
        left_div.add_style("min-width: 150px")
        left_div.add_style("width: 150px")

        title = DivWdg()
        left_div.add(title)
        title.add_style("font-weight: bold")
        title.add_style("font-size: 14px")
        title.add_style("width: 100%")
        title.add("Elements")
        title.add_gradient("background", "background", -5)
        title.add_style("padding: 10px 5px 5px 5px")
        title.add_style("height: 25px")
        title.add_style("margin-bottom: 10px")

        left.add_behavior(
            {
                "type": "smart_click_up",
                "bvr_match_class": "SPT_ELEMENT_CLICK",
                "cbjs_action": r"""
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var template_top = top.getElement(".spt_freeform_template_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");

        var element_name = bvr.src_el.getAttribute("spt_element_name");

        var template_els = template_top.getElements(".spt_element");
        var els = canvas.getElements(".spt_element");

        // get the highest number
        var number = 0;
        for ( var i = 0; i < els.length; i++) {
            var el = els[i];
            var name = el.getAttribute("spt_element_name");
            var num = name.match(/(\d+)/);
            if (!num)
                continue;
            num = parseInt(num);
            if (num > number) {
                number = num;
            }
        }
        number = number + 1;

        for ( var i = 0; i < template_els.length; i++) {
            var el = template_els[i];
            if (el.getAttribute("spt_element_name") == element_name) {
                var clone = spt.behavior.clone(el);
                canvas.appendChild(clone);
                clone.setStyle("top", "30px");
                clone.setStyle("left", "30px");
                clone.setStyle("position", "absolute");
                var new_name = element_name + number;
                clone.setAttribute("spt_element_name", new_name)
                clone.attrs = {};

                var number = Math.floor(Math.random()*10001)
                clone.setAttribute("spt_element_id", "element"+number);

                spt.freeform.select(clone);


                break;
            }
        }
        """,
            }
        )

        values = [
            "Label",
            "Box",
            "Text",
            "TextArea",
            "Button",
            "Preview",
            "Image",
            "HTML",
            "Table",
            "Border",
            "Custom Layout",
        ]
        names = ["label", "box", "text", "textarea", "button", "preview", "image", "html", "table", "border", "custom"]
        icons = [IconWdg.VIEW]

        for name, value in zip(names, values):

            element_div = DivWdg()
            left_div.add(element_div)
            element_div.add_style("padding: 3px")
            element_div.add_class("SPT_DTS")
            element_div.add_class("hand")

            icon = IconWdg(name, IconWdg.VIEW)
            element_div.add(icon)

            element_div.add(value)
            element_div.add_class("SPT_ELEMENT_CLICK")
            element_div.add_attr("spt_element_name", name)
            element_div.add_style("padding-left: 10px")

            hover = element_div.get_color("background", -10)
            element_div.add_behavior(
                {
                    "type": "hover",
                    "hover": hover,
                    "cbjs_action_over": """bvr.src_el.setStyle("background", bvr.hover)""",
                    "cbjs_action_out": """bvr.src_el.setStyle("background", "")""",
                }
            )
            element_div.add_class("hand")

            element_div.add_behavior(
                {"type": "drag", "drag_el": "@", "cb_set_prefix": "spt.freeform.create_element_drag"}
            )

        """
        button = ActionButtonWdg(title="Save")
        left_div.add(button)
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_freeform_top");
        var canvas_top = top.getElement(".spt_freeform_canvas_top");
        var canvas = canvas_top.getElement(".spt_freeform_canvas");
        spt.freeform.init(canvas);
        var xml = spt.freeform.export();
        var search_type = canvas.getAttribute("spt_search_type");
        var view = canvas.getAttribute("spt_view");
        if (!search_type || !view) {
            alert("Cannot find search type or view");
            return;
        }

        var server = TacticServerStub.get();
        var sobject = server.get_unique_sobject("config/widget_config", {search_type: search_type, view: view} );
        server.update(sobject, {config: xml} );

        '''
        } )
        """

        from tactic.ui.container import DialogWdg

        dialog = DialogWdg(display=False, show_pointer=False)
        dialog.add_title("Properties")
        my.dialog_id = dialog.get_id()
        left.add(dialog)
        attr_div = my.get_attr_wdg()
        dialog.add(attr_div)

        template_div = DivWdg()
        left.add(template_div)
        template_div.add_class("spt_freeform_template_top")
        template_div.add_style("display: none")
        template_config_xml = my.get_template_config_xml()
        freeform_layout = FreeFormCanvasWdg(
            search_type=search_type, view="freeform", config_xml=template_config_xml, dialog_id=my.dialog_id
        )
        template_div.add(freeform_layout)

        # handle the canvas
        canvas = table.add_cell(resize=False)
        canvas.add(my.get_action_wdg())
        canvas.add_style("overflow: hidden")

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

        canvas_div = DivWdg()
        canvas_div.add_style("margin: 20px")
        canvas_div.add_style("width: 90%")
        canvas_div.add_style("min-width: 300px")
        canvas_div.add_style("padding: 10px")
        canvas_div.add_style("height: 100%")
        canvas_div.add_class("spt_freeform_canvas_top")
        canvas.add(canvas_div)
        freeform_layout = FreeFormCanvasWdg(
            search_type=search_type, view=view, config_xml=config_xml, dialog_id=my.dialog_id
        )
        canvas_div.add(freeform_layout)

        table.add_resize_row()

        if my.kwargs.get("is_refresh") in [True, "true"]:
            return inner
        else:
            return top