コード例 #1
0
ファイル: shelf_wdg.py プロジェクト: 0-T-0/TACTIC
    def add_file_behaviors(my, item_div, dirname, basename):
        item_div.add_class("spt_script_item")
        if not dirname:
            path = "///%s" % (basename)
        else:
            path = "%s/%s" % (dirname, basename)
        
        scripts = my.kwargs.get("scripts")
        script = scripts.get(path)
        if not script:
            item_div.add_style("background-color", "red")
            item_div.add_behavior({"type": "click_up",
                                 "cbjs_action" : '''spt.alert("Please remove leading / in this script path's Title attribute by using the Manage button.")'''})
            item_div.add_attr("title", "Please remove special characters like / in this script path")
            return
           
        script_code = script.get("code")
        language = script.get("language")
        item_div.add_attr("spt_script_code", script_code)
        item_div.add_style("background", "transparent")

        if language:
            span = SpanWdg()
            span.add_style("font-size: 9px")
            span.add_style("opacity: 0.2")
            span.add(" &nbsp; <i>(%s)</i>" % language)
            item_div.add(span)
コード例 #2
0
    def get_input_widget_with_label(self, label, id, width):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        section_span.add(label)

        section_span.add(get_text_input_wdg(id, get_attribute_or_none(self, id), width))

        return section_span
コード例 #3
0
    def get_save_button(self):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        save_button = ButtonNewWdg(title='Save', icon='SAVE')
        save_button.add_class('save_button')
        save_button.add_behavior(self.get_save_behavior(self.metadata_report_sobject.get_code()))

        section_span.add(save_button)

        return section_span
コード例 #4
0
ファイル: shadowbox_wdg.py プロジェクト: 0-T-0/TACTIC
 def _get_loading_span(my):
     span = SpanWdg()
     span.add_style("display","none")
     img = HtmlElement.img('/context/icons/common/loading.gif')
     img.add_style("height","10px")
     msg_span = SpanWdg('loading')
     msg_span.set_class('small')
     span.add(msg_span)
     span.add(img) 
     span.set_id(my.img_span_name)
     return span
コード例 #5
0
    def get_add_row_button(self):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        add_row_button = ButtonNewWdg(title='Add Row', icon='ADD')
        add_row_button.add_class('add_row_button')
        add_row_button.add_behavior(get_add_audio_configuration_line_behavior(self.element_evaluation_code))

        section_span.add(add_row_button)

        return section_span
コード例 #6
0
    def get_save_as_new_version_button(self):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        save_as_new_version_button = ButtonNewWdg(title='Save As New Version', icon='INSERT')
        save_as_new_version_button.add_class('save_as_new_version_button')
        save_as_new_version_button.add_behavior(self.get_save_as_new_version_behavior())

        section_span.add(save_as_new_version_button)

        return section_span
コード例 #7
0
    def get_save_button(self):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        save_button = ButtonNewWdg(title='Save', icon='SAVE')
        save_button.add_class('save_button')
        save_button.add_behavior(self.get_save_behavior(self.element_eval_sobject.get_code()))

        section_span.add(save_button)

        return section_span
コード例 #8
0
    def get_export_to_pdf_button(self):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        export_to_pdf_button = ButtonNewWdg(title='Export to PDF', icon='ARROW_DOWN')
        export_to_pdf_button.add_class('export_to_pdf_button')
        export_to_pdf_button.add_behavior(self.get_export_to_pdf_behavior(self.metadata_report_sobject.get_code()))

        section_span.add(export_to_pdf_button)

        return section_span
コード例 #9
0
    def get_save_new_button(self):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        save_new_button = ButtonNewWdg(title='Save', icon='NEW')
        save_new_button.add_class('save_due_date')
        save_new_button.add_behavior(self.get_save_new_behavior())

        section_span.add(save_new_button)

        return section_span
コード例 #10
0
    def get_remove_row_button(self, line_code):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        remove_row_button = ButtonNewWdg(title='Remove Row', icon='DELETE')
        remove_row_button.add_class('remove_row_button')
        remove_row_button.add_behavior(get_remove_audio_configuration_line_behavior(self.element_evaluation_code,
                                                                                    line_code))

        section_span.add(remove_row_button)

        return section_span
コード例 #11
0
    def get_new_tab_wdg(my):
        widget = Widget()

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

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

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

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

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

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

        widget.add(div)

        return widget
コード例 #12
0
    def get_add_row_button(self):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        add_row_button = ButtonNewWdg(title='Add Row', icon='ADD')
        add_row_button.add_class('add_row_button')
        add_row_button.add_behavior(
            get_add_audio_configuration_line_behavior(
                self.element_evaluation_code))

        section_span.add(add_row_button)

        return section_span
コード例 #13
0
    def get_remove_row_button(self, line_code):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        remove_row_button = ButtonNewWdg(title='Remove Row', icon='DELETE')
        remove_row_button.add_class('remove_row_button')
        remove_row_button.add_behavior(
            get_remove_audio_configuration_line_behavior(
                self.element_evaluation_code, line_code))

        section_span.add(remove_row_button)

        return section_span
コード例 #14
0
    def get_export_to_pdf_button(self):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        export_to_pdf_button = ButtonNewWdg(title='Export to PDF',
                                            icon='ARROW_DOWN')
        export_to_pdf_button.add_class('export_to_pdf_button')
        export_to_pdf_button.add_behavior(
            self.get_export_to_pdf_behavior(
                self.metadata_report_sobject.get_code()))

        section_span.add(export_to_pdf_button)

        return section_span
コード例 #15
0
ファイル: custom_view_app_wdg.py プロジェクト: mincau/TACTIC
    def get_new_tab_wdg(self):
        widget = Widget()

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

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

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

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


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

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

        widget.add(div)

        return widget
コード例 #16
0
    def get_client_section(self):
        section_div = DivWdg()

        client_span = SpanWdg()
        client_span.add_style('display', 'inline-block')
        client_span.add('Client: ')
        client_span.add(self.get_client_select())

        status_span = SpanWdg()
        status_span.add_style('display', 'inline-block')
        status_span.add('Status: ')
        status_span.add(self.get_status_select())

        section_div.add(client_span)
        section_div.add(status_span)

        return section_div
コード例 #17
0
ファイル: clipboard_wdg.py プロジェクト: zieglerm/TACTIC
    def get_display(self):
        ajax = AjaxCmd()
        ajax.register_cmd("pyasm.widget.ClipboardAddCbk")
        progress = ajax.generate_div()
        progress.add_style('display', 'inline')

        search_type = self.sobject.get_search_type()
        search_id = self.sobject.get_id()
        ajax.set_option("search_type", search_type)
        ajax.set_option("search_id", search_id)

        search_key = self.sobject.get_search_key()

        span = SpanWdg()
        span.set_id("clipboard_%s" % search_key)
        span.add_style("display: none")

        checkbox = CheckboxWdg()
        checkbox.add_style("vertical-align: top")
        checkbox.add_style("width: 7px")

        checkbox.add_event("onclick",
                           "%s" % ajax.get_on_script(show_progress=False))
        #checkbox.add_event("onmouseover", "this.style.width=15")
        #checkbox.add_event("onmouseout", "this.style.width=7")

        # FIXME :DEPRECATED
        """
        event = WebContainer.get_event_container()
        caller = event.get_event_caller(ClipboardWdg.EVENT_ID)

        from file_wdg import ThumbWdg
        post_script = [caller]

        if self.thumbnail_mode: 
            post_script.append( ThumbWdg.get_refresh_script(\
                self.sobject, self.icon_size, show_progress=False) )
        progress.set_post_ajax_script(';'.join(post_script))
        
        if Clipboard.is_selected(self.sobject):
            checkbox.set_option("checked", "1")
        """
        span.add(checkbox)
        span.add(progress)

        return span
コード例 #18
0
    def get_client_section(self):
        section_div = DivWdg()

        client_span = SpanWdg()
        client_span.add_style('display', 'inline-block')
        client_span.add('Client: ')
        client_span.add(self.get_client_select())

        status_span = SpanWdg()
        status_span.add_style('display', 'inline-block')
        status_span.add('Status: ')
        status_span.add(self.get_status_select())

        section_div.add(client_span)
        section_div.add(status_span)

        return section_div
コード例 #19
0
ファイル: clipboard_wdg.py プロジェクト: mincau/TACTIC
    def get_display(self):
        ajax = AjaxCmd()
        ajax.register_cmd("pyasm.widget.ClipboardAddCbk")
        progress = ajax.generate_div()
        progress.add_style('display', 'inline')

        search_type = self.sobject.get_search_type()
        search_id = self.sobject.get_id()
        ajax.set_option("search_type", search_type)
        ajax.set_option("search_id", search_id)

        search_key = self.sobject.get_search_key()

        span = SpanWdg()
        span.set_id("clipboard_%s" % search_key)
        span.add_style("display: none")

        checkbox = CheckboxWdg()
        checkbox.add_style("vertical-align: top")
        checkbox.add_style("width: 7px")

        checkbox.add_event("onclick", "%s" % ajax.get_on_script(show_progress=False) )
        #checkbox.add_event("onmouseover", "this.style.width=15")
        #checkbox.add_event("onmouseout", "this.style.width=7")
        
        # FIXME :DEPRECATED
        """
        event = WebContainer.get_event_container()
        caller = event.get_event_caller(ClipboardWdg.EVENT_ID)

        from file_wdg import ThumbWdg
        post_script = [caller]

        if self.thumbnail_mode: 
            post_script.append( ThumbWdg.get_refresh_script(\
                self.sobject, self.icon_size, show_progress=False) )
        progress.set_post_ajax_script(';'.join(post_script))
        
        if Clipboard.is_selected(self.sobject):
            checkbox.set_option("checked", "1")
        """
        span.add(checkbox)
        span.add(progress)

        return span
コード例 #20
0
ファイル: error_wdg.py プロジェクト: hellios78/TACTIC
    def get_display(my):

        box = DivWdg(css="login")

        box.add_style("margin-top: auto")
        box.add_style("margin-bottom: auto")
        box.add_style("text-align: center")

        script = HtmlElement.script(
            """function login(e) {
                if (!e) var e = window.event;
                if (e.keyCode == 13) {
                submit_icon_button('Submit');
                }}
                """
        )

        div = DivWdg()
        div.add_style("margin: 0px 0px")
        div.add_class("centered")

        div.add(HtmlElement.br(6))
        sthpw = SpanWdg("SOUTHPAW TECHNOLOGY INC", css="login_sthpw")
        sthpw.add_style("color: #333")
        div.add(sthpw)
        div.add(HtmlElement.br(2))

        div.add(my.get_error_wdg())
        box.add(div)

        widget = Widget()
        # widget.add( HtmlElement.br(3) )
        table = Table()
        table.add_style("width: 100%")
        table.add_style("height: 85%")
        table.add_row()
        td = table.add_cell()
        td.add_style("vertical-align: middle")
        td.add_style("text-align: center")
        td.add_style("background: transparent")
        td.add(box)
        widget.add(table)

        return widget
コード例 #21
0
    def get_title_input_wdg(self):
        section_span = SpanWdg()
        section_span.add_style('display', 'inline-block')

        section_span.add('Title: ')

        textbox_wdg = TextInputWdg()
        textbox_wdg.set_id('title_data')
        textbox_wdg.set_name('title_data')
        textbox_wdg.add_style('width', '{0}px'.format(200))

        try:
            textbox_wdg.set_value(self.prequal_eval_sobject.get('title'))
        except AttributeError:
            pass

        section_span.add(textbox_wdg)

        return section_span
コード例 #22
0
    def get_display(my):

        box = DivWdg(css='login')

        box.add_style("margin-top: auto")
        box.add_style("margin-bottom: auto")
        box.add_style("text-align: center")

        script = HtmlElement.script('''function login(e) {
                if (!e) var e = window.event;
                if (e.keyCode == 13) {
                submit_icon_button('Submit');
                }}
                ''')

        div = DivWdg()
        div.add_style("margin: 0px 0px")
        div.add_class("centered")

        div.add(HtmlElement.br(6))
        sthpw = SpanWdg("SOUTHPAW TECHNOLOGY INC", css="login_sthpw")
        sthpw.add_style("color: #333")
        div.add(sthpw)
        div.add(HtmlElement.br(2))

        div.add(my.get_error_wdg())
        box.add(div)

        widget = Widget()
        #widget.add( HtmlElement.br(3) )
        table = Table()
        table.add_style("width: 100%")
        table.add_style("height: 85%")
        table.add_row()
        td = table.add_cell()
        td.add_style("vertical-align: middle")
        td.add_style("text-align: center")
        td.add_style("background: transparent")
        td.add(box)
        widget.add(table)

        return widget
コード例 #23
0
ファイル: flash_render_wdg.py プロジェクト: hellios78/TACTIC
    def get_title(my):
        widget = Widget()
        """
        search_key_wdg = HiddenWdg('search_key')
        search_key_wdg.get_value()
        widget.add(search_key_wdg)
        """
        WebContainer.register_cmd("pyasm.flash.widget.RenderCbk")
        if not my.get_option("no_button"):
            render_button = IconSubmitWdg("Render", IconWdg.RENDER, True, add_hidden=True)

            widget.add(render_button)
        else:
            widget.add("Frame Info")

        float_button = IconSubmitWdg("Render", IconWdg.RENDER, add_hidden=False)
        span = SpanWdg(float_button, css="med")
        span.add_style("border-left", "1px solid #777")
        WebContainer.get_float_menu().add(span)
        return widget
コード例 #24
0
    def add_file_behaviors(my, item_div, dirname, basename):
        item_div.add_class("spt_script_item")
        if not dirname:
            path = "///%s" % (basename)
        else:
            path = "%s/%s" % (dirname, basename)

        scripts = my.kwargs.get("scripts")
        script = scripts.get(path)
        script_code = script.get("code")
        language = script.get("language")
        item_div.add_attr("spt_script_code", script_code)
        item_div.add_style("background", "transparent")

        if language:
            span = SpanWdg()
            span.add_style("font-size: 9px")
            span.add_style("opacity: 0.2")
            span.add(" &nbsp; <i>(%s)</i>" % language)
            item_div.add(span)
コード例 #25
0
ファイル: shelf_wdg.py プロジェクト: nuxping/TACTIC
    def add_file_behaviors(my, item_div, dirname, basename):
        item_div.add_class("spt_script_item")
        if not dirname:
            path = "///%s" % (basename)
        else:
            path = "%s/%s" % (dirname, basename)

        scripts = my.kwargs.get("scripts")
        script = scripts.get(path)
        script_code = script.get("code")
        language = script.get("language")
        item_div.add_attr("spt_script_code", script_code)
        item_div.add_style("background", "transparent")

        if language:
            span = SpanWdg()
            span.add_style("font-size: 9px")
            span.add_style("opacity: 0.2")
            span.add(" &nbsp; <i>(%s)</i>" % language)
            item_div.add(span)
コード例 #26
0
    def get_link_wdg(my, section_id, target_id, title, options):
        view_link_wdg = SpanWdg(css="hand")
        view_link_wdg.add_class("SPT_DTS")
        view_link_wdg.add_style("color: #292929")
        view_link_wdg.add_event("onmouseover",
                                "this.style.background='#696969'")
        view_link_wdg.add_event("onmouseout",
                                "this.style.background='#949494'")

        view_link_wdg.add(title)

        path = title
        options['path'] = "/%s" % title

        if not options.get('class_name'):
            options['class_name'] = "tactic.ui.panel.ViewPanelWdg"

        behavior = {
            'type': 'click_up',
            'cbfn_action': 'spt.side_bar.display_link_cbk',
            'target_id': target_id,
            'title': title,
            'options': options,
        }
        view_link_wdg.add_behavior(behavior)

        options2 = options.copy()
        options2['inline_search'] = "true"

        behavior = {
            'type': 'click_up',
            'modkeys': 'SHIFT',
            'cbfn_action': 'spt.side_bar.display_link_cbk',
            'is_popup': 'true',
            'target_id': path,
            'title': title,
            'options': options2,
        }
        view_link_wdg.add_behavior(behavior)

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

        float_button = IconSubmitWdg("Render", IconWdg.RENDER, add_hidden=False)
        span = SpanWdg(float_button, css='med')
        span.add_style("border-left", "1px solid #777")
        WebContainer.get_float_menu().add(span)
        return widget
コード例 #28
0
ファイル: schema_section_wdg.py プロジェクト: blezek/TACTIC
    def get_link_wdg(my, section_id, target_id, title, options):
        view_link_wdg = SpanWdg(css="hand")
        view_link_wdg.add_class("SPT_DTS")
        view_link_wdg.add_style("color: #292929")
        view_link_wdg.add_event("onmouseover", "this.style.background='#696969'")
        view_link_wdg.add_event("onmouseout", "this.style.background='#949494'")

        view_link_wdg.add(title)

        path = title
        options['path'] = "/%s" % title


        if not options.get('class_name'):
            options['class_name'] = "tactic.ui.panel.ViewPanelWdg"

        behavior = {
            'type':         'click_up',
            'cbfn_action':  'spt.side_bar.display_link_cbk',
            'target_id':    target_id,
            'title':        title,
            'options':      options,
        }
        view_link_wdg.add_behavior( behavior )

        options2 = options.copy()
        options2['inline_search'] = "true"

        behavior = {
            'type':         'click_up',
            'modkeys':      'SHIFT',
            'cbfn_action':  'spt.side_bar.display_link_cbk',
            'is_popup':     'true',
            'target_id':    path,
            'title':        title,
            'options':      options2,
        }
        view_link_wdg.add_behavior( behavior )

        return view_link_wdg
コード例 #29
0
ファイル: base_section_wdg.py プロジェクト: zieglerm/TACTIC
    def get_display(self):
        self.config_search_type = self.kwargs.get("config_search_type")
        if not self.config_search_type:
            self.config_search_type = "SideBarWdg"

        title = self.kwargs.get('title')
        config = self.kwargs.get('config')
        view = self.kwargs.get('view')
        width = self.kwargs.get('width')
        #sortable = self.kwargs.get('sortable')
        if not width:
            width = "175"

        self.prefix = self.kwargs.get("prefix")
        if not self.prefix:
            self.prefix = "side_bar"

        self.mode = self.kwargs.get("mode")
        if not self.mode:
            self.mode = 'view'

        self.default = self.kwargs.get('default') == 'True'

        div = DivWdg()
        div.add_class("spt_section_top")
        div.set_attr("SPT_ACCEPT_DROP", "manageSideBar")

        # create the top widgets
        label = SpanWdg()
        label.add(title)
        label.add_style("font-size: 1.1em")
        section_div = LabeledHidableWdg(label=label)
        div.add(section_div)

        section_div.set_attr('spt_class_name',
                             Common.get_full_class_name(self))
        for name, value in self.kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        bgcolor = label.get_color("background3")
        project_div = RoundedCornerDivWdg(hex_color_code=bgcolor,
                                          corner_size="10")
        project_div.set_dimensions(width_str='%spx' % width,
                                   content_height_str='100px')
        content_div = project_div.get_content_wdg()

        #project_div = DivWdg()
        #content_div = project_div

        section_div.add(project_div)

        content_div.add_class("spt_side_bar_content")
        content_div.add_attr("spt_view", view)

        if type(view) in types.StringTypes:
            view = [view]

        view_margin_top = '4px'

        web = WebContainer.get_web()
        for viewx in view:
            config = self.get_config(self.config_search_type,
                                     viewx,
                                     default=self.default)
            if not config:
                continue

            # make up a title
            title = DivWdg()
            title.add_gradient("background",
                               "side_bar_title",
                               0,
                               -15,
                               default="background")
            title.add_color("color", "side_bar_title_color", default="color")
            title.add_styles(
                "margin-top: %s; margin-bottom: 3px; vertical-align: middle" %
                view_margin_top)
            if not web.is_IE():
                title.add_styles("margin-left: -5px; margin-right: -5px;")
            title.add_looks("navmenu_header")
            title.add_style("height: 18px")
            title.add_style("padding-top: 2px")
            """
            title = DivWdg()
            title.add_styles( "margin-top: %s; margin-bottom: 3px; vertical-align: middle" % view_margin_top )
            if not web.is_IE():
                title.add_styles( "margin-left: -10px; margin-right: -10px;")
            title.add_looks( "navmenu_header" )
            """

            # FIXME: not sure if this logic should be here. It basically
            # makes special titles for certain view names
            view_attrs = config.get_view_attributes()
            title_str = view_attrs.get("title")
            if not title_str:
                if viewx.startswith("self_view_"):
                    title_str = "My Views"
                else:
                    title_str = viewx

            title_str = Common.get_display_title(title_str)

            title_label = SpanWdg()
            title_label.add_styles("margin-left: 6px; padding-bottom: 2px;")
            title_label.add_looks("fnt_title_5 fnt_bold")
            title_label.add(title_str)
            title.add(title_label)

            content_div.add(title)

            info = {'counter': 10, 'view': viewx}
            self.generate_section(config, content_div, info)
            error_list = Container.get_seq(self.ERR_MSG)
            if error_list:
                span = SpanWdg()
                span.add_style('background', 'red')
                span.add('<br/>'.join(error_list))
                content_div.add(span)
                Container.clear_seq(self.ERR_MSG)
            self.add_dummy(config, content_div)

        return div
コード例 #30
0
    def get_value(self, name=None):
        if not name:
            name = self.get_name()

        div = DivWdg()
        div.add_style("display: inline-block")

        value = super(LoginTableElementWdg, self).get_value(name)
        if value:
            user = Search.get_by_code("sthpw/login", value)
            if user:
                value = user.get_value("display_name") or value

        #return value

        self.sobject = self.get_current_sobject()

        if self.is_editable() and not value:
            empty = SpanWdg()
            div.add(empty)
            div.add_style("text-align: center")
            div.add_style("width: 100%")
            div.add_style("white-space: nowrap")
            empty.add("--Select--")
            empty.add_style("opacity: 0.5")
            return div

        div.add(value)

        # display a link if specified

        from pyasm.biz import ProjectSetting
        link_expr = ProjectSetting.get_value_by_key(
            "task/assigned/link_expression")
        if not link_expr:
            link_expr = "@SOBJECT(sthpw/login)"

        if self.sobject and link_expr:
            # using direct behavior because new_tab isn't working consistently
            #div.add_class("tactic_new_tab")
            div.add_style("text-decoration", "underline")
            #div.add_class("tactic_new_tab")
            div.add_attr("search_key", self.sobject.get_search_key())
            div.add_attr("expression", link_expr)
            div.add_class("hand")

            search_type_sobj = self.sobject.get_search_type_obj()
            sobj_title = value

            #name = self.sobject.get_value("name", no_exception=True)
            name = None
            if not name:
                name = self.sobject.get_code()
            div.add_attr("name", value)

            # click up blocks any other behavior
            div.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.table.open_link(bvr);
                '''
            })

        return div
コード例 #31
0
ファイル: view_manager_wdg.py プロジェクト: nuxping/TACTIC
    def get_display(my):
        widget = DivWdg(id='new_item_panel')
        widget.add_class("new_item_panel")
        widget.add_class("spt_new_item_top")

        div = DivWdg()
        div.add_color("background", "background")
        div.add_color("color", "color")
        div.add_style("padding", "5px")
        div.add_border()

        if my.is_personal:
            is_personal = 'true'
        else:
            is_personal = 'false'

        if my.type == 'new_folder':
            #div.set_attr('spt_view', 'new_folder')
            div.add(HtmlElement.b('Create New Folder'))
            div.add(HtmlElement.br(2))
            item_div = DivWdg(css='spt_new_item')
            item_div.add_style('display: none')
            div.add(HtmlElement.br())
            div.add(item_div)
            """
            # add exisiting views in the div for checking with client's input
             # add exiting views:
            from panel_wdg import ViewPanelSaveWdg
            views = ViewPanelSaveWdg.get_existing_views(my.is_personal)
            hidden = HiddenWdg('existing_views', '|'.join(views))
            div.add(hidden)
            """
            text2 = TextWdg("new_title")
            text2.add_class("spt_new_item_title")
            span = SpanWdg("Title: ")
            span.set_id('create_new_title')
            #span.add_style('display: none')
            span.add_style('padding-left: 8px')
            span.add(text2)
            div.add(span)
            div.add(HtmlElement.br(2))

            div.add_style("width: 350px")

            action = '''
            var top = bvr.src_el.getParent(".spt_new_item_top");
            var name_el = top.getElement(".spt_new_item_name");
            var title = bvr.src_el.value;
            var name = title.replace(/[\?.!@#$%^&*()'"]/g, "");
            name = name.replace(/ /g, "_");
            name = name.toLowerCase();
            name_el.value = name;
            '''

            # change the name based on the title
            text2.add_behavior({'type': 'change', 'cbjs_action': action})

            div.add(
                "The name of the folder is a hidden name that is used by other elements to refer to uniquely to this item.<br/><br/>"
            )
            text = TextWdg('new_name')
            text.add_class("spt_new_item_name")
            span = SpanWdg('Name: ')
            span.add(text)
            div.add(span)

            div.add(HtmlElement.br(2))

            #script = "spt.side_bar.manage_section_action_cbk({'value':'predefined'},'project_view');"
            #link = HtmlElement.js_href(script, data='[ Predefined View ]')
            #div3 = DivWdg('Optional: drag existing elements from Project Views or %s into this new folder' %link.get_buffer_display())
            #div.add(div3)
            #item_div = DivWdg(css='spt_new_item spt_side_bar_content')
            #div.add(item_div)

            div.add("<hr/>")

            #save_div = SpanWdg(css='med hand')
            #div.add(save_div)
            #save_div.add(IconWdg('Save Folder', IconWdg.SAVE))

            save_button = ActionButtonWdg(title='Create',
                                          tip='Create a new folder')
            div.add(save_button)

            bvr = {
                "type":
                "click_up",
                "view":
                my.view,
                "is_personal":
                is_personal == 'true',
                'cbjs_action':
                '''
            var top = bvr.src_el.getParent(".spt_new_item_top");
            var name_el = top.getElement(".spt_new_item_name");
            var name_value = name_el.value;
            if (name_value == "") {
                var title_el = top.getElement(".spt_new_item_title");
                var title = title_el.value;
                var name = spt.convert_to_alpha_numeric(title);
                name_el.value = name;
            }
            if (name_value == "") {
                spt.alert("Please fill in a value for name.");
                return;
            }
            spt.side_bar.manage_section_action_cbk(
                    { 'value':'save_folder'}, bvr.view, bvr.is_personal);
            '''
            }
            save_button.add_behavior(bvr)
            div.add(HtmlElement.br())

        elif my.type == 'new_link':

            div.set_attr('spt_view', 'new_link')
            div.add(HtmlElement.b('Create New Link'))
            div.add(HtmlElement.br())

            item_div = DivWdg(css='spt_new_item')
            item_div.add_style('display: none')
            div.add(HtmlElement.br())
            div.add(item_div)

            text = TextWdg('new_link_title')
            span = SpanWdg('Title: ')
            span.add(text)
            div.add(span)

            div.add(HtmlElement.br(2))
            cb = CheckboxWdg('include_search_view',
                             label='Include Saved Search')
            cb.set_default_checked()
            div.add(cb)

            div.add(HtmlElement.br(2))
            div.add("Select a search type and view of this link")
            div.add(HtmlElement.br())

            select = SelectWdg("new_search_type")
            select.add_empty_option("-- Select Search type --")

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

            values = [x.get_value("search_type") for x in search_types]
            labels = [
                "%s (%s)" % (x.get_value("search_type"), x.get_title())
                for x in search_types
            ]
            values.append("CustomLayoutWdg")
            labels.append("CustomLayoutWdg")
            select.set_option("values", values)
            select.set_option("labels", labels)

            #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='new_search_type', \
            #    mode=select_mode)

            select.add_behavior({
                'type':
                'change',
                'cbjs_action':
                '''
                var top = bvr.src_el.getParent(".new_item_panel");
                var link_view_select = top.getElement(".link_view_select");
                var input = spt.api.Utility.get_input(top, 'new_search_type'); var values = {'search_type': input.value, 
                'is_refresh': 'true'}; 
                spt.panel.refresh(link_view_select, values);'''
            })
            div.add(HtmlElement.br())
            div.add(select)

            div.add(HtmlElement.br())

            link_view_sel = NewLinkViewSelectWdg()
            div.add(HtmlElement.br())
            div.add(link_view_sel)

            div.add(HtmlElement.br())
            #select.add_behavior('change')
            div.add(HtmlElement.hr())
            div.add(HtmlElement.br())

            #save_div = DivWdg(css='med hand')
            #div.add(save_div)
            #save_button = ProdIconButtonWdg('Save Link', IconWdg.SAVE)
            #save_div.add(save_button)

            save_button = ActionButtonWdg(title='Create',
                                          tip='Create a new link')
            div.add(save_button)
            bvr = { "type": "click_up",
                'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\
                "'value':'save_link'},'%s', %s);" %(my.view, is_personal)}
            save_button.add_behavior(bvr)
            div.add(HtmlElement.br(1))

        elif my.type == 'new_separator':
            div.set_attr('spt_view', 'new_separator')
            div.add(HtmlElement.b('Creating New Separator. . .'))
            div.add(HtmlElement.br())

            item_div = DivWdg(css='spt_new_item')
            item_div.add_style('display: none')
            div.add(HtmlElement.br())
            div.add(item_div)
            # since it's automated, this button is not needed
            """ 
            save_div = SpanWdg(css='med hand')
            save_div.add(IconWdg('Save', IconWdg.SAVE))
        
            bvr = { "type": "click_up",\
                'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\
                "'value':'save_separator'},'%s');" %my.view}
            save_div.add_behavior(bvr)
            div.add(save_div)
            """
        widget.add(div)
        return widget
コード例 #32
0
    def get_display(my):

        expr_filter = "sthpw/login['login','not in','admin|guest']['begin']['license_type','user']['license_type','is','NULL']['or']"
        current_users = Search.eval("@COUNT(%s)" %expr_filter)

        top = my.top
        top.add_class("spt_panel_user_top")
        top.add_style("min-width: 400px")
        
        tool_div = DivWdg()
        # tool_div.add_style('margin-bottom','8px')
        tool_div.add_style('display','inline-flex')
        tool_div.add_style('width','50%')
        tool_div.add_style('margin-bottom','-4px')
       
        button = ActionButtonWdg(title="Add", tip="Add New User")
        button.add_style('align-self: flex-end')
        tool_div.add(button)
        
        button.add_style("float: left")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.panel.EditWdg';
            var kwargs = {
                search_type: "sthpw/login",
                view: "insert",
                show_header: false,
            }
            var popup = spt.panel.load_popup("Create New User", class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_panel_user_top");
            popup.on_save_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )


        security = Environment.get_security()
        license = security.get_license()
        num_left = license.get_num_licenses_left()
        current_users = license.get_current_users()
        #max_users = license.get_max_users()


        div = DivWdg('Users')
        div.add_style('align-self: flex-end')
        div.add_styles("margin: 0 0 6px 20px")
        badge_span = SpanWdg(css='badge')
        badge_span.add_style('margin-left','6px')
        badge_span.add(current_users)
        div.add(badge_span)
        tool_div.add(div)

        tool_div2 = DivWdg()
        # tool_div.add_style('margin-bottom','8px')
        tool_div2.add_style('display','inline-flex')
        tool_div2.add_style('justify-content','flex-end')
        tool_div2.add_style('width','50%')

        top.add(tool_div)
        top.add(tool_div2)


        if num_left < 1000:
            div = DivWdg('Users Left')
            div.add_style('align-self: flex-end')
            div.add_styles("margin: 0 0 6px 20px")
            badge_span = SpanWdg(css='badge')
            badge_span.add_style('margin-left','6px')
            badge_span.add(num_left)
            div.add(badge_span)
            tool_div.add(div)

            top.add(tool_div)


        show_security = my.kwargs.get("show_security")
        if show_security not in ['false', False]:
            button = ActionButtonWdg(title="Security")
            button.add_style('align-self: flex-end')
            #button.add_styles("position: absolute; right: 10px;")
            tool_div2.add(button)
            #button.add_style("margin-top: -8px")
            button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.startup.SecurityWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("Security", "Security", class_name)
            '''
            } )




        br = HtmlElement.br(clear=True)
        top.add(br)



        if not current_users:
            div = DivWdg()
            top.add(div)
            div.add_style("text-align: center")
            div.add_border()
            div.add_style("min-height: 150px")
            div.add_style("margin: 15px 30px 30px 30px")
            div.add_style("padding: 30px 20px 0px 20px")
            div.add_color("background", "background3")
            icon = IconWdg( "WARNING", IconWdg.WARNING )
            div.add(icon)
            div.add("<b>No users have been added</b>")
            div.add("<br/><br/>")
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias=my.get_help_alias())
            div.add(help)
            div.add("<br/>")
            div.add("Click on the 'Add' button above to start adding new users.")

            return top




        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")
        expr = "@SEARCH(%s)" %expr_filter
        panel = ViewPanelWdg(search_type='sthpw/login',view='manage_user',show_insert='false',\
            show_gear='false', show_select='false', height='700', expression=expr,\
            simple_search_view='simple_manage_filter', show_column_manager='false',\
            show_layout_switcher='false', show_expand='false')
        div.add(panel)
        div.add_style('margin-top', '4px')
        
        return top

        """
コード例 #33
0
    def get_simple_definition_wdg(my):

        detail_wdg = DivWdg()
        detail_wdg.add_color("color", "color")
        detail_wdg.add_style("width: 350px")
        detail_wdg.add_style("margin-top: 10px")
        detail_wdg.add_style("padding: 10px")
        detail_wdg.add_border()
        title = DivWdg()
        title.add_style("margin-top: -23px")
        detail_wdg.add(title)
        if not my.name_string:
            title.add('No database column')
            return detail_wdg

        title.add("Column Definition")

        # add a name entry
        detail_wdg.add("<br/>")
        title = SpanWdg()
        detail_wdg.add("Name: ")
        detail_wdg.add(title)
        input = SpanWdg()
        input.add_style('padding-top: 6px')
        input.set_id("config_element_name")
        input.add(HtmlElement.b(my.name_string))
        detail_wdg.add(input)
        hidden = HiddenWdg('column_name', my.name_string)
        detail_wdg.add(hidden)
        hidden = HiddenWdg('target_search_type', my.search_type)
        detail_wdg.add(hidden)

        detail_wdg.add(HtmlElement.br(2))

        # add data_type entry
        data_type = SpanWdg()
        default_data_types = [
            'varchar(256)', 'varchar', 'character', 'text', 'integer', 'float',
            'boolean', 'timestamp', 'Other...'
        ]
        select = SelectWdg('config_data_type', label='Data Type: ')
        #detail_wdg.add(": ")
        select.set_option('values', default_data_types)
        select.set_value(my.data_type_string)

        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            "if (bvr.src_el.value=='Other...') {spt.show('config_data_type_custom');}\
                    else {spt.hide('config_data_type_custom');}"
        })
        data_type.add(select)

        text = TextWdg('config_data_type_custom')
        span = SpanWdg("Other: ", css='med')
        span.add(text)
        span.set_id('config_data_type_custom')
        span.add_style('display', 'none')
        text.set_value(my.data_type_string)

        data_type.add("<br/>")
        data_type.add(span)
        detail_wdg.add(data_type)

        detail_wdg.add("<br/>")
        # add a nullable entry
        nullable = SpanWdg()
        checkbox = CheckboxWdg('config_nullable',
                               label='Allow null(empty) value: ')
        #detail_wdg.add(": ")
        nullable.add(checkbox)

        if my.nullable_string in ['True', 'true']:
            checkbox.set_checked()

        detail_wdg.add(nullable)

        #constraint = DivWdg()
        #detail_wdg.add(constraint)
        #constraint.add_style("margin-top: 10px")
        #constraint.add("Constraint: ")
        #select = SelectWdg("config_constraint")
        #constraint.add(select)
        #select.set_option("values", "unique|indexed")
        #select.add_empty_option("-- None --")

        button_div = DivWdg()
        button_div.add_style("text-align: center")

        button_div.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
spt.manage_search_type = {};

spt.manage_search_type.change_column_cbk = function(bvr) {
    var class_name = 'tactic.ui.panel.AlterSearchTypeCbk';
    var options ={
        'alter_mode': bvr.alter_mode,
        'title': bvr.title
    };

    try {
        var server = TacticServerStub.get();
        var panel = $('search_type_detail');
        if (! panel.getAttribute("spt_class_name") ) {
            panel = panel.getParent(".spt_panel");
        }
        var values = spt.api.Utility.get_input_values(panel);
        rtn = server.execute_cmd(class_name, options, values);
        if (bvr.alter_mode == 'Remove Column')
            spt.info("Column [" + bvr.column + "] has been deleted.");
        else if (bvr.alter_mode == 'Modify Column')
            spt.notify.show_message("Column [" + bvr.column + "] has been modified.");
    }
    catch (e) {
        spt.alert(spt.exception.handler(e));
    }
    var view = 'db_column';
    spt.panel.refresh("ManageSearchTypeMenuWdg_" + view);
    var view = 'definition';
    spt.panel.refresh("ManageSearchTypeMenuWdg_" + view);
}


            '''
        })

        detail_wdg.add(button_div)
        button_div.add("<hr/><br/>")
        if my.is_new_column:
            button = ActionButtonWdg(title="Commit")
            #button = ProdIconButtonWdg("Commit New Column")
            button.add_behavior({"type": "click_up",
                "cbjs_action": "spt.manage_search_type.change_column_cbk(bvr)", \

                        "alter_mode": my.ADD_COLUMN})
            button_div.add(button)
        else:

            table = Table()
            button_div.add(table)
            table.add_row()
            table.center()

            button = ActionButtonWdg(title="Modify")
            #button = ProdIconButtonWdg("Modify Column")
            button.add_behavior({
                "type": "click_up",
                "cbjs_action":
                '''spt.manage_search_type.change_column_cbk(bvr);
                           ''',
                "alter_mode": my.MODIFY_COLUMN,
                "column": my.name_string,
                "title": my.title_string
            })
            table.add_cell(button)

            button = ActionButtonWdg(title="Delete")
            #button = ProdIconButtonWdg("Delete Column")
            #button.add_style('background-color: #BF462E')
            button.add_behavior({
                "type": "click_up",
                "cbjs_action": '''
                
                var yes = function() {
                    spt.manage_search_type.change_column_cbk(bvr);
                    
                }
                spt.confirm("Are you sure you wish to delete this column?", yes) 
                ''',
                "alter_mode": my.REMOVE_COLUMN,
                "column": my.name_string
            })
            table.add_cell(button)
            button_div.add(HiddenWdg('delete_column'))
            button_div.add(HiddenWdg('modify_column'))

        return detail_wdg
コード例 #34
0
ファイル: view_manager_wdg.py プロジェクト: blezek/TACTIC
    def get_display(my):
        widget = DivWdg(id='new_item_panel')
        widget.add_class("new_item_panel")
        widget.add_class("spt_new_item_top")

        div = DivWdg()
        div.add_color("background", "background")
        div.add_color("color", "color")
        div.add_style("padding", "5px")
        div.add_border()

        if my.is_personal:
            is_personal = 'true'
        else:
            is_personal = 'false'

        if my.type == 'new_folder':
            #div.set_attr('spt_view', 'new_folder')
            div.add(HtmlElement.b('Create New Folder'))
            div.add(HtmlElement.br(2))
            """
            # add exisiting views in the div for checking with client's input
             # add exiting views:
            from panel_wdg import ViewPanelSaveWdg
            views = ViewPanelSaveWdg.get_existing_views(my.is_personal)
            hidden = HiddenWdg('existing_views', '|'.join(views))
            div.add(hidden)
            """
            text2 = TextWdg("new_title")
            text2.add_class("spt_new_item_title")
            span = SpanWdg("Title: ")
            span.set_id('create_new_title')
            #span.add_style('display: none')
            span.add_style('padding-left: 8px')
            span.add(text2)
            div.add(span)
            div.add(HtmlElement.br(2))

            div.add_style("width: 350px")


            action = '''
            var top = bvr.src_el.getParent(".spt_new_item_top");
            var name_el = top.getElement(".spt_new_item_name");
            var title = bvr.src_el.value;
            var name = title.replace(/[\?.!@#$%^&*()'"]/g, "");
            name = name.replace(/ /g, "_");
            name = name.toLowerCase();
            name_el.value = name;
            '''


            # change the name based on the title
            text2.add_behavior( {
            'type': 'change',
            'cbjs_action': action
            } )

            div.add("The name of the folder is a hidden name that is used by other elements to refer to uniquely to this item.<br/><br/>")
            text = TextWdg('new_name')
            text.add_class("spt_new_item_name")
            span = SpanWdg('Name: ')
            span.add(text)
            div.add(span)

            div.add(HtmlElement.br(2))
            
            #script = "spt.side_bar.manage_section_action_cbk({'value':'predefined'},'project_view');"
            #link = HtmlElement.js_href(script, data='[ Predefined View ]')
            #div3 = DivWdg('Optional: drag existing elements from Project Views or %s into this new folder' %link.get_buffer_display())
            #div.add(div3)
            #item_div = DivWdg(css='spt_new_item spt_side_bar_content')
            #div.add(item_div)

            div.add("<hr/>")

           
            #save_div = SpanWdg(css='med hand')
            #div.add(save_div)
            #save_div.add(IconWdg('Save Folder', IconWdg.SAVE))

            save_button = ActionButtonWdg(title='Create', tip='Create a new folder')
            div.add(save_button)
       
            bvr = {
            "type": "click_up",
            "view": my.view,
            "is_personal": is_personal == 'true',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_new_item_top");
            var name_el = top.getElement(".spt_new_item_name");
            var name_value = name_el.value;
            if (name_value == "") {
                var title_el = top.getElement(".spt_new_item_title");
                var title = title_el.value;
                var name = spt.convert_to_alpha_numeric(title);
                name_el.value = name;
            }
            if (name_value == "") {
                spt.alert("Please fill in a value for name.");
                return;
            }
            spt.side_bar.manage_section_action_cbk(
                    { 'value':'save_folder'}, bvr.view, bvr.is_personal);
            ''' }
            save_button.add_behavior(bvr)
            div.add(HtmlElement.br())


        elif my.type == 'new_link':

            div.set_attr('spt_view', 'new_link')
            div.add(HtmlElement.b('Create New Link'))
            div.add(HtmlElement.br())
         
            item_div = DivWdg(css='spt_new_item')
            item_div.add_style('display: none')
            div.add(HtmlElement.br())
            div.add(item_div)
            
            text = TextWdg('new_link_title')
            span = SpanWdg('Title: ')
            span.add(text)
            div.add(span)
            
            div.add(HtmlElement.br(2))
            cb = CheckboxWdg('include_search_view', label='Include Saved Search')
            cb.set_default_checked()
            div.add(cb)

            div.add(HtmlElement.br(2))
            div.add("Select a search type and view of this link")
            div.add(HtmlElement.br())

           
            select = SelectWdg("new_search_type")
            select.add_empty_option("-- Select Search type --")
    
            security = Environment.get_security()
            if security.check_access("builtin", "view_site_admin", "allow"):
                search_types = Project.get().get_search_types(include_sthpw=True, include_config=True)
            else:
                search_types = Project.get().get_search_types()

            values = [x.get_value("search_type") for x in search_types]
            labels = ["%s (%s)" % (x.get_value("search_type"), x.get_title()) for x in search_types]
            values.append("CustomLayoutWdg")
            labels.append("CustomLayoutWdg")
            select.set_option("values", values)
            select.set_option("labels", labels)

    
            #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='new_search_type', \
            #    mode=select_mode)

            select.add_behavior({'type': 'change',
            'cbjs_action': '''
                var top = bvr.src_el.getParent(".new_item_panel");
                var link_view_select = top.getElement(".link_view_select");
                var input = spt.api.Utility.get_input(top, 'new_search_type'); var values = {'search_type': input.value, 
                'is_refresh': 'true'}; 
                spt.panel.refresh(link_view_select, values);'''
            })
            div.add(HtmlElement.br())
            div.add(select)
      

            div.add(HtmlElement.br())
                  
            
            
            link_view_sel = NewLinkViewSelectWdg()
            div.add(HtmlElement.br())
            div.add(link_view_sel)

            div.add(HtmlElement.br())
            #select.add_behavior('change')
            div.add(HtmlElement.hr())
            div.add(HtmlElement.br())
            
            #save_div = DivWdg(css='med hand')
            #div.add(save_div)
            #save_button = ProdIconButtonWdg('Save Link', IconWdg.SAVE)
            #save_div.add(save_button)

            save_button = ActionButtonWdg(title='Create', tip='Create a new link')
            div.add(save_button)
            bvr = { "type": "click_up",
                'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\
                "'value':'save_link'},'%s', %s);" %(my.view, is_personal)}
            save_button.add_behavior(bvr)
            div.add(HtmlElement.br(1))

        elif my.type == 'new_separator':
            div.set_attr('spt_view', 'new_separator')
            div.add(HtmlElement.b('Creating New Separator. . .'))
            div.add(HtmlElement.br())
           
            item_div = DivWdg(css='spt_new_item')
            item_div.add_style('display: none')
            div.add(HtmlElement.br())
            div.add(item_div)
            # since it's automated, this button is not needed
            """ 
            save_div = SpanWdg(css='med hand')
            save_div.add(IconWdg('Save', IconWdg.SAVE))
        
            bvr = { "type": "click_up",\
                'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\
                "'value':'save_separator'},'%s');" %my.view}
            save_div.add_behavior(bvr)
            div.add(save_div)
            """
        widget.add(div)
        return widget
コード例 #35
0
    def get_display(my): 

        top = my.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("padding: 10px")
        top.add_style("min-width: 400px")

        from tactic.ui.app import HelpButtonWdg
        help_wdg = HelpButtonWdg(alias="exporting-csv-data")
        top.add(help_wdg)
        help_wdg.add_style("float: right")
        help_wdg.add_style("margin-top: -3px")
        
        if not my.check(): 
            top.add(DivWdg('Error: %s' %my.error_msg))
            top.add(HtmlElement.br(2))
            return super(CsvExportWdg, my).get_display()

        if my.search_type_list and my.search_type_list[0] != my.search_type:
            st = SearchType.get(my.search_type_list[0])
            title_div =DivWdg('Exporting related items [%s]' % st.get_title())
            top.add(title_div)
            top.add(HtmlElement.br())
            my.search_type = my.search_type_list[0]
            my.view = my.related_view

        if my.mode != 'export_all':
            num = len(my.selected_search_keys)
        else:
            search = Search(my.search_type)
            num = search.get_count()
        msg_div = DivWdg('Total: %s items to export'% num)
        msg_div.add_style("font-size: 12px")
        msg_div.add_style("font-weight: bold")
        msg_div.add_style('margin-left: 4px')
        top.add(msg_div)
        if num > 300:
            msg_div.add_behavior({'type':'load',
            'cbjs_action': "spt.alert('%s items are about to be exported. It may take a while.')" %num})
                
        top.add(HtmlElement.br())

        div  = DivWdg(css='spt_csv_export', id='csv_export_action')
        div.add_color("background", "background", -10)
        div.add_style("padding: 10px")
        div.add_style("margin: 5px")
        
        div.add_styles('max-height: 350px; overflow: auto')
        table = Table( css='minimal')
        table.add_color("color", "color")
        div.add(table)
        table.set_id('csv_export_table')
        table.center()
        
        
        cb_name = 'csv_column_name'
        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_csv_export'),'%s');
                for (var i = 0; i < inputs.length; i++)
                    inputs[i].checked = !inputs[i].checked;
                    ''' %cb_name})


        span = SpanWdg('Select Columns To Export')
        span.add_style('font-weight','600')
        table.add_row_cell(span)
        table.add_row_cell(HtmlElement.br())

        tr = table.add_row()
        tr.add_style('border-bottom: 1px groove #777')
        td = table.add_cell(master_cb)
        label = HtmlElement.i('toggle all')
        label.add_style('color: #888')
        table.add_cell(label)


        col1 = table.add_col()
        col1.add_style('width: 35px')
        col2 = table.add_col()
        
        if not my.search_type or not my.view:
            return table

        
        # use overriding element names and derived titles if available
        config = WidgetConfigView.get_by_search_type(my.search_type, my.view)
        if my.element_names and config:
            filtered_columns = my.element_names
            titles = []
            for name in my.element_names:
                title = config.get_element_title(name)
                titles.append(title)

        else:
            
            # excluding FunctionalTableElement
            filtered_columns = []
            titles = []
            if not config:
                columns = search.get_columns()
                filtered_columns = columns
                titles = ['n/a'] * len(filtered_columns)
            else:
                columns = config.get_element_names()
                
                filtered_columns = columns
                titles = config.get_element_titles()

        
            """
            # commented out until it is decided 2.5 widgets will 
            # use this class to differentiate between reg and functional element
            from pyasm.widget import FunctionalTableElement
            for column in columns:
                widget = config.get_display_widget(column)

                if isinstance(widget, FunctionalTableElement):
                    continue
                filtered_columns.append(column)
            """

        for idx, column in enumerate(filtered_columns):
            table.add_row()
            cb = CheckboxWdg(cb_name)
            cb.set_option('value', column)
            cb.set_checked()
            table.add_cell(cb)
            
            
            title = titles[idx]
            table.add_cell('<b>%s</b> (%s) '%(title, column))

        action_div = DivWdg()
        widget = DivWdg()
        table.add_row_cell(widget)
        widget.add_style("margin: 20px 0 10px 0px")
        cb = CheckboxWdg('include_id', label=" Include ID")
        cb.set_default_checked()
        widget.add(cb)
        hint = HintWdg('To update entries with specific ID later, please check this option. For new inserts in this or other table later on, uncheck this option.') 
        widget.add(hint)

        label = string.capwords(my.mode.replace('_', ' '))
        button = ActionButtonWdg(title=label)

        is_export_all  = my.mode == 'export_all'
        button.add_behavior({
            'type': "click_up",
            'cbfn_action': 'spt.dg_table_action.csv_export',
            'element': 'csv_export',
            'column_names': 'csv_column_name',
            'search_type': my.search_type,
            'view': my.view,
            'search_keys' : my.selected_search_keys,
            'is_export_all' : is_export_all
            
        })

        my.close_action = "var popup = bvr.src_el.getParent('.spt_popup');spt.popup.close(popup)"
        if my.close_action:
            close_button = ActionButtonWdg(title='Close')
            close_button.add_behavior({
                'type': "click",
                'cbjs_action': my.close_action
            })


        table = Table()
        action_div.add(table)
        table.center()
        table.add_row()
        td = table.add_cell(button)
        td.add_style("width: 130px")
        table.add_cell(close_button)

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

        top.add(div)
        top.add(HtmlElement.br())
        top.add(action_div)
        return top
コード例 #36
0
ファイル: tab_wdg.py プロジェクト: 0-T-0/TACTIC
    def get_display(my):

        new_tab_names = my.tab_names
        
        app_css = app_style = None    
        if WebContainer.get_web().get_app_name_by_uri() != 'Browser':
            app_css = 'smaller'
            app_style = 'padding: 0px 2px 3px 2px' 
            
        div = my.div
        div.set_style("margin-top: 10px; margin-bottom: 20px")
        
        # add some spacing
        span = SpanWdg(css='tab_front')
        div.add(span)

        selected_widget = None

        # figure out which is the selected one
        selected_index = 0
        for i in range(0, len(new_tab_names)):
            tab_name = new_tab_names[i]
            if tab_name == my.tab_value:
                selected_index = i
                break

        for i in range(0, len(new_tab_names)):
            tab_name = new_tab_names[i]
            widget = my.get_widget(tab_name)

            tab = SpanWdg()
            if i == selected_index:
                # selected tab
                tab.set_class("%s_selected" %my.get_style_prefix())
                if app_style:
                    tab.add_style(app_style)
                selected_widget = widget
            else:
                # unselected tab
                tab.set_class("%s_unselected" %my.get_style_prefix())
                if app_style:
                    tab.add_style(app_style)
            tab.add( my.get_header(tab_name, selected_index, app_css))
            div.add(tab)

        # FIXME: hide this for now 
        #div.add( my.get_add_tab_wdg() )


        tab_hidden = HiddenWdg(my.tab_key)
        tab_hidden.set_persistence()
        # explicitly records this value for init-type submit
        tab_hidden._set_persistent_values([my.tab_value])

        # TODO: not sure if this is legal ... This is rather redundant,
        # but set_value is a pretty complex function.  In the end this
        # forces it to be set to a value even though widget settings is disabled
        value = tab_hidden.get_value()
        if value:
            tab_hidden.set_value(value)

        div.add(tab_hidden)
        
        
        
        # if an error occured, draw the error 
        if my.error_wdg:
            div.add(my.error_wdg)
        else:
            # display the content
            content_div = HtmlElement.div()
            if my.content_height:
                content_div.add_style("height: %spx" % my.content_height)
                content_div.add_style("padding: 10px 0 10px 0")
                content_div.add_style("overflow: auto")
                content_div.add_style("border-style: solid")
            
            content_div.set_class("%s_content" %my.get_style_prefix())
            content_div.add_style("display: block")

            try:
                content = my.get_content(selected_widget)
                if isinstance( content, Widget):
                    content = content.get_buffer_display()
            except Exception, e:
                my.handle_exception(e)

                # TODO: need some way to make this automatic in Widget.
                #if my.tab_path:
                #    last_buffer = len(my.tab_path)+1
                #    buffer = my.get_buffer_on_exception(last_buffer)
                #else:
                buffer = my.get_buffer_on_exception()

                div.add(buffer)


                content = my.error_wdg

            content_div.add( content )
            div.add(content_div)
コード例 #37
0
ファイル: reset_password_wdg.py プロジェクト: nuxping/TACTIC
    def get_display(my):

        web = WebContainer.get_web()
        login_name = web.get_form_value('login')
        hidden = HiddenWdg('login', login_name)
        box = DivWdg(css='login')

        if web.is_IE():
            box.add_style("margin-top: 150px")
            box.add_style("margin-bottom: 150px")
        else:
            box.add_style("margin-top: auto")
            box.add_style("margin-bottom: auto")
        box.add_style("text-align: center")

        div = DivWdg()
        div.add_style("margin: 0px 0px")
        div.add_class("centered")

        div.add_style("padding-top: 95px")

        sthpw = SpanWdg("SOUTHPAW TECHNOLOGY INC", css="login_sthpw")
        sthpw.add_style("color: #CCCCCC")
        div.add(sthpw)
        div.add(HtmlElement.br())
        div.add(hidden)
        box.add(div)

        # hidden element in the form to pass message that this was not
        # actually a typical submitted form, but rather the result
        # of a login page
        div.add(HiddenWdg("is_from_login", "yes"))
        div.add_style("font-size: 10px")

        table = Table(css="login")
        table.center()
        table.set_attr("cellpadding", "3px")
        table.add_row()

        table2 = Table(css="login")
        table2.center()
        table2.add_style("width: 240px")

        table2.add_row()

        td = table2.add_header(
            'After reset, the new password will be sent to the email address for [ %s ].'
            % login_name)
        td.add_color('color', 'color', +80)
        table2.add_row_cell('&nbsp;')
        # build the button manually
        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(tip='Reset Password', title='Reset')
        button.add_style('margin: auto')
        button.add_event(
            'onclick',
            "document.form.elements['reset_password'].value='true'; document.form.submit()"
        )
        table2.add_row()
        td = table2.add_cell(button)
        hidden = HiddenWdg('reset_password')
        td.add(hidden)

        #th.add_class('center_content')

        table2.add_row()

        div.add(HtmlElement.br())
        div.add(table)

        div.add(HtmlElement.spacer_div(1, 14))
        div.add(table2)
        #div.add(HiddenWdg(my.LOGIN_MSG))

        #box.add(script)

        widget = Widget()
        #widget.add( HtmlElement.br(3) )
        table = Table()
        table.add_style("width: 100%")
        table.add_style("height: 85%")
        table.add_row()
        td = table.add_cell()
        td.add_style("vertical-align: middle")
        td.add_style("text-align: center")
        td.add_style("background: transparent")
        td.add(box)
        widget.add(table)

        return widget
コード例 #38
0
ファイル: message_wdg.py プロジェクト: hellios78/TACTIC
    def get_category_wdg(my, category, mode="new"):

        subscriptions = my.get_subscriptions(category, mode)
        if not subscriptions:
            return

        div = DivWdg()
        div.add_style("width: 100%")

        title_div = DivWdg()
        div.add(title_div)
        title_div.add_style("padding: 10px")
        title_div.add_border()
        title_div.add_color("background", "background3")
        title = category or "Subscriptions"
        title_div.add("%s " % title)
        

        summary_div = SpanWdg()
        title_div.add(summary_div)
        summary_div.add_style("font-size: 0.8em")
        summary_div.add_style("opacity: 0.5")


        search_keys = [x.get_search_key() for x in subscriptions]
        button = ActionButtonWdg(title="Clear All")
        div.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'search_keys': search_keys,
            'cbjs_action': '''
            var server = TacticServerStub.get();
            for (var i = 0; i < bvr.search_keys.length; i++) {
                var search_key = bvr.search_keys[i];
                server.update(search_key, {'last_cleared':'NOW'});
            spt.panel.refresh(bvr.src_el);
            }
            '''
        } )



        # types of subscriptions

        table = Table()
        table.add_style('width: 100%')
        table.add_border()
        table.add_color("background", "background3")


        div.add(table)
        ss = []
        for subscription in subscriptions:
            table.add_row()
            td = table.add_cell()

            message_code = subscription.get_value("message_code")

            search = Search("sthpw/message")
            search.add_filter("code", message_code)
            message = search.get_sobject()

            # show the thumb
            if not message:
                if mode == "all":
                    td = table.add_cell(FormatMessageWdg.get_preview_wdg(subscription))

                    td = table.add_cell()
                    td.add("No Messages")
                continue

            size = 60

            msg_element = FormatMessageWdg(subscription=subscription, short_format='true')
            # this is optional
            msg_element.set_sobject(message)
            description = msg_element.get_buffer_display() 
          
            #td = table.add_cell()
            history_icon = IconButtonWdg(title="Subscription History", icon=IconWdg.HISTORY)
            #td.add(icon)
            message_code = subscription.get_value("message_code")
            history_icon.add_behavior( {
                'type': 'click_up',
                'message_code': message_code,
                'cbjs_action': '''
                var class_name = 'tactic.ui.panel.FastTableLayoutWdg';
                var message_code = bvr.message_code;
                var kwargs = {
                    search_type: 'sthpw/message_log',
                    show_shelf: false,
                    expression: "@SOBJECT(sthpw/message_log['message_code','"+message_code+"'])",
                    view: 'history'
                };
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Message History", "Message History", class_name, kwargs);
                '''
            } )
 

            # description can take up 70%
            td = table.add_cell()
            td.add_style("width: %spx"%(SubscriptionBarWdg.WIDTH*0.7))

            desc_div = DivWdg()
            td.add(desc_div)
            desc_div.add(description)
            desc_div.add_style("padding: 0px 20px")

            td = table.add_cell()
            #td.add(message.get_value("status"))
            #td = table.add_cell()
            timestamp = message.get_datetime_value("timestamp")
            if timestamp:
                timestamp_str = timestamp.strftime("%b %d, %Y - %H:%M")
            else:
                timestamp_str = ""
            td.add(timestamp_str)

            #td = table.add_cell()
            #td.add(subscription.get_value("last_cleared"))

            td = table.add_cell()
            td.add(history_icon)
            td.add(HtmlElement.br(2))
            td.add_style('width: 30px')
            icon = IconButtonWdg(title="Unsubscribe", icon=IconWdg.DELETE)
            td.add(icon)
            subscription_key = subscription.get_search_key()
            icon.add_behavior( {
                'type': 'click_up',
                'search_key': subscription_key,
                'message_code': message_code,
                'cbjs_action': '''
                    if (!confirm("Unsubscribe from [" + bvr.message_code + "]?")) {
                        return;
                    }
                    var top = bvr.src_el.getParent(".spt_subscription_top");
                    var server = TacticServerStub.get();
                    server.delete_sobject(bvr.search_key);
                    spt.panel.refresh(top);
                '''
            } )






            ss.append(subscription)

        num_sobjects = len(ss)
        if not num_sobjects:
            return None
        summary_div.add("(%s changes)" % num_sobjects)

        #from tactic.ui.panel import FastTableLayoutWdg
        #table = FastTableLayoutWdg(search_type="sthpw/subscription",show_shelf=False)
        #div.add(table)
        #table.set_sobjects(ss)


        return div
コード例 #39
0
ファイル: task_wdg.py プロジェクト: mincau/TACTIC
    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
コード例 #40
0
    def get_simple_definition_wdg(self):

        detail_wdg = DivWdg()
        detail_wdg.add_color("color", "color")
        detail_wdg.add_style("width: 350px")
        detail_wdg.add_style("margin-top: 10px")
        detail_wdg.add_style("padding: 10px")
        detail_wdg.add_border()
        title = DivWdg()
        title.add_style("margin-top: -23px")
        detail_wdg.add(title)
        if not self.name_string:
            title.add('No database column')
            return detail_wdg
        
        title.add("Column Definition")
       


        # add a name entry
        detail_wdg.add("<br/>")
        title = SpanWdg()
        detail_wdg.add("Name: ")
        detail_wdg.add(title)
        input = SpanWdg()
        input.add_style('padding-top: 6px')
        input.set_id("config_element_name")
        input.add(HtmlElement.b(self.name_string))
        detail_wdg.add(input)
        hidden = HiddenWdg('column_name', self.name_string)
        detail_wdg.add(hidden)
        hidden = HiddenWdg('target_search_type', self.search_type)
        detail_wdg.add(hidden)

        detail_wdg.add(HtmlElement.br(2))

        # add data_type entry
        data_type = SpanWdg()
        default_data_types = ['varchar(256)','varchar', 'character', 'text', 'integer', 'float', 'boolean', 'timestamp', 'Other...']
        select = SelectWdg('config_data_type', label ='Data Type: ')
        #detail_wdg.add(": ")
        select.set_option('values', default_data_types )
        select.set_value(self.data_type_string)
        
        select.add_behavior({'type': 'change', 
            'cbjs_action': "if (bvr.src_el.value=='Other...') {spt.show('config_data_type_custom');}\
                    else {spt.hide('config_data_type_custom');}"})
        data_type.add(select) 

        text = TextWdg('config_data_type_custom')
        span = SpanWdg("Other: ", css='med')
        span.add(text)
        span.set_id('config_data_type_custom')
        span.add_style('display','none')
        text.set_value(self.data_type_string)

        data_type.add("<br/>")
        data_type.add(span)
        detail_wdg.add(data_type)
            
        detail_wdg.add("<br/>")
        # add a nullable entry
        nullable = SpanWdg()
        checkbox = CheckboxWdg('config_nullable', label ='Allow null(empty) value: ')
        #detail_wdg.add(": ")
        nullable.add(checkbox)
   

        if self.nullable_string in ['True', 'true']:
            checkbox.set_checked()
        
        detail_wdg.add(nullable)


        #constraint = DivWdg()
        #detail_wdg.add(constraint)
        #constraint.add_style("margin-top: 10px")
        #constraint.add("Constraint: ")
        #select = SelectWdg("config_constraint")
        #constraint.add(select)
        #select.set_option("values", "unique|indexed")
        #select.add_empty_option("-- None --")




        button_div = DivWdg()
        button_div.add_style("text-align: center")


        button_div.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
spt.manage_search_type = {};

spt.manage_search_type.change_column_cbk = function(bvr) {
    var class_name = 'tactic.ui.panel.AlterSearchTypeCbk';
    var options ={
        'alter_mode': bvr.alter_mode,
        'title': bvr.title
    };

    try {
        var server = TacticServerStub.get();
        var panel = $('search_type_detail');
        if (! panel.getAttribute("spt_class_name") ) {
            panel = panel.getParent(".spt_panel");
        }
        var values = spt.api.Utility.get_input_values(panel);
        rtn = server.execute_cmd(class_name, options, values);
        if (bvr.alter_mode == 'Remove Column')
            spt.info("Column [" + bvr.column + "] has been deleted.");
        else if (bvr.alter_mode == 'Modify Column')
            spt.notify.show_message("Column [" + bvr.column + "] has been modified.");
    }
    catch (e) {
        spt.alert(spt.exception.handler(e));
    }
    var view = 'db_column';
    spt.panel.refresh("ManageSearchTypeMenuWdg_" + view);
    var view = 'definition';
    spt.panel.refresh("ManageSearchTypeMenuWdg_" + view);
}


            '''
        } )


        detail_wdg.add(button_div)
        button_div.add("<hr/><br/>")
        if self.is_new_column:
            button = ActionButtonWdg(title="Commit") 
            #button = ProdIconButtonWdg("Commit New Column")
            button.add_behavior({"type": "click_up", 
                "cbjs_action": "spt.manage_search_type.change_column_cbk(bvr)", \
                        
                        "alter_mode": self.ADD_COLUMN})
            button_div.add(button)
        else:

            table = Table()
            button_div.add(table)
            table.add_row()
            table.center()

            button = ActionButtonWdg(title="Modify") 
            #button = ProdIconButtonWdg("Modify Column")
            button.add_behavior({"type": "click_up", 
            "cbjs_action": '''spt.manage_search_type.change_column_cbk(bvr);
                           ''',
                    "alter_mode": self.MODIFY_COLUMN,
                    "column": self.name_string,
                    "title": self.title_string
                    })
            table.add_cell(button)

            button = ActionButtonWdg(title="Delete") 
            #button = ProdIconButtonWdg("Delete Column")
            #button.add_style('background-color: #BF462E')
            button.add_behavior({"type": "click_up", 
                "cbjs_action": '''
                
                var yes = function() {
                    spt.manage_search_type.change_column_cbk(bvr);
                    
                }
                spt.confirm("Are you sure you wish to delete this column?", yes) 
                ''',
                "alter_mode": self.REMOVE_COLUMN,
                "column": self.name_string
                
                })
            table.add_cell(button)
            button_div.add(HiddenWdg('delete_column'))
            button_div.add(HiddenWdg('modify_column'))

        return detail_wdg
コード例 #41
0
    def get_new_definition_wdg(self):
        detail_wdg = DivWdg()
        detail_wdg.add_style("color: black")
        detail_wdg.add_style("width: 350px")
        detail_wdg.add_style("margin-top: 10px")
        detail_wdg.add_style("padding: 10px")
        detail_wdg.add_border()
        title = DivWdg()
        title.add_style("color: black")
        title.add("Column Definition")
        title.add_style("margin-top: -22px")
        detail_wdg.add(title)


        # add a name entry
        title = SpanWdg()
        detail_wdg.add("Name: ")
        detail_wdg.add(title)
        input = SpanWdg()
        input.add_style('padding-top: 6px')
        input.set_id("config_element_name")
        text = TextWdg('column_name')
        text.set_value(self.name_string)
        input.add(text)
        detail_wdg.add(input)
        hidden = HiddenWdg('target_search_type', self.search_type)
        detail_wdg.add(hidden)

        detail_wdg.add(HtmlElement.br(2))

        # add data_type entry
        data_type = SpanWdg()
        default_data_types = ['varchar(256)','varchar', 'character', 'text', 'integer', 'float', 'boolean', 'timestamp', 'Other...']
        select = SelectWdg('config_data_type', label ='Data Type: ')
        #detail_wdg.add(": ")
        select.set_option('values', default_data_types )
        select.set_value(self.data_type_string)
        
        select.add_behavior({'type': 'change', 
            'cbjs_action': "if (bvr.src_el.value=='Other...') {spt.show('config_data_type_custom');}\
                    else {spt.hide('config_data_type_custom');}"})
        data_type.add(select) 

        text = TextWdg('config_data_type_custom')
        span = SpanWdg("Other: ", css='med')
        span.add(text)
        span.set_id('config_data_type_custom')
        span.add_style('display','none')
        text.set_value(self.data_type_string)

        data_type.add("<br/>")
        data_type.add(span)
        detail_wdg.add(data_type)
            
        detail_wdg.add("<br/>")
        # add a nullable entry
        nullable = DivWdg()
        checkbox = CheckboxWdg('config_nullable', label ='Allow null(empty) value: ')
        nullable.add(checkbox)

        if self.nullable_string in ['True', 'true']:
            checkbox.set_checked()
        
        detail_wdg.add(nullable)

        return detail_wdg
コード例 #42
0
                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))
コード例 #43
0
    def handle_directories(self, top):
        # deal with asset directories
        top.add(DivWdg('Asset Folders', css='spt_info_title'))
        mailserver = Config.get_value("services", "mailserver")
        table = Table()
        table.add_color("color", "color")
        table.add_style("margin: 10px")
        top.add(table)
        table.add_row()
        td = table.add_cell("asset_base_dir: ")
        td.add_style("width: 150px")
        asset_base_dir = Config.get_value("checkin", "asset_base_dir")
        if asset_base_dir:
            table.add_cell(asset_base_dir)
            tr = table.add_row()
            tr.add_style('border-bottom: 1px #bbb solid')
            # check if it is writable
            is_writable = os.access(asset_base_dir, os.W_OK)
            span = SpanWdg("writable:")
            span.add_style('padding-left: 20px')
            td = table.add_cell(span)
            td = table.add_cell(str(is_writable))
        else:
            table.add_cell("None configured")

        client_os = Environment.get_env_object().get_client_os()
        if os.name == 'nt':
            os_name = 'win32'
        else:
            os_name = 'linux'
        if client_os == 'nt':
            client_os_name = 'win32'
        else:
            client_os_name = 'linux'

        env = Environment.get()
        client_handoff_dir = env.get_client_handoff_dir(include_ticket=False,
                                                        no_exception=True)
        client_asset_dir = env.get_client_repo_dir()

        table.add_row()
        td = table.add_cell("%s_server_handoff_dir: " % os_name)
        td.add_style("width: 150px")
        handoff_dir = Config.get_value("checkin",
                                       "%s_server_handoff_dir" % os_name)

        if handoff_dir:
            table.add_cell(handoff_dir)
            table.add_row()
            # check if it is writable
            is_writable = os.access(handoff_dir, os.W_OK)
            span = SpanWdg("writable:")
            span.add_style('padding-left: 20px')
            td = table.add_cell(span)
            td = table.add_cell(str(is_writable))
        else:
            table.add_cell("None configured")

        table.add_row()
        td = table.add_cell("%s hand-off test: " % client_os_name)
        td.add_style("width: 150px")

        button = ActionButtonWdg(title='Test')
        button.add_behavior({
            'type':
            'click_up',
            'handoff_dir':
            client_handoff_dir,
            'asset_dir':
            client_asset_dir,
            'cbjs_action':
            '''
            
            var env = spt.Environment.get();


            var applet = spt.Applet.get();
            var handoff_state = applet.exists(bvr.handoff_dir);
            var asset_state = applet.exists(bvr.asset_dir);
            if (asset_state == false) {
                env.set_transfer_mode("web");
                spt.error('client repo directory is not accessible: ' + bvr.asset_dir);
            }
            else if (handoff_state == false) {
                env.set_transfer_mode("web");
                spt.error('client handoff directory is not accessible: ' + bvr.handoff_dir);
            }
            else {
                env.set_transfer_mode("copy");
                spt.info('<div>client handoff directory: ' + bvr.handoff_dir + '</div><br/><div>client repo directory :' + bvr.asset_dir +  '</div><br/><div> can be successfully accessed.</div>', {type:'html'});
            }
            '''
        })

        table.add_cell(button)
コード例 #44
0
ファイル: shelf_wdg.py プロジェクト: hellios78/TACTIC
    def get_script_wdg(my):

        search = Search("config/custom_script")
        #search.add_user_filter()
        search.add_order_by("folder")
        search.add_order_by("title")
        scripts = search.get_sobjects()

        widget = DivWdg()
        widget.add_style("width: 100%")

        from pyasm.web.palette import Palette
        palette = Palette.get()
        bg_color = palette.color("background3")
        hover_color = palette.color("background3", 20)
        widget.add_color("background", bg_color)
        '''
        # Try the table layout widget
        from tactic.ui.panel import TableLayoutWdg
        table = TableLayoutWdg(id='js_edit_list',search_type="config/custom_script", view='simple')
        table.set_sobjects(scripts)
        widget.add(table)
        '''

        title = DivWdg()
        title.add("Saved Scripts")
        title.add_style("font-size: 14px")
        title.add_color("color", "color")
        title.add_style("padding: 3px")
        title.add_style("margin: 0 0 0 -1")
        title.add_gradient("background", "background")
        title.add_border()
        widget.add(title)

        script_div = DivWdg()
        script_div.add_border()
        script_div.add_color("background", "background3")
        script_div.add_color("color", "color3")
        script_div.add_style("padding: 8px")
        script_div.add_style("overflow-x: hidden")
        script_div.add_style("overflow-y: auto")
        script_div.add_style("height: 100%")
        script_div.add_style("min-width: 100px")
        script_div.add_style("width: 220px")
        script_div.add_style("margin: -1px 0px 0px -1px")
        script_div.add_class("spt_resizable")

        inner = DivWdg()
        script_div.add(inner)
        inner.add_style("height: 100%")
        inner.add_style("width: 800px")

        last_folder = ''
        for script in scripts:
            title = script.get_value("title")
            folder = script.get_value("folder")
            language = script.get_value("language", no_exception=True)
            if not language:
                language = 'javascript'

            if folder != last_folder:
                div = DivWdg()
                icon = IconWdg("Script", IconWdg.FOLDER)
                div.add(icon)
                div.add(" %s" % folder)
                inner.add(div)

            last_folder = folder

            div = DivWdg()
            inner.add(div)
            div.add_class('hand')
            icon = IconWdg("Script", IconWdg.TOGGLE_ON)
            icon.add_style("margin-left: 10px")
            div.add(icon)
            div.add("%s" % title)

            span = SpanWdg()
            span.add_style("font-size: 9px")
            span.add_style("opacity: 0.2")
            span.add(" <i>(%s)</i>" % language)
            div.add(span)

            div.add_event("onmouseover",
                          "this.style.background='%s'" % hover_color)
            div.add_event("onmouseout",
                          "this.style.background='%s'" % bg_color)

            behavior = {
                'type': 'click_up',
                'editor_id': my.editor_id,
                'cbjs_action':
                'spt.script_editor.display_script_cbk(evt, bvr)',
                'code': script.get_code()
            }
            div.add_behavior(behavior)

        widget.add(script_div)

        return widget
コード例 #45
0
ファイル: tab_wdg.py プロジェクト: rajubuddha/TACTIC
    def get_display(my):

        new_tab_names = my.tab_names

        app_css = app_style = None
        if WebContainer.get_web().get_app_name_by_uri() != 'Browser':
            app_css = 'smaller'
            app_style = 'padding: 0px 2px 3px 2px'

        div = my.div
        div.set_style("margin-top: 10px; margin-bottom: 20px")

        # add some spacing
        span = SpanWdg(css='tab_front')
        div.add(span)

        selected_widget = None

        # figure out which is the selected one
        selected_index = 0
        for i in range(0, len(new_tab_names)):
            tab_name = new_tab_names[i]
            if tab_name == my.tab_value:
                selected_index = i
                break

        for i in range(0, len(new_tab_names)):
            tab_name = new_tab_names[i]
            widget = my.get_widget(tab_name)

            tab = SpanWdg()
            if i == selected_index:
                # selected tab
                tab.set_class("%s_selected" % my.get_style_prefix())
                if app_style:
                    tab.add_style(app_style)
                selected_widget = widget
            else:
                # unselected tab
                tab.set_class("%s_unselected" % my.get_style_prefix())
                if app_style:
                    tab.add_style(app_style)
            tab.add(my.get_header(tab_name, selected_index, app_css))
            div.add(tab)

        # FIXME: hide this for now
        #div.add( my.get_add_tab_wdg() )

        tab_hidden = HiddenWdg(my.tab_key)
        tab_hidden.set_persistence()
        # explicitly records this value for init-type submit
        tab_hidden._set_persistent_values([my.tab_value])

        # TODO: not sure if this is legal ... This is rather redundant,
        # but set_value is a pretty complex function.  In the end this
        # forces it to be set to a value even though widget settings is disabled
        value = tab_hidden.get_value()
        if value:
            tab_hidden.set_value(value)

        div.add(tab_hidden)

        # if an error occured, draw the error
        if my.error_wdg:
            div.add(my.error_wdg)
        else:
            # display the content
            content_div = HtmlElement.div()
            if my.content_height:
                content_div.add_style("height: %spx" % my.content_height)
                content_div.add_style("padding: 10px 0 10px 0")
                content_div.add_style("overflow: auto")
                content_div.add_style("border-style: solid")

            content_div.set_class("%s_content" % my.get_style_prefix())
            content_div.add_style("display: block")

            try:
                content = my.get_content(selected_widget)
                if isinstance(content, Widget):
                    content = content.get_buffer_display()
            except Exception, e:
                my.handle_exception(e)

                # TODO: need some way to make this automatic in Widget.
                #if my.tab_path:
                #    last_buffer = len(my.tab_path)+1
                #    buffer = my.get_buffer_on_exception(last_buffer)
                #else:
                buffer = my.get_buffer_on_exception()

                div.add(buffer)

                content = my.error_wdg

            content_div.add(content)
            div.add(content_div)
コード例 #46
0
    def get_new_definition_wdg(my):
        detail_wdg = DivWdg()
        detail_wdg.add_style("color: black")
        detail_wdg.add_style("width: 350px")
        detail_wdg.add_style("margin-top: 10px")
        detail_wdg.add_style("padding: 10px")
        detail_wdg.add_border()
        title = DivWdg()
        title.add_style("color: black")
        title.add("Column Definition")
        title.add_style("margin-top: -22px")
        detail_wdg.add(title)

        # add a name entry
        title = SpanWdg()
        detail_wdg.add("Name: ")
        detail_wdg.add(title)
        input = SpanWdg()
        input.add_style('padding-top: 6px')
        input.set_id("config_element_name")
        text = TextWdg('column_name')
        text.set_value(my.name_string)
        input.add(text)
        detail_wdg.add(input)
        hidden = HiddenWdg('target_search_type', my.search_type)
        detail_wdg.add(hidden)

        detail_wdg.add(HtmlElement.br(2))

        # add data_type entry
        data_type = SpanWdg()
        default_data_types = [
            'varchar(256)', 'varchar', 'character', 'text', 'integer', 'float',
            'boolean', 'timestamp', 'Other...'
        ]
        select = SelectWdg('config_data_type', label='Data Type: ')
        #detail_wdg.add(": ")
        select.set_option('values', default_data_types)
        select.set_value(my.data_type_string)

        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            "if (bvr.src_el.value=='Other...') {spt.show('config_data_type_custom');}\
                    else {spt.hide('config_data_type_custom');}"
        })
        data_type.add(select)

        text = TextWdg('config_data_type_custom')
        span = SpanWdg("Other: ", css='med')
        span.add(text)
        span.set_id('config_data_type_custom')
        span.add_style('display', 'none')
        text.set_value(my.data_type_string)

        data_type.add("<br/>")
        data_type.add(span)
        detail_wdg.add(data_type)

        detail_wdg.add("<br/>")
        # add a nullable entry
        nullable = DivWdg()
        checkbox = CheckboxWdg('config_nullable',
                               label='Allow null(empty) value: ')
        nullable.add(checkbox)

        if my.nullable_string in ['True', 'true']:
            checkbox.set_checked()

        detail_wdg.add(nullable)

        return detail_wdg
コード例 #47
0
ファイル: message_wdg.py プロジェクト: blezek/TACTIC
    def get_category_wdg(my, category, mode="new"):

        subscriptions = my.get_subscriptions(category, mode)
        if not subscriptions:
            return

        div = DivWdg()
        div.add_style("width: 100%")

        title_div = DivWdg()
        div.add(title_div)
        title_div.add_style("padding: 10px")
        title_div.add_border()
        title_div.add_color("background", "background3")
        title = category or "Subscriptions"
        title_div.add("%s " % title)
        

        summary_div = SpanWdg()
        title_div.add(summary_div)
        summary_div.add_style("font-size: 0.8em")
        summary_div.add_style("opacity: 0.5")


        search_keys = [x.get_search_key() for x in subscriptions]
        button = ActionButtonWdg(title="Clear All")
        div.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'search_keys': search_keys,
            'cbjs_action': '''
            var server = TacticServerStub.get();
            for (var i = 0; i < bvr.search_keys.length; i++) {
                var search_key = bvr.search_keys[i];
                server.update(search_key, {'last_cleared':'NOW'});
            spt.panel.refresh(bvr.src_el);
            }
            '''
        } )



        # types of subscriptions

        table = Table()
        table.add_style("width: 100%")
        table.add_border()
        table.add_color("background", "background3")


        div.add(table)
        ss = []
        for subscription in subscriptions:
            table.add_row()
            td = table.add_cell()

            message_code = subscription.get_value("message_code")

            search = Search("sthpw/message")
            search.add_filter("code", message_code)
            message = search.get_sobject()

            # show the thumb
            if not message:
                if mode == "all":
                    td = table.add_cell(my.get_preview_wdg(subscription))

                    td = table.add_cell()
                    td.add("No Messages")
                continue

            size = 60

            category = message.get_value("category")
            td = table.add_cell()
            td.add( my.get_preview_wdg(subscription) )


            #td = table.add_cell(message_code)

            message_value = message.get_value("message")
            if message_value.startswith("{") and message_value.endswith("}"):

                # FIXME: this is needed because the json has some bad
                # \\ issues. 
                message_value = message_value.replace(r"\\", "\\");
                message_value = jsonloads(message_value)
                update_data = message_value.get("update_data")

                if category == "sobject":
                    search_type = message_value.get("search_type")
                    if search_type == "sthpw/note":
                        description = "<b>Note Added:</b><br/>%s" % update_data.get("note")
                    elif search_type == "sthpw/task":
                        description = "<b>Task modified:</b><br/>%s" % update_data.get("process")
                    elif search_type == "sthpw/snapshot":
                        sobject = message_value.get("sobject")
                        description = "<b>Files Checked In:</b><br/>%s" % sobject.get("process")
                    else:
                        description = "<b>Data modified:</b><br/>%s" % update_data


                else:
                    description = message_value.get("description")


            else:

                if category == "chat":
                    login = message.get("login")
                    timestamp = message.get("timestamp")

                    message_value = message.get("message")
                    message_value = message_value.replace("\n", "<br/>")

                    description = '''
                    <b>%s</b><br/>
                    %s
                    ''' % (login, message_value)
                else:
                    description = message_value


            td = table.add_cell()
            icon = IconButtonWdg(title="Subscription History", icon=IconWdg.HISTORY)
            td.add(icon)
            subscription_key = subscription.get_search_key()
            message_code = subscription.get_value("message_code")
            icon.add_behavior( {
                'type': 'click_up',
                'message_code': message_code,
                'cbjs_action': '''
                var class_name = 'tactic.ui.panel.FastTableLayoutWdg';
                var message_code = bvr.message_code;
                alert(message_code);
                var kwargs = {
                    search_type: 'sthpw/message_log',
                    show_shelf: false,
                    expression: "@SOBJECT(sthpw/message_log['message_code','"+message_code+"'])",
                };
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Message History", "Message History", class_name, kwargs);
                '''
            } )
 

            td = table.add_cell()

            desc_div = DivWdg()
            td.add(desc_div)
            desc_div.add(description)
            desc_div.add_style("padding: 0px 20px")
            desc_div.add_style("max-width: 600px")

            td = table.add_cell()
            #td.add(message.get_value("status"))
            #td = table.add_cell()
            timestamp = message.get_datetime_value("timestamp")
            if timestamp:
                timestamp_str = timestamp.strftime("%b %d, %Y - %H:%M")
            else:
                timestamp_str = ""
            td.add(timestamp_str)

            #td = table.add_cell()
            #td.add(subscription.get_value("last_cleared"))

            td = table.add_cell()
            icon = IconButtonWdg(title="Unsubscribe", icon=IconWdg.DELETE)
            td.add(icon)
            subscription_key = subscription.get_search_key()
            icon.add_behavior( {
                'type': 'click_up',
                'search_key': subscription_key,
                'cbjs_action': '''
                    if (!confirm("Confirm subscription delete?")) {
                        return;
                    }
                    var top = bvr.src_el.getParent(".spt_subscription_top");
                    var server = TacticServerStub.get();
                    server.delete_sobject(bvr.search_key);
                    spt.panel.refresh(top);
                '''
            } )






            ss.append(subscription)

        num_sobjects = len(ss)
        if not num_sobjects:
            return None
        summary_div.add("(%s changes)" % num_sobjects)

        #from tactic.ui.panel import FastTableLayoutWdg
        #table = FastTableLayoutWdg(search_type="sthpw/subscription",show_shelf=False)
        #div.add(table)
        #table.set_sobjects(ss)


        return div
コード例 #48
0
ファイル: button_wdg.py プロジェクト: 0-T-0/TACTIC
    def get_display(my): 

        web = WebContainer.get_web()
        skin = web.get_skin()

        # default to 'small' size ...
        h = 16
        fnt_sz = 11

        if my.size == 'medium':
            h = 18
            fnt_sz = 13
        elif my.size == 'large':
            h = 20
            fnt_sz = 15

        w = (h / 2) - 1

        my.top_el.add_styles( "height: %spx;" % (h) )

        t_styles = "color: #c2c2c2; border: 0px; border-collapse: collapse; padding: 0px"
        bgi_open = "background-image: url(/context/themes/%(skin)s/images/text_btn/%(skin)s_btn_h%(h)s_" % \
                    {'skin': skin, 'h': h}
        bgi_close = ".png)"

        # pos_list = [ 'left', 'middle', 'right' ]
        spacer = HtmlElement.img( IconWdg.get_icon_path("TRANSPARENT") )
        spacer.add_styles( "width: 2px;" )

        div_left = DivWdg()
        div_left.add_styles( "%(bgi_open)s%(pos)s%(bgi_close)s;" %
                                    {'bgi_open': bgi_open, 'pos': 'left', 'bgi_close': bgi_close} )
        div_left.add_styles("float: left; height: %spx; width: %spx;" % (h, w) )

        div_mid = DivWdg()
        div_mid.add_styles( "%(bgi_open)s%(pos)s%(bgi_close)s;" %
                                    {'bgi_open': bgi_open, 'pos': 'middle', 'bgi_close': bgi_close} )
        div_mid.add_styles("float: left; height: %spx; width: auto;" % (h) )
        div_mid.add_styles("color: #c2c2c2;")
        div_mid.add_styles("vertical-align: middle")
        # move the text lower by 1 px
        div_mid.add_style('padding-top: 1px')

        div_mid.add_styles( "font-family: Arial, Helvetica, sans-serif; font-size: %spx;" % fnt_sz )
        div_mid.add( spacer )
        span = SpanWdg(my.label)

        # this is better fixed. Bold fonts don't look good 
        span.add_style('font-weight: 100')
        span.add_style('vertical-align: middle')

        div_mid.add( span )
        div_mid.add( spacer )

        if my.show_option:
            bgi_close = '_options.png)'
            w += 10
        
        my.div_right.add_styles( "%(bgi_open)s%(pos)s%(bgi_close)s;" %
                                    {'bgi_open': bgi_open, 'pos': 'right', 'bgi_close': bgi_close} )
        my.div_right.add_styles("float: left; height: %spx; width: %spx;" % (h, w) )
        my.top_el.add( div_left )
        my.top_el.add( div_mid )
        my.top_el.add( my.div_right )

        my.top_el.add_styles("overflow: hidden;")
        if my.horiz_align == 'center':
            my.top_el.add_styles("margin: auto;")   # margin: auto -- used for centering in non-IE brwsrs
        elif my.horiz_align == 'left':
            my.top_el.add_styles("margin-left: %s;" % my.horiz_offset)

        if my.vert_offset:
            my.top_el.add_styles("margin-top: %s;" % my.vert_offset)

        if my.width:
            if type(my.width) == str:
                my.width.replace("px","")
            my.top_el.add_styles("width: %spx" % my.width)
        else:
            my.top_el.add_behavior({'type': 'load', 'cbjs_action': 'spt.widget.btn_wdg.set_btn_width( bvr.src_el );' })

        return my.top_el
コード例 #49
0
ファイル: search_limit_wdg.py プロジェクト: rajubuddha/TACTIC
    def get_display(my):

        web = WebContainer.get_web()

        widget = Widget()

        div = SpanWdg(css='med')
        div.set_attr("nowrap", "1")

        limit_wdg = my.text
        limit_wdg.add_event(
            'onchange',
            'if (this.value < 20 || !Common.validate_int(this.value)) this.value=20 '
        )
        limit_wdg.add_style("margin-top: -3px")
        limit_wdg.set_attr("size", "1")
        #limit_wdg.set_value(my.search_limit)

        offset_wdg = HiddenWdg("%s_last_search_offset" % my.label)
        offset_wdg.set_value(my.current_offset)
        #div.add(limit_wdg)
        div.add(offset_wdg)

        if my.search or my.sobjects:
            # my.count should have been set in alter_search()
            # which can be called explicitly thru this instance, my.
            if not my.count:
                my.count = my.search.get_count()

            # if my.sobjects exist thru inheriting from parent widgets
            # or explicitly set, (this is not mandatory though)
            if my.sobjects and len(my.sobjects) < my.search_limit:
                limit = len(my.sobjects)
            elif my.search and my.count < my.search_limit:
                # this is only true if the total result of the search is
                # less than the limit and so this wdg will not display
                limit = my.count
            else:
                limit = my.search_limit

            if my.current_offset == 0 and limit < my.search_limit:
                return None

            if my.refresh:
                prev = IconSubmitWdg("Prev", IconWdg.LEFT, False)
                next = IconSubmitWdg("Next",
                                     IconWdg.RIGHT,
                                     False,
                                     icon_pos="right")
            else:
                prev = IconButtonWdg("Prev", IconWdg.LEFT, False)
                hidden_name = my.prev_hidden_name
                hidden = HiddenWdg(hidden_name, "")
                prev.add(hidden)
                prev.add_event('onclick',"get_elements('%s').set_value('Prev');%s"\
                        %(hidden_name, my.refresh_script))
                next = IconButtonWdg("Next",
                                     IconWdg.RIGHT,
                                     False,
                                     icon_pos="right")
                hidden_name = my.next_hidden_name
                hidden = HiddenWdg(hidden_name, "")
                next.add(hidden)
                next.add_event('onclick',"get_elements('%s').set_value('Next');%s" \
                        %(hidden_name, my.refresh_script))

            label_span = SpanWdg("Showing:")
            label_span.add_style('color', '#c2895d')
            div.add(label_span)
            div.add(prev)

            # this min calculation is used so that if my.sobjects is not set
            # above for the calculation of the limit, which will make the last
            # set of range numbers too big

            left_bound = my.current_offset + 1
            right_bound = min(my.current_offset + limit, my.count)
            if left_bound > right_bound:
                left_bound = 1
            current_value = "%d - %d" % (left_bound, right_bound)

            if my.style == my.SIMPLE:
                div.add(current_value)
            else:
                # add a range selector using ItemsNavigatorWdg
                from input_wdg import ItemsNavigatorWdg
                selector = ItemsNavigatorWdg(my.label,
                                             my.count,
                                             my.search_limit,
                                             refresh=my.refresh)
                selector.set_style(my.style)

                selector.set_value(current_value)
                selector.set_display_label(False)
                if my.refresh_script:
                    selector.set_refresh_script(my.refresh_script)
                div.add(selector)
                div.add(" - ")
                div.add(limit_wdg)

            div.add(next)

            widget.add(div)

        return widget
コード例 #50
0
    def get_action_wdg(my, name):
        '''get the action widget for ui option of note entry'''

        note_wdg = DivWdg()
        note_wdg.add_style("padding-top: 3px")

        # note options

        option = DivWdg(css='spt_uber_note_option')
        cb = CheckboxWdg('is_private')
        #cb.set_default_checked()

        checkbox_name = 'note_master_private_cb'
        master_cb = CheckboxWdg(checkbox_name)
        if master_cb.is_checked():
            cb.set_default_checked()

        option.add_style('margin-right', '5px')
        option.add_style('float', 'right')

        option.add(cb)
        option.add('private')

        #commit = TextBtnWdg(label='save', size='small')
        commit = ActionButtonWdg(title='save', tip="Save Changes")
        commit.add_style('margin-top: -5px')
        commit.add_style('margin-bottom: 5px')
        commit.add_style('float: right')
        commit.add_behavior({
            'type': 'click_up',
            'cbjs_action': '''
            var td = bvr.src_el.getParent(".spt_table_td");
            var text = td.getElement(".spt_note_text");
            text.blur();
            spt.dg_table.update_row(evt, bvr);
            td.setStyle('background-color','');
            ''',
            'cell_only': True
        })
        #commit.set_scale("0.75")

        # do some gynastics to handle a refresh.
        if my.parent_wdg:
            info = my.parent_wdg.get_aux_info()
            sobject_dict = info.get('sobjects')
            sobject = sobject_dict.get(my.get_name())
            parent = info.get('parent')
        else:
            sobject = None
            parent = None

        if not sobject:

            if my.parent_key:
                parent = SearchKey.get_by_search_key(my.parent_key)
            # get the latest note
            #search_key = my.kwargs.get("search_key")
            #if search_key:
            #    sobject = SearchKey.get_by_search_key(search_key)

            search = Search('sthpw/note')
            search.add_parent_filter(parent)
            search.add_filter('context', name)
            # Make the assumption that the last one entered is by timestamp
            search.add_order_by('timestamp desc')
            sobject = search.get_sobject()

        # Show a history of notes
        if sobject:
            history = ActionButtonWdg(title='history', tip="Show note history")
            #history = TextBtnWdg(label='history', size='small')
            #history.get_top_el().add_style("margin-left: 4px")
            #history.get_top_el().add_style('float: left')
            history.add_style("float: left")
            history.add_style("margin-top: -5px")
            history.add_style("margin-bottom: 5px")
            note_wdg.add(history)

            my.parent_key = SearchKey.get_by_sobject(parent)

            context = name
            filter = '[{"prefix":"main_body","main_body_enabled":"on","main_body_column":"context","main_body_relation":"is","main_body_value":"%s"}]' % context
            history.add_behavior({
                'type': 'click_up',
                'cbjs_action': "spt.popup.get_widget(evt, bvr)",
                'options': {
                    'class_name': 'tactic.ui.panel.ViewPanelWdg',
                    'title': 'Notes History',
                    'popup_id': 'Notes_History_%s' % context
                },
                'args': {
                    'search_type': 'sthpw/note',
                    'view': 'summary',
                    'parent_key': my.parent_key,
                    'filter': filter,
                }
            })

        note_wdg.add(commit)
        note_wdg.add(option)

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

        from pyasm.biz import PrefSetting
        quick_text = PrefSetting.get_value_by_key('quick_text')
        if quick_text:
            quick_sel = SelectWdg('quick_text', label='quick: ')
            quick_sel.set_option('values', quick_text)
            quick_sel.add_empty_option('-- text --', '')
            quick_sel.add_behavior({
                'type':
                'change',
                'cbjs_action':
                '''var val = bvr.src_el.value; 
            var text=bvr.src_el.getParent('.spt_note_top').getElement('.spt_note_text')
            text.value = text.value + val;
            '''
            })

            note_wdg.add(SpanWdg(quick_sel, css='small'))
            note_wdg.add(HtmlElement.br(2))
        # Show the last note
        note_wdg.add("<i>Last note</i> ")

        if sobject:
            timestamp = sobject.get_value("timestamp")
            timestamp = parser.parse(timestamp)
            timestamp = timestamp.strftime("%m/%d %H:%M")
            timestamp_div = SpanWdg()
            timestamp_div.add("(%s)" % timestamp)
            note_wdg.add(timestamp_div)
            timestamp_div.add_style("font-size: 11px")
            timestamp_div.add_style("font-style: italic")

            # add a private tag
            access = sobject.get_value("access")
            if access == 'private':
                private = SpanWdg()
                #private.add_style('float: right')
                private.add(" &nbsp; <i>-- private --</i>")
                note_wdg.add(private)

        hr = DivWdg("<hr/>")
        hr.add_style("height: 1px")
        hr.add_style("margin-top: -5px")
        note_wdg.add(hr)

        div = DivWdg()
        note_wdg.add(div)
        div.add_style("max-height", "50px")
        div.add_style("overflow", "auto")
        div.add_style("padding: 3px")
        if sobject:
            value = sobject.get_value('note')
            from pyasm.web import WikiUtil
            value = WikiUtil().convert(value)
            div.add(value)

        else:
            no_notes = DivWdg()
            div.add(no_notes)
            no_notes.add('<i> -- No Notes --</i>')
            no_notes.add_style("font-size: 11px")
            no_notes.add_style("opacity: 0.7")

        return note_wdg
コード例 #51
0
    def get_top_section(self):
        name_div = DivWdg()
        name_div.add("Name")
        name_div.add(self.get_text_input_wdg('name_data', 400))

        title_span = SpanWdg()
        title_span.add_style('display', 'inline-block')
        title_span.add("Title")
        title_span.add(self.get_text_input_wdg('title_data', 400))

        episode_span = SpanWdg()
        episode_span.add_style('display', 'inline-block')
        episode_span.add("Episode")
        episode_span.add(self.get_text_input_wdg('episode', 400))

        cont_span = SpanWdg()
        cont_span.add_style('display', 'inline-block')
        cont_span.add("Cont")
        cont_span.add(self.get_text_input_wdg('cont', 400))

        source_type_span = SpanWdg()
        source_type_span.add_style('display', 'inline-block')
        source_type_span.add("Source Type")
        source_type_span.add(self.get_text_input_wdg('source_type', 400))

        left_div = DivWdg()
        left_div.add_style('float', 'left')
        left_div.add_style('margin-right', '20px')
        left_div.add(title_span)
        left_div.add(episode_span)
        left_div.add(cont_span)
        left_div.add(source_type_span)

        qc_operator_span = SpanWdg()
        qc_operator_span.add_style('display', 'inline-block')
        qc_operator_span.add('QC Operator')
        qc_operator_span.add(self.get_text_input_wdg('qc_operator', 400))

        qc_date_span = SpanWdg()
        qc_date_span.add_style('display', 'inline-block')
        qc_date_span.add('QC Date')
        qc_date_span.add(self.get_date_calendar_wdg())

        trt_feature_span = SpanWdg()
        trt_feature_span.add_style('display', 'inline-block')
        trt_feature_span.add('TRT Feature')
        trt_feature_span.add(self.get_text_input_wdg('trt_feature', 400))

        trt_trailer_preview_span = SpanWdg()
        trt_trailer_preview_span.add_style('display', 'inline-block')
        trt_trailer_preview_span.add('TRT Trailer/Preview')
        trt_trailer_preview_span.add(self.get_text_input_wdg('trt_trailer_preview', 400))

        right_div = DivWdg()
        right_div.add(qc_operator_span)
        right_div.add(qc_date_span)
        right_div.add(trt_feature_span)
        right_div.add(trt_trailer_preview_span)

        section_div = DivWdg()
        section_div.add(name_div)
        section_div.add(left_div)
        section_div.add(right_div)
        section_div.add(self.get_text_area_input_wdg('QC Notes', 'qc_notes'))

        return section_div
コード例 #52
0
    def get_category_wdg(self, category, mode="new"):

        subscriptions = self.get_subscriptions(category, mode)
        if not subscriptions:
            return

        div = DivWdg()
        div.add_style("width: 100%")

        title_div = DivWdg()
        div.add(title_div)
        title_div.add_style("padding: 10px")
        title_div.add_border()
        title_div.add_color("background", "background3")
        title = category or "Subscriptions"
        title_div.add("%s " % title)
        

        summary_div = SpanWdg()
        title_div.add(summary_div)
        summary_div.add_style("font-size: 0.8em")
        summary_div.add_style("opacity: 0.5")


        search_keys = [x.get_search_key() for x in subscriptions]
        button = ActionButtonWdg(title="Clear All")
        button.add_styles('float: right; padding: 2px')
        button_div = DivWdg(button)
        button_div.add_style('min-height: 26px')
        div.add(button_div)

        button.add_behavior( {
            'type': 'click_up',
            'search_keys': search_keys,
            'cbjs_action': '''
            var server = TacticServerStub.get();
            for (var i = 0; i < bvr.search_keys.length; i++) {
                var search_key = bvr.search_keys[i];
                server.update(search_key, {'last_cleared':'NOW'});
            spt.panel.refresh(bvr.src_el);
            }
            '''
        } )



        # types of subscriptions
        table_div = DivWdg()
        table_div.add_styles('overflow-y: auto; max-height: 500px; width: 100%')
        div.add(table_div)
        table = Table()
        table.add_style('width: 100%')
        table.add_border()
        table.add_color("background", "background3")

        
        table_div.add(table)
        ss = []
        for subscription in subscriptions:
            table.add_row()
            td = table.add_cell()

            message_code = subscription.get_value("message_code")
            search = Search("sthpw/message")
            search.add_filter("code", message_code)
            message = search.get_sobject()

            # show the thumb
            if not message:
                if mode == "all":
                    td = table.add_cell(FormatMessageWdg.get_preview_wdg(subscription))
                    td = table.add_cell()
                    td.add("No Messages")
                continue

            size = 60

            
            show_preview = self.kwargs.get('show_preview')
            if show_preview in ['',None]:
                show_preview = True

            msg_element = FormatMessageWdg(subscription=subscription, short_format='true',show_preview=show_preview)
            # this is optional
            msg_element.set_sobject(message)
            description = msg_element.get_buffer_display() 
          
            #td = table.add_cell()

            history_icon = IconButtonWdg(title="Subscription History", icon=IconWdg.HISTORY)
            #td.add(icon)
            message_code = subscription.get_value("message_code")
            history_icon.add_behavior( {
                'type': 'click_up',
                'message_code': message_code,
                'cbjs_action': '''
                var class_name = 'tactic.ui.panel.FastTableLayoutWdg';
                var message_code = bvr.message_code;
                var kwargs = {
                    search_type: 'sthpw/message_log',
                    show_shelf: false,
                    expression: "@SOBJECT(sthpw/message_log['message_code','"+message_code+"'])",
                    view: 'history'
                };
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Message History", "Message History", class_name, kwargs);
                '''
            } )
 

            # description can take up 70%
            td = table.add_cell()
            td.add_style("width: %spx"%(SubscriptionBarWdg.WIDTH*0.7))

            desc_div = DivWdg()
            td.add(desc_div)
            desc_div.add(description)
            desc_div.add_style("padding: 0px 20px")

            td = table.add_cell()
            #td.add(message.get_value("status"))
            #td = table.add_cell()
            timestamp = message.get_datetime_value("timestamp")
            if timestamp:
                timestamp_str = timestamp.strftime("%b %d, %Y - %H:%M")
            else:
                timestamp_str = ""

            
            show_timestamp = self.kwargs.get('show_timestamp')
            if show_timestamp in ['',None]:
                show_timestamp = True

            if show_timestamp in ["True","true",True]:
                td.add(timestamp_str)

            #td = table.add_cell()
            #td.add(subscription.get_value("last_cleared"))

            td = table.add_cell()
            
            show_message_history = self.kwargs.get('show_message_history')
            if show_message_history in ['',None]:
                show_message_history = True
            if show_message_history in ["True","true",True]:
                td.add(history_icon)

            td.add(HtmlElement.br(2))
            td.add_style('width: 30px')
            icon = IconButtonWdg(title="Unsubscribe", icon=IconWdg.DELETE)
            icon.add_style('bottom: 14px')

            subscription_key = subscription.get_search_key()
            icon.add_behavior( {
                'type': 'click_up',
                'search_key': subscription_key,
                'message_code': message_code,
                'cbjs_action': '''
                    if (!confirm("Unsubscribe from [" + bvr.message_code + "]?")) {
                        return;
                    }
                    var top = bvr.src_el.getParent(".spt_subscription_top");
                    var server = TacticServerStub.get();
                    server.delete_sobject(bvr.search_key);
                    spt.panel.refresh(top);
                '''
            } )
            
            show_unsubscribe = self.kwargs.get('show_unsubscribe')
            if show_unsubscribe in ['',None]: 
                show_unsubscribe = False
            if show_unsubscribe in ["True","true",True]:
                td.add(icon)

            
            






            ss.append(subscription)

        num_sobjects = len(ss)
        if not num_sobjects:
            return None
        summary_div.add("(%s changes)" % num_sobjects)

        #from tactic.ui.panel import FastTableLayoutWdg
        #table = FastTableLayoutWdg(search_type="sthpw/subscription",show_shelf=False)
        #div.add(table)
        #table.set_sobjects(ss)


        return div
コード例 #53
0
ファイル: search_limit_wdg.py プロジェクト: hellios78/TACTIC
    def get_display(my):

        web = WebContainer.get_web()

        widget = DivWdg()
        widget.add_class("spt_search_limit_top")
        #widget.add_style("border", "solid 1px blue")
        widget.add_color("background", "background")
        widget.add_color("color", "color")
        widget.add_style("padding: 5px")

        hidden = HiddenWdg("prefix", my.prefix)
        widget.add(hidden)

   
        if not my.search and not my.sobjects:
            widget.add("No search or sobjects found")
            return widget

        # my.count should have been set in alter_search()
        # which can be called explicitly thru this instance, my.
        if not my.count:
            my.count = my.search.get_count(no_exception=True)
        
        # if my.sobjects exist thru inheriting from parent widgets
        # or explicitly set, (this is not mandatory though)
        if my.sobjects and len(my.sobjects) < my.search_limit:
            limit = len(my.sobjects)
        elif my.search and my.count < my.search_limit:
            # this is only true if the total result of the search is 
            # less than the limit and so this wdg will not display
            limit = my.count
        else:
            limit = my.search_limit

        if not limit:
            limit = 50
            my.search_limit = limit

    
        if my.refresh: 
            prev = SpanWdg( IconButtonWdg("Prev", IconWdg.LEFT, False ) )
            prev.add_style("margin-left: 8px")
            prev.add_style("margin-right: 6px")
            prev.add_style("margin-top: -2px")
            next = IconButtonWdg("Next", IconWdg.RIGHT, False, icon_pos="right" )
            next.add_style("margin-left: 6px")

            prev.add_behavior( {
                'type': 'click_up',
                'cbjs_action': my.refresh_script
            } )
            next.add_behavior( {
                'type': 'click_up',
                'cbjs_action': my.refresh_script
            } )
        else: # the old code pre 2.5
            prev = IconButtonWdg("Prev", IconWdg.LEFT, False )
            hidden_name = my.prev_hidden_name
            hidden = HiddenWdg(hidden_name,"")
            prev.add(hidden)
            prev.add_event('onclick'," spt.api.Utility.get_input(document,'%s').value ='Prev';%s"\
                    %(hidden_name, my.refresh_script))
            next = IconButtonWdg("Next", IconWdg.RIGHT, False, icon_pos="right" )
            hidden_name = my.next_hidden_name
            hidden = HiddenWdg(hidden_name,"")
            next.add(hidden)
            next.add_event('onclick',"spt.api.Utility.get_input(document,'%s').value ='Next';%s" \
                    %(hidden_name, my.refresh_script))


        showing_wdg = DivWdg()
        widget.add(showing_wdg)
        showing_wdg.add_style("padding: 10px")
        showing_wdg.add_style("margin: 10px")
        showing_wdg.add_color("background", "background", -5)
        showing_wdg.add_border()

        label_span = SpanWdg("Showing: ")
        showing_wdg.add(label_span)
        showing_wdg.add( prev )
       

        # this min calculation is used so that if my.sobjects is not set
        # above for the calculation of the limit, which will make the last 
        # set of range numbers too big
        
        left_bound = my.current_offset+1
        if not limit:
            # prevent error in ItemsNavigatorWdg if a search encounters query error
            limit = 50
            my.search_limit = limit

        right_bound = min(my.current_offset+limit, my.count)
        if left_bound > right_bound:
            left_bound = 1
        current_value = "%d - %d" % (left_bound, right_bound)

        if my.style == my.SIMPLE:
            showing_wdg.add( current_value )
        else:
            # add a range selector using ItemsNavigatorWdg
            from pyasm.widget import ItemsNavigatorWdg
            selector = ItemsNavigatorWdg(my.label, my.count, my.search_limit)
            selector.select.add_behavior( {
                'type': 'change',
                'cbjs_action': my.refresh_script
            } )

            selector.set_style(my.style)

            selector.set_value(current_value)
            selector.set_display_label(False)

            showing_wdg.add( selector) 

        showing_wdg.add( next )

        #showing_wdg.add( " x ")
        showing_wdg.add(my.text)
        my.text.add_style("margin-top: -3px")
        my.text.set_attr("size", "1")
        my.text.add_attr("title", "Set number of items per page")

        widget.add("<hr/>")


        # set the limit
        set_limit_wdg = my.get_set_limit_wdg()
        widget.add(set_limit_wdg)


        from tactic.ui.widget.button_new_wdg import ActionButtonWdg
        button = ActionButtonWdg(title='Search')
        widget.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: 8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_search_limit_top");
            var select = top.getElement(".spt_search_limit_select");
            var value = select.value;
            if (value == 'Custom') {
                custom = top.getElement(".spt_search_limit_custom_text");
                value = custom.value;
            }
            if (value == '') {
                value = 20;
            }
            var text = top.getElement(".spt_search_limit_text");
            text.value = value;

            spt.dg_table.search_cbk({}, bvr) 
            '''
        } )


        offset_wdg = HiddenWdg("%s_last_search_offset" %my.label)
        offset_wdg.set_value(my.current_offset)
        widget.add(offset_wdg)

        widget.add("<br clear='all'/>")
 
        return widget
コード例 #54
0
ファイル: shelf_wdg.py プロジェクト: 2gDigitalPost/tactic_src
    def get_script_wdg(my):

        search = Search("config/custom_script")
        #search.add_user_filter()
        search.add_order_by("folder")
        search.add_order_by("title")
        scripts = search.get_sobjects()

        widget = DivWdg()
        widget.add_style("width: 100%")

        from pyasm.web.palette import Palette
        palette = Palette.get()
        bg_color = palette.color("background3")
        hover_color = palette.color("background3", 20)
        widget.add_color("background", bg_color)

        '''
        # Try the table layout widget
        from tactic.ui.panel import TableLayoutWdg
        table = TableLayoutWdg(id='js_edit_list',search_type="config/custom_script", view='simple')
        table.set_sobjects(scripts)
        widget.add(table)
        '''

        title = DivWdg()
        title.add("Saved Scripts")
        title.add_style("font-size: 14px")
        title.add_color("color", "color")
        title.add_style("padding: 8px 3px")
        title.add_style("margin: 0 0 0 -1")
        title.add_color("background", "background", -5)
        title.add_border()
        widget.add(title)


        script_div = DivWdg()
        script_div.add_border()
        script_div.add_color("background", "background3")
        script_div.add_color("color", "color3")
        script_div.add_style("padding: 8px")
        script_div.add_style("overflow-x: hidden")
        script_div.add_style("overflow-y: auto")
        script_div.add_style("height: 100%")
        script_div.add_style("min-width: 100px")
        script_div.add_style("width: 220px")
        script_div.add_style("margin: -1px 0px 0px -1px")
        script_div.add_class("spt_resizable")

        inner = DivWdg()
        script_div.add(inner)
        inner.add_style("height: 100%")
        inner.add_style("width: 800px")

        last_folder = ''
        for script in scripts:
            title = script.get_value("title")
            folder = script.get_value("folder")
            language = script.get_value("language", no_exception=True)
            if not language:
                language = 'javascript'

            if folder != last_folder:
                div = DivWdg()
                icon = IconWdg("Script", IconWdg.FOLDER)
                div.add(icon)
                div.add(" %s" % folder)
                inner.add(div)


            last_folder = folder

            div = DivWdg()
            inner.add(div)
            div.add_class('hand')
            icon = IconWdg("Script", IconWdg.TOGGLE_ON)
            icon.add_style("margin-left: 10px")
            div.add(icon)
            div.add("%s" %title)

            span = SpanWdg()
            span.add_style("font-size: 9px")
            span.add_style("opacity: 0.2")
            span.add(" <i>(%s)</i>" % language)
            div.add(span)

            div.add_event("onmou8eover", "this.style.background='%s'" % hover_color)
            div.add_event("onmouseout", "this.style.background='%s'" % bg_color)


            behavior = {
                'type': 'click_up',
                'editor_id': my.editor_id, 
                'cbjs_action': 'spt.script_editor.display_script_cbk(evt, bvr)',
                'code': script.get_code()
            }
            div.add_behavior(behavior)



        widget.add(script_div)

        return widget
コード例 #55
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
コード例 #56
0
    def get_display(my):

        web = WebContainer.get_web()

        widget = DivWdg()
        widget.add_class("spt_search_limit_top")
        #widget.add_style("border", "solid 1px blue")
        widget.add_color("background", "background")
        widget.add_color("color", "color")
        widget.add_style("padding: 5px")

        hidden = HiddenWdg("prefix", my.prefix)
        widget.add(hidden)

        if not my.search and not my.sobjects:
            widget.add("No search or sobjects found")
            return widget

        # my.count should have been set in alter_search()
        # which can be called explicitly thru this instance, my.
        if not my.count:
            my.count = my.search.get_count(no_exception=True)

        # if my.sobjects exist thru inheriting from parent widgets
        # or explicitly set, (this is not mandatory though)
        if my.sobjects and len(my.sobjects) < my.search_limit:
            limit = len(my.sobjects)
        elif my.search and my.count < my.search_limit:
            # this is only true if the total result of the search is
            # less than the limit and so this wdg will not display
            limit = my.count
        else:
            limit = my.search_limit

        if not limit:
            limit = 50
            my.search_limit = limit

        if my.refresh:
            prev = SpanWdg(IconButtonWdg("Prev", IconWdg.LEFT, False))
            prev.add_style("margin-left: 8px")
            prev.add_style("margin-right: 6px")
            prev.add_style("margin-top: -2px")
            next = IconButtonWdg("Next",
                                 IconWdg.RIGHT,
                                 False,
                                 icon_pos="right")
            next.add_style("margin-left: 6px")

            prev.add_behavior({
                'type': 'click_up',
                'cbjs_action': my.refresh_script
            })
            next.add_behavior({
                'type': 'click_up',
                'cbjs_action': my.refresh_script
            })
        else:  # the old code pre 2.5
            prev = IconButtonWdg("Prev", IconWdg.LEFT, False)
            hidden_name = my.prev_hidden_name
            hidden = HiddenWdg(hidden_name, "")
            prev.add(hidden)
            prev.add_event('onclick'," spt.api.Utility.get_input(document,'%s').value ='Prev';%s"\
                    %(hidden_name, my.refresh_script))
            next = IconButtonWdg("Next",
                                 IconWdg.RIGHT,
                                 False,
                                 icon_pos="right")
            hidden_name = my.next_hidden_name
            hidden = HiddenWdg(hidden_name, "")
            next.add(hidden)
            next.add_event('onclick',"spt.api.Utility.get_input(document,'%s').value ='Next';%s" \
                    %(hidden_name, my.refresh_script))

        showing_wdg = DivWdg()
        widget.add(showing_wdg)
        showing_wdg.add_style("padding: 10px")
        showing_wdg.add_style("margin: 10px")
        showing_wdg.add_color("background", "background", -5)
        showing_wdg.add_border()

        label_span = SpanWdg("Showing: ")
        showing_wdg.add(label_span)
        showing_wdg.add(prev)

        # this min calculation is used so that if my.sobjects is not set
        # above for the calculation of the limit, which will make the last
        # set of range numbers too big

        left_bound = my.current_offset + 1
        if not limit:
            # prevent error in ItemsNavigatorWdg if a search encounters query error
            limit = 50
            my.search_limit = limit

        right_bound = min(my.current_offset + limit, my.count)
        if left_bound > right_bound:
            left_bound = 1
        current_value = "%d - %d" % (left_bound, right_bound)

        if my.style == my.SIMPLE:
            showing_wdg.add(current_value)
        else:
            # add a range selector using ItemsNavigatorWdg
            from pyasm.widget import ItemsNavigatorWdg
            selector = ItemsNavigatorWdg(my.label, my.count, my.search_limit)
            selector.select.add_behavior({
                'type': 'change',
                'cbjs_action': my.refresh_script
            })

            selector.set_style(my.style)

            selector.set_value(current_value)
            selector.set_display_label(False)

            showing_wdg.add(selector)

        showing_wdg.add(next)

        #showing_wdg.add( " x ")
        showing_wdg.add(my.text)
        my.text.add_style("margin-top: -3px")
        my.text.set_attr("size", "1")
        my.text.add_attr("title", "Set number of items per page")

        widget.add("<hr/>")

        # set the limit
        set_limit_wdg = my.get_set_limit_wdg()
        widget.add(set_limit_wdg)

        from tactic.ui.widget.button_new_wdg import ActionButtonWdg
        button = ActionButtonWdg(title='Search')
        widget.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: 8px")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_search_limit_top");
            var select = top.getElement(".spt_search_limit_select");
            var value = select.value;
            if (value == 'Custom') {
                custom = top.getElement(".spt_search_limit_custom_text");
                value = custom.value;
            }
            if (value == '') {
                value = 20;
            }
            var text = top.getElement(".spt_search_limit_text");
            text.value = value;

            spt.dg_table.search_cbk({}, bvr) 
            '''
        })

        offset_wdg = HiddenWdg("%s_last_search_offset" % my.label)
        offset_wdg.set_value(my.current_offset)
        widget.add(offset_wdg)

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

        return widget
コード例 #57
0
ファイル: button_wdg.py プロジェクト: zieglerm/TACTIC
    def get_display(self):

        web = WebContainer.get_web()
        skin = web.get_skin()

        # default to 'small' size ...
        h = 16
        fnt_sz = 11

        if self.size == 'medium':
            h = 18
            fnt_sz = 13
        elif self.size == 'large':
            h = 20
            fnt_sz = 15

        w = (h / 2) - 1

        self.top_el.add_styles("height: %spx;" % (h))

        t_styles = "color: #c2c2c2; border: 0px; border-collapse: collapse; padding: 0px"
        bgi_open = "background-image: url(/context/themes/%(skin)s/images/text_btn/%(skin)s_btn_h%(h)s_" % \
                    {'skin': skin, 'h': h}
        bgi_close = ".png)"

        # pos_list = [ 'left', 'middle', 'right' ]
        spacer = HtmlElement.img(IconWdg.get_icon_path("TRANSPARENT"))
        spacer.add_styles("width: 2px;")

        div_left = DivWdg()
        div_left.add_styles("%(bgi_open)s%(pos)s%(bgi_close)s;" % {
            'bgi_open': bgi_open,
            'pos': 'left',
            'bgi_close': bgi_close
        })
        div_left.add_styles("float: left; height: %spx; width: %spx;" % (h, w))

        div_mid = DivWdg()
        div_mid.add_styles("%(bgi_open)s%(pos)s%(bgi_close)s;" % {
            'bgi_open': bgi_open,
            'pos': 'middle',
            'bgi_close': bgi_close
        })
        div_mid.add_styles("float: left; height: %spx; width: auto;" % (h))
        div_mid.add_styles("color: #c2c2c2;")
        div_mid.add_styles("vertical-align: middle")
        # move the text lower by 1 px
        div_mid.add_style('padding-top: 1px')

        div_mid.add_styles(
            "font-family: Arial, Helvetica, sans-serif; font-size: %spx;" %
            fnt_sz)
        div_mid.add(spacer)
        span = SpanWdg(self.label)

        # this is better fixed. Bold fonts don't look good
        span.add_style('font-weight: 100')
        span.add_style('vertical-align: middle')

        div_mid.add(span)
        div_mid.add(spacer)

        if self.show_option:
            bgi_close = '_options.png)'
            w += 10

        self.div_right.add_styles("%(bgi_open)s%(pos)s%(bgi_close)s;" % {
            'bgi_open': bgi_open,
            'pos': 'right',
            'bgi_close': bgi_close
        })
        self.div_right.add_styles("float: left; height: %spx; width: %spx;" %
                                  (h, w))
        self.top_el.add(div_left)
        self.top_el.add(div_mid)
        self.top_el.add(self.div_right)

        self.top_el.add_styles("overflow: hidden;")
        if self.horiz_align == 'center':
            self.top_el.add_styles(
                "margin: auto;"
            )  # margin: auto -- used for centering in non-IE brwsrs
        elif self.horiz_align == 'left':
            self.top_el.add_styles("margin-left: %s;" % self.horiz_offset)

        if self.vert_offset:
            self.top_el.add_styles("margin-top: %s;" % self.vert_offset)

        if self.width:
            if type(self.width) == str:
                self.width.replace("px", "")
            self.top_el.add_styles("width: %spx" % self.width)
        else:
            self.top_el.add_behavior({
                'type':
                'load',
                'cbjs_action':
                'spt.widget.btn_wdg.set_btn_width( bvr.src_el );'
            })

        return self.top_el
コード例 #58
0
ファイル: project_config_wdg.py プロジェクト: nuxping/TACTIC
    def get_display(my):

        expr_filter = "sthpw/login['login','not in','admin|guest']['begin']['license_type','user']['license_type','is','NULL']['or']"
        current_users = Search.eval("@COUNT(%s)" %expr_filter)

        top = my.top
        top.add_class("spt_panel_user_top")
        top.add_style("min-width: 400px")
        
        tool_div = DivWdg()
        # tool_div.add_style('margin-bottom','8px')
        tool_div.add_style('display','inline-flex')
        tool_div.add_style('width','50%')
        tool_div.add_style('margin-bottom','-4px')
       
        button = ActionButtonWdg(title="Add", tip="Add New User")
        button.add_style('align-self: flex-end')
        tool_div.add(button)
        
        button.add_style("float: left")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.panel.EditWdg';
            var kwargs = {
                search_type: "sthpw/login",
                view: "edit",
                show_header: false,
            }
            var popup = spt.panel.load_popup("Create New User", class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_panel_user_top");
            popup.on_save_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )


        security = Environment.get_security()
        license = security.get_license()
        num_left = license.get_num_licenses_left()
        current_users = license.get_current_users()
        #max_users = license.get_max_users()


        div = DivWdg('Users')
        div.add_style('align-self: flex-end')
        div.add_styles("margin: 0 0 6px 20px")
        badge_span = SpanWdg(css='badge')
        badge_span.add_style('margin-left','6px')
        badge_span.add(current_users)
        div.add(badge_span)
        tool_div.add(div)

        tool_div2 = DivWdg()
        # tool_div.add_style('margin-bottom','8px')
        tool_div2.add_style('display','inline-flex')
        tool_div2.add_style('justify-content','flex-end')
        tool_div2.add_style('width','50%')

        top.add(tool_div)
        top.add(tool_div2)


        if num_left < 1000:
            div = DivWdg('Users Left')
            div.add_style('align-self: flex-end')
            div.add_styles("margin: 0 0 6px 20px")
            badge_span = SpanWdg(css='badge')
            badge_span.add_style('margin-left','6px')
            badge_span.add(num_left)
            div.add(badge_span)
            tool_div.add(div)

            top.add(tool_div)


        show_security = my.kwargs.get("show_security")
        if show_security not in ['false', False]:
            button = ActionButtonWdg(title="Security")
            button.add_style('align-self: flex-end')
            #button.add_styles("position: absolute; right: 10px;")
            tool_div2.add(button)
            #button.add_style("margin-top: -8px")
            button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.startup.SecurityWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("Security", "Security", class_name)
            '''
            } )




        br = HtmlElement.br(clear=True)
        top.add(br)



        if not current_users:
            div = DivWdg()
            top.add(div)
            div.add_style("text-align: center")
            div.add_border()
            div.add_style("min-height: 150px")
            div.add_style("margin: 15px 30px 30px 30px")
            div.add_style("padding: 30px 20px 0px 20px")
            div.add_color("background", "background3")
            icon = IconWdg( "WARNING", IconWdg.WARNING )
            div.add(icon)
            div.add("<b>No users have been added</b>")
            div.add("<br/><br/>")
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias=my.get_help_alias())
            div.add(help)
            div.add("<br/>")
            div.add("Click on the 'Add' button above to start adding new users.")

            return top




        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")
        expr = "@SEARCH(%s)" %expr_filter
        panel = ViewPanelWdg(search_type='sthpw/login',view='manage_user',show_insert='false',\
            show_gear='false', show_select='false', height='700', expression=expr,\
            simple_search_view='simple_manage_filter', show_column_manager='false',\
            show_layout_switcher='false', show_expand='false')
        div.add(panel)
        div.add_style('margin-top', '4px')
        
        return top

        """
コード例 #59
0
    def get_value(self, name=None):
        if not name:
            name = self.get_name()

        div = DivWdg()
        div.add_style("display: inline-block")

        value = super(LoginTableElementWdg, self).get_value(name)
        if value:
            user = Search.get_by_code("sthpw/login", value)
            if user:
                value = user.get_value("display_name") or value

        #return value

        self.sobject = self.get_current_sobject()

        if self.is_editable() and not value:
            empty = SpanWdg()
            div.add(empty)
            div.add_style("text-align: center")
            div.add_style("width: 100%")
            div.add_style("white-space: nowrap" )
            empty.add("--Select--")
            empty.add_style("opacity: 0.5")
            return div

        div.add(value)

        # display a link if specified

        from pyasm.biz import ProjectSetting
        link_expr = ProjectSetting.get_value_by_key("task/assigned/link_expression")
        if not link_expr:
            link_expr = "@SOBJECT(sthpw/login)"

        if self.sobject and link_expr:
            # using direct behavior because new_tab isn't working consistently
            #div.add_class("tactic_new_tab")
            div.add_style("text-decoration", "underline")
            #div.add_class("tactic_new_tab")
            div.add_attr("search_key", self.sobject.get_search_key())
            div.add_attr("expression", link_expr)
            div.add_class("hand")

            search_type_sobj = self.sobject.get_search_type_obj()
            sobj_title = value

            #name = self.sobject.get_value("name", no_exception=True)
            name = None
            if not name:
                name = self.sobject.get_code()
            div.add_attr("name", value)

            # click up blocks any other behavior
            div.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.table.open_link(bvr);
                '''
            } )



        return div