Esempio n. 1
0
    def get_display(self):
        #self.init()
        item_table = Table(css='minimal')
        item_table.add_style('margin-left', '30px')

        for item in self.items:
            item_table.add_row()
            space_td = item_table.add_blank_cell()

            item_td = item_table.add_cell(item.get_description())
            item_td.set_attr("nowrap", "1")

            delete = IconSubmitWdg("Remove from group", \
                IconWdg.DELETE, add_hidden=False)
            delete.add_event("onclick","document.form.remove_cmd.value=\
                '%s|%s';document.form.submit();" \
                % (self.group.get_primary_key_value(), item.get_primary_key_value()) )
            del_span = SpanWdg(css='med')
            del_span.add(delete)
            item_table.add_cell(del_span)
        if not self.items:
            item_table.add_blank_cell()

        self.add(item_table)
        return super(ItemInContainerWdg, self).get_display()
Esempio n. 2
0
 def get_display(my): 
     #my.init()
     item_table = Table(css='minimal')
     item_table.add_style('margin-left','30px')
    
     for item in my.items:
         item_table.add_row()
         space_td = item_table.add_blank_cell()
         
         item_td = item_table.add_cell(item.get_description())
         item_td.set_attr("nowrap", "1")
         
         delete = IconSubmitWdg("Remove from group", \
             "stock_stop-16.png",add_hidden=False)
         delete.add_event("onclick","document.form.remove_cmd.value=\
             '%s|%s';document.form.submit();" \
             % (my.group.get_primary_key_value(), item.get_primary_key_value()) )
         del_span = SpanWdg(css='med')
         del_span.add(delete)
         item_table.add_cell(del_span)
     if not my.items:
         item_table.add_blank_cell()
    
     my.add(item_table)
     return super(ItemInContainerWdg, my).get_display()
Esempio n. 3
0
    def get_action_wdg(my):

        main_div = DivWdg(css="filter_box center_content")
        div = DivWdg()
        div.add_style('height', '16px')
        div.add_style('margin', '3px 0 3px 0')

        main_div.add(my.get_view_select())

        main_div.add(div)
        div.add(HtmlElement.b("Action: "))
        add_button = IconSubmitWdg("Add to Shot", IconWdg.ADD, long=True)
        div.add(add_button)
        remove_button = IconSubmitWdg("Retire from %s" %
                                      TaskRetireCbk.CONTAINER_NAME,
                                      IconWdg.DELETE,
                                      long=True)
        div.add(remove_button)

        WebContainer.register_cmd("pyasm.prod.web.TaskPlannerCbk")
        WebContainer.register_cmd("pyasm.prod.web.TaskRetireCbk")

        #FIXME: hardcode to shot for now
        search_type = 'prod/shot'
        WebState.get().add_state("ref_search_type", search_type)
        return main_div
Esempio n. 4
0
    def get_action_wdg(self):

        main_div = DivWdg(css="filter_box center_content")
        div = DivWdg()
        main_div.add(div)
        div.add_style('height', '16px')
        div.add_style('margin', '3px 0 3px 0')
        div.add(HtmlElement.b("Action: "))
        add_button = IconSubmitWdg("Add to Parent", IconWdg.ADD, long=True)
        div.add(add_button)
        remove_button = IconSubmitWdg("Remove Parent", IconWdg.DELETE, long=True)
        div.add(remove_button)

        WebContainer.register_cmd("pyasm.prod.web.ShotParentCbk")

        return main_div
Esempio n. 5
0
    def get_action_wdg(my):

        main_div = DivWdg(css="filter_box center_content")
        div = DivWdg()
        main_div.add(my.get_view_select())
        main_div.add(div)
        div.add_style('height', '16px')
        div.add_style('margin', '3px 0 3px 0')

        div.add(HtmlElement.b("Action: "))
        add_button = IconSubmitWdg(my.ADD_BUTTON, IconWdg.ADD, long=True)
        div.add(add_button)
        remove_button = IconSubmitWdg("Remove from %s" % my.CONTAINER_NAME,\
            IconWdg.DELETE, long=True)
        div.add(remove_button)
        for cbk in my.get_action_cbk():
            WebContainer.register_cmd(cbk)

        return main_div
Esempio n. 6
0
    def get_new_tab_wdg(my):
        widget = Widget()

        span = SpanWdg()
        swap = SwapDisplayWdg.get_triangle_wdg()
        title = SpanWdg("Tab Creation")
        span.add(swap)
        span.add(title)
        span.add_style("float: left")
        widget.add(span)
        widget.add(HtmlElement.br())

        # add the tab selector
        div = DivWdg()
        SwapDisplayWdg.create_swap_title(title, swap, div)

        tab_text = TextWdg("tab")
        tab_text.set_persistence()
        span = SpanWdg(css="med")
        span.add("Tab: ")
        span.add(tab_text)
        div.add(span)

        # parent
        index_text = TextWdg("parent_tab")
        index_text.set_persistence()
        span = SpanWdg(css="med")
        span.add("Parent Tab: ")
        span.add(index_text)
        span.add(
            HintWdg(
                "Enter the name of the tab that this will fall under. Leave empty to put on the main tab"
            ))
        div.add(span)

        # index
        index_text = TextWdg("index")
        index_text.set_attr("size", "4")
        index_text.set_persistence()
        span = SpanWdg(css="med")
        span.add("Index: ")
        span.add(index_text)
        span.add(
            HintWdg("Enter the numeric location for this tab to be placed"))
        div.add(span)

        WebContainer.register_cmd("CreateTabCmd")
        button = IconSubmitWdg("Create Tab", IconWdg.CREATE, True)
        div.add(button)

        widget.add(div)

        return widget
Esempio n. 7
0
    def get_title(my):
        widget = Widget()
        '''
        search_key_wdg = HiddenWdg('search_key')
        search_key_wdg.get_value()
        widget.add(search_key_wdg)
        '''
        WebContainer.register_cmd("pyasm.flash.widget.RenderCbk")
        if not my.get_option("no_button"):   
            render_button = IconSubmitWdg("Render", IconWdg.RENDER, True, \
            add_hidden=True)
           
            widget.add(render_button)
        else:
            widget.add("Frame Info")

        float_button = IconSubmitWdg("Render", IconWdg.RENDER, add_hidden=False)
        span = SpanWdg(float_button, css='med')
        span.add_style("border-left", "1px solid #777")
        WebContainer.get_float_menu().add(span)
        return widget
Esempio n. 8
0
    def get_action_wdg(my):

        main_div = DivWdg(css="filter_box center_content")
        div = DivWdg()
        div.add_style('height', '16px')
        div.add_style('margin', '3px 0 3px 0')

        main_div.add(my.get_view_select())
        main_div.add(div)

        div.add(HtmlElement.b("Action: "))
        add_button = IconSubmitWdg(my.ADD_BUTTON, IconWdg.ADD, long=True)
        div.add(add_button)
        #remove_button = IconSubmitWdg("Remove from Sequence", IconWdg.DELETE, long=True)
        #div.add(remove_button)

        WebContainer.register_cmd("pyasm.prod.web.SequencePlannerCbk")

        return main_div
Esempio n. 9
0
    def init(my):
        
 
        my.item_cls = my.kwargs.get('left_search_type')
        my.container_cls = my.kwargs.get('right_search_type')
        my.grouping_cls  = my.kwargs.get('search_type')

        my.item_sobj = my.container_sobj = None 
        
        # List the items
        search = Search(my.item_cls)
        my._order_search(search)    
        
        items = search.get_sobjects()
        if items:
            my.item_sobj = items[0]
        #select = MultiSelectWdg("item_ids")
        #select.set_search_for_options(search,"login", "get_full_name()")

        user_span = SpanWdg(css='med')
        
        user_table = Table(css='table')
        user_table.add_style("margin-left: 6px")
        user_table.set_max_width()
        user_table.add_col(css='small')
        user_table.add_col()
        
        user_table.add_style("min-width: 14em")
        user_table.add_row_cell(search.get_search_type_obj()\
            .get_description(), "heading")

        for item in items:
            user_table.add_row()
            checkbox = CheckboxWdg("item_ids")
            checkbox.set_option("value", item.get_primary_key_value() )
            user_table.add_cell( checkbox )

            project_code = item.get_value("project_code", no_exception=True)
            if project_code:
                user_table.add_cell( "[ %s ]" % project_code )
            else:
                user_table.add_cell( "[ * ]" )

            user_table.add_cell( item.get_description() )
        user_span.add(user_table)

        # control widget in the middle
        control_div = DivWdg()
        control_div.add_style('padding: 100px 10px 0 10px')

        button = IconSubmitWdg(my.ADD_LABEL, "stock_insert-slide.png", True)
        button.add_style('padding: 2px 30px 4px 30px')
        control_div.add(button)
        
        
        main_table = Table(css='collapse')
        main_table.set_max_width()
        main_table.add_row(css='plain_bg')
        main_table.add_cell(user_span, 'valign_top')
        td = main_table.add_cell(control_div, 'valign_top')
        td.add_style('width','12em')
        main_table.add_cell(my._get_target_span(), 'valign_top')

        my.add(main_table)
    
        # register command here
        if my.item_sobj and my.container_sobj:
            marshaller = WebContainer.register_cmd("pyasm.widget.SObjectGroupCmd")
            marshaller.set_option("grouping_search_type", my.grouping_cls)
            marshaller.set_option("item_foreign_key", my.item_sobj.get_foreign_key())
            marshaller.set_option("container_foreign_key", my.container_sobj.get_foreign_key())
Esempio n. 10
0
 def get_title(self):
     WebContainer.register_cmd("pyasm.prod.web.SObjectRenderCbk")
     render_button = IconSubmitWdg("Render", IconWdg.RENDER, False)
     return render_button
Esempio n. 11
0
    def get_upload_wdg(self):
        widget = Widget()

        # get the search type
        widget.add("1. Select type of asset: ")

        # handle new search_types
        new_search_type = CheckboxWdg("new_search_type_checkbox")
        new_search_type.add_event("onclick",
                                  "toggle_display('new_search_type_div')")
        #span = SpanWdg(css="med")
        #span.add(new_search_type)
        #span.add("Create new type")
        #span.add(" ... or ... ")
        #widget.add(span)

        new_search_type_div = DivWdg()
        new_search_type_div.set_id("new_search_type_div")

        name_input = TextWdg("asset_name")
        title = TextWdg("asset_title")
        description = TextAreaWdg("asset_description")

        table = Table()
        table.add_style("margin: 10px 20px")
        table.add_col().set_attr('width', '140')
        table.add_col().set_attr('width', '400')

        table.add_row()
        table.add_header("Search Type: ").set_attr('align', 'left')
        table.add_cell(name_input)
        table.add_row()
        table.add_header("Title: ").set_attr('align', 'left')
        table.add_cell(title)
        table.add_row()
        table.add_header("Description: ").set_attr('align', 'left')
        table.add_cell(description)
        new_search_type_div.add(table)
        new_search_type_div.add_style("display: none")
        #widget.add(new_search_type_div)

        # or use a pre-existing one
        search_type_select = SearchTypeSelectWdg("filter|search_type")
        search_type_select.add_empty_option("-- Select --")
        search_type_select.set_persist_on_submit()
        search_type_select.set_submit_onchange()
        widget.add(search_type_select)

        self.search_type = search_type_select.get_value()
        if self.search_type:
            sobj = SObjectFactory.create(self.search_type)
            required_columns = sobj.get_required_columns()

            widget.add(SpanWdg("Required Columns: ", css='med'))
            if not required_columns:
                required_columns = ['n/a']
            widget.add(SpanWdg(', '.join(required_columns), css='med'))

        widget.add(HtmlElement.br(2))
        widget.add("2. Upload a csv file: ")
        upload_wdg = HtmlElement.upload("uploaded_file")
        widget.add(upload_wdg)
        submit = IconSubmitWdg("Upload", IconWdg.UPLOAD, True)
        widget.add(submit)

        web = WebContainer.get_web()
        field_storage = web.get_form_value("uploaded_file")
        if field_storage != "":
            upload = FileUpload()
            upload.set_field_storage(field_storage)
            upload.set_create_icon(False)
            upload.execute()

            files = upload.get_files()
            if files:
                self.file_path = files[0]
            else:
                self.file_path = web.get_form_value("file_path")

        if self.file_path:
            hidden = HiddenWdg("file_path", self.file_path)
            widget.add(hidden)

        return widget
Esempio n. 12
0
    def get_preview_wdg(self):

        widget = Widget()

        web = WebContainer.get_web()

        csv_parser = CsvParser(self.file_path)
        csv_parser.parse()
        csv_titles = csv_parser.get_titles()
        csv_data = csv_parser.get_data()

        ajax = AjaxCmd()
        ajax.set_option("search_type", self.search_type)
        ajax.set_option("file_path", self.file_path)
        ajax.add_element_name("has_title")

        event = WebContainer.get_event_container()
        caller = event.get_event_caller(SiteMenuWdg.EVENT_ID)
        div = ajax.generate_div()
        div.set_post_ajax_script(caller)
        widget.add(div)

        columns = []
        num_columns = len(csv_titles)
        ajax.set_option("num_columns", num_columns)
        for i in range(0, num_columns):
            column = web.get_form_value("column_%s" % i)
            if column:
                column = csv_titles[i]
            else:
                column = web.get_form_value("column_new_%s" % i)

            columns.append(column)

            ajax.add_element_name("column_%s" % i)
            ajax.add_element_name("new_column_%s" % i)

        ajax.register_cmd("pyasm.command.csv_import_cmd.CsvImportCmd")
        import_button = IconButtonWdg("Import", IconWdg.REFRESH, True)
        import_button.add_event("onclick",
                                ajax.get_on_script(show_progress=False))
        import_button.add_style("float: right")
        widget.add(import_button)

        preview_submit = IconSubmitWdg("Preview", IconWdg.REFRESH, True)
        preview_submit.add_style("float: right")
        widget.add(preview_submit)

        sobject_title = self.search_type_obj.get_title()
        widget.add("<p>4. Import</p>")
        widget.add(HtmlElement.br())
        widget.add(
            "<p>The following table will be imported into %s (Showing Max: 100)</p>"
            % sobject_title)

        table = Table(css="table")
        table.add_style("width: 100%")

        table.add_row()
        for i, title in enumerate(columns):
            if not title:
                title = "<b style='color:red'>*</b>"
            table.add_header(title)

        for i, row in enumerate(csv_data):
            if i > 100:
                break
            table.add_row()
            for j, cell in enumerate(row):
                table.add_cell(cell)

        widget.add(table)

        return widget
Esempio n. 13
0
    def init(self):

        # List the items
        search = Search(self.item_cls.SEARCH_TYPE)
        self._order_search(search)

        items = search.get_sobjects()
        if items:
            self.item_sobj = items[0]
        #select = MultiSelectWdg("item_ids")
        #select.set_search_for_options(search,"login", "get_full_name()")

        user_span = SpanWdg(css='med')

        user_table = Table(css='table')
        user_table.add_style("margin-left: 6px")
        user_table.set_max_width()
        user_table.add_col(css='small')
        user_table.add_col()

        user_table.add_style("min-width: 14em")
        user_table.add_row_cell(search.get_search_type_obj()\
            .get_description(), "heading")

        for item in items:
            user_table.add_row()
            checkbox = CheckboxWdg("item_ids")
            checkbox.set_option("value", item.get_primary_key_value())
            user_table.add_cell(checkbox)

            project_code = item.get_value("project_code", no_exception=True)
            if project_code:
                user_table.add_cell("[ %s ]" % project_code)
            else:
                user_table.add_cell("[ * ]")

            user_table.add_cell(item.get_description())
        user_span.add(user_table)

        # control widget in the middle
        control_div = DivWdg()
        control_div.add_style('padding: 100px 10px 0 10px')

        button = IconSubmitWdg(self.ADD_LABEL, IconWdg.INSERT, True)
        button.add_style('padding: 2px 30px 4px 30px')
        control_div.add(button)

        main_table = Table(css='collapse')
        main_table.set_max_width()
        main_table.add_row(css='plain_bg')
        main_table.add_cell(user_span, 'valign_top')
        td = main_table.add_cell(control_div, 'valign_top')
        td.add_style('width', '12em')
        main_table.add_cell(self._get_target_span(), 'valign_top')

        self.add(main_table)

        # register command here
        if self.item_sobj and self.container_sobj:
            marshaller = WebContainer.register_cmd(
                "pyasm.widget.SObjectGroupCmd")
            marshaller.set_option("grouping_search_type",
                                  self.grouping_cls.SEARCH_TYPE)
            marshaller.set_option("item_foreign_key",
                                  self.item_sobj.get_foreign_key())
            marshaller.set_option("container_foreign_key",
                                  self.container_sobj.get_foreign_key())
Esempio n. 14
0
    def get_display(my):
        if not my.search_type:
            return "No search type found"

        web = WebContainer.get_web()
        my.view = web.get_form_value("view")
        if not my.view:
            my.view = web.get_form_value("filter|view")
        if not my.view:
            my.view = get_template_view()

        widget = Widget()

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

        element_names = []

        # see if there is an override
        search_type_obj = SearchType.get(my.search_type)  
        config = WidgetConfig.get_by_search_type(my.search_type,"browser_list")
        if config:
            element_names = config.get_element_names()


        search = Search("sthpw/widget_config")
        search.add_filter("search_type", my.search_type)
        search.add_filter("view", my.view)
        widget_config = search.get_sobject()
        if widget_config:
            edit_link_wdg = EditLinkWdg("sthpw/widget_config", widget_config.get_id(), text="Edit XML", long=True)
            edit_link_wdg.set_iframe_width(95)
            widget.add(edit_link_wdg)


        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 = PopupMenuWdg("table_action", multi=True, width='12em')
        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 )

        # if there is an override
        if element_names:
            for element_name in element_names:
                if element_name not in custom_element_names:
                    action_popup.add( " %s" % element_name, "add|%s" % element_name )


        # get all of the columns
        else:
            search_type_obj = SearchType.get(my.search_type)
            element_names = search_type_obj.get_columns()

            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 )


        # add the edit button
        edit = IconButtonWdg("Edit View", IconWdg.EDIT, True)

        edit.add_event("oncontextmenu", "%s;return false" % action_popup.get_on_script() )
        edit.add_event("onclick", "%s" % action_popup.get_on_script() )



        # lay it all out
        widget.add(SpanWdg(action_popup))
        widget.add(edit)

        # add the edit button
        #save = IconButtonWdg("Save", IconWdg.SAVE, True)
        #widget.add(save)

        # add the add property button
        if my.mode == "admin":
            add = CustomAddPropertyLinkWdg(my.search_type, my.view)
            widget.add(add)
            #add_element = CustomAddElementLinkWdg(my.search_type, my.view)
            #widget.add(add_element)


        # add the clear button
        if my.mode == "admin" or my.view.startswith("custom_"):
            clear = IconSubmitWdg("Clear", IconWdg.DELETE, True)
            widget.add(clear)

        
        widget.add(SpanWdg(css="small"))


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

        return widget
Esempio n. 15
0
    def get_preview_wdg(my):

        widget = Widget()

        web = WebContainer.get_web()

        csv_parser = CsvParser(my.file_path)
        csv_parser.parse()
        csv_titles = csv_parser.get_titles()
        csv_data = csv_parser.get_data()



        ajax = AjaxCmd()
        ajax.set_option("search_type", my.search_type)
        ajax.set_option("file_path", my.file_path)
        ajax.add_element_name("has_title")

        event = WebContainer.get_event_container()
        caller = event.get_event_caller(SiteMenuWdg.EVENT_ID)
        div = ajax.generate_div()
        div.set_post_ajax_script(caller)
        widget.add(div)

        columns = []
        num_columns = len(csv_titles)
        ajax.set_option("num_columns", num_columns)
        for i in range(0, num_columns):
            column = web.get_form_value("column_%s" % i)
            if column:
                column = csv_titles[i]
            else:
                column = web.get_form_value("column_new_%s" % i)

            columns.append(column)

            ajax.add_element_name("column_%s" % i)
            ajax.add_element_name("new_column_%s" % i)


        ajax.register_cmd("pyasm.command.csv_import_cmd.CsvImportCmd")
        import_button = IconButtonWdg("Import", IconWdg.REFRESH, True)
        import_button.add_event("onclick", ajax.get_on_script(show_progress=False))
        import_button.add_style("float: right")
        widget.add( import_button )


        preview_submit = IconSubmitWdg("Preview", IconWdg.REFRESH, True)
        preview_submit.add_style("float: right")
        widget.add(preview_submit)

        sobject_title = my.search_type_obj.get_title()
        widget.add("<p>4. Import</p>")
        widget.add(HtmlElement.br())
        widget.add("<p>The following table will be imported into %s (Showing Max: 100)</p>" % sobject_title)


        table = Table(css="table")
        table.add_style("width: 100%")

        table.add_row()
        for i, title in enumerate(columns):
            if not title:
                title = "<b style='color:red'>*</b>"
            table.add_header(title)

        for i, row in enumerate(csv_data):
            if i > 100:
                break
            table.add_row()
            for j, cell in enumerate(row):
                table.add_cell(cell)

        widget.add(table)

        return widget