예제 #1
0
    def get_info_wdg(my):

        widget = Widget()

        table = Table()
        table.set_class("minimal")
        table.add_style("font-size: 0.8em")

        context_option = my.kwargs.get('context')
        context_expr_option = my.kwargs.get('context_expr')

        pipeline_option = my.kwargs.get('pipeline') in ['true', True, 'True']
        setting_option = my.kwargs.get('setting')
        context_name = "%s|context" % my.get_input_name()
        text = None
        span1 = SpanWdg("Context", id='context_mode')
        span2 = SpanWdg("Context<br/>/Subcontext", id='subcontext_mode')
        span2.add_style('display', 'none')
        table.add_cell(span1)
        table.add_data(span2)
        if context_expr_option or context_option or setting_option:
            # add swap display for subcontext only if there is setting or context option
            swap = SwapDisplayWdg()
            table.add_data(SpanWdg(swap, css='small'))
            swap.set_display_widgets(StringWdg('[+]'), StringWdg('[-]'))
            subcontext_name = "%s|subcontext" % my.get_input_name()
            subcontext = SpanWdg('/ ', css='small')
            subcontext.add(TextWdg(subcontext_name))
            subcontext.add_style('display', 'none')
            subcontext.set_id(subcontext_name)
            on_script = "set_display_on('%s');swap_display('subcontext_mode','context_mode')" % subcontext_name
            off_script = "set_display_off('%s');get_elements('%s').set_value(''); "\
                "swap_display('context_mode','subcontext_mode')"%(subcontext_name, subcontext_name)
            swap.add_action_script(on_script, off_script)
            text = SelectWdg(context_name)
            if my.sobjects:
                text.set_sobject(my.sobjects[0])
            if context_expr_option:
                text.set_option('values_expr', context_expr_option)
            elif context_option:
                text.set_option('values', context_option)
            elif setting_option:
                text.set_option('setting', setting_option)

            td = table.add_cell(text)

            table.add_data(subcontext)

        elif pipeline_option:
            from pyasm.biz import Pipeline
            sobject = my.sobjects[0]
            pipeline = Pipeline.get_by_sobject(sobject)
            context_names = []
            process_names = pipeline.get_process_names(recurse=True)
            for process in process_names:
                context_names.append(pipeline.get_output_contexts(process))
            text = SelectWdg(context_name)
            text.set_option('values', process_names)
            table.add_cell(text)

        else:
            text = TextWdg(context_name)
            table.add_cell(text)
            hint = HintWdg('If not specified, the default is [publish]')
            table.add_data(hint)

        revision_cb = CheckboxWdg('%s|is_revision' %my.get_input_name(),\
            label='is revision', css='med')
        table.add_data(revision_cb)
        table.add_row()
        table.add_cell("Comment")
        textarea = TextAreaWdg("%s|description" % my.get_input_name())
        table.add_cell(textarea)
        widget.add(table)

        return widget
예제 #2
0
    def get_display(self):
        top = DivWdg()

        search_type = self.kwargs.get("search_type")
        view = self.kwargs.get("view")
        element_name = self.kwargs.get("element_name")

        config_view = WidgetConfigView.get_by_search_type(search_type, view)

        #inner_div = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10")
        inner_div = RoundedCornerDivWdg(hex_color_code="272727",
                                        corner_size="10")
        inner_div.set_dimensions(width_str='400px', content_height_str='600px')
        top.add(inner_div)

        # add the save button
        buttons_list = []
        buttons_list.append({
            'label': 'Save as View',
            'tip': 'Save as View',
            'bvr': {
                'cbjs_action': "alert('Not Implemented')"
            }
        })
        buttons_list.append({
            'label': 'Save as Def',
            'tip': 'Save as Definition',
            'bvr': {
                'cbjs_action': "alert('Not Implemented')"
            }
        })

        buttons = TextBtnSetWdg(float="right",
                                buttons=buttons_list,
                                spacing=6,
                                size='small',
                                side_padding=4)

        inner_div.add(buttons)

        title_div = DivWdg()
        title_div.add_style("margin-bottom: 10px")
        title_div.add_class("maq_search_bar")
        title_div.add("Element Definition")
        inner_div.add(title_div)

        test = SimpleElementDefinitionWdg(config_view=config_view,
                                          element_name=element_name)
        inner_div.add(test)

        config_title_wdg = DivWdg()
        inner_div.add(config_title_wdg)
        config_title_wdg.add("<b>Definitions in config</b>")
        config_title_wdg.add_style("margin: 15px 0px 5px 0px")

        for config in config_view.get_configs():
            view = config.get_view()
            xml = config.get_element_xml(element_name)

            config_div = DivWdg()
            inner_div.add(config_div)

            # add the title
            from pyasm.widget import SwapDisplayWdg, IconWdg

            view_div = DivWdg()
            view_div.add_class("spt_view")
            config_div.add(view_div)

            if not xml:
                icon_wdg = IconWdg("Nothing defined", IconWdg.DOT_RED)
                icon_wdg.add_style("float: right")
                view_div.add(icon_wdg)
            else:
                icon_wdg = IconWdg("Is defined", IconWdg.DOT_GREEN)
                icon_wdg.add_style("float: right")
                view_div.add(icon_wdg)

            swap = SwapDisplayWdg()
            view_div.add(swap)
            swap.add_action_script('''
                var info_wdg = bvr.src_el.getParent('.spt_view').getElement('.spt_info');
                spt.toggle_show_hide(info_wdg);
            ''')

            mode = "predefined"
            file_path = config.get_file_path()
            if not file_path:
                mode = "database"
            elif file_path == 'generated':
                mode = 'generated'

            # display the title
            view_div.add("%s" % view)
            view_div.add(" - [%s]" % mode)

            info_div = DivWdg()
            info_div.add_class("spt_info")
            info_div.add_style("margin-left: 20px")
            info_div.add_style("display: none")
            #if not xml:
            #    info_div.add_style("display: none")
            #else:
            #    swap.set_off()
            view_div.add(info_div)

            path_div = DivWdg()
            if not file_path:
                file_path = mode
            path_div.add("Defined in: %s" % file_path)
            info_div.add(path_div)

            text_wdg = TextAreaWdg()
            text_wdg.set_option("rows", 15)
            text_wdg.set_option("cols", 80)
            text_wdg.set_value(xml)
            info_div.add(text_wdg)

            #view_div.add("<hr/>")

        return top
예제 #3
0
    def get_info_wdg(my):

        widget = Widget()

        table = Table()
        table.set_class("minimal")
        table.add_style("font-size: 0.8em")

        context_option = my.kwargs.get('context')
        context_expr_option = my.kwargs.get('context_expr')
        
        pipeline_option = my.kwargs.get('pipeline') in ['true', True, 'True']
        setting_option = my.kwargs.get('setting')
        context_name = "%s|context" % my.get_input_name()
        text = None 
        span1 = SpanWdg("Context", id='context_mode')
        span2 = SpanWdg("Context<br/>/Subcontext", id='subcontext_mode')
        span2.add_style('display','none')
        table.add_cell(span1)
        table.add_data(span2)
        if context_expr_option or context_option or setting_option:
            # add swap display for subcontext only if there is setting or context option
            swap = SwapDisplayWdg()
            table.add_data(SpanWdg(swap, css='small'))
            swap.set_display_widgets(StringWdg('[+]'), StringWdg('[-]'))
            subcontext_name = "%s|subcontext" % my.get_input_name()
            subcontext = SpanWdg('/ ', css='small')
            subcontext.add(TextWdg(subcontext_name))
            subcontext.add_style('display','none')
            subcontext.set_id(subcontext_name)
            on_script = "set_display_on('%s');swap_display('subcontext_mode','context_mode')"%subcontext_name
            off_script = "set_display_off('%s');get_elements('%s').set_value(''); "\
                "swap_display('context_mode','subcontext_mode')"%(subcontext_name, subcontext_name)
            swap.add_action_script(on_script, off_script)
            text = SelectWdg(context_name)
            if my.sobjects:
                text.set_sobject(my.sobjects[0])
            if context_expr_option:
                text.set_option('values_expr', context_expr_option)
            elif context_option:
                text.set_option('values', context_option)
            elif setting_option:
                text.set_option('setting', setting_option)
                    

            td = table.add_cell(text)
            
            table.add_data(subcontext)
            
        elif pipeline_option:
            from pyasm.biz import Pipeline
            sobject = my.sobjects[0]
            pipeline = Pipeline.get_by_sobject(sobject)
            context_names = []
            process_names = pipeline.get_process_names(recurse=True)
            for process in process_names:
                context_names.append(pipeline.get_output_contexts(process))
            text = SelectWdg(context_name)
            text.set_option('values', process_names)
            table.add_cell(text)
            
        else:
            text = TextWdg(context_name)
            table.add_cell(text)
            hint = HintWdg('If not specified, the default is [publish]')
            table.add_data(hint)
      
        revision_cb = CheckboxWdg('%s|is_revision' %my.get_input_name(),\
            label='is revision', css='med')
        table.add_data(revision_cb)
        table.add_row()
        table.add_cell("Comment")
        textarea = TextAreaWdg("%s|description"% my.get_input_name())
        table.add_cell(textarea)
        widget.add(table)

        return widget
예제 #4
0
    def get_display(my):
        top = DivWdg()


        search_type = my.kwargs.get("search_type")
        view = my.kwargs.get("view")
        element_name = my.kwargs.get("element_name")

        config_view = WidgetConfigView.get_by_search_type(search_type, view)


        #inner_div = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10")
        inner_div = RoundedCornerDivWdg(hex_color_code="272727",corner_size="10")
        inner_div.set_dimensions( width_str='400px', content_height_str='600px' )
        top.add(inner_div)


        # add the save button
        buttons_list = []
        buttons_list.append( {'label': 'Save as View', 'tip': 'Save as View',
                'bvr': { 'cbjs_action': "alert('Not Implemented')" }
        })
        buttons_list.append( {'label': 'Save as Def', 'tip': 'Save as Definition',
                'bvr': { 'cbjs_action': "alert('Not Implemented')" }
        })

        buttons = TextBtnSetWdg( float="right", buttons=buttons_list,
                                 spacing=6, size='small', side_padding=4 )


        inner_div.add(buttons)


        title_div = DivWdg()
        title_div.add_style("margin-bottom: 10px")
        title_div.add_class("maq_search_bar")
        title_div.add("Element Definition")
        inner_div.add(title_div)



        test = SimpleElementDefinitionWdg(config_view=config_view, element_name=element_name)
        inner_div.add(test)



        config_title_wdg = DivWdg()
        inner_div.add(config_title_wdg)
        config_title_wdg.add("<b>Definitions in config</b>")
        config_title_wdg.add_style("margin: 15px 0px 5px 0px")

        for config in config_view.get_configs():
            view = config.get_view()
            xml = config.get_element_xml(element_name)

            config_div = DivWdg()
            inner_div.add(config_div)



            # add the title
            from pyasm.widget import SwapDisplayWdg, IconWdg

            view_div = DivWdg()
            view_div.add_class("spt_view")
            config_div.add(view_div)

            if not xml:
                icon_wdg = IconWdg( "Nothing defined", IconWdg.DOT_RED )
                icon_wdg.add_style("float: right")
                view_div.add(icon_wdg)
            else:
                icon_wdg = IconWdg( "Is defined", IconWdg.DOT_GREEN )
                icon_wdg.add_style("float: right")
                view_div.add(icon_wdg)

            swap = SwapDisplayWdg()
            view_div.add(swap)
            swap.add_action_script('''
                var info_wdg = bvr.src_el.getParent('.spt_view').getElement('.spt_info');
                spt.toggle_show_hide(info_wdg);
            ''')


            mode = "predefined"
            file_path = config.get_file_path()
            if not file_path:
                mode = "database"
            elif file_path == 'generated':
                mode = 'generated'
                

            # display the title
            view_div.add("%s" % view)
            view_div.add(" - [%s]" % mode)

            info_div = DivWdg()
            info_div.add_class("spt_info")
            info_div.add_style("margin-left: 20px")
            info_div.add_style("display: none")
            #if not xml:
            #    info_div.add_style("display: none")
            #else:
            #    swap.set_off()
            view_div.add(info_div)

            path_div = DivWdg()
            if not file_path:
                file_path = mode
            path_div.add("Defined in: %s" % file_path)
            info_div.add(path_div)

            text_wdg = TextAreaWdg()
            text_wdg.set_option("rows", 15)
            text_wdg.set_option("cols", 80)
            text_wdg.set_value(xml)
            info_div.add(text_wdg)

            #view_div.add("<hr/>")

        return top