Пример #1
0
    def get_display(my):
        widget = Widget()
        
        thumb = super(ThumbPublishWdg, my).get_display()

        widget.add(thumb)
        sobject = my.get_current_sobject()
        search_type = sobject.get_search_type()
        search_id = sobject.get_id()

        publish_link = PublishLinkWdg(search_type,search_id) 
        div = DivWdg(publish_link)
        div.set_style('clear: left; padding-top: 6px')
        widget.add(div)

        # build an iframe to show publish browsing
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        iframe = WebContainer.get_iframe()
        iframe.set_width(100)

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
        url.set_option("search_type", search_type)
        url.set_option("search_id", search_id)
        script = iframe.get_on_script(url.to_string())
        browse_link.add_event("onclick", script)

        div.add(browse_link)
        div.set_style('padding-top: 6px')


        return widget
Пример #2
0
    def get_display(my):
        widget = Widget()

        thumb = super(ThumbPublishWdg, my).get_display()

        widget.add(thumb)
        sobject = my.get_current_sobject()
        search_type = sobject.get_search_type()
        search_id = sobject.get_id()

        publish_link = PublishLinkWdg(search_type, search_id)
        div = DivWdg(publish_link)
        div.set_style('clear: left; padding-top: 6px')
        widget.add(div)

        # build an iframe to show publish browsing
        browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS)
        iframe = WebContainer.get_iframe()
        iframe.set_width(100)

        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg")
        url.set_option("search_type", search_type)
        url.set_option("search_id", search_id)
        script = iframe.get_on_script(url.to_string())
        browse_link.add_event("onclick", script)

        div.add(browse_link)
        div.set_style('padding-top: 6px')

        return widget
Пример #3
0
    def get_display(self):
        # set up the self refresh event for other widgets or callbacks to call
        event_container = WebContainer.get_event_container()
        script = ClipboardWdg.get_self_refresh_script(show_progress=False)
        event_container.add_listener(self.EVENT_ID, script, replace=True )

        if self.is_from_ajax():
            div = Widget()
        else:
            div = DivWdg()
            div.set_id(self.ID)
            div.add_style("display: block")
            div.add_class("background_box")
            div.add_style("padding-left: 3px")
            div.add_style("padding-right: 3px")
            div.add_style("height: 1.5em")
            div.add_style("width: 150px")

        # handle the ajax
        self.set_ajax_top_id(self.ID)
        self.register_cmd(ClipboardClearCbk)
        refresh_script = self.get_refresh_script()

        search = Search("sthpw/clipboard")
        search.add_user_filter()
        search.add_filter("category", "select")
        count = search.get_count()

        div.add("Clipboard: %s items: " % count)


        web = WebContainer.get_web()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.ClipboardListWdg")
        ref = url.to_string()

        iframe = WebContainer.get_iframe()
        iframe.set_width(64)
        action = iframe.get_on_script(ref)
       
        button = IconButtonWdg("View Clipboard", IconWdg.LOAD)
        button.add_event("onclick", action)
        div.add(button)



        # add the clear clipboard icon
        clear_icon = IconButtonWdg("Clear Clipboard", IconWdg.CLEAR)
        clear_icon.add_event("onclick", refresh_script)

        div.add(clear_icon)

        return div
Пример #4
0
    def get_display(self):
        # set up the self refresh event for other widgets or callbacks to call
        event_container = WebContainer.get_event_container()
        script = ClipboardWdg.get_self_refresh_script(show_progress=False)
        event_container.add_listener(self.EVENT_ID, script, replace=True)

        if self.is_from_ajax():
            div = Widget()
        else:
            div = DivWdg()
            div.set_id(self.ID)
            div.add_style("display: block")
            div.add_class("background_box")
            div.add_style("padding-left: 3px")
            div.add_style("padding-right: 3px")
            div.add_style("height: 1.5em")
            div.add_style("width: 150px")

        # handle the ajax
        self.set_ajax_top_id(self.ID)
        self.register_cmd(ClipboardClearCbk)
        refresh_script = self.get_refresh_script()

        search = Search("sthpw/clipboard")
        search.add_user_filter()
        search.add_filter("category", "select")
        count = search.get_count()

        div.add("Clipboard: %s items: " % count)

        web = WebContainer.get_web()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.ClipboardListWdg")
        ref = url.to_string()

        iframe = WebContainer.get_iframe()
        iframe.set_width(64)
        action = iframe.get_on_script(ref)

        button = IconButtonWdg("View Clipboard", IconWdg.LOAD)
        button.add_event("onclick", action)
        div.add(button)

        # add the clear clipboard icon
        clear_icon = IconButtonWdg("Clear Clipboard", IconWdg.CLEAR)
        clear_icon.add_event("onclick", refresh_script)

        div.add(clear_icon)

        return div
Пример #5
0
    def get_popup_script(msg='', css='', icon='', ref=None, width=70):
        ''' returns a javascript that will trigger a popup message box in
            an iframe '''
        if not ref:
            url = WebContainer.get_web().get_widget_url()
            url.set_option("widget", "MessageWdg")
            url.set_option("args", [msg, css, icon])
            
            ref = url.get_url()

        # open iframe
        iframe = WebContainer.get_iframe()
        iframe.set_width(width)
        action = iframe.get_on_script(ref)
        return action    
Пример #6
0
    def get_popup_script(msg='', css='', icon='', ref=None, width=70):
        ''' returns a javascript that will trigger a popup message box in
            an iframe '''
        if not ref:
            url = WebContainer.get_web().get_widget_url()
            url.set_option("widget", "MessageWdg")
            url.set_option("args", [msg, css, icon])

            ref = url.get_url()

        # open iframe
        iframe = WebContainer.get_iframe()
        iframe.set_width(width)
        action = iframe.get_on_script(ref)
        return action
Пример #7
0
    def get_display(my):
        # add the add property button
        iframe = WebContainer.get_iframe()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.CustomAddPropertyWdg")
        url.set_option("search_type", my.search_type)
        url.set_option("view", my.view)
        action = iframe.get_on_script(url.to_string() )
        add = IconButtonWdg("Add Property", IconWdg.INSERT, True)

        add.add_event("oncontextmenu", "%s;return false" % action )
        add.add_event("onclick", "%s" % action )

        widget = Widget()
        widget.add(add)
        return widget
Пример #8
0
    def get_display(my):
        # add the add property button
        iframe = WebContainer.get_iframe()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.CustomAddPropertyWdg")
        url.set_option("search_type", my.search_type)
        url.set_option("view", my.view)
        action = iframe.get_on_script(url.to_string() )
        add = IconButtonWdg("Add Property", IconWdg.INSERT, True)

        add.add_event("oncontextmenu", "%s;return false" % action )
        add.add_event("onclick", "%s" % action )

        widget = Widget()
        widget.add(add)
        return widget
Пример #9
0
    def get_display(my):
        web = WebContainer.get_web()
        if not my.view:
            my.view = web.get_form_value("view")
        if not my.view:
            my.view = get_template_view()

        widget = Widget()
        widget.add( HiddenWdg("search_type", my.search_type) )

        # get a list of all of the element names possible
        search_type_obj = SearchType.get(my.search_type)  
        config = WidgetConfigView.get_by_search_type(my.search_type,DEFAULT_VIEW)
        if config:
            element_names = config.get_element_names()

        # FIXME: also get those from the default (not sure about this)
        config = WidgetConfigView.get_by_search_type(my.search_type,"default")
        if config:
            element_names.extend( config.get_element_names() )

        if not element_names:
            element_names = []


        # get the custom element names from config
        custom_config = WidgetConfigView.get_by_search_type(my.search_type,my.view)
        custom_element_names = custom_config.get_element_names()




        # get the custom properties
        search = Search("prod/custom_property")
        search.add_filter("search_type", my.search_type)
        custom_properties = search.get_sobjects()


        # action popup
        action_popup = my.action_popup
        action_popup.set_auto_hide(False)
        action_popup.set_submit(False)
        action_popup.add( HtmlElement.href("Add ...", "javascript:document.form.submit()") )


        for custom_property in custom_properties:
            element_name = custom_property.get_name()
            if element_name not in custom_element_names:
                action_popup.add( " %s" % element_name, "add|%s" % element_name )

        for element_name in element_names:
            if element_name not in custom_element_names:
                action_popup.add( " %s" % element_name, "add|%s" % element_name )

        # add some standard properties
        if my.view in ["edit", "insert"]:
            for element_name in PREDEFINED_EDIT_ELEMENTS:
                if element_name not in custom_element_names:
                    action_popup.add( " %s" % element_name, "add|%s" % element_name )
        else:
            for element_name in PREDEFINED_ELEMENTS:
                if element_name not in custom_element_names:
                    action_popup.add( " %s" % element_name, "add|%s" % element_name )

        action_popup.add_separator()
        action_popup.add( HtmlElement.href("Remove ...", "javascript:document.form.submit()") )
        for element_name in custom_element_names:
            action_popup.add( " %s" % element_name, "remove|%s" % element_name )
        action_popup.add_separator()

        span = SpanWdg("New Custom ...", css="hand")
        iframe = WebContainer.get_iframe()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.CustomAddPropertyWdg")
        url.set_option("search_type", my.search_type)
        url.set_option("view", my.view)
        action = iframe.get_on_script(url.to_string() )
        span.add_event("onclick", action)
        action_popup.add( span )

        WebContainer.register_cmd("pyasm.widget.CustomViewAction")

        widget.add(action_popup)
        return widget
Пример #10
0
    def get_display(my):
        web = WebContainer.get_web()
        if not my.view:
            my.view = web.get_form_value("view")
        if not my.view:
            my.view = get_template_view()

        widget = Widget()
        widget.add( HiddenWdg("search_type", my.search_type) )

        # get a list of all of the element names possible
        search_type_obj = SearchType.get(my.search_type)  
        config = WidgetConfigView.get_by_search_type(my.search_type,DEFAULT_VIEW)
        if config:
            element_names = config.get_element_names()

        # FIXME: also get those from the default (not sure about this)
        config = WidgetConfigView.get_by_search_type(my.search_type,"default")
        if config:
            element_names.extend( config.get_element_names() )

        if not element_names:
            element_names = []


        # get the custom element names from config
        custom_config = WidgetConfigView.get_by_search_type(my.search_type,my.view)
        custom_element_names = custom_config.get_element_names()




        # get the custom properties
        search = Search("prod/custom_property")
        search.add_filter("search_type", my.search_type)
        custom_properties = search.get_sobjects()


        # action popup
        action_popup = my.action_popup
        action_popup.set_auto_hide(False)
        action_popup.set_submit(False)
        action_popup.add( HtmlElement.href("Add ...", "javascript:document.form.submit()") )


        for custom_property in custom_properties:
            element_name = custom_property.get_name()
            if element_name not in custom_element_names:
                action_popup.add( " %s" % element_name, "add|%s" % element_name )

        for element_name in element_names:
            if element_name not in custom_element_names:
                action_popup.add( " %s" % element_name, "add|%s" % element_name )

        # add some standard properties
        if my.view in ["edit", "insert"]:
            for element_name in PREDEFINED_EDIT_ELEMENTS:
                if element_name not in custom_element_names:
                    action_popup.add( " %s" % element_name, "add|%s" % element_name )
        else:
            for element_name in PREDEFINED_ELEMENTS:
                if element_name not in custom_element_names:
                    action_popup.add( " %s" % element_name, "add|%s" % element_name )

        action_popup.add_separator()
        action_popup.add( HtmlElement.href("Remove ...", "javascript:document.form.submit()") )
        for element_name in custom_element_names:
            action_popup.add( " %s" % element_name, "remove|%s" % element_name )
        action_popup.add_separator()

        span = SpanWdg("New Custom ...", css="hand")
        iframe = WebContainer.get_iframe()
        url = WebContainer.get_web().get_widget_url()
        url.set_option("widget", "pyasm.widget.CustomAddPropertyWdg")
        url.set_option("search_type", my.search_type)
        url.set_option("view", my.view)
        action = iframe.get_on_script(url.to_string() )
        span.add_event("onclick", action)
        action_popup.add( span )

        WebContainer.register_cmd("pyasm.widget.CustomViewAction")

        widget.add(action_popup)
        return widget