Example #1
0
    def get_file_type_wdg(my):
        '''drop down which selects which file type to export to'''
        # add a filter
        div = DivWdg()

        filter_div = FloatDivWdg(HtmlElement.b("File Type:"), width="15em")
        div.add(filter_div)

        select = SelectWdg()
        select.set_name("file_type")
        select.set_id("file_type")

        app = WebContainer.get_web().get_selected_app()

        if app == 'Maya':
            select.set_option("values", "mayaAscii|mayaBinary|obj|collada")
            select.set_option("labels", "Maya Ascii (.ma)|Maya Binary (.mb)|Wavefront .obj|Collada (.dae)")
        elif app == 'Houdini':
            select.set_option("values", "otl")
            select.set_option("labels", "Houdini Digital Asset(.otl)")
        elif app == 'XSI':
            select.set_option("values", "emdl|dotXSI|obj")
            select.set_option("labels", "3D Model (.emdl)|SoftImage dotXSI (.xsi)|Wavefront .obj")
        else:
            select.set_option("values", "mayaAscii|mayaBinary|obj|collada")
            select.set_option("labels", "Maya Ascii (.ma)|Maya Binary (.mb)|Wavefront .obj|Collada (.dae)")

        select.add_style("font-size: 0.8em")
        select.add_style("margin-top: 5px")
        select.add_style("margin-right: 10px")
        select.set_persistence()
        
        div.add(select)
        return div
Example #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
Example #3
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
    def get_file_type_wdg(my):
        '''drop down which selects which file type to export to'''
        # add a filter
        div = DivWdg()

        filter_div = FloatDivWdg(HtmlElement.b("File Type:"), width="15em")
        div.add(filter_div)

        select = SelectWdg()
        select.set_name("file_type")
        select.set_id("file_type")

        app = WebContainer.get_web().get_selected_app()

        if app == 'Maya':
            select.set_option("values", "mayaAscii|mayaBinary|obj|collada")
            select.set_option(
                "labels",
                "Maya Ascii (.ma)|Maya Binary (.mb)|Wavefront .obj|Collada (.dae)"
            )
        elif app == 'Houdini':
            select.set_option("values", "otl")
            select.set_option("labels", "Houdini Digital Asset(.otl)")
        elif app == 'XSI':
            select.set_option("values", "emdl|dotXSI|obj")
            select.set_option(
                "labels",
                "3D Model (.emdl)|SoftImage dotXSI (.xsi)|Wavefront .obj")
        else:
            select.set_option("values", "mayaAscii|mayaBinary|obj|collada")
            select.set_option(
                "labels",
                "Maya Ascii (.ma)|Maya Binary (.mb)|Wavefront .obj|Collada (.dae)"
            )

        select.add_style("font-size: 0.8em")
        select.add_style("margin-top: 5px")
        select.add_style("margin-right: 10px")
        select.set_persistence()

        div.add(select)
        return div
Example #5
0
    def get_filter_wdg(my):

        div = DivWdg()
        div.add_style("padding: 10px")
        div.add_style("margin: -10 -10 10 -10")
        div.add_style("min-width: 600px")
        div.add_class("spt_view_manager_filter")

        from tactic.ui.app import HelpButtonWdg

        help_wdg = HelpButtonWdg(alias="view-manager|what-are-views")
        div.add(help_wdg)
        help_wdg.add_style("float: right")

        div.add("<b>Search Type:</b> ")

        div.add_gradient("background", "background", -10)

        security = Environment.get_security()
        project = Project.get()
        if security.check_access("builtin", "view_site_admin", "allow"):
            search_type_objs = project.get_search_types(include_sthpw=True, include_config=True)
        else:
            search_type_objs = project.get_search_types()

        search_types = [x.get_value("search_type") for x in search_type_objs]
        titles = ["%s (%s)" % (x.get_value("search_type"), x.get_value("title")) for x in search_type_objs]

        select = SelectWdg(name="search_type")
        select.set_option("values", search_types)
        select.set_option("labels", titles)
        select.add_empty_option("-- Select --")
        select.set_persistence()
        # select.set_persist_on_submit()

        # security = Environment.get_security()
        # if security.check_access("builtin", "view_site_admin", "allow"):
        #    select_mode =  SearchTypeSelectWdg.ALL
        # else:
        #    select_mode =  SearchTypeSelectWdg.ALL_BUT_STHPW
        # select = SearchTypeSelectWdg(name='search_type', \
        #    mode=select_mode)

        behavior = {
            "type": "change",
            "cbjs_action": """
            var manager_top = bvr.src_el.getParent(".spt_view_manager_top");

            var input = spt.api.Utility.get_input(manager_top, 'search_type');
            var view_input = spt.api.Utility.get_input(manager_top, 'view');
            var view_input_value = '';
            if (view_input != null) {
                view_input_value = view_input.value;
            }
            var values = {'search_type': input.value, 'view': view_input_value, 'is_refresh': 'true'}; 
            spt.panel.refresh(manager_top, values);"""
            # //spt.panel.refresh(manager_top, values);'''
        }
        select.add_behavior(behavior)
        select.set_value(my.search_type)
        div.add(select)

        if not my.search_type:
            content = DivWdg()
            content.add_style("width: 400px")
            content.add_style("height: 400px")
            div.add(content)
            content.add_style("padding: 20px")
            content.add(IconWdg("WARNING", IconWdg.WARNING))
            content.add("No Search Type Selected")
            content.add_border()
            content.add_style("margin-top: 20px")
            content.add_color("background", "background")
            content.add_style("font-weight: bold")

            return div

        div.add("&nbsp;&nbsp;&nbsp;")
        div.add("<b>View: </b>")
        view_wdg = SelectWdg("view")
        view_wdg.set_value(my.view)
        view_wdg.add_empty_option("-- Select --")
        view_wdg.add_behavior(behavior)
        div.add(view_wdg)

        search = Search("config/widget_config")
        search.add_filter("search_type", my.search_type)
        db_configs = search.get_sobjects()

        views = set()
        for db_config in db_configs:
            view = db_config.get_value("view")
            if view.startswith("link_search:"):
                continue
            views.update([view])

        # print "search_type: ", my.search_type
        # print "view: ", views, my.view

        if my.search_type and my.view:
            config_view = WidgetConfigView.get_by_search_type(my.search_type, my.view)

            configs = config_view.get_configs()
            for x in configs:
                view = x.get_view()
                file_path = x.get_file_path()
                if view != my.view:
                    continue
                if file_path and file_path.endswith("DEFAULT-conf.xml"):
                    continue
                config_views = x.get_all_views()
                views.update(config_views)

        views_list = list(views)
        views_list.sort()
        view_wdg.set_option("values", views_list)

        return div
    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
Example #7
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
Example #8
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
Example #9
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
Example #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)
Example #11
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)
Example #12
0
    def get_filter_wdg(my):

        div = DivWdg()
        div.add_style("padding: 10px")
        div.add_style("margin: -10 -10 10 -10")
        div.add_style("min-width: 600px")
        div.add_class("spt_view_manager_filter")



        from tactic.ui.app import HelpButtonWdg
        help_wdg = HelpButtonWdg(alias="view-manager|what-are-views")
        div.add(help_wdg)
        help_wdg.add_style("float: right")





        div.add('<b>Search Type:</b> ')

        div.add_gradient("background", "background", -10)


        security = Environment.get_security()
        project = Project.get()
        if security.check_access("builtin", "view_site_admin", "allow"):
            search_type_objs = project.get_search_types(include_sthpw=True, include_config=True)
        else:
            search_type_objs = project.get_search_types()

        search_types = [x.get_value("search_type") for x in search_type_objs]
        titles = ["%s (%s)" % (x.get_value("search_type"), x.get_value("title")) for x in search_type_objs]


        select = SelectWdg(name='search_type')
        select.set_option('values', search_types)
        select.set_option('labels', titles)
        select.add_empty_option('-- Select --')
        select.set_persistence()
        #select.set_persist_on_submit()


        #security = Environment.get_security()
        #if security.check_access("builtin", "view_site_admin", "allow"):
        #    select_mode =  SearchTypeSelectWdg.ALL
        #else:
        #    select_mode =  SearchTypeSelectWdg.ALL_BUT_STHPW
        #select = SearchTypeSelectWdg(name='search_type', \
        #    mode=select_mode)

        behavior = {'type': 'change', 'cbjs_action': '''
            var manager_top = bvr.src_el.getParent(".spt_view_manager_top");

            var input = spt.api.Utility.get_input(manager_top, 'search_type');
            var view_input = spt.api.Utility.get_input(manager_top, 'view');
            var view_input_value = '';
            if (view_input != null) {
                view_input_value = view_input.value;
            }
            var values = {'search_type': input.value, 'view': view_input_value, 'is_refresh': 'true'}; 
            spt.panel.refresh(manager_top, values);'''
            #//spt.panel.refresh(manager_top, values);'''
        }
        select.add_behavior(behavior)
        select.set_value(my.search_type)
        div.add(select)

        if not my.search_type:
            content = DivWdg()
            content.add_style("width: 400px")
            content.add_style("height: 400px")
            div.add(content)
            content.add_style("padding: 20px")
            content.add( IconWdg("WARNING", IconWdg.WARNING) )
            content.add("No Search Type Selected")
            content.add_border()
            content.add_style("margin-top: 20px")
            content.add_color("background", "background")
            content.add_style("font-weight: bold")

            return div

        div.add('&nbsp;&nbsp;&nbsp;')
        div.add('<b>View: </b>')
        view_wdg = SelectWdg("view")
        view_wdg.set_value(my.view)
        view_wdg.add_empty_option("-- Select --")
        view_wdg.add_behavior(behavior)
        div.add(view_wdg)


        search = Search("config/widget_config")
        search.add_filter("search_type", my.search_type)
        db_configs = search.get_sobjects()


        views = set()
        for db_config in db_configs:
            view = db_config.get_value("view")
            if view.startswith('link_search:'):
                continue
            views.update([view])

        #print "search_type: ", my.search_type
        #print "view: ", views, my.view

        if my.search_type and my.view:
            config_view = WidgetConfigView.get_by_search_type(my.search_type, my.view)

            configs = config_view.get_configs()
            for x in configs:
                view = x.get_view()
                file_path = x.get_file_path()
                if view != my.view:
                    continue
                if file_path and file_path.endswith("DEFAULT-conf.xml"):
                    continue
                config_views = x.get_all_views()
                views.update(config_views)

        views_list = list(views)
        views_list.sort()
        view_wdg.set_option("values", views_list)


        return div
Example #13
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
Example #14
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