Пример #1
0
    def get_display(my):

        widget = Widget()

        div = DivWdg(css="filter_box")

        show_span = SpanWdg(css="med")
        show_span.add("Show All Types: ")
        checkbox = FilterCheckboxWdg("show_all_types")
        checkbox.set_persistence()
        show_span.add(checkbox)
        show_all_types = checkbox.get_value()
        div.add(show_span)

        span = SpanWdg(css="med")
        span.add("Search Type: ")

        select = SelectWdg("filter|search_type")
        select.add_empty_option("-- Select --")
        project = Project.get()
        project_type = project.get_base_type()
        search = Search("sthpw/search_object")
        if show_all_types:
            search.add_where(
                """
            namespace = '%s' or namespace = '%s' or search_type in ('sthpw/task')
            """
                % (project_type, project.get_code())
            )
        else:
            # show only the custom ones
            search.add_filter("namespace", project.get_code())

        search.add_order_by("title")
        sobjects = search.get_sobjects()

        select.set_sobjects_for_options(sobjects, "search_type", "title")
        # select.set_option("query", "sthpw/search_object|search_type|title")
        select.set_persistence()
        select.add_event("onchange", "document.form.submit()")
        search_type = select.get_value()
        span.add(select)
        div.add(span)

        # make sure the current selection exists
        try:
            SearchType.get(search_type)
        except SearchException, e:
            return div
Пример #2
0
    def get_display(my):

        widget = Widget()

        div = DivWdg(css="filter_box")

        show_span = SpanWdg(css='med')
        show_span.add('Show All Types: ')
        checkbox = FilterCheckboxWdg('show_all_types')
        checkbox.set_persistence()
        show_span.add(checkbox)
        show_all_types = checkbox.get_value()
        div.add(show_span)

        span = SpanWdg(css="med")
        span.add("Search Type: ")

        select = SelectWdg("filter|search_type")
        select.add_empty_option("-- Select --")
        project = Project.get()
        project_type = project.get_base_type()
        search = Search("sthpw/search_object")
        if show_all_types:
            search.add_where('''
            namespace = '%s' or namespace = '%s' or search_type in ('sthpw/task')
            ''' % (project_type, project.get_code()))
        else:
            # show only the custom ones
            search.add_filter('namespace', project.get_code())

        search.add_order_by("title")
        sobjects = search.get_sobjects()

        select.set_sobjects_for_options(sobjects, "search_type", "title")
        #select.set_option("query", "sthpw/search_object|search_type|title")
        select.set_persistence()
        select.add_event("onchange", "document.form.submit()")
        search_type = select.get_value()
        span.add(select)
        div.add(span)

        # make sure the current selection exists
        try:
            SearchType.get(search_type)
        except SearchException, e:
            return div
Пример #3
0
        div.add(HtmlElement.br(2))

        div.add(my.get_new_tab_wdg())

        widget.add(div)

        search = Search("sthpw/widget_config")
        #search.add_user_filter()
        search.add_filter("search_type", search_type)
        search.add_where("view != 'definition' and view != 'custom'")
        #search.add_column("view")
        widget_configs = search.get_sobjects()
        if widget_configs:
            view_select.set_sobjects_for_options(widget_configs, "view",
                                                 "view")
        view = view_select.get_value()
        if not view:
            view = "custom"
            #return widget

        # get the selected widget config
        for widget_config in widget_configs:
            if widget_config.get_value("view") == view:
                break
        else:
            return widget

        # get the handler: a little HACKY.
        config_xml = widget_config.get_xml_value("config")
        handler = config_xml.get_value("config/%s/@handler" % view)
Пример #4
0
    def get_display(my):

        web = WebContainer.get_web()
        naming_util = NamingUtil()

        if not my.widget_name:
            my.widget_name = my.get_name()

        # get the sobject required by this input
        sobject = my.get_current_sobject()
        if not sobject:
            sobject = Search.get_by_id(my.search_type, my.search_id)

        if my.new_sample_name:
            my.new_sample_name.replace("//", "/")
        else:
            my.new_sample_name = sobject.get_value(my.widget_name)

        widget = DivWdg()
        widget.set_id("naming")
        widget.add_style("display: block")

        # set the sample text
        div = DivWdg()
        div.add("Sample name: <i>%s</i>" % my.new_sample_name)
        div.add(HtmlElement.br(2))

        new_sample_wdg = ProdIconButtonWdg("Set New Sample")
        new_sample_wdg.add_event("onclick", "toggle_display('generate')")
        div.add(new_sample_wdg)

        generate = DivWdg()
        generate.add(HtmlElement.br())
        generate.set_id("generate")
        generate.add_style("display: none")
        sample_text = TextWdg("new_sample_name")
        sample_text.set_option("size", "30")
        # sample_text.set_persist_on_submit()
        # if my.new_sample_name:
        #    sample_text.set_value(my.new_sample_name)
        generate.add(sample_text)

        button = IconButtonWdg("Generate", IconWdg.REFRESH, long=True)
        on_script = my.setup_ajax("naming")
        button.add_event("onclick", on_script)
        generate.add(button)
        generate.add(HtmlElement.br(2))

        div.add(generate)
        widget.add(div)

        hidden = TextWdg(my.widget_name)
        value = my.naming
        hidden.set_value(my.new_sample_name)
        widget.add(my.widget_name)
        widget.add(hidden)

        # get all of the parts

        # TODO: not sure if this should be dictated by the sample name
        # break up the name into parts
        import re

        if my.new_sample_name:
            tmp = my.new_sample_name.strip("/")
            parts = re.split("[\\/._]", tmp)
            print "parts: ", parts
        else:
            return widget

        # if there is a naming, then populate that
        if my.edit_search_type:
            options = naming_util.get_options(my.edit_search_type)
        else:
            options = naming_util.get_options(sobject.get_value("search_type"))

        table = Table()
        type_values = []
        padding_values = []
        for idx, part in enumerate(parts):
            table.add_row()
            table.add_cell(part)

            type_select = SelectWdg("type_%s" % idx)
            type_select.add_empty_option("-- Explicit --")
            type_select.set_persist_on_submit()
            type_select.set_option("values", "|".join(options))
            type_values.append(type_select.get_value())
            td = table.add_cell(type_select)

        widget.add(table)

        return widget
Пример #5
0
    def get_display(self):
        self.check()
        if self.is_refresh:
            div = Widget()
        else:
            div = DivWdg()
            self.set_as_panel(div)
            div.add_style('padding', '6px')
            min_width = '400px'
            div.add_style('min-width', min_width)
            div.add_color('background', 'background')
            div.add_class('spt_add_task_panel')
            div.add_style("padding: 20px")

        from tactic.ui.app import HelpButtonWdg
        help_button = HelpButtonWdg(alias="creating-tasks")
        div.add(help_button)
        help_button.add_style("float: right")
        help_button.add_style("margin-top: -5px")

        if not self.search_key_list:
            msg_div = DivWdg()
            msg_table = Table()
            msg_div.add(msg_table)
            msg_table.add_row()
            msg_table.add_cell(IconWdg("No items selected", IconWdg.WARNING))
            msg_table.add_cell(
                'Please select at least 1 item to add tasks to.')

            msg_div.add_style('margin: 10px')
            msg_table.add_style("font-weight: bold")
            div.add(msg_div)
            return div

        msg_div = DivWdg()
        msg_div.add_style('margin-left: 4px')
        div.add(msg_div, 'info')
        msg_div.add('Total: %s item/s to add tasks to' %
                    len(self.search_key_list))
        div.add(HtmlElement.br())
        hint = HintWdg('Tasks are added according to the assigned pipeline.')
        msg_div.add(" &nbsp; ")
        msg_div.add(hint)
        msg_div.add(HtmlElement.br())

        option_div = DivWdg(css='spt_ui_options')
        #option_div.add_style('margin-left: 12px')

        sel = SelectWdg('pipeline_mode', label='Create tasks by: ')
        sel.set_option('values', ['simple process', 'context', 'standard'])
        sel.set_option('labels',
                       ['process', 'context', 'all contexts in process'])
        sel.set_persistence()
        sel.add_behavior({
            'type': 'change',
            'cbjs_action': 'spt.panel.refresh(bvr.src_el)'
        })

        option_div.add(sel)

        value = sel.get_value()
        # default to simple process
        if not value:
            value = 'simple process'
        msg = ''
        if value not in ['simple process', 'context', 'standard']:
            value = 'simple process'

        if value == 'context':
            msg = 'In context mode, a single task will be created for each selected context.'
        elif value == 'simple process':
            msg = 'In process mode, a single task will be created for each selected process.'

        elif value == 'standard':
            msg = 'In this mode, a task will be created for all contexts of each selected process.'

        option_div.add(HintWdg(msg))
        div.add(option_div)
        div.add(HtmlElement.br())

        title = DivWdg('Assigned Pipelines')
        title.add_style('padding: 6px')
        title.add_color('background', 'background2')
        title.add_color('color', 'color', +120)
        div.add(title)

        content_div = DivWdg()
        content_div.add_style('min-height', '150px')
        div.add(content_div)
        content_div.add_border()

        filtered_search_key_list = []
        for sk in self.search_key_list:
            id = SearchKey.extract_id(sk)
            if id == '-1':
                continue
            filtered_search_key_list.append(sk)

        sobjects = SearchKey.get_by_search_keys(filtered_search_key_list)
        skipped = []
        pipeline_codes = []
        for sobject in sobjects:
            if isinstance(sobject, Task):
                msg_div = DivWdg(
                    'WARNING: Creation of task for [Task] is not allowed.')
                msg_div.add_style('margin-left: 10px')
                div.add(msg_div, 'info')
                return div
            pipeline_code = sobject.get_value('pipeline_code',
                                              no_exception=True)
            if not pipeline_code:
                skipped.append(sobject)
            if pipeline_code not in pipeline_codes:
                pipeline_codes.append(pipeline_code)

        pipelines = Search.get_by_code('sthpw/pipeline', pipeline_codes)
        if pipelines == None:
            pipelines = []
        #if not pipelines:
        #    msg_div = DivWdg('WARNING: No Pipelines found for selected.')
        #    msg_div.add_style('margin-left: 10px')
        #    div.add(msg_div, 'info')
        #    return div

        # expand the width according to num of pipelines
        content_div.add_style('min-width', len(pipelines) * 250)
        mode_cb = SelectWdg('pipeline_mode')
        mode_cb.set_persistence()
        mode = mode_cb.get_value()
        if 'context' == mode:
            mode = 'context'
        else:
            mode = 'process'

        show_subpipeline = True
        min_height = '150px'

        # create a temp default pipeline
        if not pipelines:
            pipeline = SearchType.create("sthpw/pipeline")
            pipeline.set_value("code", "__default__")
            pipeline.set_value(
                "pipeline", '''
<pipeline>
    <process name='publish'/>
</pipeline>
            ''')
            # FIXME: HACK to initialize virtual pipeline
            pipeline.set_pipeline(pipeline.get_value("pipeline"))
            pipelines = [pipeline]

        for pipeline in pipelines:
            name = pipeline.get_value("name")
            if not name:
                name = pipeline.get_code()
            span = SpanWdg("Pipeline: %s" % name)
            span.add_style('font-weight: bold')
            v_div = FloatDivWdg(span)
            v_div.add_style('margin: 20px')
            v_div.add_style('min-height', min_height)
            v_div.add(HtmlElement.br(2))
            content_div.add(v_div)
            processes = pipeline.get_processes(recurse=show_subpipeline,
                                               type=['manual', 'approval'])

            cb_name = '%s|task_process' % pipeline.get_code()
            master_cb = CheckboxWdg('master_control')
            master_cb.set_checked()
            master_cb.add_behavior({
                'type':
                'click_up',
                'propagate_evt':
                True,
                'cbjs_action':
                '''
                    var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_add_task_panel'),'%s');
                    for (var i = 0; i < inputs.length; i++)
                        inputs[i].checked = bvr.src_el.checked;
                        ''' % cb_name
            })
            toggle_div = DivWdg()
            toggle_div.add(SpanWdg(master_cb, css='small'))
            label = HtmlElement.i('toggle all')
            label.add_style('color: #888')
            toggle_div.add_styles(
                'border-bottom: 1px solid #888; width: 170px')
            toggle_div.add(label)
            v_div.add(toggle_div)
            process_names = []

            for process in processes:
                process_labels = []
                if process.is_from_sub_pipeline():
                    process_name = process.get_full_name()
                else:
                    process_name = process.get_name()

                process_label = process.get_label()
                if not process_label:
                    process_label = ''
                if mode == 'context':
                    contexts = pipeline.get_output_contexts(process.get_name())

                    labels = contexts
                    if process.is_from_sub_pipeline():
                        labels = [
                            '%s/%s' % (process.parent_pipeline_code, x)
                            for x in contexts
                        ]

                    for x in labels:
                        process_labels.append(process_label)

                    # prepend process to contexts in this mode to ensure uniqueness
                    contexts = ['%s:%s' % (process_name, x) for x in contexts]
                else:
                    contexts = [process_name]
                    labels = contexts

                    process_labels.append(process_label)

                for idx, context in enumerate(contexts):
                    cb = CheckboxWdg(cb_name)
                    cb.set_checked()
                    cb.set_option('value', context)
                    v_div.add(SpanWdg(cb, css='small'))
                    if mode == 'context':
                        span = SpanWdg(process_name, css='med')
                        #span.add_color('color','color')
                        v_div.add(span)
                    v_div.add(SpanWdg(labels[idx]))
                    process_label = process_labels[idx]
                    if process_label:
                        v_div.add(SpanWdg("(%s)" % process_label, css='small'))
                    v_div.add(HtmlElement.br())

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

        skipped = []

        if True:
            div.add("<br/>")
            btn = ActionButtonWdg(title='Add Tasks')
            btn.add_behavior({
                'type': 'click_up',
                'post_event': 'search_table_%s' % self.table_id,
                'cbjs_action': '''
            spt.dg_table.add_task_selected(bvr);
            ''',
                'search_key_list': self.search_key_list
            })
            cb = CheckboxWdg('skip_duplicated', label='Skip Duplicates')
            cb.set_checked()
            option_div = DivWdg(cb)
            option_div.add_style('width', '130px')
            option_div.add_style('align: left')
            div.add(option_div)
            div.add(HtmlElement.br())
            btn.add_style("float: right")
            div.add(btn)
            div.add(HtmlElement.br(clear="all"))

        if skipped:
            content_div.add(HtmlElement.br())
            skip_div = DivWdg('Missing pipeline code (Skipped)')
            skip_div.add_style('text-decoration: underline')
            content_div.add(skip_div)
            content_div.add(HtmlElement.br())
            item_div = DivWdg()
            item_div.add_style('margin-left: 10px')
            content_div.add(item_div)
        for skip in skipped:
            item_div.add(skip.get_code())
            item_div.add(HtmlElement.br())

        return div
Пример #6
0
    def get_display(self):
        self.check()
        if self.is_refresh:
            div = Widget()
        else:
            div = DivWdg()
            self.set_as_panel(div)
            div.add_style('padding','6px')
            min_width = '400px'
            div.add_style('min-width', min_width)
            div.add_color('background','background')
            div.add_class('spt_add_task_panel')
            div.add_style("padding: 20px")


        from tactic.ui.app import HelpButtonWdg
        help_button = HelpButtonWdg(alias="creating-tasks")
        div.add(help_button)
        help_button.add_style("float: right")
        help_button.add_style("margin-top: -5px")

        if not self.search_key_list:
            msg_div = DivWdg()
            msg_table = Table()
            msg_div.add(msg_table)
            msg_table.add_row()
            msg_table.add_cell( IconWdg("No items selected", IconWdg.WARNING) )
            msg_table.add_cell('Please select at least 1 item to add tasks to.')

            msg_div.add_style('margin: 10px')
            msg_table.add_style("font-weight: bold")
            div.add(msg_div)
            return div

        msg_div = DivWdg()
        msg_div.add_style('margin-left: 4px')
        div.add(msg_div, 'info')
        msg_div.add('Total: %s item/s to add tasks to' %len(self.search_key_list))
        div.add(HtmlElement.br())
        hint = HintWdg('Tasks are added according to the assigned pipeline.')
        msg_div.add(" &nbsp; ")
        msg_div.add(hint)
        msg_div.add(HtmlElement.br())
        
        
        option_div = DivWdg(css='spt_ui_options')
        #option_div.add_style('margin-left: 12px')
        
        sel = SelectWdg('pipeline_mode', label='Create tasks by: ')
        sel.set_option('values', ['simple process','context', 'standard'])
        sel.set_option('labels', ['process','context', 'all contexts in process'])
        sel.set_persistence()
        sel.add_behavior({'type':'change',
                 'cbjs_action': 'spt.panel.refresh(bvr.src_el)'}) 
        
        option_div.add(sel)

        value = sel.get_value()
        # default to simple process
        if not value:
            value = 'simple process'
        msg = ''
        if value not in ['simple process','context','standard']:
            value = 'simple process'
        
        if value == 'context':
            msg = 'In context mode, a single task will be created for each selected context.'
        elif value == 'simple process':
            msg = 'In process mode, a single task will be created for each selected process.'

        elif value == 'standard':
            msg = 'In this mode, a task will be created for all contexts of each selected process.'

        option_div.add(HintWdg(msg))
        div.add(option_div)
        div.add(HtmlElement.br())

        title = DivWdg('Assigned Pipelines')
        title.add_style('padding: 6px')
        title.add_color('background','background2')
        title.add_color('color','color', +120)
        div.add(title)
    
        content_div = DivWdg()
        content_div.add_style('min-height', '150px')
        div.add(content_div)
        content_div.add_border()
        
        filtered_search_key_list = []
        for sk in self.search_key_list:
            id = SearchKey.extract_id(sk)
            if id=='-1':
                continue
            filtered_search_key_list.append(sk)

        sobjects = SearchKey.get_by_search_keys(filtered_search_key_list)
        skipped = []
        pipeline_codes = []
        for sobject in sobjects:
            if isinstance(sobject, Task):
                msg_div = DivWdg('WARNING: Creation of task for [Task] is not allowed.')
                msg_div.add_style('margin-left: 10px')
                div.add(msg_div, 'info')
                return div
            pipeline_code = sobject.get_value('pipeline_code', no_exception=True)
            if not pipeline_code:
                skipped.append(sobject)
            if pipeline_code not in pipeline_codes:
                pipeline_codes.append(pipeline_code)
       

        pipelines = Search.get_by_code('sthpw/pipeline', pipeline_codes)
        if pipelines == None:
            pipelines = []
        #if not pipelines:
        #    msg_div = DivWdg('WARNING: No Pipelines found for selected.')
        #    msg_div.add_style('margin-left: 10px')
        #    div.add(msg_div, 'info')
        #    return div

        # expand the width according to num of pipelines
        content_div.add_style('min-width', len(pipelines)*250)
        mode_cb = SelectWdg('pipeline_mode') 
        mode_cb.set_persistence()
        mode = mode_cb.get_value()
        if 'context' == mode:
            mode = 'context'
        else:   
            mode = 'process'

        show_subpipeline = True
        min_height = '150px'



        # create a temp default pipeline
        if not pipelines:
            pipeline = SearchType.create("sthpw/pipeline")
            pipeline.set_value("code", "__default__")
            pipeline.set_value("pipeline", '''
<pipeline>
    <process name='publish'/>
</pipeline>
            ''')
            # FIXME: HACK to initialize virtual pipeline
            pipeline.set_pipeline(pipeline.get_value("pipeline"))
            pipelines = [pipeline]

        for pipeline in pipelines:
            name = pipeline.get_value("name")
            if not name:
                name = pipeline.get_code()
            span = SpanWdg("Pipeline: %s" % name)
            span.add_style('font-weight: bold')
            v_div = FloatDivWdg(span)
            v_div.add_style('margin: 20px')
            v_div.add_style('min-height', min_height)
            v_div.add(HtmlElement.br(2))
            content_div.add(v_div)    
            processes = pipeline.get_processes(recurse=show_subpipeline, type=['manual','approval'])

            cb_name = '%s|task_process'  %pipeline.get_code()
            master_cb = CheckboxWdg('master_control')
            master_cb.set_checked()
            master_cb.add_behavior({'type': 'click_up',
                'propagate_evt': True,
                'cbjs_action': '''
                    var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_add_task_panel'),'%s');
                    for (var i = 0; i < inputs.length; i++)
                        inputs[i].checked = bvr.src_el.checked;
                        ''' %cb_name})
            toggle_div = DivWdg()
            toggle_div.add(SpanWdg(master_cb, css='small'))
            label = HtmlElement.i('toggle all')
            label.add_style('color: #888')
            toggle_div.add_styles('border-bottom: 1px solid #888; width: 170px')
            toggle_div.add(label)
            v_div.add(toggle_div)
            process_names = []

            for process in processes:
                process_labels = []
                if process.is_from_sub_pipeline():
                    process_name  = process.get_full_name()
                else:
                    process_name  = process.get_name()

                process_label = process.get_label()
                if not process_label:
                    process_label = ''
                if mode =='context':
                    contexts =  pipeline.get_output_contexts(process.get_name())
                    
                    labels = contexts
                    if process.is_from_sub_pipeline():
                        labels = ['%s/%s'%(process.parent_pipeline_code, x) for x in contexts]
                    
                    for x in labels: 
                        process_labels.append(process_label)
                    
                    # prepend process to contexts in this mode to ensure uniqueness
                    contexts = ['%s:%s' %(process_name, x) for x in contexts]
                else:
                    contexts = [process_name]
                    labels = contexts
                
                    process_labels.append(process_label)

                for idx, context in enumerate(contexts):
                    cb = CheckboxWdg(cb_name)
                    cb.set_checked()
                    cb.set_option('value', context)
                    v_div.add(SpanWdg(cb, css='small'))
                    if mode == 'context':
                        span = SpanWdg(process_name, css='med')
                        #span.add_color('color','color')
                        v_div.add(span)
                    v_div.add(SpanWdg(labels[idx]))
                    process_label = process_labels[idx]
                    if process_label:
                        v_div.add(SpanWdg("(%s)" %process_label, css='small'))
                    v_div.add(HtmlElement.br())
        
       
        content_div.add("<br clear='all'/>")

        skipped = [] 

        if True:
            div.add("<br/>")
            btn = ActionButtonWdg(title='Add Tasks')
            btn.add_behavior({'type' : 'click_up',
            'post_event': 'search_table_%s'% self.table_id,
            'cbjs_action': '''
            spt.dg_table.add_task_selected(bvr);
            ''',
            'search_key_list': self.search_key_list
            })
            cb = CheckboxWdg('skip_duplicated', label='Skip Duplicates')
            cb.set_checked()
            option_div =DivWdg(cb)
            option_div.add_style('width', '130px')
            option_div.add_style('align: left')
            div.add(option_div)
            div.add(HtmlElement.br())
            btn.add_style("float: right")
            div.add(btn)
            div.add(HtmlElement.br(clear="all"))


        if skipped:
            content_div.add(HtmlElement.br())
            skip_div = DivWdg('Missing pipeline code (Skipped)')
            skip_div.add_style('text-decoration: underline')
            content_div.add(skip_div)
            content_div.add(HtmlElement.br())
            item_div = DivWdg()
            item_div.add_style('margin-left: 10px')
            content_div.add(item_div)
        for skip in skipped:
            item_div.add(skip.get_code())
            item_div.add(HtmlElement.br())



        return div
Пример #7
0
    def get_display(self):

        # add the detail widget
        detail_wdg = DivWdg(css='spt_detail_panel')
        if not self.name_string and not self.config_string:
            detail_wdg.add("<br/>"*3)
            detail_wdg.add('<- Click on an item on the left for modification.')
            detail_wdg.add_style("padding: 10px")
            detail_wdg.add_color("background", "background", -5)
            detail_wdg.add_style("width: 350px")
            detail_wdg.add_style("height: 400px")
            detail_wdg.add_border()

            return detail_wdg

        if self.kwargs.get("mode") == "empty":
            overlay = DivWdg()
            detail_wdg.add(overlay)

        detail_wdg.add_border()
        detail_wdg.add_color("color", "black")
        detail_wdg.add_style("padding: 10px")
        detail_wdg.add_color("background", "background", -5)

        detail_wdg.set_id('search_type_detail')

        # put in the selection for simple or advanced
        select = SelectWdg("config_mode", label='Mode: ')
        select.set_persistence()
        values = ['simple', 'advanced']
        select.set_option("values", values)
        config_mode = select.get_value()
        #select.add_behavior({"type": "change", "cbjs_action": "spt.simple_display_toggle( spt.get_cousin(bvr.src_el, '.spt_detail_panel','.config_simple') )"})
        select.add_behavior({"type": "change", "cbjs_action": \
            "spt.simple_display_toggle( spt.get_cousin(bvr.src_el, '.spt_detail_panel','.config_advanced')); %s" %select.get_save_script()})

        select.add_class('spt_config_mode')

        title_div = DivWdg("Column Detail")
        title_div.add_class("maq_search_bar")
        detail_wdg.add(title_div)
        detail_wdg.add("<br/>")
        detail_wdg.add(select)
        detail_wdg.add(HtmlElement.br(2))

        #simple_mode_wdg = WidgetDetailSimpleModeWdg()
        #detail_wdg.add(simple_mode_wdg)
        #detail_wdg.add(HtmlElement.br(2))

        if self.is_new_column:
            detail_wdg.add( self.get_new_definition_wdg() )
        else:
            
            simple_wdg = self.get_simple_definition_wdg()
           
            simple_wdg.add_class("config_simple")
            detail_wdg.add( simple_wdg )
            adv_wdg = self.get_advanced_definition_wdg()
            adv_wdg.add_class("config_advanced")
            if config_mode == 'simple':
                adv_wdg.add_style('display: none')
            detail_wdg.add(HtmlElement.br(2))
            detail_wdg.add( adv_wdg )

        detail_wdg.add(HtmlElement.br(2))


        security_wdg = self.get_security_wdg()
        detail_wdg.add(security_wdg)


        # add hidden input for view for panel refreshing
        # we are only interested in whether it is project_view or definition
        # sub-views of project_view is not of our interest

        #if self.view != 'project_view':
        #    self.view = 'custom_definition'
        detail_wdg.add(HiddenWdg('view', self.view))


        return detail_wdg
Пример #8
0
    def get_display(self):

        widget = Widget()

        div = DivWdg(css="filter_box")

        show_span = SpanWdg(css='med')
        show_span.add('Show All Types: ')
        checkbox = FilterCheckboxWdg('show_all_types')
        checkbox.set_persistence()
        show_span.add(checkbox)
        show_all_types = checkbox.get_value()
        div.add(show_span)


        span = SpanWdg(css="med")
        span.add("Search Type: ")

        select = SelectWdg("filter|search_type")
        select.add_empty_option("-- Select --")
        project = Project.get()
        project_type = project.get_base_type()
        search = Search("sthpw/search_object")
        if show_all_types:
            search.add_where('''
            namespace = '%s' or namespace = '%s' or search_type in ('sthpw/task')
            ''' % (project_type, project.get_code()) )
        else:
            # show only the custom ones
            search.add_filter('namespace', project.get_code() )

        search.add_order_by("title")
        sobjects = search.get_sobjects()

        select.set_sobjects_for_options(sobjects,"search_type", "title")
        #select.set_option("query", "sthpw/search_object|search_type|title")
        select.set_persistence()
        select.add_event("onchange", "document.form.submit()")
        search_type = select.get_value()
        span.add(select)
        div.add(span)


        # make sure the current selection exists
        try:
            SearchType.get(search_type)
        except SearchException as e:
            return div
        except SqlException as e:
            return div


        # add the view selector
        view_select = SelectWdg("view")
        view_select.add_empty_option("-- View --")
        view_select.add_event("onchange", "document.form.submit()")
        view_select.set_persist_on_submit()
        #view_select.set_persistence()
        span = SpanWdg(css="med")
        span.add("Defined Views: ")
        span.add(view_select)
        div.add(span)

        div.add( self.get_create_view_wdg(search_type))

        div.add( HtmlElement.br(2) )


        div.add( self.get_new_tab_wdg() )


        widget.add(div)

        search = Search("sthpw/widget_config")
        #search.add_user_filter()
        search.add_filter("search_type", search_type)
        search.add_where("view != 'definition' and view != 'custom'")
        #search.add_column("view")
        widget_configs = search.get_sobjects()
        if widget_configs:
            view_select.set_sobjects_for_options(widget_configs,"view","view")
        view = view_select.get_value()
        if not view:
            view = "custom"
            #return widget

        # get the selected widget config
        for widget_config in widget_configs:
            if widget_config.get_value("view") == view:
                break
        else:
            return widget

        # get the handler: a little HACKY.
        config_xml = widget_config.get_xml_value("config")
        handler = config_xml.get_value("config/%s/@handler" % view)

        if not search_type:
            return widget

        widget.add(HtmlElement.br())
        span = SpanWdg()
        custom_view = CustomViewWdg(search_type)
        span.add(custom_view)
        span.add_style("float: right")
        widget.add(span)


        widget.add( HtmlElement.br() )
        widget.add("<h3>Example View [%s]</h3>" % view)

        # add a general filter
        filter_div = DivWdg()
        for i in range(0,1):
            filter = GeneralFilterWdg()
            filter.set_columns_from_search_type(search_type)
            filter_div.add("Filter: ")
            filter_div.add(filter)
            #filter_div.add(IconWdg("Remove Filter", IconWdg.RETIRE))
            filter_div.add( HtmlElement.br(2) )

        widget.add(filter_div)

        search = Search(search_type)
        search.set_limit(5)
        filter.alter_search(search)

        
        if not handler:
            if view in ["edit","insert"]:
                table = EditWdg(search_type, view)
            else:
                table = TableWdg(search_type, view)
        else:
            table = eval("%s(search_type,view)" % handler)

        #table.alter_search(search)
        sobjects = search.get_sobjects()

        if not sobjects and view in ["edit","insert"]:
            sobjects = [SObjectFactory.create(search_type)]
        table.set_sobjects(sobjects)
        widget.add(table)

        # show the custom properties
        widget.add("<h3>Custom Properties [%s]</h3>" % search_type)
        search = Search("prod/custom_property")
        search.add_filter("search_type", search_type)
        # This is actually reading the sthpw/custom_property conf file, weird
        table = TableWdg("prod/custom_property")
        table.set_search_limit(5)
        table.set_sobjects(search.get_sobjects() )
        widget.add(table)

        return widget
Пример #9
0
    def get_display(self):

        web = WebContainer.get_web()
        naming_util = NamingUtil()

        if not self.widget_name:
            self.widget_name = self.get_name()

        # get the sobject required by this input
        sobject = self.get_current_sobject()
        if not sobject:
            sobject = Search.get_by_id(self.search_type, self.search_id)

        if self.new_sample_name:
            self.new_sample_name.replace("//", "/")
        else:
            self.new_sample_name = sobject.get_value(self.widget_name)

        widget = DivWdg()
        widget.set_id("naming")
        widget.add_style("display: block")

        # set the sample text
        div = DivWdg()
        div.add("Sample name: <i>%s</i>" % self.new_sample_name)
        div.add(HtmlElement.br(2))

        new_sample_wdg = ProdIconButtonWdg("Set New Sample")
        new_sample_wdg.add_event("onclick", "toggle_display('generate')")
        div.add(new_sample_wdg)

        generate = DivWdg()
        generate.add(HtmlElement.br())
        generate.set_id("generate")
        generate.add_style("display: none")
        sample_text = TextWdg("new_sample_name")
        sample_text.set_option("size", "30")
        #sample_text.set_persist_on_submit()
        #if self.new_sample_name:
        #    sample_text.set_value(self.new_sample_name)
        generate.add(sample_text)

        button = IconButtonWdg("Generate", IconWdg.REFRESH, long=True)
        on_script = self.setup_ajax("naming")
        button.add_event("onclick", on_script)
        generate.add(button)
        generate.add(HtmlElement.br(2))

        div.add(generate)
        widget.add(div)

        hidden = TextWdg(self.widget_name)
        value = self.naming
        hidden.set_value(self.new_sample_name)
        widget.add(self.widget_name)
        widget.add(hidden)

        # get all of the parts

        # TODO: not sure if this should be dictated by the sample name
        # break up the name into parts
        import re
        if self.new_sample_name:
            tmp = self.new_sample_name.strip("/")
            parts = re.split('[\\/._]', tmp)
            print "parts: ", parts
        else:
            return widget

        # if there is a naming, then populate that
        if self.edit_search_type:
            options = naming_util.get_options(self.edit_search_type)
        else:
            options = naming_util.get_options(sobject.get_value("search_type"))

        table = Table()
        type_values = []
        padding_values = []
        for idx, part in enumerate(parts):
            table.add_row()
            table.add_cell(part)

            type_select = SelectWdg("type_%s" % idx)
            type_select.add_empty_option("-- Explicit --")
            type_select.set_persist_on_submit()
            type_select.set_option("values", "|".join(options))
            type_values.append(type_select.get_value())
            td = table.add_cell(type_select)

        widget.add(table)

        return widget
Пример #10
0
    def init(my):

        search = Search("sthpw/queue")
        search.add_order_by("priority desc")
        search.add_order_by("timestamp desc")

        widget = Widget()

        div = DivWdg(css="filter_box")

        span = SpanWdg(css="med")

        from pyasm.prod.web import SearchFilterWdg
        search_filter = SearchFilterWdg(columns=Queue.get_search_columns())
        search_filter.alter_search(search)
        span.add(search_filter)
        div.add(span)

        span = SpanWdg(css="med")
        priority_wdg = TextWdg("priority_search")
        priority_wdg.set_persistence()
        priority = priority_wdg.get_value()
        if priority:
            search.add_filter("priority", priority)
        span.add("Priority: ")
        span.add(priority_wdg)
        div.add(span)

        select = SelectWdg("queue_state")
        select.set_option("values", "|pending|locked|error|done")
        select.set_option("labels", "All|pending|locked|error|done")
        select.add_event("onchange", "document.form.submit()")
        select.set_persistence()

        span = SpanWdg(css="med")
        span.add("State: ")
        span.add(select)
        div.add(span)
        queue_state = select.get_value()
        if queue_state != "":
            search.add_filter("state", queue_state)

        user_select = SelectWdg("user_select")
        user_select.add_empty_option()

        user_search = Search("sthpw/login")
        user_select.set_search_for_options(user_search, "login", "login")
        user_select.add_event("onchange", "document.form.submit()")
        user_select.set_persistence()

        div.add("User: "******"":
            search.add_filter("login", queue_user)

        search_limit = SearchLimitWdg()
        search_limit.set_limit(10)
        div.add(search_limit)
        search_limit.alter_search(search)

        widget.add(div)

        sobjects = search.get_sobjects()

        table = TableWdg("sthpw/queue")
        table.set_sobjects(sobjects)
        widget.add(table)

        my.add(widget)
Пример #11
0
    def get_first_row_wdg(self):

        # read the csv file
        self.file_path = ""

        div = DivWdg()

        div.add(self.get_upload_wdg())

        if not self.search_type:
            return div

        if not self.file_path:
            return div

        if not self.file_path.endswith(".csv"):
            div.add("Uploaded file [%s] is not a csv file" % self.file_path)
            return div

        if not os.path.exists(self.file_path):
            raise Exception("Path '%s' does not exists" % self.file_path)

        div.add(HtmlElement.br(2))

        div.add(
            HtmlElement.
            b("The following is taken from first line in the uploaded csv file.  Select the appropriate column to match."
              ))
        div.add(HtmlElement.br())
        div.add(
            HtmlElement.b(
                "Make sure you have all the required columns** in the csv."))
        option_div = DivWdg()

        option_div.add_style("float: left")
        option_div.add_style("margin-right: 30px")

        option_div.add("<p>3. Parsing Options:</p>")

        self.search_type_obj = SearchType.get(self.search_type)

        # first row and second row
        option_div.add(HtmlElement.br(2))
        option_div.add("Use Title Row: ")
        title_row_checkbox = FilterCheckboxWdg("has_title")
        title_row_checkbox.set_default_checked()
        option_div.add(title_row_checkbox)
        option_div.add(
            HintWdg(
                "Set this to use the first row as a title row to match up columns in the database"
            ))

        option_div.add(HtmlElement.br(2))
        option_div.add("Sample Data Row: ")
        data_row_text = TextWdg("data_row")
        data_row_text.set_attr("size", "3")
        option_div.add(data_row_text)
        option_div.add(
            HintWdg(
                "Set this as a sample data row to match the columns to the database"
            ))

        option_div.add(HtmlElement.br(2))

        div.add(option_div)
        self.has_title = title_row_checkbox.is_checked()

        # parse the first fow
        csv_parser = CsvParser(self.file_path)
        if self.has_title:
            csv_parser.set_has_title_row(True)
        else:
            csv_parser.set_has_title_row(False)
        csv_parser.parse()
        csv_titles = csv_parser.get_titles()
        csv_data = csv_parser.get_data()

        data_row = data_row_text.get_value()
        if not data_row:
            data_row = 0
        else:
            try:
                data_row = int(data_row)
            except ValueError:
                data_row = 0

            if data_row >= len(csv_data):
                data_row = len(csv_data) - 1
        data_row_text.set_value(data_row)

        table = Table()
        table.set_attr("cellpadding", "10")

        table.add_row()
        table.add_header("CSV Column Value")
        table.add_header("TACTIC Column")
        table.add_header("Create New Column")

        columns = self.search_type_obj.get_columns()
        search_type = self.search_type_obj.get_base_search_type()
        sobj = SObjectFactory.create(search_type)
        required_columns = sobj.get_required_columns()

        row = csv_data[data_row]
        labels = []
        for column in columns:
            if column in required_columns:
                label = '%s**' % column
            else:
                label = column
            labels.append(label)

        for j, cell in enumerate(row):
            table.add_row()
            table.add_cell(cell)

            column_select = SelectWdg("column_%s" % j)
            column_select.add_event(
                "onchange",
                "if (this.value!='') {set_display_off('new_column_div_%s')} else {set_display_on('new_column_div_%s')}"
                % (j, j))

            column_select.add_empty_option("-- Select --")
            column_select.set_option("values", columns)
            column_select.set_option("labels", labels)

            # only set the value if it is actually in there
            if csv_titles[j] in columns:
                column_select.set_option("default", csv_titles[j])
            column_select.set_persist_on_submit()
            column_select_value = column_select.get_value()

            display = column_select.get_buffer_display()
            td = table.add_cell(display)

            if csv_titles[j] not in columns:
                td.add(" <b style='color: red'>*</b>")

                # new property
                new_column_div = DivWdg()

                if column_select_value:
                    new_column_div.add_style("display", "none")
                else:
                    new_column_div.add_style("display", "block")

                new_column_div.set_id("new_column_div_%s" % j)

                td = table.add_cell(new_column_div)
                text = TextWdg("new_column_%s" % j)
                text.set_persist_on_submit()

                if self.has_title:
                    text.set_value(csv_titles[j])

                new_column_div.add(" ... or ...")
                new_column_div.add(text)

        self.num_columns = len(row)
        hidden = HiddenWdg("num_columns", self.num_columns)

        # need to somehow specify defaults for columns

        div.add(table)

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

        div.add(self.get_preview_wdg())

        return div
Пример #12
0
    def get_display(my):

        div = DivWdg()
        div.add_style("padding: 10px 0px 10px 0px")

        behavior = {"type": "keyboard", "kbd_handler_name": "DgTableMultiLineTextEdit"}
        div.add_behavior(behavior)

        project_code = None
        sobject = my.get_current_sobject()
        if sobject:
            project_code = sobject.get_project_code()
        project_filter = Project.get_project_filter(project_code)

        query_filter = my.get_option("query_filter")
        if not query_filter:
            # try getting it from the search_type
            web = WebContainer.get_web()
            search_type = web.get_form_value("search_type")
            if search_type:
                search_type_obj = SearchType.get(search_type)
                base_search_type = search_type_obj.get_base_search_type()
                query_filter = "search_type = '%s'" % base_search_type

        # add the project filter
        if query_filter:
            query_filter = "%s and %s" % (query_filter, project_filter)
        else:
            query_filter = project_filter

        my.set_option("query_filter", query_filter)

        select = SelectWdg()
        select.add_empty_option("-- Select --")
        select.copy(my)

        select.add_event("onchange", "alert('cow')")
        div.add(select)

        span = SpanWdg(css="med")
        span.add("Add Initial Tasks: ")
        checkbox = CheckboxWdg("add_initial_tasks")
        checkbox.set_persistence()
        if checkbox.is_checked(False):
            checkbox.set_checked()
        span.add(checkbox)
        div.add(span)

        # list all of the processes with checkboxes
        pipeline_code = select.get_value()
        if pipeline_code:
            pipeline = Pipeline.get_by_code(pipeline_code)
            if not pipeline:
                print "WARNING: pipeline '%s' does not exist" % pipeline_code
                return
            process_names = pipeline.get_process_names(recurse=True)

            process_div = DivWdg()
            for process in process_names:
                checkbox = CheckboxWdg("add_initial_tasks")
                process_div.add(checkbox)
                process_div.add("&nbsp;")
                process_div.add(process)
                process_div.add(HtmlElement.br())
            div.add(process_div)

        return div
Пример #13
0
        div.add(HtmlElement.br(2))

        div.add(my.get_new_tab_wdg())

        widget.add(div)

        search = Search("sthpw/widget_config")
        # search.add_user_filter()
        search.add_filter("search_type", search_type)
        search.add_where("view != 'definition' and view != 'custom'")
        # search.add_column("view")
        widget_configs = search.get_sobjects()
        if widget_configs:
            view_select.set_sobjects_for_options(widget_configs, "view", "view")
        view = view_select.get_value()
        if not view:
            view = "custom"
            # return widget

        # get the selected widget config
        for widget_config in widget_configs:
            if widget_config.get_value("view") == view:
                break
        else:
            return widget

        # get the handler: a little HACKY.
        config_xml = widget_config.get_xml_value("config")
        handler = config_xml.get_value("config/%s/@handler" % view)
Пример #14
0
    def get_first_row_wdg(my):

        # read the csv file
        my.file_path = ""

        div = DivWdg()

        div.add( my.get_upload_wdg() )

        if not my.search_type:
            return div

        if not my.file_path:
            return div


        if not my.file_path.endswith(".csv"):
            div.add( "Uploaded file [%s] is not a csv file"% my.file_path)
            return div

        if not os.path.exists(my.file_path):
            raise Exception("Path '%s' does not exists" % my.file_path)

        div.add(HtmlElement.br(2))

        div.add( HtmlElement.b("The following is taken from first line in the uploaded csv file.  Select the appropriate column to match.") )
        div.add(HtmlElement.br())
        div.add(  HtmlElement.b("Make sure you have all the required columns** in the csv."))
        option_div = DivWdg()
        
        option_div.add_style("float: left")
        option_div.add_style("margin-right: 30px")

        option_div.add("<p>3. Parsing Options:</p>")

        my.search_type_obj = SearchType.get(my.search_type)


        # first row and second row
        option_div.add( HtmlElement.br(2) )
        option_div.add("Use Title Row: ")
        title_row_checkbox = FilterCheckboxWdg("has_title")
        title_row_checkbox.set_default_checked()
        option_div.add(title_row_checkbox)
        option_div.add( HintWdg("Set this to use the first row as a title row to match up columns in the database") )
        
        option_div.add( HtmlElement.br(2) )
        option_div.add("Sample Data Row: ")
        data_row_text = TextWdg("data_row")
        data_row_text.set_attr("size", "3")
        option_div.add(data_row_text)
        option_div.add( HintWdg("Set this as a sample data row to match the columns to the database") )

        option_div.add( HtmlElement.br(2) )
        
       
        div.add(option_div)
        my.has_title = title_row_checkbox.is_checked()
        
        
        # parse the first fow
        csv_parser = CsvParser(my.file_path)
        if my.has_title:
            csv_parser.set_has_title_row(True)
        else:
            csv_parser.set_has_title_row(False)
        csv_parser.parse()
        csv_titles = csv_parser.get_titles()
        csv_data = csv_parser.get_data()



        data_row = data_row_text.get_value()
        if not data_row:
            data_row = 0
        else:
            try:
                data_row = int(data_row)
            except ValueError:
                data_row = 0

            if data_row >= len(csv_data):
                data_row = len(csv_data)-1
        data_row_text.set_value(data_row)




        table = Table()
        table.set_attr("cellpadding", "10")

        table.add_row()
        table.add_header("CSV Column Value")
        table.add_header("TACTIC Column")
        table.add_header("Create New Column")
        
        columns = my.search_type_obj.get_columns()
        search_type = my.search_type_obj.get_base_search_type()
        sobj = SObjectFactory.create(search_type)
        required_columns = sobj.get_required_columns()
        
        row = csv_data[data_row]
        labels = []
        for column in columns:
            if column in required_columns:
                label = '%s**'%column
            else:
                label = column
            labels.append(label)

        for j, cell in enumerate(row):
            table.add_row()
            table.add_cell(cell)

            column_select = SelectWdg("column_%s" % j)
            column_select.add_event("onchange", "if (this.value!='') {set_display_off('new_column_div_%s')} else {set_display_on('new_column_div_%s')}" % (j,j))

            column_select.add_empty_option("-- Select --")
            column_select.set_option("values", columns)
            column_select.set_option("labels", labels)

            # only set the value if it is actually in there
            if csv_titles[j] in columns:
                column_select.set_option("default", csv_titles[j])
            column_select.set_persist_on_submit()
            column_select_value = column_select.get_value()


            display = column_select.get_buffer_display()
            td = table.add_cell( display )

            if csv_titles[j] not in columns:
                td.add(" <b style='color: red'>*</b>")

                # new property
                new_column_div = DivWdg()

                if column_select_value:
                    new_column_div.add_style("display", "none")
                else:
                    new_column_div.add_style("display", "block")

                new_column_div.set_id("new_column_div_%s" % j)

                td = table.add_cell( new_column_div )
                text = TextWdg("new_column_%s" % j)
                text.set_persist_on_submit()

                if my.has_title:
                    text.set_value(csv_titles[j])


                new_column_div.add( " ... or ..." )
                new_column_div.add( text )


        my.num_columns = len(row)
        hidden = HiddenWdg("num_columns", my.num_columns)


        # need to somehow specify defaults for columns


        div.add(table)

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


        div.add(my.get_preview_wdg())


        return div          
Пример #15
0
    def get_display(my):

        # add the detail widget
        detail_wdg = DivWdg(css='spt_detail_panel')
        if not my.name_string and not my.config_string:
            detail_wdg.add("<br/>" * 3)
            detail_wdg.add('<- Click on an item on the left for modification.')
            detail_wdg.add_style("padding: 10px")
            detail_wdg.add_color("background", "background", -5)
            detail_wdg.add_style("width: 350px")
            detail_wdg.add_style("height: 400px")
            detail_wdg.add_border()

            return detail_wdg

        if my.kwargs.get("mode") == "empty":
            overlay = DivWdg()
            detail_wdg.add(overlay)

        detail_wdg.add_border()
        detail_wdg.add_color("color", "black")
        detail_wdg.add_style("padding: 10px")
        detail_wdg.add_color("background", "background", -5)

        detail_wdg.set_id('search_type_detail')

        # put in the selection for simple or advanced
        select = SelectWdg("config_mode", label='Mode: ')
        select.set_persistence()
        values = ['simple', 'advanced']
        select.set_option("values", values)
        config_mode = select.get_value()
        #select.add_behavior({"type": "change", "cbjs_action": "spt.simple_display_toggle( spt.get_cousin(bvr.src_el, '.spt_detail_panel','.config_simple') )"})
        select.add_behavior({"type": "change", "cbjs_action": \
            "spt.simple_display_toggle( spt.get_cousin(bvr.src_el, '.spt_detail_panel','.config_advanced')); %s" %select.get_save_script()})

        select.add_class('spt_config_mode')

        title_div = DivWdg("Column Detail")
        title_div.add_class("maq_search_bar")
        detail_wdg.add(title_div)
        detail_wdg.add("<br/>")
        detail_wdg.add(select)
        detail_wdg.add(HtmlElement.br(2))

        #simple_mode_wdg = WidgetDetailSimpleModeWdg()
        #detail_wdg.add(simple_mode_wdg)
        #detail_wdg.add(HtmlElement.br(2))

        if my.is_new_column:
            detail_wdg.add(my.get_new_definition_wdg())
        else:

            simple_wdg = my.get_simple_definition_wdg()

            simple_wdg.add_class("config_simple")
            detail_wdg.add(simple_wdg)
            adv_wdg = my.get_advanced_definition_wdg()
            adv_wdg.add_class("config_advanced")
            if config_mode == 'simple':
                adv_wdg.add_style('display: none')
            detail_wdg.add(HtmlElement.br(2))
            detail_wdg.add(adv_wdg)

        detail_wdg.add(HtmlElement.br(2))

        security_wdg = my.get_security_wdg()
        detail_wdg.add(security_wdg)

        # add hidden input for view for panel refreshing
        # we are only interested in whether it is project_view or definition
        # sub-views of project_view is not of our interest

        #if my.view != 'project_view':
        #    my.view = 'custom_definition'
        detail_wdg.add(HiddenWdg('view', my.view))

        return detail_wdg
Пример #16
0
    def init(my):

        search = Search("sthpw/queue")
        search.add_order_by("priority desc")
        search.add_order_by("timestamp desc")

        widget = Widget()

        div = DivWdg(css="filter_box")

        span = SpanWdg(css="med")

        from pyasm.prod.web import SearchFilterWdg

        search_filter = SearchFilterWdg(columns=Queue.get_search_columns())
        search_filter.alter_search(search)
        span.add(search_filter)
        div.add(span)

        span = SpanWdg(css="med")
        priority_wdg = TextWdg("priority_search")
        priority_wdg.set_persistence()
        priority = priority_wdg.get_value()
        if priority:
            search.add_filter("priority", priority)
        span.add("Priority: ")
        span.add(priority_wdg)
        div.add(span)

        select = SelectWdg("queue_state")
        select.set_option("values", "|pending|locked|error|done")
        select.set_option("labels", "All|pending|locked|error|done")
        select.add_event("onchange", "document.form.submit()")
        select.set_persistence()

        span = SpanWdg(css="med")
        span.add("State: ")
        span.add(select)
        div.add(span)
        queue_state = select.get_value()
        if queue_state != "":
            search.add_filter("state", queue_state)

        user_select = SelectWdg("user_select")
        user_select.add_empty_option()

        user_search = Search("sthpw/login")
        user_select.set_search_for_options(user_search, "login", "login")
        user_select.add_event("onchange", "document.form.submit()")
        user_select.set_persistence()

        div.add("User: "******"":
            search.add_filter("login", queue_user)

        search_limit = SearchLimitWdg()
        search_limit.set_limit(10)
        div.add(search_limit)
        search_limit.alter_search(search)

        widget.add(div)

        sobjects = search.get_sobjects()

        table = TableWdg("sthpw/queue")
        table.set_sobjects(sobjects)
        widget.add(table)

        my.add(widget)
Пример #17
0
    def get_display(self):

        div = DivWdg()
        div.add_style("padding: 10px 0px 10px 0px")

        behavior = {
            'type': 'keyboard',
            'kbd_handler_name': 'DgTableMultiLineTextEdit'
        }
        div.add_behavior(behavior)

        project_code = None
        sobject = self.get_current_sobject()
        if sobject:
            project_code = sobject.get_project_code()
        project_filter = Project.get_project_filter(project_code)

        query_filter = self.get_option("query_filter")
        if not query_filter:
            # try getting it from the search_type
            web = WebContainer.get_web()
            search_type = web.get_form_value("search_type")
            if search_type:
                search_type_obj = SearchType.get(search_type)
                base_search_type = search_type_obj.get_base_search_type()
                query_filter = "search_type = '%s'" % base_search_type

        # add the project filter
        if query_filter:
            query_filter = "%s and %s" % (query_filter, project_filter)
        else:
            query_filter = project_filter

        self.set_option("query_filter", query_filter)

        select = SelectWdg()
        select.add_empty_option("-- Select --")
        select.copy(self)

        select.add_event("onchange", "alert('cow')")
        div.add(select)

        span = SpanWdg(css="med")
        span.add("Add Initial Tasks: ")
        checkbox = CheckboxWdg("add_initial_tasks")
        checkbox.set_persistence()
        if checkbox.is_checked(False):
            checkbox.set_checked()
        span.add(checkbox)
        div.add(span)

        # list all of the processes with checkboxes
        pipeline_code = select.get_value()
        if pipeline_code:
            pipeline = Pipeline.get_by_code(pipeline_code)
            if not pipeline:
                print "WARNING: pipeline '%s' does not exist" % pipeline_code
                return
            process_names = pipeline.get_process_names(recurse=True)

            process_div = DivWdg()
            for process in process_names:
                checkbox = CheckboxWdg("add_initial_tasks")
                process_div.add(checkbox)
                process_div.add("&nbsp;")
                process_div.add(process)
                process_div.add(HtmlElement.br())
            div.add(process_div)

        return div
Пример #18
0
    def get_display(self):

        widget = Widget()

        div = DivWdg(css="filter_box")

        show_span = SpanWdg(css='med')
        show_span.add('Show All Types: ')
        checkbox = FilterCheckboxWdg('show_all_types')
        checkbox.set_persistence()
        show_span.add(checkbox)
        show_all_types = checkbox.get_value()
        div.add(show_span)

        span = SpanWdg(css="med")
        span.add("Search Type: ")

        select = SelectWdg("filter|search_type")
        select.add_empty_option("-- Select --")
        project = Project.get()
        project_type = project.get_base_type()
        search = Search("sthpw/search_object")
        if show_all_types:
            search.add_where('''
            namespace = '%s' or namespace = '%s' or search_type in ('sthpw/task')
            ''' % (project_type, project.get_code()))
        else:
            # show only the custom ones
            search.add_filter('namespace', project.get_code())

        search.add_order_by("title")
        sobjects = search.get_sobjects()

        select.set_sobjects_for_options(sobjects, "search_type", "title")
        #select.set_option("query", "sthpw/search_object|search_type|title")
        select.set_persistence()
        select.add_event("onchange", "document.form.submit()")
        search_type = select.get_value()
        span.add(select)
        div.add(span)

        # make sure the current selection exists
        try:
            SearchType.get(search_type)
        except SearchException as e:
            return div
        except SqlException as e:
            return div

        # add the view selector
        view_select = SelectWdg("view")
        view_select.add_empty_option("-- View --")
        view_select.add_event("onchange", "document.form.submit()")
        view_select.set_persist_on_submit()
        #view_select.set_persistence()
        span = SpanWdg(css="med")
        span.add("Defined Views: ")
        span.add(view_select)
        div.add(span)

        div.add(self.get_create_view_wdg(search_type))

        div.add(HtmlElement.br(2))

        div.add(self.get_new_tab_wdg())

        widget.add(div)

        search = Search("sthpw/widget_config")
        #search.add_user_filter()
        search.add_filter("search_type", search_type)
        search.add_where("view != 'definition' and view != 'custom'")
        #search.add_column("view")
        widget_configs = search.get_sobjects()
        if widget_configs:
            view_select.set_sobjects_for_options(widget_configs, "view",
                                                 "view")
        view = view_select.get_value()
        if not view:
            view = "custom"
            #return widget

        # get the selected widget config
        for widget_config in widget_configs:
            if widget_config.get_value("view") == view:
                break
        else:
            return widget

        # get the handler: a little HACKY.
        config_xml = widget_config.get_xml_value("config")
        handler = config_xml.get_value("config/%s/@handler" % view)

        if not search_type:
            return widget

        widget.add(HtmlElement.br())
        span = SpanWdg()
        custom_view = CustomViewWdg(search_type)
        span.add(custom_view)
        span.add_style("float: right")
        widget.add(span)

        widget.add(HtmlElement.br())
        widget.add("<h3>Example View [%s]</h3>" % view)

        # add a general filter
        filter_div = DivWdg()
        for i in range(0, 1):
            filter = GeneralFilterWdg()
            filter.set_columns_from_search_type(search_type)
            filter_div.add("Filter: ")
            filter_div.add(filter)
            #filter_div.add(IconWdg("Remove Filter", IconWdg.RETIRE))
            filter_div.add(HtmlElement.br(2))

        widget.add(filter_div)

        search = Search(search_type)
        search.set_limit(5)
        filter.alter_search(search)

        if not handler:
            if view in ["edit", "insert"]:
                table = EditWdg(search_type, view)
            else:
                table = TableWdg(search_type, view)
        else:
            table = eval("%s(search_type,view)" % handler)

        #table.alter_search(search)
        sobjects = search.get_sobjects()

        if not sobjects and view in ["edit", "insert"]:
            sobjects = [SObjectFactory.create(search_type)]
        table.set_sobjects(sobjects)
        widget.add(table)

        # show the custom properties
        widget.add("<h3>Custom Properties [%s]</h3>" % search_type)
        search = Search("prod/custom_property")
        search.add_filter("search_type", search_type)
        # This is actually reading the sthpw/custom_property conf file, weird
        table = TableWdg("prod/custom_property")
        table.set_search_limit(5)
        table.set_sobjects(search.get_sobjects())
        widget.add(table)

        return widget