Beispiel #1
0
    def get_example_display(self):

        div = DivWdg()
        div.add_styles("background: grey; padding: 10px; width: 450px;")
        div.add("<br/><br/>")

        from tactic.ui.container import RoundedCornerDivWdg
        rc_wdg = RoundedCornerDivWdg(corner_size=10)
        # rc_wdg.set_dimensions(width_str="100%", content_height_str='100%', height_str="100%")
        rs0_wdg = ResizeScrollWdg(
            width=300,
            height=200,
            scroll_bar_size_str='thin',
            scroll_expansion='inside',
            # max_content_w=500, max_content_h=400,
            set_max_to_content_size=True,
            min_content_w=100,
            min_content_h=50)
        rs0_wdg.add(self.get_popwin_oversize_content())

        rc_wdg.add(rs0_wdg)
        div.add(rc_wdg)

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

        div.add(
            "<p style='color: black;'>Resize/Scroll Widget example ...</p>")
        rs_wdg = ResizeScrollWdg(width=300,
                                 height=200,
                                 scroll_bar_size_str='thin',
                                 scroll_expansion='inside')
        rs_wdg.add(self.get_popwin_oversize_content())
        div.add(rs_wdg)

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

        div.add( "<p style='color: black;'>Resize/Scroll Widget example WITH NO RESIZE CAPABILITY" \
                 " (just scroll bars) ...</p>" )
        rs2_wdg = ResizeScrollWdg(width=300,
                                  height=200,
                                  scroll_bar_size_str='thin',
                                  scroll_expansion='inside',
                                  no_resize=True)
        rs2_wdg.add(self.get_popwin_oversize_content())
        div.add(rs2_wdg)

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

        popwin_id = "NewPopupWindowTest"
        popwin_title = "New Popup Window Widget Test"
        popwin = PopWindowWdg(top_id=popwin_id,
                              title=popwin_title,
                              width=150,
                              height=150)
        popwin.add(self.get_popwin_oversize_content())
        div.add(popwin)
        pwin_launch = DivWdg()

        pwin_launch.add_styles(
            "cursor: pointer; background-color: red; color: black; border: 1px solid black; width: 100px; height: 50px;"
        )
        pwin_launch.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            'spt.popup.open("' + popwin_id + '");'
        })
        pwin_launch.add("Click to launch New Popup Window")
        div.add(pwin_launch)

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

        test_div = DivWdg()
        test_div.add_styles(
            "background: black; padding: 10px; width: 350px; text-align: center;"
        )

        test_div.add(
            SpanWdg("This black DIV has<br/>text-align set to center"))

        my_table = Table()
        my_table.add_row()
        my_table.add_cell("This").add_styles(
            "border: 1px solid white; padding: 4px;")
        my_table.add_cell("that").add_styles(
            "border: 1px solid white; padding: 4px;")
        my_table.add_cell("and").add_styles(
            "border: 1px solid white; padding: 4px;")
        my_table.add_cell("The").add_styles(
            "border: 1px solid white; padding: 4px;")
        my_table.add_cell("other").add_styles(
            "border: 1px solid white; padding: 4px;")

        test_div.add("<br/><br/>")
        test_div.add(my_table)

        test_div.add("<br/><br/>")
        tmp_div = DivWdg()
        tmp_div.add_styles(
            "width: 200px; background-color: green; color: black; padding: 10px;"
        )
        tmp_div.add("I am a DIV without self margins set")
        test_div.add(tmp_div)

        test_div.add("<br/><br/>")
        tmp_div = DivWdg()
        tmp_div.add_styles(
            "width: 200px; background-color: green; color: black; padding: 10px;"
        )
        tmp_div.center()
        tmp_div.add(
            "I am a DIV with self margins<br/>set using HtmlElement.center()")
        test_div.add(tmp_div)

        test_div.add("<br/><br/>")
        buttons_list = [{
            'label': "Insert",
            'tip': "This is an insert",
            'bvr': {
                'cbjs_action': 'alert("Insert!");'
            }
        }, {
            'label': 'Cancel',
            'tip': 'Cancel',
            'bvr': {
                'cbjs_action': 'alert("Cancel!");'
            }
        }]
        buttons = TextBtnSetWdg(float="",
                                align="center",
                                buttons=buttons_list,
                                spacing=6,
                                size='medium',
                                side_padding=4)
        test_div.add(buttons)

        div.add(test_div)

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

        buttons_list = [
            {
                'label': 'One',
                'tip': 'Button One',
                'bvr': {
                    'cbjs_action': 'alert("First button!");'
                }
            },
            {
                'label': 'Two',
                'tip': 'Button Two',
                'bvr': {
                    'cbjs_action': 'alert("Second button!");'
                }
            },
            {
                'label': 'Three',
                'tip': 'Button Three',
                'bvr': {
                    'cbjs_action': 'alert("Third button!");'
                }
            },
            {
                'label': 'Four',
                'tip': 'Button Four',
                'bvr': {
                    'cbjs_action': 'alert("Fourth button!");'
                }
            },
        ]

        txt_btn_set = TextBtnSetWdg(float='right',
                                    buttons=buttons_list,
                                    spacing=6,
                                    size='large',
                                    side_padding=4)
        txt_btn_set.get_btn_by_label('Three').add_behavior({
            'type':
            'click_up',
            'modkeys':
            'SHIFT',
            'cbjs_action':
            'alert("SHIFT happened!");'
        })
        div.add(txt_btn_set)

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

        d1 = self.get_simple_div(
            "Drop Zone (runs cbjs_action of drag-drop element on drop)", None)
        d1.set_attr("SPT_ACCEPT_DROP", "Qweejibo")
        d1.add_behavior({
            'type': 'hover',
            'mod_styles': 'background-color: green;'
        })

        table1 = Table()
        tr = table1.add_row()
        tr.add_behavior({
            'type': 'hover',
            'mod_styles': 'background-color: #f11; color: green'
        })

        td = table1.add_cell('what')
        #td.add_behavior( { 'type': 'hover', 'mod_styles': 'background-color: orange;' } )
        td = table1.add_cell('is')
        #td.add_behavior( { 'type': 'hover', 'mod_styles': 'background-color: green;' } )
        div.add(table1)

        # d2 = self.get_simple_div( "Pick Up!", "white" )
        d2 = self.get_simple_div("Override with 'accept_drop' behavior!", None)
        d2.add_looks("menu")

        # NOTE: with 'accept_drop' behavior you do not need to set the "SPT_ACCEPT_DROP" attribute on the
        #       given drop-on element, just need to add the same value to a 'drop_code' attribute in the
        #       'accept_drop' bvr spec (doing this will automatically add it to the SPT_ACCEPT_DROP at
        #       behavior construction time
        # so we do not need this here --> d2.set_attr("SPT_ACCEPT_DROP","Qweejibo")
        d2.add_behavior({
            'type': 'accept_drop',
            'cbjs_action': 'log.debug("Override #1 on Qweejibo");',
            'drop_code': 'Qweejibo'
        })
        d2.add_behavior({
            'type': 'accept_drop',
            'cbjs_action': '''
                log.debug("Override #2 on Qweejibo");
                var el = bvr._drop_source_bvr.src_el;
                el.setStyle("background-color", "white");
            ''',
            'drop_code': 'Qweejibo'
        })

        d2.add_behavior({'type': 'hover', 'add_looks': 'menu_hover'})
        d2.add_behavior({
            'type': 'hover',
            'mod_styles': 'border: 1px solid red;',
            'drag_drop_codes': 'Qweejibo',
        })

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

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

        btn = DivWdg()
        btn.add("TEST JS LOG TIME")
        btn.add_styles(
            "padding: 4px; width: 150px; cursor: pointer; background: red; color: white; "
            + "border: 1px solid white;")
        btn.add_behavior({
            'type': 'click',
            'cbjs_action': 'spt.js_log.test_perf();'
        })

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

        dragme = DivWdg()
        dragme.add_styles( "background: blue; padding: 10px; width: 200px; border: 1px solid black; " \
                           "position: absolute; top: 200px; left: 400px; cursor: default;" )
        dragme.add("Click me OR Drag me!")

        # dragme.add_behavior( { 'type': 'drag', 'drag_el': '@', 'use_default_cbs': 'true',
        #                        'cbjs_action_onnomotion': 'alert("I\'ve been clicked!");' } )

        dragme.add_behavior({
            'type':
            'smart_drag',
            'drag_el':
            '@',
            'use_copy':
            'true',
            'use_delta':
            'true',
            'dx':
            1,
            'dy':
            1,
            'drop_code':
            'Qweejibo',
            'copy_styles':
            'background: red; opacity: .3;',
            'cbjs_action':
            'alert("Got Qweejibo");',
            'cbjs_action_onnomotion':
            'alert("I\'ve been clicked!");'
        })

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

        select = SelectWdg("OnChangeTestSelectWidget")
        select.add_behavior({
            'type':
            'change',
            'cbjs_preaction':
            '''
                alert("Click OK then see Web Client Output Log for 'change' behavior activity");
                log.debug("[preaction] My value is now: "+bvr.src_el.value);
                ''',
            'cbjs_action':
            'log.debug("[action] My value is now: "+bvr.src_el.value);',
            'cbjs_postaction':
            'log.debug("[postaction] My value is now: "+bvr.src_el.value);'
        })
        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            'log.debug("ORIG - stacked change behavior #2!");'
        })
        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            'log.debug("ORIG - stacked change behavior #3!");'
        })
        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            'log.debug("ORIG - stacked change behavior #4!");'
        })
        select.set_option("values", "One|Day|In|Your|Life")
        select.set_value("Life")

        # Test for set_behavior override with stacked onchange behaviors ...
        '''
        select.set_behavior( {'type': 'change', 'cbjs_action': 'alert("This is what me gots: "+bvr.src_el.value);'} );
        select.add_behavior( {'type': 'change', 'cbjs_action': 'log.debug("OVERRIDE - stacked change behavior #5!");'} );
        select.add_behavior( {'type': 'change', 'cbjs_action': 'log.debug("OVERRIDE - stacked change behavior #6!");'} );
        '''

        div.add(select)

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

        click_core_div = DivWdg()
        click_core_div.add_styles(
            "background-color: blue; color: white; border: 1px solid black; padding: 10px"
        )
        click_core_div.add_styles("cursor: pointer;")
        click_core_div.add("Click me for preaction, action, postaction test")
        click_core_div.add_behavior({
            'type':
            'click',
            'cbjs_preaction':
            '''
                alert("Click OK then see Web output log for 'click' behavior activity");
                log.debug("Click pre-action");
            ''',
            'cbjs_action':
            'log.debug("Click action");',
            'cbjs_postaction':
            'log.debug("Click post-action");'
        })

        div.add(click_core_div)

        div.add("<br/><br/>")
        override = DivWdg()
        override.add_styles(
            "padding: 4px; background: white; color: black; border: 1px solid black; cursor: pointer;"
        )
        override.add("Set Behavior Override Test")

        bvr = {
            'type': 'click',
            'modkeys': 'SHIFT',
            'cbjs_action': 'alert("Load ONE");'
        }
        override.add_behavior(bvr)

        bvr = {
            'type': 'click',
            'modkeys': 'SHIFT',
            'cbjs_action': 'alert("Load ONE OVERRIDDEN!");'
        }
        override.set_behavior(bvr)

        div.add(override)

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

        div1 = DivWdg()
        div1.add_styles(
            "background: #444477; border: solid 1px black; padding: 10px;")
        div1.add("Div1")
        div1.set_id("Div_1")

        div2 = DivWdg()
        div2.add_styles(
            "background: #4444BB; border: solid 1px black; padding: 10px; cursor: pointer;"
        )
        div2.add("Div2")
        div2.set_id("Div_2")

        # div2.add_behavior( { 'type': 'click_up', 'cbjs_action': '$("Div_3").inject("Div_2","after");' } )
        div2.add_behavior({
            'type': 'click_up',
            'cbjs_action': '$("Div_3").inject("Div_1","bottom");'
        })

        div1.add(div2)

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

        div3 = DivWdg()
        div3.add_styles(
            "background: #4444FF; border: solid 1px black; padding: 10px;")
        div3.add("Div3")
        div3.set_id("Div_3")

        div.add(div3)

        return div
Beispiel #2
0
    def get_first_row_wdg(my):

        # read the csv file
        my.file_path = ""

        div = DivWdg()

        div.add( my.get_upload_wdg() )

        if not my.search_type:
            return div

        if not my.file_path:
            return div


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

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

        div.add(HtmlElement.br(2))

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

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

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


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

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



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

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




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

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

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

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

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

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


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

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

                # new property
                new_column_div = DivWdg()

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

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

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

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


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


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


        # need to somehow specify defaults for columns


        div.add(table)

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


        div.add(my.get_preview_wdg())


        return div          
Beispiel #3
0
                    icon_missing = True
            else:
                icon_link = icon_link.replace("indicator_snake.gif",
                                              "generic_image.png")

        div.set_id("thumb_%s" % sobject.get_search_key())
        div.add_style("display: block")
        div.add_style("%s: %s" % (my.aspect, icon_size))
        div.add_style("min-%s: %s" % (my.aspect, min_size))
        div.set_box_shadow("0px 0px 5px")
        div.add_border()

        div.add_style("text-align: left")

        if icon_missing:
            missing_div = DivWdg()
            div.add(missing_div)
            missing_icon = IconWdg("Missing files",
                                   IconWdg.ERROR,
                                   width='12px')
            missing_div.add(missing_icon)

            missing_div.add_style("margin-top: 0px")
            missing_div.add_style("position: absolute")

        img = HtmlElement.img(icon_link)
        img.add_class("spt_image")

        # TODO: make this a preference
        img.add_style("background: #ccc")
Beispiel #4
0
    def get_top(my):
        top = my.top
        top.add_color("background", "background", -5)
        top.add_style("margin-bottom: -2px")
        top.add_class("spt_filter_top")


        table = Table()
        top.add(table)


        title_div = DivWdg()
        tr, td = table.add_row_cell()
        td.add(title_div)
        title_div.add("<div style='font-size: 16px'>Search Criteria</div>")
        title_div.add("<div>Select filters to refine your search</div>")
        title_div.add_style("padding: 20px 0px 0px 20px")

        table.add_style("margin-left: auto")
        table.add_style("margin-right: auto")
        table.add_style("margin-bottom: 15px")
        table.add_style("width: 100%")


        tr = table.add_row()

        if not my.content:
            my.content = DivWdg()
            my.content.add("No Content")

        td = table.add_cell()
        td.add(my.content)
        #my.content.add_style("margin: -2 -1 0 -1")


        show_search = my.kwargs.get("show_search")
        if show_search in [False, 'false']:
            show_search = False
        else:
            show_search = True
        show_search = False
        if show_search:
            search_wdg = my.get_search_wdg()
            table.add_row()
            search_wdg.add_style("float: left")

            search_wdg.add_style("padding-top: 6px")
            search_wdg.add_style("padding-left: 10px")
            search_wdg.add_style("height: 33px")

            td = table.add_cell()
            td.add(search_wdg)
            td.add_style("padding: 5px 20px")
            #td.add_border()
            #td.add_color("background", "background", -10)



        hidden = HiddenWdg("prefix", my.prefix)
        top.add(hidden)
        # this cannot be spt_search as it will confuse spt.dg_table.search_cbk() 
        top.add_class("spt_simple_search")

        return top
Beispiel #5
0
        #select.set_option("query_filter", "\"view\" like 'saved_search:%'")
        div.add(select)

        retrieve_button = ButtonWdg("Retrieve Search")
        behavior = {
            'type': 'click',
            'cbjs_action': 'spt.dg_table.retrieve_search_cbk(evt, bvr);'
        }
        retrieve_button.add_behavior(behavior)

        cancel_button = ButtonWdg("Cancel")
        cancel_button.add_event(
            "onclick", "$('retrieve_search_wdg').style.display = 'none'")

        div.add(HtmlElement.hr())
        button_div = DivWdg()
        button_div.add_style("text-align: center")
        button_div.add(retrieve_button)
        button_div.add("&nbsp;&nbsp;")
        button_div.add(cancel_button)
        div.add(button_div)

        popup.add(div, "content")

        return popup

    def get_save_wdg(my):

        # add the popup
        popup = PopupWdg(id='save_search_wdg')
        popup.add("Save Search", "title")
Beispiel #6
0
    def get_display(my):

        web = WebContainer.get_web()
        show_multi_project = web.get_form_value('show_multi_project')
        project = Project.get()
        search_type_objs = project.get_search_types(
            include_multi_project=show_multi_project)

        top = my.top
        top.add_class("spt_panel_stype_list_top")
        #top.add_style("min-width: 400px")
        #top.add_style("max-width: 1000px")
        #top.add_style("width: 100%")
        top.center()

        button = SingleButtonWdg(title="Advanced Setup", icon=IconWdg.ADVANCED)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.app.ProjectStartWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("project_setup", "Project Setup", class_name)
            '''
        })

        button = SingleButtonWdg(title="Add",
                                 tip="Add New Searchable Type (sType)",
                                 icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.app.SearchTypeCreatorWdg';

            var kwargs = {
            };
            var popup = spt.panel.load_popup("Create New Searchable Type", class_name, kwargs);

            var top = bvr.src_el.getParent(".spt_panel_stype_list_top");
            popup.on_register_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        })

        cb = CheckboxWdg('show_multi_project', label=' show multi-project')
        if show_multi_project:
            cb.set_checked()
        cb.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
                var panel = bvr.src_el.getParent('.spt_panel_stype_list_top')
                spt.panel.refresh(panel, {show_multi_project: bvr.src_el.checked});
            '''
        })
        span = SpanWdg(css='small')
        top.add(span)
        top.add(cb)
        top.add("<br clear='all'/>")
        #search_type_objs = []
        if not search_type_objs:
            arrow_div = DivWdg()
            top.add(arrow_div)
            icon = IconWdg("Click to Add", IconWdg.ARROW_UP_LEFT_32)
            icon.add_style("margin-top: -20")
            icon.add_style("margin-left: -15")
            icon.add_style("position: absolute")
            arrow_div.add(icon)
            arrow_div.add("&nbsp;" * 5)
            arrow_div.add("<b>Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: 5px")
            arrow_div.add_style("margin-left: 20px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 25px")
            arrow_div.set_box_shadow("0px 5px 20px")
            arrow_div.set_round_corners(30)
            arrow_div.add_color("background", "background")

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("width: 600px")
            div.add_style("margin: 30px auto")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg("WARNING", IconWdg.WARNING)
            div.add(icon)
            div.add("<b>No Searchable Types have been created</b>")
            div.add("<br/><br/>")
            div.add(
                "Searchables Types contain lists of items that are managed in this project.  Each item will automatically have the ability to have files checked into it, track tasks and status and record work hours."
            )
            div.add("<br/>" * 2)
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias="main")
            div.add(help)
            div.add("<br/>")
            div.add(
                "Click on the 'Add' button above to start adding new types.")
            return top

        div = DivWdg()
        top.add(div)
        #div.add_style("max-height: 300px")
        #div.add_style("overflow-y: auto")

        table = Table()
        div.add(table)
        table.add_style("margin-top: 10px")
        table.set_max_width()

        # group mouse over
        table.add_relay_behavior({
            'type':
            "mouseover",
            'bvr_match_class':
            'spt_row',
            'cbjs_action':
            "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        })
        table.add_relay_behavior({
            'type':
            "mouseout",
            'bvr_match_class':
            'spt_row',
            'cbjs_action':
            "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        })

        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("")
        th.add_style("text-align: left")
        th = table.add_header("Title")
        th.add_style("text-align: left")
        th = table.add_header("# Items")
        th.add_style("text-align: left")
        th = table.add_header("View")
        th.add_style("text-align: left")
        th = table.add_header("Add")
        th.add_style("text-align: left")
        th = table.add_header("Import")
        th.add_style("text-align: left")
        th = table.add_header("Custom Columns")
        th.add_style("text-align: left")
        th = table.add_header("Workflow")
        th.add_style("text-align: left")
        th = table.add_header("Notifications")
        th.add_style("text-align: left")
        th = table.add_header("Triggers")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")
        #th = table.add_header("Security")
        #th.add_style("text-align: left")

        for i, search_type_obj in enumerate(search_type_objs):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i % 2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2)

            thumb = ThumbWdg()
            thumb.set_sobject(search_type_obj)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)

            search_type = search_type_obj.get_value("search_type")
            title = search_type_obj.get_title()

            table.add_cell(title)

            try:
                search = Search(search_type)
                count = search.get_count()
                if count:
                    table.add_cell("%s item/s" % count)
                else:
                    table.add_cell("&nbsp;")
            except:
                td = table.add_cell("&lt; No table &gt;")
                td.add_style("font-style: italic")
                td.add_style("color: #F00")
                continue

            #search = Search(search_type)
            #search.add_interval_filter("timestamp", "today")
            #created_today = search.get_count()
            #table.add_cell(created_today)

            td = table.add_cell()
            button = IconButtonWdg(title="View", icon=IconWdg.ZOOM)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_type':
                search_type,
                'title':
                title,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            })
            button.add_style("float: left")

            arrow_button = IconButtonWdg(tip="More Views",
                                         icon=IconWdg.ARROWHEAD_DARK_DOWN)
            arrow_button.add_style("margin-left: 20px")
            td.add(arrow_button)

            cbk = '''
            var activator = spt.smenu.get_activator(bvr);

            var class_name = bvr.class_name;
            var layout = bvr.layout;

            var kwargs = {
                search_type: bvr.search_type,
                layout: layout,
                view: bvr.view,
                simple_search_view: 'simple_search',
                element_names: bvr.element_names,
            };

            // use tab
            var top = activator.getParent(".spt_dashboard_top");
            spt.tab.set_tab_top(top);
            spt.tab.add_new('%s', '%s', class_name, kwargs);
            ''' % (title, title)

            from tactic.ui.panel import SwitchLayoutMenu
            SwitchLayoutMenu(search_type=search_type,
                             activator=arrow_button,
                             cbk=cbk,
                             is_refresh=False)

            td = table.add_cell()
            button = IconButtonWdg(title="Add", icon=IconWdg.ADD)
            td.add(button)
            button.add_behavior({
                'type':
                'listen',
                'search_type':
                search_type,
                'event_name':
                'startup_save:' + search_type_obj.get_title(),
                'title':
                search_type_obj.get_title(),
                'cbjs_action':
                '''
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
 

                '''
            })
            button.add_behavior({
                'type':
                'click_up',
                'search_type':
                search_type,
                'title':
                search_type_obj.get_title(),
                'cbjs_action':
                '''

                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: "insert",
                    save_event: "startup_save:" + bvr.title
                }
                spt.panel.load_popup("Add New Items ("+bvr.title+")", class_name, kwargs);

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'table',
                    'simple_search_view': 'simple_search'
                };

                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                '''
            })
            """
            td = table.add_cell()
            button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                    view: 'checkin',
                    element_names: ['preview','code','name','description','history','general_checkin','notes']
                };

                // use tab
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new(bvr.title, bvr.title, class_name, kwargs);
                //spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            } )
            """

            td = table.add_cell()
            button = IconButtonWdg(title="Import", icon=IconWdg.IMPORT)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_type':
                search_type,
                'title':
                "Import Data",
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.widget.CsvImportWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };

                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Custom Columns",
                                   icon=IconWdg.COLUMNS)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_type':
                search_type,
                'title':
                "Add Custom Columns",
                'cbjs_action':
                '''
                var class_name = 'tactic.ui.startup.ColumnEditWdg';
                var kwargs = {
                    search_type: bvr.search_type,
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);

                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Workflow", icon=IconWdg.PIPELINE)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/pipeline")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg("Has Items", IconWdg.CHECK, width=8)
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")

            button.add_behavior({
                'type':
                'click_up',
                'title':
                'Workflow',
                'search_type':
                search_type,
                'cbjs_action':
                '''
                var class_name = 'tactic.ui.startup.PipelineEditWdg';
                var kwargs = {
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Notifications", icon=IconWdg.MAIL)
            button.add_style("float: left")
            td.add(button)

            search = Search("sthpw/notification")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg("Has Items", IconWdg.CHECK, width=8)
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")

            button.add_behavior({
                'type':
                'click_up',
                'title':
                'Trigger',
                'search_type':
                search_type,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Triggers", icon=IconWdg.ARROW_OUT)
            td.add(button)
            button.add_style("float: left")

            search = Search("config/trigger")
            search.add_filter("search_type", search_type)
            count = search.get_count()
            if count:
                check = IconWdg("Has Items", IconWdg.CHECK, width=8)
                td.add(check)
                #check.add_style("margin-left: 0px")
                check.add_style("margin-top: 4px")

            button.add_behavior({
                'type':
                'click_up',
                'title':
                'Trigger',
                'search_type':
                search_type,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.tools.TriggerToolWdg';
                var kwargs = {
                    mode: "search_type",
                    search_type: bvr.search_type
                };
                spt.panel.load_popup(bvr.title, class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Edit Searchable Type",
                                   icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_type_obj.get_search_key(),
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/sobject",
                    view: "edit_startup",
                    search_key: bvr.search_key
                }
                spt.panel.load_popup("Edit Searchable Type", class_name, kwargs);


                '''
            })
            """
            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'title': 'Trigger',
                'search_type': search_type,
                'cbjs_action': '''
                alert("security");
                '''
            } )
            """

        columns_wdg = DivWdg()
        top.add(columns_wdg)

        return top
Beispiel #7
0
    def get_display(my):

        top = my.top

        sources = my.kwargs.get("sources")
        if sources and isinstance(sources, basestring):
            sources = sources.split("|")

        source_types = my.kwargs.get("source_types")
        if not source_types:
            source_types = []

        poster = my.kwargs.get("poster")
        width = my.kwargs.get("width")
        height = my.kwargs.get("height")
        preload = my.kwargs.get("preload")
        controls = my.kwargs.get("controls")
        autoplay = my.kwargs.get("autoplay")

        is_test = my.kwargs.get("is_test")
        is_test = False
        if is_test in [True, 'true']:
            poster = "http://video-js.zencoder.com/oceans-clip.png"
            sources = ["http://video-js.zencoder.com/oceans-clip.mp4"]
            sources = ["http://video-js.zencoder.com/oceans-clip.mp4"]
            sources = ["http://techslides.com/demos/sample-videos/small.ogv"]

        video = my.video
        video.add_class("video-js")
        video.add_class("vjs-default-skin")
        top.add(video)

        my.video_id = my.kwargs.get("video_id")
        if not my.video_id:
            my.video_id = video.set_unique_id()
        else:
            video.set_attr("id", my.video_id)

        # FIXME: this has refereneces to the Gallery ....!
        if my.index == 0:
            overlay = DivWdg()
            overlay.add_class('video_overlay')
            overlay.add_styles(
                'background: transparent; z-index: 300; position: fixed; top: 38%; left: 12%;\
                margin-left: auto; margin-right: auto; width: 75%; height: 45%'
            )

            overlay.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                var overlay = bvr.src_el;
                
                var idx = spt.gallery.index;
                var video_id = spt.gallery.videos[idx];
                
                if (!video_id) return;

                var player = videojs(video_id, {"nativeControlsForTouch": false});
                if (player.paused()) {
                    player.play();
                    //console.log("play " + video_id)
                }
                else 
                    player.pause();
                '''
            })

            top.add(overlay)

        top.add_behavior({'type': 'load', 'cbjs_action': my.get_onload_js()})

        top.add_behavior({
            'type':
            'load',
            'index':
            my.index,
            'video_id':
            my.video_id,
            'cbjs_action':
            '''
            if (!bvr.index) bvr.index = 0;

            var video_id = bvr.video_id;


            spt.video.init_videojs(video_id);


            if (spt.gallery) {
                
                spt.gallery.videos[bvr.index] = video_id;

                if (!spt.gallery.portrait) {
                    var overlay = bvr.src_el.getElement('.video_overlay');
                    if (overlay)
                        overlay.setStyles({'top': '4%', 'left': '5%', 
                            'width': '90%', 'height':'87%'});
                }
            }
            
            
            '''
        })
        #video.add_attr("data-setup", "{}")

        if width:
            video.add_attr("width", width)
        if height:
            video.add_attr("height", height)

        if poster:
            video.add_attr("poster", poster)

        if preload == None:
            preload = "none"

        if controls == None:
            controls = True

        autoplay = False

        # videojs uses a json data structre
        data = {'preload': preload, 'controls': controls, 'autoplay': autoplay}

        from pyasm.common import jsondumps
        data_str = jsondumps(data)
        video.add_attr("data-setup", data_str)

        for i, src in enumerate(sources):

            source = HtmlElement(type="source")
            source.add_attr("src", src)

            if len(source_types) > i:
                source_type = source_types[i]
                source.add_attr("type", source_type)

            video.add(source)

        #print top.get_buffer_display()
        return top
Beispiel #8
0
    def get_display(my):
        my.check()
        if my.is_refresh:
            div = Widget()
        else:
            div = DivWdg()
            my.set_as_panel(div)
            div.add_style('padding','6px')
            min_width = '300px'
            div.add_style('min-width', min_width)
            div.add_color('background','background')
            div.add_class('spt_add_task_panel')


        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 my.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 items to add tasks to' %len(my.search_key_list))
        div.add(HtmlElement.br())
        hint = HintWdg('Tasks are added according to the assigned pipeline.')
        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 my.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:
            span = SpanWdg("Pipeline: %s" % pipeline.get_code())
            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)

            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 len(skipped) == len(sobjects):
        #if skipped:
        #    msg_div = DivWdg('WARNING: No valid item to add task for.')
        #    msg_div.add_style('margin-left: 10px')
        #    div.add(msg_div, 'info')
        #else:
        if True:
            #btn = TextBtnWdg(size='medium', label='Add Tasks', horiz_aligh='center')
            btn = ActionButtonWdg(title='Add Tasks')
            btn.add_behavior({'type' : 'click_up',
            'post_event': 'search_table_%s'% my.table_id,
            'cbjs_action': '''
            spt.dg_table.add_task_selected(bvr);
            ''',
            'search_key_list': my.search_key_list
            })
            cb = CheckboxWdg('skip_duplicated', label='skip duplicated')
            cb.set_checked()
            option_div =DivWdg(cb)
            option_div.add_style('width', '130px')
            hint = HintWdg("If checked, it won't add the task if a task for the checked process has already been created.")
            option_div.add(hint)
            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
Beispiel #9
0
    def get_title(my, sobject):
        div = DivWdg()

        div.add_class("spt_tile_title")

        div.add_color("background", "background3")
        div.add_style("padding: 5px")
        div.add_style("height: 20px")


        if sobject.get_base_search_type() not in ["sthpw/snapshot"]:
            detail_div = DivWdg()
            div.add(detail_div)
            detail_div.add_class("spt_tile_detail")
            detail_div.add_style("float: right")
            detail_div.add_style("margin-top: -2px")

            #detail = IconButtonWdg(title="Detail", icon=IconWdg.ZOOM)
            detail = IconButtonWdg(title="Detail", icon="BS_SEARCH")
            detail_div.add(detail)


        header_div = DivWdg()
        header_div.add_class("spt_tile_select")
        #header_div.add_attr("title",'[ draggable ]')
        div.add(header_div)
        header_div.add_class("SPT_DTS")
        header_div.add_style("overflow-x: hidden")
        header_div.add_style("overflow-y: hidden")

        from pyasm.widget import CheckboxWdg
        checkbox = CheckboxWdg("select")
        checkbox.add_class("spt_tile_checkbox")
        # to prevent clicking on the checkbox directly and not turning on the yellow border
        #checkbox.add_attr("disabled","disabled")

        title_expr = my.kwargs.get("title_expr")
        if title_expr:
            title = Search.eval(title_expr, sobject, single=True)
        elif sobject.get_base_search_type() == "sthpw/snapshot":
            title = sobject.get_value("context")
        else:
            title = sobject.get_value("name", no_exception=True)
        if not title:
            title = sobject.get_value("code", no_exception=True)
      
        table = Table()
        header_div.add(table)
        header_div.add_style("position: relative")

        table.add_cell(checkbox)

        title_div = DivWdg()
        td = table.add_cell(title_div)
        title_div.add(title)
        title_div.add_style("height: 15px")
        title_div.add_style("left: 25px")
        title_div.add_style("top: 3px")
        title_div.add_style("position: absolute")
        title_div.add_attr("title", title)
        #title_div.add_style("white-space", "nowrap")
        #td.add_style("overflow: hidden")
        title_div.add("<br clear='all'/>")
        title_div.add_class("hand")


        description = sobject.get_value("description", no_exception=True)
        if description:
            div.add_attr("title", sobject.get_code())



        return div
Beispiel #10
0
    def get_display(self):
        top = self.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_class('spt_delete_stype_top')
        top.add_border()

        project_code = Project.get_project_code()
        # Note search types should only really be deleted if they were just
        # created

        search_type = self.kwargs.get("search_type")
        if not search_type:
            node_name = self.kwargs.get("node_name")
            if node_name:
                #project_code = Project.get_project_code()
                search_type = "%s/%s" % (project_code, node_name)

        assert search_type
        built_in_stypes = [
            'task', 'note', 'work_hour', 'login', 'login_group', 'schema',
            'project', 'login_in_group', 'snapshot', 'file', 'trigger',
            'spt_trigger', 'widget_config', 'custom_script', 'notification',
            'notification_log', 'file_access', 'cache', 'exception_log',
            'milestone', 'pipeline', 'pref_list', 'pref_setting',
            'project_type', 'repo', 'remote_repo', 'search_sobject',
            'sobject_list', 'ticket', 'db_resource', 'wdg_settings',
            'status_log', 'debug_log', 'transaction_log', 'sobject_log'
        ]

        for tbl in built_in_stypes:
            if search_type == 'sthpw/%s' % tbl:
                top.add("sType [%s] is internal and cannot be deleted!" %
                        search_type)
                top.add_style("font-size: 14px")
                top.add_style('padding: 20px')
                return top

        search_type_obj = SearchType.get(search_type)
        if not search_type:
            top.add("sType [%s] does not exist!" % search_type)
            top.add_style("font-size: 14px")
            top.add_style('padding: 20px')
            return top
        table = search_type_obj.get_table()

        db_val = search_type_obj.get_value('database')
        if db_val == '{project}':
            label = ''
        elif db_val == 'sthpw':
            label = 'built-in'
        else:
            label = 'project-specific'

        # warn if more than 1 sType point to the same table in the same project
        expr = "@GET(sthpw/search_type['table_name', '%s']['database', 'in',  '{project}|%s']['namespace','%s'].search_type)" % (
            table, project_code, project_code)
        rtn = Search.eval(expr)

        warning_msg = ''
        if len(rtn) > 1:
            warning_msg = 'Warning: There is more than 1 sType [%s] pointing to the same table [%s]. Deleting will affect both sTypes.' % (
                ', '.join(rtn), table)

        title_wdg = DivWdg()

        top.add(title_wdg)
        title_wdg.add(IconWdg(icon=IconWdg.WARNING))
        title_wdg.add("Delete %s sType: %s" % (label, search_type))
        title_wdg.add_color("background", "background", -10)
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_style("font-size: 14px")

        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")

        if warning_msg:
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
        content.add("This sType uses the table \"%s\" to store items.<br/>" %
                    table)

        content.add("<br/>")

        search = Search(search_type)
        count = search.get_count()
        content.add("Number of items in the table: %s<br/>" % count)

        content.add("<br/>")

        search.add_column("id")
        sobjects = search.get_sobjects()

        if sobjects:
            items_search_type = sobjects[0].get_search_type()

            search_ids = [x.get_id() for x in sobjects]

            notes_search = Search("sthpw/note")
            notes_search.add_filters("search_id", search_ids)
            notes_search.add_filter("search_type", items_search_type)
            note_count = notes_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/note')
            content.add(cb)
            content.add(
                SpanWdg("Number of related notes: %s" % note_count,
                        css='small'))
            content.add(HtmlElement.br())

            tasks_search = Search("sthpw/task")
            tasks_search.add_filters("search_id", search_ids)
            tasks_search.add_filter("search_type", items_search_type)
            task_count = tasks_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/task')
            content.add(cb)
            content.add(
                SpanWdg("Number of related tasks: %s" % task_count,
                        css='small'))
            content.add(HtmlElement.br())

            snapshots_search = Search("sthpw/snapshot")
            snapshots_search.add_filters("search_id", search_ids)
            snapshots_search.add_filter("search_type", items_search_type)
            snapshot_count = snapshots_search.get_count()
            cb = CheckboxWdg('related_types')
            cb.set_attr('value', 'sthpw/snapshot')
            content.add(cb)
            content.add(
                SpanWdg("Number of related snapshots: %s" % snapshot_count,
                        css='small'))
            content.add(HtmlElement.br())

        pipelines_search = Search("sthpw/pipeline")
        pipelines_search.add_filter("search_type", search_type)
        pipeline_count = pipelines_search.get_count()
        cb = CheckboxWdg('related_types')
        cb.set_attr('value', 'sthpw/pipeline')
        content.add(cb)
        content.add(
            SpanWdg("Number of related pipelines: %s" % pipeline_count,
                    css='small'))
        content.add(HtmlElement.br(2))

        content.add(
            "<b>WARNING: Deleting the sType will delete all of these items.</b> "
        )
        content.add("<br/>" * 2)
        content.add("Do you wish to continue deleting?")
        content.add("<br/>" * 2)

        button_div = DivWdg()
        button_div.add_styles('width: 300px; height: 50px')
        button = ActionButtonWdg(title="Delete")
        button_div.add(button)
        content.add(button_div)
        button.add_style("float: left")

        button.add_behavior({
            'type':
            'click_up',
            'search_type':
            search_type,
            'cbjs_action':
            '''
        spt.app_busy.show("Deleting sType");
        var class_name = "tactic.ui.tools.DeleteSearchTypeCmd";
        var ui_top = bvr.src_el.getParent(".spt_delete_stype_top");
        var values = spt.api.Utility.get_input_values(ui_top);
        var kwargs = {
            'search_type': bvr.search_type,
             'values': values
        };
        var server = TacticServerStub.get();
        try {
            server.start({'title': 'Delete sType', 'description': 'Delete sType [' + bvr.search_type + ']'});
            server.execute_cmd(class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_popup");
            spt.pipeline.remove_node(top.stype_node);

            // force a schema save
            spt.named_events.fire_event('schema|save', bvr)
            top.destroy();
            
            server.finish();
        
        }
        catch(e) {
            spt.alert(spt.exception.handler(e));
        }

        spt.app_busy.hide();

        spt.notify.show_message("Successfully deleted sType ["+bvr.search_type+"]");
       
        '''
        })

        button = ActionButtonWdg(title="Cancel")
        button.add_style("float: left")
        button_div.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        })

        return top
Beispiel #11
0
    def get_display(self):

        top = self.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_border()
        top.add_class("spt_delete_project_tool_top")
        site = self.kwargs.get("site")
        set_site = self.kwargs.get("set_site")

        if set_site != False and site:
            Site.set_site(site)

        login = Environment.get_user_name()

        security = Environment.get_security()

        if not security.is_admin() and not security.is_in_group(
                self.delete_group):

            top.add(IconWdg(icon=IconWdg.WARNING))
            top.add("Only Admin can delete projects")
            top.add_style("padding: 50px")
            top.add_style("text-align: center")
            if set_site and site:
                Site.pop_site()
            return top

        project_code = self.kwargs.get("project_code")

        # check if delete permissions exist for this site and project
        security = Environment.get_security()
        if False and not security.check_access("project", project_code,
                                               "delete"):
            top.add(IconWdg(icon=IconWdg.WARNING))
            top.add("Not permitted to delete this project")
            top.add_style("padding: 30px")
            top.add_style("text-align: center")
            top.add_style("margin: 50px 30px")
            top.add_border()
            top.add_color("background", "background3")
            return top

        if project_code:
            project = Project.get_by_code(project_code)
            if not project:
                top.add(IconWdg(icon=IconWdg.WARNING))
                top.add("No project [%s] exists in this database" %
                        project_code)
                top.add_style("padding: 30px")
                top.add_style("text-align: center")
                top.add_style("margin: 50px 30px")
                top.add_border()
                top.add_color("background", "background3")
                return top
            search_key = project.get_search_key()
        else:
            search_key = self.kwargs.get("search_key")
            project = Search.get_by_search_key(search_key)
            if project:
                project_code = project.get_code()

        title_wdg = DivWdg()

        if project:
            top.add(title_wdg)
            title_wdg.add(IconWdg(icon=IconWdg.WARNING))
            title_wdg.add("Deleting Project: %s" % project.get_value("title"))
            title_wdg.add_color("background", "background", -5)
            title_wdg.add_style("padding: 5px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_style("font-size: 14px")

        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")

        if not search_key:
            warning_msg = "Projects must be deleted individually"
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
            return top

        warning_msg = "Deleting a project will delete the database associated with this project.  All data and files will be lost.  Please consider carefully before proceeding."
        if warning_msg:
            warning_wdg = DivWdg(warning_msg, css='warning')
            content.add(warning_wdg)
            warning_wdg.add_style("margin: 20 10px")
            content.add("<br/>")

        if not project_code:
            content.add("This project [%s] has been deleted." % search_key)
            return top
        elif not project:
            content.add("This project [%s] has been deleted." % project_code)
            return top

        assert project_code
        assert project

        content.add("<br/>")

        content.add(
            "<b>NOTE: These items will be deleted, but the sTypes entries in search_objects table will be retained.</b> "
        )

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

        total_items_wdg = DivWdg()
        total_items = 0
        content.add(total_items_wdg)

        # find all of the sTypes
        details_wdg = DivWdg()
        content.add(details_wdg)
        details_wdg.add_style("max-height: 300px")
        details_wdg.add_style("overflow-y: auto")
        details_wdg.add_style("padding-left: 15px")
        details_wdg.add_border()

        search_types = project.get_search_types()

        related_types = []

        for search_type_obj in search_types:
            search_type_wdg = DivWdg()
            title = search_type_obj.get_title()
            search_type = search_type_obj.get_value("search_type")

            search_type_wdg.add_style("margin-top: 5px")
            search_type_wdg.add_style("margin-bottom: 5px")

            details_wdg.add(search_type_wdg)
            search_type_wdg.add(title)
            search_type_wdg.add(" (%s)" % search_type)

            search = Search(search_type, project_code=project_code)
            count = search.get_count()
            total_items += count
            search_type_wdg.add("&nbsp; - &nbsp; %s item(s)" % count)

            # TODO: this is similar to SearchType.get_related_types(). streamline at some point.
            related_types = self.get_related_types(search_type)
            for related_type in related_types:

                try:
                    search = Search(related_type)
                except Exception as e:
                    print("WARNING: ", e)
                    continue
                full_search_type = "%s?project=%s" % (search_type,
                                                      project_code)
                if related_type.startswith("sthpw/"):
                    search.add_filter("search_type", full_search_type)
                count = search.get_count()
                if count == 0:
                    continue
                total_items += count

                related_wdg = DivWdg()
                related_wdg.add_style('padding-left: 25px')
                search_type_wdg.add(related_wdg)
                related_wdg.add(related_type)
                related_wdg.add("&nbsp; - &nbsp; %s item(s)" % count)

        if total_items:
            total_items_wdg.add("Total # of items to be deleted: ")
            total_items_wdg.add(total_items)
            total_items_wdg.add_style("font-size: 14px")
            total_items_wdg.add_style("font-weight: bold")
            total_items_wdg.add("<br/>")

        content.add("<br/>" * 2)
        content.add("<b>Do you wish to continue deleting? </b>")
        radio = RadioWdg("mode")
        radio.add_class("spt_mode_radio")
        radio.set_value("delete")
        radio.add_style("margin-left: 15")
        radio.add_style("margin-top: 5")
        content.add(radio)
        content.add("<br/>" * 3)

        #content.add("<b>Or do you just wish to retire the project? </b>")
        #radio = RadioWdg("mode")
        #radio.add_class("spt_mode_radio")
        #radio.set_value("retire")
        #content.add(radio)
        #content.add(radio)

        #content.add("<br/>"*2)

        #button = ActionButtonWdg(title="Retire")
        #content.add(button)
        #button.add_style("float: left")

        buttons = Table()
        content.add(buttons)
        buttons.add_row()
        buttons.add_style("margin-left: auto")
        buttons.add_style("margin-right: auto")
        buttons.add_style("width: 250px")

        button = ActionButtonWdg(title="Delete", color="danger")
        buttons.add_cell(button)

        command_class = self.kwargs.get("command_class")
        if not command_class:
            command_class = 'tactic.ui.tools.DeleteProjectCmd'

        on_complete = self.kwargs.get("on_complete")

        button.add_behavior({
            'type':
            'click_up',
            #'search_type': search_type,
            'project_code':
            project_code,
            'site':
            site,
            'related_types':
            related_types,
            'command_class':
            command_class,
            'on_complete':
            on_complete,
            'cbjs_action':
            '''
            spt.app_busy.show("Deleting");
            var class_name = bvr.command_class;
            var kwargs = {
                'site': bvr.site,
                'project_code': bvr.project_code,
                'related_types': bvr.related_types
            };

            var top = bvr.src_el.getParent(".spt_delete_project_tool_top");
            var radios = top.getElements(".spt_mode_radio");

            //if (!radios[0].checked && !radios[1].checked) {
            if (!radios[0].checked) {
                spt.alert("Please confirm the delete by checking the radio button.");
                spt.app_busy.hide();
                return;
            }

            var mode = 'retire';
            if (radios[0].checked == true) {
                mode = 'delete';
            }


            if (mode == 'retire') {
                return;
            }



            var success = false;
            var server = TacticServerStub.get();
            setTimeout(function() {
                spt.app_busy.show("Deleting Project ["+bvr.project_code+"]")
                var error_message = "Error deleting project ["+bvr.project_code+"]";
                try {
                    server.start({'title': 'Deleted Project ', 'description': 'Deleted Project [' + bvr.project_code + ']'});
                    server.execute_cmd(class_name, kwargs);
                    success = true;
                }
                catch(e) {
                    error_message = spt.exception.handler(e);
                }

                
                spt.app_busy.hide();

                if (success) {


                    if (bvr.on_complete) {
                       on_complete = function() {
                           eval(bvr.on_complete);
                       }
                       on_complete();
                    }

                    spt.notify.show_message("Successfully deleted project ["+bvr.project_code+"]");

                    spt.tab.set_main_body_tab();
                    spt.tab.reload_selected();
                }
                else {
                    if (error_message.test(/does not exist/))
                        error_message += '. You are advised to sign out and log in again.';
                    spt.error(error_message);
                }
                
                
                var top = bvr.src_el.getParent(".spt_popup");
                spt.popup.destroy(top);
                server.finish();
                    
                    
            }, 100);
       
        '''
        })

        button = ActionButtonWdg(title="Cancel")
        buttons.add_cell(button)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_popup");
        spt.popup.destroy(top);
        '''
        })

        if site:
            Site.pop_site()

        return top
Beispiel #12
0
    def get_display(self):
        top = self.top
        self.set_as_panel(top)
        top.add_class("spt_delete_top")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_border()
        top.add_style("width: 400px")
        top.add_border()

        search_key = self.kwargs.get("search_key")
        search_keys = self.kwargs.get("search_keys")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            sobjects = [sobject]
            search_keys = [search_key]
        elif search_keys:
            sobjects = Search.get_by_search_keys(search_keys)
            sobject = sobjects[0]

        if not sobjects or not sobject:
            msg = "%s not found" % search_key
            return msg
        search_type = sobject.get_base_search_type()

        if search_type in ['sthpw/project', 'sthpw/search_object']:
            msg = 'You cannot delete these items with this tool'
            return msg

        self.search_keys = search_keys

        title = DivWdg()
        top.add(title)

        icon = IconWdg("WARNING", IconWdg.WARNING)
        icon.add_style("float: left")
        title.add(icon)

        if len(self.search_keys) > 1:
            title.add("Delete %s Items" % len(self.search_keys))
        else:
            title.add("Delete Item [%s]" % (sobject.get_code()))
        title.add_style("font-size: 20px")
        title.add_style("font-weight: bold")
        title.add_style("padding: 10px")

        title.add("<hr/>")

        content = DivWdg()
        top.add(content)
        content.add_style("margin: 5px 10px 20px 10px")

        content.add(
            "The item to be deleted has a number of dependencies as described below:<br/>",
            'heading')

        # find all the relationships
        related_types = SearchType.get_related_types(search_type,
                                                     direction='children')

        items_div = DivWdg()
        content.add(items_div)
        items_div.add_style("padding: 10px")
        valid_related_ctr = 0
        for related_type in related_types:
            if related_type == "*":
                print("WARNING: related_type is *")
                continue
            if related_type == search_type:
                continue
            if related_type in ['sthpw/search_object', 'sthpw/search_type']:
                continue

            item_div = self.get_item_div(sobjects, related_type)
            if item_div:
                items_div.add(item_div)
                valid_related_ctr += 1

        if valid_related_ctr > 0:
            #icon = IconWdg("Note", "BS_NOTE")
            #icon.add_style("float: left")
            #content.add( icon )
            content.add(
                "<div><b>By selecting the above, the corresponding related items will be deleted as well.</b></div>"
            )
            content.add("<br/>" * 2)
        else:
            # changed the heading to say no dependencies
            content.add("The item to be deleted has no dependencies.<br/>",
                        'heading')

        num_items = len(self.search_keys)
        if num_items == 1:
            verb = "is 1 item"
        else:
            verb = "are %s items" % num_items
        content.add("There %s to be deleted" % verb)
        content.add("<br/>" * 2)

        content.add("Do you wish to continue deleting?")
        content.add("<br/>" * 3)

        button_div = DivWdg()
        button_div.add_class("spt_buttons")
        content.add(button_div)
        button_div.add_style('text-align: center')

        button = ActionButtonWdg(title="Delete", width=100, color="danger")
        button_div.add(button)
        button.add_style("display: inline-block")

        deleting_div = DivWdg()
        content.add(deleting_div)
        deleting_div.add(
            "<img src='/context/icons/common/indicator_snake.gif'/>")
        deleting_div.add_class("spt_delete_msg")
        deleting_div.add(" Deleting ...")
        deleting_div.add_style("text-align: center")
        deleting_div.add_style("font-size: 16px")
        deleting_div.add_style("margin: 20px")
        deleting_div.add_style("display: none")

        on_complete = self.kwargs.get("on_complete")

        button.add_behavior({
            'type':
            'click_up',
            'search_keys':
            self.search_keys,
            'on_complete':
            on_complete,
            'cbjs_action':
            '''
        spt.app_busy.show("Deleting");
        //spt.notify.show_message("Deleting ...");

        //var button_el = bvr.src_el.getParent(".spt_buttons");
        //button_el.setStyle("display", "none");

        var top = bvr.src_el.getParent(".spt_delete_top");
        var values = spt.api.Utility.get_input_values(top);

        var class_name = "tactic.ui.tools.DeleteCmd";
        var kwargs = {
            'search_keys': bvr.search_keys,
            'values': values
        };

        var del_trigger = function() {
            
            // for fast table
            var tmps = spt.split_search_key(bvr.search_keys[0])
            var tmps2 = tmps[0].split('?');
            var del_st_event = "delete|" + tmps2[0];
            var bvr_fire = {};
            var input = {'search_keys': bvr.search_keys};
            bvr_fire.options = input;
            spt.named_events.fire_event(del_st_event, bvr_fire);
        }

        var server = TacticServerStub.get();

        server.execute_cmd(class_name, kwargs, null, {
            on_complete: function() {
                //spt.notify.show_message("Finshed deleting ...");

                // run the post delete and destroy the popup
                var popup = bvr.src_el.getParent(".spt_popup");
                if (popup.spt_on_post_delete) {
                    popup.spt_on_post_delete();
                }

                del_trigger();

                spt.popup.destroy(popup);


                if (bvr.on_complete) {
                   on_complete = function() {
                       eval(bvr.on_complete);
                   }
                   on_complete();
                }

                spt.app_busy.hide();
            },
            on_error: function(e) {
                spt.notify.show_message("Error on delete");
                spt.alert(spt.exception.handler(e));
                spt.app_busy.hide();
            }
        } );

        '''
        })

        button = ActionButtonWdg(title="Cancel", width=100)
        button_div.add(button)
        button.add_style("display: inline-block")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_popup");
        top.destroy();
        '''
        })

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

        return top
Beispiel #13
0
    def get_display(my):

        top = my.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_border()
        top.add_class("spt_delete_project_tool_top")

        login = Environment.get_user_name()
        if login != 'admin':
            top.add(IconWdg(icon=IconWdg.WARNING))
            top.add("Only Admin can delete projects")
            top.add_style("padding: 50px")
            top.add_style("text-align: center")
            return top



        site = my.kwargs.get("site")
        if site:
            Site.set_site(site)



        project_code = my.kwargs.get("project_code")

        # check if delete permissions exist for this site and project
        security = Environment.get_security()
        if False and not security.check_access("project", project_code, "delete"):
            top.add(IconWdg(icon=IconWdg.WARNING))
            top.add("Not permitted to delete this project")
            top.add_style("padding: 30px")
            top.add_style("text-align: center")
            top.add_style("margin: 50px 30px")
            top.add_border()
            top.add_color("background", "background3")
            return top


        


        if project_code:
            project = Project.get_by_code(project_code)
            if not project:
                top.add(IconWdg(icon=IconWdg.WARNING))
                top.add("No project [%s] exists in this database" % project_code)
                top.add_style("padding: 30px")
                top.add_style("text-align: center")
                top.add_style("margin: 50px 30px")
                top.add_border()
                top.add_color("background", "background3")
                return top
            search_key = project.get_search_key()
        else:
            search_key = my.kwargs.get("search_key")
            project = Search.get_by_search_key(search_key)
            if project:
                project_code = project.get_code()

       
           
        title_wdg = DivWdg()

        if project:
            top.add(title_wdg)
            title_wdg.add(IconWdg(icon=IconWdg.WARNING))
            title_wdg.add("Deleting Project: %s" % project.get_value("title") ) 
            title_wdg.add_color("background", "background", -5)
            title_wdg.add_style("padding: 5px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_style("font-size: 14px")


        content = DivWdg()
        top.add(content)
        content.add_style("padding: 10px")

        if not search_key:
            warning_msg = "Projects must be deleted individually"
            content.add(DivWdg(warning_msg, css='warning'))
            content.add("<br/>")
            return top

        warning_msg = "Deleting a project will delete the database associated with this project.  All data and files will be lost.  Please consider carefully before proceeding."
        if warning_msg:
            warning_wdg = DivWdg(warning_msg, css='warning')
            content.add(warning_wdg)
            warning_wdg.add_style("margin: 20 10px")
            content.add("<br/>")

        
        if not project_code:
            content.add("This project [%s] has been deleted."%search_key)
            return top
        elif not project:
            content.add("This project [%s] has been deleted."%project_code)
            return top


        assert project_code
        assert project

        content.add("<br/>")

        content.add("<b>NOTE: These items will be deleted, but the sTypes entries in search_objects table will be retained.</b> ")


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

        total_items_wdg = DivWdg()
        total_items = 0
        content.add(total_items_wdg)


        # find all of the sTypes
        details_wdg = DivWdg()
        content.add(details_wdg)
        details_wdg.add_style("max-height: 300px")
        details_wdg.add_style("overflow-y: auto")
        details_wdg.add_style("padding-left: 15px")
        details_wdg.add_border()

        search_types = project.get_search_types()

        related_types = []

        for search_type_obj in search_types:
            search_type_wdg = DivWdg()
            title = search_type_obj.get_title()
            search_type = search_type_obj.get_value("search_type")

            search_type_wdg.add_style("margin-top: 5px")
            search_type_wdg.add_style("margin-bottom: 5px")


            details_wdg.add(search_type_wdg)
            search_type_wdg.add(title)
            search_type_wdg.add(" (%s)" % search_type )

            search = Search( search_type, project_code=project_code )
            count = search.get_count()
            total_items += count
            search_type_wdg.add("&nbsp; - &nbsp; %s item(s)" % count)

            # TODO: this is similar to SearchType.get_related_types(). streamline at some point. 
            related_types = my.get_related_types(search_type)
            for related_type in related_types:

                try:
                    search = Search(related_type)
                except Exception, e:
                    print "WARNING: ", e
                    continue
                full_search_type = "%s?project=%s" % (search_type, project_code)
                if related_type.startswith("sthpw/"):
                    search.add_filter("search_type", full_search_type)
                count = search.get_count()
                if count == 0:
                    continue
                total_items += count


                related_wdg = DivWdg()
                related_wdg.add_style('padding-left: 25px')
                search_type_wdg.add(related_wdg)
                related_wdg.add(related_type)
                related_wdg.add("&nbsp; - &nbsp; %s item(s)" % count)
Beispiel #14
0
    def get_popwin_oversize_content(self):

        div = DivWdg()
        div.add_styles(
            "background-color: orange; color: black; padding: 20px; width: 600px;"
        )
        div.add('''
<p>SCENE I. DUKE ORSINO's palace.</p>

<p>Enter DUKE ORSINO, CURIO, and other Lords; Musicians attending</p>

<h2>DUKE ORSINO</h2>

<p>If music be the food of love, play on;
Give me excess of it, that, surfeiting,
The appetite may sicken, and so die.
That strain again! it had a dying fall:
O, it came o'er self ear like the sweet sound,
That breathes upon a bank of violets,
Stealing and giving odour! Enough; no more:
'Tis not so sweet now as it was before.
O spirit of love! how quick and fresh art thou,
That, notwithstanding thy capacity
Receiveth as the sea, nought enters there,
Of what validity and pitch soe'er,
But falls into abatement and low price,
Even in a minute: so full of shapes is fancy
That it alone is high fantastical.</p>

<h2>CURIO</h2>

<p>Will you go hunt, self lord?</p>

<h2>DUKE ORSINO</h2>

<p>What, Curio?</p>

<h2>CURIO</h2>

<p>The hart.</p>

<h2>DUKE ORSINO</h2>

<p>Why, so I do, the noblest that I have:
O, when mine eyes did see Olivia first,
Methought she purged the air of pestilence!
That instant was I turn'd into a hart;
And self desires, like fell and cruel hounds,
E'er since pursue me.</p>

<p><i>Enter VALENTINE</i><p>

<p>How now! what news from her?</p>

<h2>VALENTINE</h2>

<p>So please self lord, I might not be admitted;
But from her handmaid do return this answer:
The element itself, till seven years' heat,
Shall not behold her face at ample view;
But, like a cloistress, she will veiled walk
And water once a day her chamber round
With eye-offending brine: all this to season
A brother's dead love, which she would keep fresh
And lasting in her sad remembrance.</p>

<h2>DUKE ORSINO</h2>

<p>O, she that hath a heart of that fine frame
To pay this debt of love but to a brother,
How will she love, when the rich golden shaft
Hath kill'd the flock of all affections else
That live in her; when liver, brain and heart,
These sovereign thrones, are all supplied, and fill'd
Her sweet perfections with one self king!
Away before me to sweet beds of flowers:
Love-thoughts lie rich when canopied with bowers.</p>

<p><i>Exeunt</i></p>

        ''')

        return div
    def get_display(my):
        div = DivWdg()

        div.add_class("spt_security")
        div.add_attr("id", "SecurityManagerWdg")
        div.add_attr("spt_class_name", Common.get_full_class_name(my))
        div.add_attr("spt_search_key", my.search_key)
        div.add_attr("spt_update", "true")

        project_div = DivWdg()
        project_div.add_color("background", "background")
        project_div.add_color("color", "color")
        project_div.add_style("padding: 10px")
        project_div.add_border()
        project_div.add_style("width: 300px")

        #project_div = RoundedCornerDivWdg(hex_color_code="949494",corner_size="10")
        #project_div.set_dimensions( width_str='175px', content_height_str='100px' )

        group = SearchKey.get_by_search_key(my.search_key)

        title = DivWdg()
        title.add_class("maq_search_bar")
        name = group.get_value("login_group")
        title.add("Global security settings for %s" % name)

        project_div.add(title)

        access_rules = group.get_xml_value("access_rules")
        access_manager = AccessManager()
        access_manager.add_xml_rules(access_rules)

        group = "builtin"
        global_default_access = "deny"

        list_div = DivWdg()
        list_div.add_style("color: #222")
        for item in permission_list:
            if item.get('group'):
                group_div = DivWdg()
                list_div.add(group_div)
                group_div.add_style("margin-top: 10px")
                group_div.add_style("font-weight: bold")
                group_div.add(item.get('group'))
                group_div.add("<hr/>")
                continue

            item_div = DivWdg()
            list_div.add(item_div)
            item_div.add_style("margin-top: 5px")

            key = item.get('key')
            item_default = item.get('default')
            if item_default:
                default_access = item_default
            else:
                default_access = global_default_access

            allowed = access_manager.check_access(group,
                                                  key,
                                                  "allow",
                                                  default=default_access)

            checkbox = CheckboxWdg("rule")
            if allowed:
                checkbox.set_checked()
            checkbox.set_option("value", key)

            item_div.add(checkbox)

            item_div.add_style("color: #222")
            item_div.add(item.get('title'))

        project_div.add(list_div)

        project_div.add("<hr>")

        #close_script = "spt.popup.close(bvr.src_el.getParent('.spt_popup'))"

        save_button = ActionButtonWdg(title="Save",
                                      tip="Save Security Settings")
        save_button.add_behavior({
            "type":
            "click_up",
            "cbjs_action":
            "el=bvr.src_el.getParent('.spt_security');spt.panel.refresh(el);"
        })

        save_button.add_style("margin-left: auto")
        save_button.add_style("margin-right: auto")
        project_div.add(save_button)

        div.add(project_div)
        if my.update == "true":
            div.add(HtmlElement.br())
            div.add(HtmlElement.b(my.description))

        return div
Beispiel #16
0
    def get_content_wdg(my):
        div = DivWdg()
        div.add_class("spt_tile_layout_top")
        if my.top_styles:
            div.add_styles(my.top_styles)
        inner = DivWdg()
        div.add(inner)


        
        menus_in = {}
        # set up the context menus
        if my.show_context_menu == True:
            menus_in['DG_HEADER_CTX'] = [ my.get_smart_header_context_menu_data() ]
            menus_in['DG_DROW_SMENU_CTX'] = [ my.get_data_row_smart_context_menu_details() ]
        elif my.show_context_menu == 'none':
            div.add_event('oncontextmenu', 'return false;')
        if menus_in:
            SmartMenu.attach_smart_context_menu( inner, menus_in, False )
 




        

        temp = my.kwargs.get("temp")
        has_loading = False

        
        inner.add_style("margin-left: 20px")
       

        inner.add_attr("ondragenter", "return false")
        inner.add_attr("ondragover", "return false")
        inner.add_attr("ondrop", "spt.thumb.background_drop(event, this)")

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

        if my.sobjects:
            inner.add( my.get_scale_wdg() )

            for row, sobject in enumerate(my.sobjects):

                if False and not temp and row > 4: 
                    tile_wdg = DivWdg()
                    inner.add(tile_wdg)
                    tile_wdg.add_style("width: 120px")
                    tile_wdg.add_style("height: 120px")
                    tile_wdg.add_style("float: left")
                    tile_wdg.add_style("padding: 20px")
                    tile_wdg.add_style("text-align: center")
                    tile_wdg.add('<img src="/context/icons/common/indicator_snake.gif" border="0"/>')
                    tile_wdg.add(" Loading ...")
                    tile_wdg.add_attr("spt_search_key", sobject.get_search_key())
                    tile_wdg.add_class("spt_loading")
                    has_loading = True
                    continue


                kwargs = my.kwargs.copy()
                tile = my.get_tile_wdg(sobject)
                inner.add(tile)
        else:
            table = Table()
            inner.add(table)
            my.handle_no_results(table)


        chunk_size = 5
        if has_loading:
            inner.add_behavior( {
            'type': 'load',
            'chunk': chunk_size,
            'cbjs_action': '''
            var layout = bvr.src_el.getParent(".spt_layout");
            spt.table.set_layout(layout);
            var rows = layout.getElements(".spt_loading");

            var jobs = [];
            var count = 0;
            var chunk = bvr.chunk;
            while (true) {
                var job_item = rows.slice(count, count+chunk);
                if (job_item.length == 0) {
                    break;
                }
                jobs.push(job_item);
                count += chunk;
            }

            var count = -1;
            var func = function() {
                count += 1;
                var rows = jobs[count];
                if (! rows || rows.length == 0) {
                    return;
                }
                for (var i = 0; i < rows.length; i++) {
                    rows[i].removeClass("spt_loading");
                }
                spt.table.refresh_rows(rows, null, null, {on_complete: func});
            }
            func();

            '''
            } )





        inner.add("<br clear='all'/>")
        return div
Beispiel #17
0
    def get_display(self):
        sobject = self.get_current_sobject()
        search_key = SearchKey.build_by_sobject(sobject)

        display = DivWdg()
        display.add_style("position: relative")
        display.add_class("spt_button_top")
        display.add_style("width: 26px")
        display.add_style("margin-left: auto")
        display.add_style("margin-right: auto")

        BASE = '/context/themes2/default/'
        over_div = DivWdg()
        display.add(over_div)
        over_div.add_class("spt_button_over")
        over_img = "<img src='%s/MainButton_over.png'/>" % BASE
        over_div.add(over_img)
        over_div.add_style("position: absolute")
        over_div.add_style("top: -9px")
        over_div.add_style("left: 0px")
        over_div.add_style("display: none")

        click_div = DivWdg()
        display.add(click_div)
        click_div.add_class("spt_button_click")
        click_img = "<img src='%s/MainButton_click.png'/>" % BASE
        click_div.add(click_img)
        click_div.add_style("position: absolute")
        click_div.add_style("top: -9px")
        click_div.add_style("left: 0px")
        click_div.add_style("display: none")

        if self.get_option('align') == 'left':
            display.add_style("text-align: left")
        else:
            display.add_style("text-align: center")

        icon = self.get_option("icon")
        if not icon:
            icon = "create"

        icon_tip = self.get_option("icon_tip")
        if not icon_tip:
            icon_tip = self.get_option("hint")
        if not icon_tip:
            icon_tip = ""

        enable = self.get_option("enable")
        if enable:
            result = ExpressionParser().eval(enable, sobject)
            if not result:
                return "&nbsp;"

        if not self.script_obj and not self.script:
            icon_wdg = IconButtonWdg("No Script Found", IconWdg.ERROR)
        else:
            icon_link = icon.upper()

            icon_wdg = IconButtonWdg(icon_tip, icon=icon_link)
            if not sobject.is_insert():
                icon_wdg.add_class("hand")
                #icon_wdg.add_behavior(self.behavior)
                icon_wdg.add_class("spt_button_%s" % self.name)

        icon_div = DivWdg()
        icon_div.add(icon_wdg)
        icon_div.add_style("position: absolute")
        icon_div.add_style("top: 2px")
        icon_div.add_style("left: 5px")
        display.add(icon_div)

        hit_wdg = icon_div
        hit_wdg.add_class("spt_button_hit")

        if sobject.is_insert():
            hit_wdg.add_style("opacity: 0.4")
        else:
            hit_wdg.add_class("spt_button_hit_wdg")

        display.add_style("height: 18px")
        display.add_style("min-width: 21px")
        #display.add_style("overflow: hidden")
        display.add_style("margin-top: 0px")

        expression = self.kwargs.get('expression')
        if expression:
            value = Search.eval(expression, sobject, single=True)

            if value:

                badge = DivWdg()
                badge.add_style("position: absolute")

                badge.add_style("right: -30px")
                badge.add_style("top: -2px")
                badge.add_style("margin: 4px 3px 3px 6px")
                badge.add_style("opacity: 0.5")
                badge.add_style("font-size: 0.7em")
                badge.add_class("badge")
                badge.add(value)

                display.add(badge)
                display.add_style("position: relative")

                #return top

        return display
Beispiel #18
0
    def add_layout_behaviors(my, layout_wdg):
        border_color = layout_wdg.get_color('border', modifier=20)
        layout_wdg.add_behavior( {
            'type': 'smart_drag',
            'bvr_match_class': 'spt_tile_checkbox',
            'drag_el': 'drag_ghost_copy',
            'use_copy': 'true',
            'use_delta': 'true',
            'border_color': border_color,
            'dx': 10, 'dy': 10,
            'drop_code': 'DROP_ROW',
            
             # don't use cbjs_pre_motion_setup as it assumes the drag el
                                
            'copy_styles': 'z-index: 1000; opacity: 0.7; border: solid 1px %s; text-align: left; padding: 10px; width: 0px; background: %s' \
                    % (layout_wdg.get_color("border"), layout_wdg.get_color("background")),

            'cbjs_setup': '''
            if(spt.drop) {spt.drop.sobject_drop_setup( evt, bvr );}
            ''',

            "cbjs_motion": '''
                spt.mouse._smart_default_drag_motion(evt, bvr, mouse_411);
                var target_el = spt.get_event_target(evt);
                target_el = spt.mouse.check_parent(target_el, bvr.drop_code);
                if (target_el) {
                    var orig_border_color = target_el.getStyle('border-color');
                    var orig_border_style = target_el.getStyle('border-style');
                    target_el.setStyle('border','dashed 2px ' + bvr.border_color);
                    if (!target_el.getAttribute('orig_border_color')) {
                        target_el.setAttribute('orig_border_color', orig_border_color);
                        target_el.setAttribute('orig_border_style', orig_border_style);
                    }
                }
            ''',
            "cbjs_action": '''
            if (spt.drop) {
                spt.drop.sobject_drop_action(evt, bvr);
            }
            '''
        } )


        detail_element_names = my.kwargs.get("detail_element_names")

        layout_wdg.add_relay_behavior( {
            'type': 'mouseup',
            'bvr_match_class': 'spt_tile_detail',
            'detail_element_names': detail_element_names,
            'cbjs_action': '''
            spt.tab.set_main_body_tab();
            var top = bvr.src_el.getParent(".spt_tile_top");
            var search_key = top.getAttribute("spt_search_key");
            var name = top.getAttribute("spt_name");
            var search_code = top.getAttribute("spt_search_code");
            var class_name = 'tactic.ui.tools.SObjectDetailWdg';
            var kwargs = {
                search_key: search_key,
                tab_element_names: bvr.detail_element_names
            };
            spt.tab.add_new(search_code, name, class_name, kwargs);
            '''
        } )




        mode = my.kwargs.get("expand_mode")
        if not mode:
            mode = "gallery"

        
        gallery_width = my.kwargs.get("gallery_width")
        if not gallery_width:
            gallery_width = ''
        if mode == "view":
            layout_wdg.add_relay_behavior( {
                'type': 'click',
                'bvr_match_class': 'spt_tile_content',
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_tile_top");
                var search_key = top.getAttribute("spt_search_key");
                var server = TacticServerStub.get();
                var snapshot = server.get_snapshot(search_key, {context: "", process:"publish",include_web_paths_dict:true});
                if (snapshot.__search_key__) {
                    window.open(snapshot.__web_paths_dict__.main);
                }
                else {
                    var snapshot = server.get_snapshot(search_key, {context: "",include_web_paths_dict:true});
                    if (snapshot.__search_key__) {
                        window.open(snapshot.__web_paths_dict__.main);
                    }
                    else {
                        alert("WARNING: No file for this asset");
                    }
                }
                '''
            } )
        elif mode == "detail":
            tab_element_names = my.kwargs.get("tab_element_names")
            layout_wdg.add_relay_behavior( {
                'type': 'click',
                'bvr_match_class': 'spt_tile_content',
                'tab_element_names': tab_element_names,
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_tile_top");
                var search_key = top.getAttribute("spt_search_key");

                spt.tab.set_main_body_tab();
                var class_name = 'tactic.ui.tools.SObjectDetailWdg';
                var kwargs = {
                    search_key: search_key,
                    tab_element_names: bvr.tab_element_names,
                };
                spt.tab.add_new(search_key, "Detail []", class_name, kwargs);
                '''
            } )

        elif mode == "gallery":
            gallery_div = DivWdg()
            layout_wdg.add( gallery_div )
            gallery_div.add_class("spt_tile_gallery")
            layout_wdg.add_relay_behavior( {
                'type': 'click',
                'width': gallery_width,
                'bvr_match_class': 'spt_tile_content',
                'cbjs_action': '''
                var layout = bvr.src_el.getParent(".spt_layout");
                var tile_tops = layout.getElements(".spt_tile_top");

                var search_keys = [];
                for (var i = 0; i < tile_tops.length; i++) {
                    var tile_top = tile_tops[i];
                    var search_key = tile_top.getAttribute("spt_search_key_v2");
                    search_keys.push(search_key);
                }

                var tile_top = bvr.src_el.getParent(".spt_tile_top");
                var search_key = tile_top.getAttribute("spt_search_key_v2");

                var class_name = 'tactic.ui.widget.gallery_wdg.GalleryWdg';
                var kwargs = {
                    search_keys: search_keys,
                    search_key: search_key,
                };
                if (bvr.width) 
                    kwargs['width'] = bvr.width;
                var gallery_el = layout.getElement(".spt_tile_gallery");
                spt.panel.load(gallery_el, class_name, kwargs);



                '''
            } )
 
        elif mode == "custom":
            
            script_path = my.kwargs.get("script_path")
            script = None
            if script_path:
                script_obj = CustomScript.get_by_path(script_path)
                script = script_obj.get_value("script")

            if not script:
                script = my.kwargs.get("script")

            if not script:
                script = '''
                alert("Script path [%s] not implemented");
                ''' % script_path

            layout_wdg.add_relay_behavior( {
                'type': 'click',
                'bvr_match_class': 'spt_tile_content',
                'cbjs_action': script
            } )
 

        bg1 = layout_wdg.get_color("background3")
        bg2 = layout_wdg.get_color("background3", 5)
        layout_wdg.add_relay_behavior( {
            'type': 'mouseover',
            'bvr_match_class': 'spt_tile_top',
            'cbjs_action': '''
            bvr.src_el.setStyle("opacity", "0.8");
            var el = bvr.src_el.getElement(".spt_tile_title");
            if (el)
                el.setStyle("background", "%s");
            ''' % bg2
        } )

        layout_wdg.add_relay_behavior( {
            'type': 'mouseout',
            'bvr_match_class': 'spt_tile_top',
            'cbjs_action': '''
            bvr.src_el.setStyle("opacity", "1.0");
            var el = bvr.src_el.getElement(".spt_tile_title");
            if (el)
                el.setStyle("background", "%s");
            ''' % bg1
        } )


        process = my.kwargs.get("process")
        if not process:
            process = "publish"
        if my.parent_key:
            search_type = None
        else:
            search_type = my.search_type


        layout_wdg.add_behavior( {
            'type': 'load',
            'search_type': search_type,
            'search_key': my.parent_key,
            'process': process,
            'cbjs_action': '''

            spt.thumb = {};

            spt.thumb.background_drop = function(evt, el) {

                evt.stopPropagation();
                evt.preventDefault();

                var top = $(el);

                var server = TacticServerStub.get();

                evt.dataTransfer.dropEffect = 'copy';
                var files = evt.dataTransfer.files;
                evt.stopPropagation();
                evt.preventDefault();

                spt.app_busy.show("Attaching file");


                for (var i = 0; i < files.length; i++) {
                    var size = files[i].size;
                    var file = files[i];

                    var filename = file.name;

                    var search_key;
                    var data = {
                        name: filename
                    }
                    if (bvr.search_key) {
                       search_key = bvr.search_key
                    }
                    else {
                        var search_type = bvr.search_type;
                        var item = server.insert(search_type, data);
                        search_key = item.__search_key__;
                    }

                    var context = bvr.process + "/" + filename;

                    var upload_file_kwargs =  {
                        files: [files[i]],
                        upload_complete: function() {
                            var server = TacticServerStub.get();
                            var kwargs = {mode: 'uploaded'};
                            server.simple_checkin( search_key, context, filename, kwargs);

                            var layout = el.getParent(".spt_layout");
                            spt.table.set_layout(layout);

                            spt.table.run_search();

                        }
                    };
                    spt.html5upload.upload_file(upload_file_kwargs);

                    // just support one file at the moment
                    break;
         
                }

                spt.app_busy.hide();
            }
 

            spt.thumb.noop = function(evt, el) {
                evt.dataTransfer.dropEffect = 'copy';
                var files = evt.dataTransfer.files;
                evt.stopPropagation();
                evt.preventDefault();

                var top = $(el);
                var thumb_el = top.getElement(".spt_thumb_top");


                for (var i = 0; i < files.length; i++) {
                    var size = files[i].size;
                    var file = files[i];

                    setTimeout( function() {
                        var loadingImage = loadImage(
                            file,
                            function (img) {
                                thumb_el.innerHTML = "";
                                thumb_el.appendChild(img);
                            },
                            {maxWidth: 240, canvas: true, contain: true}
                        );
                    }, 0 );


                    var search_key = top.getAttribute("spt_search_key");
                    var filename = file.name;
                    var context = "publish" + "/" + filename;

                    var upload_file_kwargs =  {
                        files: files,
                        upload_complete: function() {
                            var server = TacticServerStub.get();
                            var kwargs = {mode: 'uploaded'};
                            server.simple_checkin( search_key, context, filename, kwargs);
                        }
                    };
                    spt.html5upload.upload_file(upload_file_kwargs);
         


     
                }
            }
            '''
        } )

        
        border = layout_wdg.get_color("border")
        layout_wdg.add_relay_behavior( {
            'type': 'mouseup',
            'border': border,
            'bvr_match_class': 'spt_tile_select',
            'cbjs_action': '''
            if (evt.shift == true) {

                spt.table.set_table(bvr.src_el);
                var row = bvr.src_el.getParent(".spt_table_row");


                var rows = spt.table.get_all_rows(true);
                var last_selected = spt.table.last_selected_row;
                var last_index = -1;
                var cur_index = -1;
                for (var i = 0; i < rows.length; i++) {
                    if (rows[i] == last_selected) {
                        last_index = i;
                    }
                    if (rows[i] == row) {
                        cur_index = i;
                    }

                    if (cur_index != -1 && last_index != -1) {
                        break;
                    }

                }
                var start_index;
                var end_index;
                if (last_index < cur_index) {
                    start_index = last_index;
                    end_index = cur_index;
                }
                else {
                    start_index = cur_index;
                    end_index = last_index;
                }


                var select = last_selected.hasClass("spt_table_selected");
                for (var i = start_index; i < end_index+1; i++) {

                    var row = rows[i];
                    var checkbox = row.getElement(".spt_tile_checkbox");

                    if (select) {
                        checkbox.checked = true;
                        row.removeClass("spt_table_selected");

                        spt.table.select_row(row);
                        row.setStyle("box-shadow", "0px 0px 15px #FF0");


                    }
                    else {
                        checkbox.checked = false;
                        row.addClass("spt_table_selected");
                        spt.table.unselect_row(row);

                        row.setStyle("box-shadow", "0px 0px 15px rgba(0,0,0,0.5)");

                    }
                }

            }
            else {

                var row = bvr.src_el.getParent(".spt_table_row");
                var checkbox = bvr.src_el.getElement(".spt_tile_checkbox");

                if (checkbox.checked == true) {
                    checkbox.checked = false;
                    row.removeClass("spt_table_selected");
                    spt.table.unselect_row(row);
                    row.setStyle("box-shadow", "0px 0px 15px rgba(0,0,0,0.5)");

                }
                else {
                    checkbox.checked = true;
                    row.addClass("spt_table_selected");
                    spt.table.select_row(row);
                    row.setStyle("box-shadow", "0px 0px 15px #FF0");

                }

            }

            '''
        } )


        layout_wdg.add_relay_behavior( {
            'type': 'mouseup',
            'bvr_match_class': 'spt_tile_checkbox',
            'cbjs_action': '''
            if (bvr.src_el.checked) {
                bvr.src_el.checked = false;
            }
            else {
                bvr.src_el.checked = true;
            }
            evt.stopPropagation();
            '''
        } )
Beispiel #19
0
    def get_display(my):

        search = Search("sthpw/login")
        logins = search.get_sobjects()

        top = my.top
        top.add_class("spt_panel_user_top")
        top.add_style("min-width: 400px")

        button = SingleButtonWdg(title="Advanced Security", icon=IconWdg.LOCK)
        top.add(button)
        button.add_style("float: right")
        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)
            '''
        })

        button = SingleButtonWdg(title="Add",
                                 tip="Add New User",
                                 icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        top.add("<br clear='all'/>")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.panel.EditWdg';
            var kwargs = {
                search_type: "sthpw/login",
                view: "edit",
            }
            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);
            }

            '''
        })

        #logins = []
        if not logins:
            arrow_div = DivWdg()
            top.add(arrow_div)
            arrow_div.add("<b><<< Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: -35px")
            arrow_div.add_style("margin-left: 35px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 5px")
            arrow_div.set_box_shadow("1px 1px 2px 2px")
            arrow_div.set_round_corners(10, corners=['TL', 'BL'])

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("margin: 15px 30px 30px 30px")
            div.add_style("padding: 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")

        table = Table()
        table.set_max_width()
        table.add_style("margin-top: 10px")
        div.add(table)

        # group mouse over
        table.add_relay_behavior({
            'type':
            "mouseover",
            'bvr_match_class':
            'spt_row',
            'cbjs_action':
            "spt.mouse.table_layout_hover_over({}, {src_el: bvr.src_el, add_color_modifier: -2})"
        })
        table.add_relay_behavior({
            'type':
            "mouseout",
            'bvr_match_class':
            'spt_row',
            'cbjs_action':
            "spt.mouse.table_layout_hover_out({}, {src_el: bvr.src_el})"
        })

        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("&nbsp;")
        th.add_style("text-align: left")
        th = table.add_header("Login")
        th.add_style("text-align: left")
        th = table.add_header("First Name")
        th.add_style("text-align: left")
        th = table.add_header("Last Name")
        th.add_style("text-align: left")
        th = table.add_header("Display Name")
        th.add_style("text-align: left")
        th = table.add_header("Activity")
        th.add_style("text-align: left")
        th = table.add_header("Groups")
        th.add_style("text-align: left")
        th = table.add_header("Security")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")

        for i, login in enumerate(logins):
            tr = table.add_row()
            tr.add_class("spt_row")

            if not i or not i % 2:
                tr.add_color("background", "background3")
            else:
                tr.add_color("background", "background", -2)

            thumb = ThumbWdg()
            thumb.set_sobject(login)
            thumb.set_icon_size(30)
            td = table.add_cell(thumb)

            td = table.add_cell(login.get_value("login"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("first_name"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("last_name"))
            td.add_style("padding: 3px")

            td = table.add_cell(login.get_value("display_name"))
            td.add_style("padding: 3px")

            search_key = login.get_search_key()
            login_code = login.get_code()
            full_name = login.get_full_name()

            td = table.add_cell()
            button = IconButtonWdg(tip="Activity", icon=IconWdg.CALENDAR)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'login_code':
                login_code,
                'full_name':
                full_name,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.tools.ScheduleUserToolWdg';
                var kwargs = {
                    login: bvr.login_code
                }

                var title = bvr.full_name + ' Schedule';
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new("user_schedule", title, class_name, kwargs);
                //spt.panel.load_popup("Activty", class_name, kwargs);


                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Groups", icon=IconWdg.GROUP_LINK)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_key,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.startup.GroupAssignWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Group Assignment", class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_key,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.startup.GroupSummaryWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Security Summary", class_name, kwargs);
                '''
            })

            td = table.add_cell()
            button = IconButtonWdg(title="Edit User", icon=IconWdg.EDIT)
            td.add(button)
            button.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_key,
                'cbjs_action':
                '''

                var top = bvr.src_el.getParent(".spt_panel_user_top");
                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/login",
                    view: "edit",
                    search_key: bvr.search_key
                }
                var popup = spt.panel.load_popup("Create New User", class_name, kwargs);

                popup.on_save_cbk = function() {
                    spt.panel.refresh(top);
                }

                '''
            })

        return top
Beispiel #20
0
    def get_tile_wdg(my, sobject):

        div = DivWdg()

        
        div.add_class("spt_tile_top")
        div.add_class("unselectable")
        div.add_style('margin', my.spacing)
        div.add_style('background-color','transparent')

        div.add_class("spt_table_row")
        div.add_class("spt_table_row_%s" % my.table_id)

        if my.kwargs.get("show_title") not in ['false', False]:
            if my.title_wdg:
                my.title_wdg.set_sobject(sobject)
                div.add(my.title_wdg.get_buffer_display())
            else:
                title_wdg = my.get_title(sobject)
                div.add( title_wdg )

        div.add_attr("spt_search_key", sobject.get_search_key(use_id=True))
        div.add_attr("spt_search_key_v2", sobject.get_search_key())
        div.add_attr("spt_name", sobject.get_name())
        div.add_attr("spt_search_code", sobject.get_code())

        display_value = sobject.get_display_value(long=True)
        div.add_attr("spt_display_value", display_value)

        SmartMenu.assign_as_local_activator( div, 'DG_DROW_SMENU_CTX' )

        
        if my.kwargs.get("show_drop_shadow") not in ['false', False]:
            div.set_box_shadow()
        div.add_color("background", "background", -3)
        
        div.add_style("overflow: hidden")

        div.add_style("float: left")

        border_color = div.get_color('border', modifier=20)

        thumb_drag_div = DivWdg()
        div.add(thumb_drag_div)
        thumb_drag_div.add_class("spt_tile_drag")
        thumb_drag_div.add_style("width: auto")
        thumb_drag_div.add_style("height: auto")
        thumb_drag_div.add_behavior( {
            "type": "drag",
            #'drag_el': 'drag_ghost_copy',
            #//'use_copy': 'true',
            "drag_el": '@',
            'drop_code': 'DROP_ROW',
            'border_color': border_color,
            "cb_set_prefix": 'spt.tile_layout.image_drag'
        } )

        thumb_div = DivWdg()
        thumb_drag_div.add(thumb_div)
        thumb_div.add_class("spt_tile_content")


        
        thumb_div.add_style("width: %s" % my.aspect_ratio[0])

        thumb_div.add_style("height: %s" % my.aspect_ratio[1])
        #thumb_div.add_style("overflow: hidden")

        kwargs = {'show_name_hover': my.show_name_hover}

        thumb = ThumbWdg2(**kwargs)
        thumb.set_sobject(sobject)
        thumb_div.add(thumb)
        thumb_div.add_border()

        #bottom_view = my.kwargs.get("bottom_view")
        #if bottom_view:
        #    div.add( my.get_view_wdg(sobject, bottom_view) )
        if my.bottom:
            my.bottom.set_sobject(sobject)
            div.add(my.bottom.get_buffer_display())
        

        div.add_attr("ondragenter", "return false")
        div.add_attr("ondragover", "return false")
        div.add_attr("ondrop", "spt.thumb.noop(event, this)")

        return div
Beispiel #21
0
    def get_widget_from_hash(cls,
                             hash,
                             return_none=False,
                             force_no_index=False,
                             kwargs={}):

        from pyasm.web import DivWdg
        if hash.startswith("//"):
            use_top = False
            hash = hash[1:]
        else:
            use_top = True

        import re
        p = re.compile("^/(\w+)")
        m = p.search(hash)
        if not m:
            if return_none:
                return None
            print "Cannot parse hash[%s]" % hash
            return DivWdg("Cannot parse hash [%s]" % hash)
        key = m.groups()[0]

        if key != 'login':
            security = Environment.get_security()
            login = security.get_user_name()
            # guest user should never be able to see admin site
            if login == "guest" and key == 'admin':
                #from pyasm.widget import Error403Wdg
                #return Error403Wdg().get_buffer_display()
                from pyasm.widget import WebLoginWdg
                # HACK: if the guest access is full, the the outer form
                # is not defined ... force it in here.  This is because the
                # top used it TopWdg and not TitleTopWdg
                div = DivWdg()
                div.add(
                    "<form id='form' name='form' method='post' enctype='multipart/form-data'>\n"
                )
                web_login_wdg = WebLoginWdg().get_buffer_display()
                div.add(web_login_wdg)
                div.add("</form>\n")
                return div

        sobject = cls._get_predefined_url(key, hash)

        # look up the url
        if not sobject:
            search = Search("config/url")
            search.add_filter("url", "/%s/%%" % key, "like")
            search.add_filter("url", "/%s" % key)
            search.add_where("or")
            sobject = search.get_sobject()

        if not sobject:
            if return_none:
                return None
            return DivWdg("No Widget found for hash [%s]" % hash)

        config = sobject.get_value("widget")
        config = config.replace('&', '&amp;')

        url = sobject.get_value("url")
        url = url.strip()

        # update the config value with expressions
        options = Common.extract_dict(hash, url)
        for name, value in options.items():
            config = config.replace("{%s}" % name, value)

        xml = Xml()
        xml.read_string(config)

        use_index, use_admin, use_sidebar = cls._get_flags(
            xml, sobject, force_no_index, kwargs)

        if use_admin:
            # use admin
            from tactic.ui.app import PageNavContainerWdg
            top = PageNavContainerWdg(hash=hash, use_sidebar=use_sidebar)
            return top.get_buffer_display()

        elif use_index:

            # check if there is an index
            search = Search("config/url")
            search.add_filter("url", "/index")
            index = search.get_sobject()
            # just use admin if no index page is found
            if not index:
                from tactic.ui.app import PageNavContainerWdg
                top = PageNavContainerWdg(hash=hash, use_sidebar=use_sidebar)
                return top.get_buffer_display()

            config = index.get_value("widget")
            xml = Xml()
            xml.read_string(config)
            node = xml.get_node("element/display")

            options.update(xml.get_node_values_of_children(node))

            class_name = xml.get_value("element/display/@class")
            if class_name:
                options['class_name'] = class_name

            # this passes the hash value to the index widget
            # which must handle it accordingly
            options['hash'] = hash
            top = cls.build_widget(options)

            return top.get_buffer_display()

        # process the options and then build the widget from the xml

        options = Common.extract_dict(hash, url)
        for name, value in kwargs.items():
            options[name] = value

        node = xml.get_node("element/display")
        options.update(xml.get_node_values_of_children(node))

        class_name = xml.get_value("element/display/@class")
        if class_name:
            options['class_name'] = class_name

        widget = cls.build_widget(options)

        name = hash.lstrip("/")
        name_array = name.split("/")
        if name_array:
            name_end = name_array[-1]
            name_end = name_end.replace("_", " ")
            widget.set_name(name_end)
        else:
            widget.set_name(name)

        return widget
Beispiel #22
0
    def get_scale_wdg(my):

        if my.scale_called == True:
            return None
        my.scale_called = True

        show_scale = my.kwargs.get("show_scale")

        div = DivWdg()
        if show_scale in [False, 'false']:
            div.add_style("display: none")
        div.add_style("padding: 5px")
        div.add_class("spt_table_search")
        hidden = HiddenWdg("prefix", "tile_layout")
        div.add(hidden)
        div.add_behavior( {
            'type': 'load',
            'scale_prefix':  my.scale_prefix,
            'default_scale': my.scale,
            'aspect_ratio': my.aspect_ratio,
            'cbjs_action': '''
spt.tile_layout = {}
spt.tile_layout.layout = null;

spt.tile_layout.set_layout = function(layout) {
    if (!layout.hasClass("spt_layout")) {
        layout = layout.getParent(".spt_layout");
    }
    spt.tile_layout.layout = layout;
    return layout;
}

spt.tile_layout.get_scale = function() {
    var scale_value = spt.tile_layout.layout.getElement(".spt_scale_value");
    var value = scale_value.value;
    value = parseInt(value);
    return value;
}


spt.tile_layout.set_scale = function(scale) {

    var scale_value = spt.tile_layout.layout.getElement(".spt_scale_value");
    scale_value.value = scale;

    var size_x = bvr.aspect_ratio[0]*scale/100;
    var size_y = bvr.aspect_ratio[1]*scale/100;

    //var top = bvr.src_el.getParent(".spt_tile_layout_top");
    var top = spt.tile_layout.layout;
    var els = top.getElements(".spt_tile_content");
    for (var i = 0; i < els.length; i++) {
        var el = els[i];
        el.setStyle( "width",  size_x);
        el.setStyle( "height", size_y);
    }

    var container_id = "tile_layout::scale"+bvr.scale_prefix;
    spt.container.set_value( container_id, scale);
}


spt.tile_layout.drag_start_x = null;
spt.tile_layout.drag_start_value = null;

spt.tile_layout.drag_setup = function(evt, bvr, mouse_411) {
    spt.tile_layout.set_layout(bvr.src_el);
    spt.tile_layout.drag_start_x = mouse_411.curr_x;
    var src_el = spt.behavior.get_bvr_src( bvr );
    if (!src_el.value) {
        src_el.value = 0;
    }
    spt.tile_layout.drag_start_value = src_el.value;
    src_el.focus();
    src_el.select();
}
spt.tile_layout.drag_motion = function(evt, bvr, mouse_411) {
    var start_value = spt.tile_layout.drag_start_value; 
    if (isNaN(parseInt(start_value))) {
        return;
    }
    var dx = mouse_411.curr_x - spt.tile_layout.drag_start_x;
    var increment = parseInt(dx / 5);
    var multiplier;
    if (increment < 0)
        multiplier = 0.975;
    else
        multiplier = 1 / 0.975;
    increment = Math.abs(increment);
    var scale = spt.tile_layout.drag_start_value;
    for (var i = 0; i < increment; i++) {
        scale = scale * multiplier;
    }
    if (scale > 400)
        scale = 400;
    scale = parseInt(scale);
    spt.tile_layout.set_scale(scale);

}
spt.tile_layout.setup_control = function() {
   var slider = spt.tile_layout.layout.getElement('.spt_slider');
   var container_id = "tile_layout::scale"+bvr.scale_prefix;
   var initial_value = spt.container.get_value(container_id) ?  spt.container.get_value(container_id) : bvr.default_scale;

   spt.tile_layout.set_scale(initial_value);
   new Slider(slider, slider.getElement('.knob'), {
    range: [30, 400],
    steps: 74,
    initialStep: initial_value,
    onChange: function(value){
      if (value) spt.tile_layout.set_scale(value);
    }
  });
}



spt.tile_layout.image_drag_setup = function(evt, bvr, mouse_411) {
    bvr.use_copy = true;
    bvr.use_delta = true;
    //bvr.border_color = border_color;
    bvr.dx = 10;
    bvr.dy = 10;
    bvr.drop_code = 'DROP_ROW';


}

spt.tile_layout.image_drag_motion = function(evt, bvr, mouse_411) {

    spt.mouse._smart_default_drag_motion(evt, bvr, mouse_411);
    var target_el = spt.get_event_target(evt);
    target_el = spt.mouse.check_parent(target_el, bvr.drop_code);
    if (target_el) {
        var orig_border_color = target_el.getStyle('border-color');
        var orig_border_style = target_el.getStyle('border-style');
        target_el.setStyle('border','dashed 2px ' + bvr.border_color);
        if (!target_el.getAttribute('orig_border_color')) {
            target_el.setAttribute('orig_border_color', orig_border_color);
            target_el.setAttribute('orig_border_style', orig_border_style);
        }
    }

}

spt.tile_layout.image_drag_action = function(evt, bvr, mouse_411) {
    if (spt.drop) {
        spt.drop.sobject_drop_action(evt, bvr);
    }
    else {
        if( bvr._drag_copy_el ) {
            spt.behavior.destroy_element(bvr._drag_copy_el);
        }
    }
}

        ''' } )


        scale = my.kwargs.get("scale")


        div.add_behavior( {
        'type': 'load',
        'scale': scale,
        'cbjs_action': '''
        spt.tile_layout.set_layout(bvr.src_el);

        spt.tile_layout.setup_control();

        if (bvr.scale) {
            spt.tile_layout.set_scale(bvr.scale);
        }
      
        '''
        } )

        table = Table()
        div.add(table)
        table.add_row()

        """
        # TO BE DELETED
        less_div = DivWdg()
        less_div.add("<input type='button' value='&lt;&lt;'/>")
        table.add_cell(less_div)

        less_div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tile_layout.set_layout(bvr.src_el);
            var scale = spt.tile_layout.get_scale();
            scale = scale * 0.95;
            scale = parseInt(scale);
            spt.tile_layout.set_scale(scale);
            '''
        } )
        """

        dark_color = div.get_color("background", -5)
        light_color = div.get_color('color')
        med_color = div.get_color('color2')
        
        slider_div = DivWdg(css='spt_slider')
        slider_div.add_styles('valign: bottom; background: %s; height: 6px; width: 100px;'% light_color)
        knob_div = DivWdg(css='knob')
        knob_div.add_behavior({'type':'click',
                'cbjs_action': 'spt.tile_layout.set_layout(bvr.src_el)'
                })
        knob_div.add_styles('background: %s; bottom: 4px;\
                height: 16px; width: 12px; border-radius: 6px 6px 0 0;\
                border: 1px %s solid'\
                %(dark_color, med_color ))
        slider_div.add(knob_div)
        td = table.add_cell(slider_div)
        value_wdg = TextWdg("scale")
        value_wdg.add_class("spt_scale_value")
        td = table.add_cell(value_wdg)
        td.add("&nbsp;%")

        td.add_style("padding: 3px 8px")

        """
        # TO BE DELETED
        from tactic.ui.filter import FilterData
        filter_data = FilterData.get()
        data_list = filter_data.get_values_by_prefix("tile_layout")
        if data_list:
            data = data_list[0]
        else:
            data = {}
        my.scale = data.get("scale")
        if my.scale == None:
            my.scale = my.kwargs.get("scale")
        """
        if my.scale:
            value_wdg.set_value(my.scale)
        value_wdg.add_style("width: 28px")
        value_wdg.add_style("text-align: center")
        value_wdg.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var value = bvr.src_el.value;
        var scale = parseInt(value);
        spt.tile_layout.set_layout(bvr.src_el);
        spt.tile_layout.set_scale(scale);
        '''
        } )
        value_wdg.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        var value = bvr.src_el.value;
        if (!value) {
            value = 100;
        }
        var scale = parseInt(value);
        spt.tile_layout.set_layout(bvr.src_el);
        spt.tile_layout.set_scale(scale);
        '''
        } )



 
        value_wdg.add_behavior( {
            'type': 'smart_drag',
            'bvr_match_class': 'spt_scale_value',
            'ignore_default_motion' : True,
            "cbjs_setup": 'spt.tile_layout.drag_setup( evt, bvr, mouse_411 );',
            "cbjs_motion": 'spt.tile_layout.drag_motion( evt, bvr, mouse_411 );'
        } )

        
        """
        # TO BE DELETED
        more_div = DivWdg()
        more_div.add("<input type='button' value='&gt;&gt;'/>")
        table.add_cell(more_div)

        more_div.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.tile_layout.set_layout(bvr.src_el);
            var scale = spt.tile_layout.get_scale();
            scale = scale / 0.95;
            scale = parseInt(scale);
            spt.tile_layout.set_scale(scale);
            '''
        } )

        """


       

        return div
Beispiel #23
0
    def get_display(my):

        element_data_dict = {}

        config = my.get_config()
        element_names = config.get_element_names()
        content_wdg = DivWdg()


        if not element_names:
            element_names = ['keywords']

        my.set_content(content_wdg)

        
        # this is somewhat duplicated logic from alter_search, but since this is called 
        # in ViewPanelWdg, it's a diff instance and needs to retrieve again
        filter_data = FilterData.get()
        data_list = filter_data.get_values_by_prefix(my.prefix)
        for data in data_list:
            handler = data.get("handler")
            element_name = data.get("element_name")
            if not element_name:
                continue

            element_data_dict[element_name] = data

        elements_wdg = DivWdg()
        content_wdg.add(elements_wdg)
        elements_wdg.add_color("color", "color")
        elements_wdg.add_style("padding-top: 10px")
        elements_wdg.add_style("padding-bottom: 15px")

        #elements_wdg.add_color("background", "background3", 0)
        elements_wdg.add_color("background", "background", -3)
        elements_wdg.add_border()



        if len(element_names) == 1:
            elements_wdg.add_style("border-width: 0px 0px 0px 0px" )
            elements_wdg.add_style("padding-right: 50px" )
        else:
            elements_wdg.add_style("border-width: 0px 0px 0px 0px" )

        table = Table()
        table.add_color("color", "color")
        elements_wdg.add(table)
        table.add_class("spt_simple_search_table")
        
        columns = my.kwargs.get("columns")
        if not columns:
            columns = 2
        else:
            columns = int(columns) 
       
        num_rows = int(len(element_names)/columns)+1
        tot_rows = int(len(element_names)/columns)+1
        project_code = Project.get_project_code()
        # my.search_type could be the same as my.base_search_type
        full_search_type = SearchType.build_search_type(my.search_type, project_code)


        visible_rows = my.kwargs.get("visible_rows")
        if visible_rows:
            visible_rows = int(visible_rows)
            num_rows = visible_rows
        else:
            visible_rows = 0

        titles = config.get_element_titles() 
        row_count = 0
        for i, element_name in enumerate(element_names):
            attrs = config.get_element_attributes(element_name)
            if i % columns == 0:

                if visible_rows and row_count == visible_rows:
                    tr, td = table.add_row_cell("+ more ...")
                    td.add_class("hand")
                    td.add_class("SPT_DTS")
                    td.add_class("spt_toggle")
                    td.add_style("padding-left: 10px")

                    td.add_behavior( {
                        'type': 'click_up',
                        'visible_rows': visible_rows,
                        'cbjs_action': '''
                        var top = bvr.src_el.getParent(".spt_simple_search_table");
                        var expand = true;
                        var rows = top.getElements(".spt_simple_search_row");
                        for (var i = 0; i < rows.length; i++) {
                            var row = rows[i];
                            if (row.getStyle("display") == "none") {
                                row.setStyle("display", "");
                            }
                            else {
                                row.setStyle("display", "none");
                                expand = false;
                            }
                        }
                        var spacer = top.getElements(".spt_spacer");
                        var cell = top.getElement(".spt_toggle");
                        if (expand) {
                            spacer.setStyle("height", (rows.length+bvr.visible_rows)*20);
                            cell.innerHTML = "- less ...";
                        }
                        else {
                            spacer.setStyle("height", bvr.visible_rows*20);
                            cell.innerHTML = "+ more ...";
                        }

                        '''
                    } )


                tr = table.add_row()
                if visible_rows and row_count >= visible_rows:

                    tr.add_class("spt_simple_search_row")
                    tr.add_style("display: none")
                    tr.add_style("height: 0px")

                row_count += 1

            icon_td = table.add_cell()
            title_td = table.add_cell()
            element_td =table.add_cell()


            # show the title
            title_td.add_style("text-align: right")
            title_td.add_style("padding-right: 5px")
            title_td.add_style("min-width: 100px")


            element_wdg = DivWdg()
            if attrs.get('view') == 'false':
                element_wdg.add_style('display: none')
            element_td.add(element_wdg)

            #title_td.add_style("border: solid 1px red")
            #element_td.add_style("border: solid 1px blue")
            #element_wdg.add_style("border: solid 1px yellow")


            if i >= 0  and i < columns -1 and len(element_names) > 1:
                spacer = DivWdg()
                spacer.add_class("spt_spacer")
                spacer.add_style("border-style: solid")
                spacer.add_style("border-width: 0 0 0 0")
                #spacer.add_style("height: %spx" % (num_rows*20))
                spacer.add_style("height: %spx" % (num_rows*20))
                spacer.add_style("width: 10px")
                spacer.add_style("border-color: %s" % spacer.get_color("border") )
                spacer.add("&nbsp;")
                td = table.add_cell(spacer)
                td.add_attr("rowspan", tot_rows)

            #element_wdg.add_color("color", "color3")
            #element_wdg.add_color("background", "background3")
            #element_wdg.set_round_corners()
            #element_wdg.add_border()

            element_wdg.add_style("padding: 4px 10px 4px 5px")
            element_wdg.add_class("spt_table_search")
            element_wdg.add_style("margin: 1px")
            element_wdg.add_style("min-height: 20px")
            element_wdg.add_style("min-width: 250px")

            # this is done at get_top()
            #element_wdg.add_class("spt_search")
            element_wdg.add( HiddenWdg("prefix", my.prefix))

            display_handler = config.get_display_handler(element_name)
            element_wdg.add( HiddenWdg("handler", display_handler))


            element_wdg.add( HiddenWdg("element_name", element_name))
        

            from pyasm.widget import ExceptionWdg
            try:
                widget = config.get_display_widget(element_name)
                if widget:
                    widget.set_title(titles[i])

            except Exception, e:
                element_wdg.add(ExceptionWdg(e))
                continue


            if not widget:
                # the default for KeywordFilterElementWdg is mode=keyword
                if not my.column_choice:
                    my.column_choice = my.get_search_col(my.search_type)
                widget = KeywordFilterElementWdg(column=my.column_choice)
                widget.set_name(element_name)
                


            from pyasm.widget import IconWdg
            icon_div = DivWdg()
            icon_td.add(icon_div)
            icon_div.add_style("width: 20px")
            icon_div.add_style("margin-top: 2px")
            icon_div.add_style("padding-left: 5px")
            icon_div.add_class("spt_filter_top")


            widget.set_show_title(False)
            #element_wdg.add("%s: " % title)
            data = element_data_dict.get(element_name)
			
			
            view_panel_keywords = my.kwargs.get("keywords")
            #user data takes precedence over view_panel_keywords
            if isinstance(widget, KeywordFilterElementWdg):
                if view_panel_keywords:
                    widget.set_value("value", view_panel_keywords)
            if data:
                widget.set_values(data)

                
           
			    
                    

            if isinstance(widget, KeywordFilterElementWdg) and not full_search_type.startswith('sthpw/sobject_list'):
                widget.set_option('filter_search_type', full_search_type)
            try:
                if attrs.get('view') != 'false':
                    title_td.add(widget.get_title_wdg())

                element_wdg.add(widget.get_buffer_display())
            except Exception, e:
                element_wdg.add(ExceptionWdg(e))
                continue
Beispiel #24
0
    def init(my):

        # get the args in the URL
        args = WebContainer.get_web().get_form_args()
        search_type = args['search_type']
        search_id = args['search_id']

        sobject = Search.get_by_id(search_type, search_id)

        main_div = DivWdg()
        main_div.add_style("width: 95%")
        main_div.add_style("float: right")
        my.add(main_div)

        
        if isinstance(sobject, Shot):

            content_id ='summary_story_%s' %sobject.get_id()
            title_id = 'story_head_%s' %sobject.get_id()
            story_div = DivWdg(id=content_id)
            story_div.add_style('display','block')
            
            story_head = HtmlElement.h3("Storyboard")
            my.add_title_style(story_head, title_id, content_id)
            
            main_div.add(story_head)
            main_div.add(story_div)

            storyboard_table = TableWdg("prod/storyboard", "summary", css='minimal')
            search = Search("prod/storyboard")
            search.add_filter( sobject.get_foreign_key(), sobject.get_code() )
            sobjects = search.get_sobjects()
            storyboard_table.set_sobjects(sobjects)
            story_div.add(storyboard_table)


        # add reference material
        search = Search("sthpw/connection")
        search.add_filter("src_search_type", search_type)
        search.add_filter("src_search_id", search_id)
        connections = search.get_sobjects()

        if connections:
            content_id ='summary_ref_%s' %sobject.get_id()
            title_id = 'ref_head_%s' %sobject.get_id()

            ref_head = HtmlElement.h3("Reference")
            my.add_title_style(ref_head, title_id, content_id)
            
            ref_div = DivWdg(id = content_id)
            ref_div.add_style('display','block')
            
            for connection in connections:
                thumb = ThumbWdg()
                thumb.set_name("snapshot")
                dst_search_type = connection.get_value("dst_search_type")
                dst_search_id = connection.get_value("dst_search_id")
                dst = Search.get_by_id(dst_search_type, dst_search_id)
                thumb.set_sobject(dst)
                ref_div.add(thumb)

            
            main_div.add(ref_head)
            main_div.add(ref_div)


       
        task_head = HtmlElement.h3("Tasks")
        content_id ='summary_task_%s' %sobject.get_id()
        title_id = 'task_head_%s' %sobject.get_id()
        my.add_title_style(task_head, title_id, content_id)
        
        main_div.add(task_head)

        task_div = DivWdg(id=content_id)
        task_div.add_style('display','block')
        
        main_div.add(task_div)
        
        search = Search("sthpw/task")
        #if process != "":
        #    search.add_filter("process", process)

        search.add_filter("search_type", search_type)
        search.add_filter("search_id", search_id)

        #search.set_limit(4)
        task_table = TableWdg("sthpw/task", "summary", css='minimal')
        task_table.set_id('sthpw/task%s' % search_id)
        task_table.set_search(search)
        task_div.add(task_table)

        content_id ='summary_hist_%s' %sobject.get_id()
        title_id = 'hist_head_%s' %sobject.get_id()
        hist_head = HtmlElement.h3("Checkin History")
        my.add_title_style(hist_head, title_id, content_id)
        
        hist_div = DivWdg(id=content_id)
        hist_div.add_style('display','block')
        
        
        main_div.add(hist_head)
        main_div.add(hist_div)
        from flash_asset_history_wdg import FlashAssetHistoryWdg
        history = FlashAssetHistoryWdg()
        hist_div.add(history)
        main_div.add(HtmlElement.br())
Beispiel #25
0
    def get_display(my):
        # if no filters are defined, then display nothing
        if not my.filters:
            return Widget()

        #filter_top = DivWdg(css="maq_search_bar")
        filter_top = DivWdg()
        filter_top.add_color("color", "color")
        filter_top.add_color("background", "background", -5)
        filter_top.add_style("padding: 5px")
        filter_top.add_style("min-width: 800px")
        filter_top.add_border()
        my.set_as_panel(filter_top)

        # TEST link to help for search widget
        help_button = ActionButtonWdg(title="?",
                                      tip="Search Documentation",
                                      size='small')
        filter_top.add(help_button)
        help_button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.help.set_top();
            spt.help.load_alias("search-quickstart|what-is-searching|search-interface|search-compound|search-expressions");
            '''
        })
        help_button.add_style("float: right")

        # this id should be removed
        filter_top.set_id("%s_search" % my.prefix)
        filter_top.add_class("spt_search")

        for name, value in my.kwargs.items():
            filter_top.set_attr("spt_%s" % name, value)

        #filter_top.add(my.statement)
        popup = my.get_retrieve_wdg()
        filter_top.add(popup)
        popup = my.get_save_wdg()
        filter_top.add(popup)

        display = my.kwargs.get('display')

        # Add a number of filters indicator
        div = DivWdg()
        div.add_class("spt_search_num_filters")
        div.add_style("float: right")
        div.add_style("font-size: 0.9em")
        div.add_style("margin: 0 10 0 10")
        #search_summary.add(div)
        filter_top.add(div)

        if my.num_filters_enabled:
            msg = "[%s] filter/s" % my.num_filters_enabled
            icon = IconWdg(msg, IconWdg.DOT_GREEN)
            div.add(icon)
            div.add("%s" % msg)

        filter_div = DivWdg()
        filter_div.set_id("search_filters")
        filter_div.add_class("spt_search_filters")

        # TODO: disabling for now
        # add the action buttons
        #action_wdg =  my.get_action_wdg()
        #action_wdg.add_style("text-align: right")
        #filter_div.add( action_wdg )
        # add the top
        display_str = 'block'
        if not display:
            display_str = 'none'
        filter_div.add_style("display: %s" % display_str)

        search_wdg = my.get_search_wdg()

        prefix = "filter_mode"
        if my.prefix_namespace:
            prefix = '%s_%s' % (my.prefix_namespace, prefix)
        hidden = HiddenWdg("prefix", prefix)

        match_div = DivWdg()
        match_div.add(hidden)
        match_div.add_class('spt_search_filter')

        palette = match_div.get_palette()
        bg_color = palette.color('background')
        light_bg_color = palette.color('background', modifier=+10)

        select = SelectWdg("filter_mode")
        select.add_style("width: 110px")

        select.add_class("spt_search_filter_mode")
        select.set_persist_on_submit(prefix)
        select.remove_empty_option()
        # for Local search, leave out compound search for now
        if my.kwargs.get('prefix_namespace'):
            select.set_option("labels", "Match all|Match any")
            select.set_option("values", "and|or")
        else:
            select.set_option("labels", "Match all|Match any|Compound")
            select.set_option("values", "and|or|custom")
        #select.set_option("labels", "all|any")
        #select.set_option("values", "and|or")

        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
        var display = bvr.src_el.value == 'custom';;

        var top = bvr.src_el.getParent(".spt_search");
        var ops = top.getElements(".spt_op");
        for (var i = 0; i < ops.length; i++) {
            var op = ops[i];
            var element = op.getElement(".spt_op_display");
            var value = op.getAttribute("spt_op");
            if (display) {
                element.innerHTML = value;
                var level = op.getAttribute("spt_level");
                if (level == 1) {
                    element.setStyle("background", "%s")
                    element.setStyle("padding", "4px")
                }
            } else {
                element.innerHTML = '&nbsp;';
                element.setStyle("background", "%s")
                element.setStyle("padding", "1px")
            }
        }
        ''' % (light_bg_color, bg_color)
        })

        match_div.add(select)
        match_div.add_color("color", "color2")
        #match_div.add(" on the following")
        #hint = HintWdg( "An 'AND' operation is always applied to each category below. " \
        #                "This controls only the filters within each category." )
        #match_div.add(hint)
        #match_div.add('<br/>')
        #match_div.add_style("padding-top: 5px")

        filter_div.add(search_wdg)
        search_wdg.add_style("float: left")
        filter_div.add(match_div)

        filter_div.add(HtmlElement.br())

        filters_div = DivWdg()
        filters_div.add_style("margin: 0 -6 0 -6")

        security = Environment.get_security()

        # add all the filters
        for filter in my.filters:
            element_name = filter.get_name()

            if not security.check_access("search", element_name, "view"):
                continue

            # no need to create it again
            #filter = my.config.get_display_widget(element_name)
            div = DivWdg()
            filters_div.add(div)

            div.add_class("hand")
            class_suffix = element_name.replace(' ', '_')
            cbjs_action = 'var el=spt.get_cousin(bvr.src_el,".spt_search",".spt_filter_%s");spt.simple_display_toggle(el);' % class_suffix
            div.add_behavior({'type': 'click_up', 'cbjs_action': cbjs_action})
            div.add_color("color", "color", +5)
            #div.add_gradient("background", "background", -5, -5)
            div.add_style("margin-top: -1px")
            div.add_style("height: 18px")

            div.add_border()
            div.add_style("padding: 8px 5px")
            div.add_style("whitespace: nowrap")

            if element_name in ["Parent", 'Children']:
                swap = SwapDisplayWdg.get_triangle_wdg()
            else:
                swap = SwapDisplayWdg.get_triangle_wdg()
                swap.set_off()
            swap.add_action_script(cbjs_action)

            div.add_event("onclick", swap.get_swap_script())
            div.add(swap)
            div.add_class("SPT_DTS")
            div.add(element_name)

            div = DivWdg()
            div.add_class("spt_filter_%s" % class_suffix)

            if element_name in ["Parent", 'Children']:
                div.add_style("display: none")
            else:
                div.add_style("display: block")

            #div.add_style("background-color: #333")
            div.add_color("background", "background")
            div.add_border()
            div.add_style("padding: 10px 8px")
            div.add_style("margin-top: -1px")
            #div.add_style("margin-left: 20px")
            #div.add_style("width: 660")
            div.add(filter)
            filters_div.add(div)

        filter_div.add(filters_div)

        buttons_div = DivWdg()
        buttons_div.add_style("margin-top: 7px")
        buttons_div.add_style("margin-bottom: 7px")
        search_wdg = my.get_search_wdg()
        search_wdg.add_style("margin: 15px auto")
        buttons_div.add(search_wdg)
        filter_div.add(buttons_div)

        filter_top.add(filter_div)

        return filter_top
        summary = my.get_option("total_summary")
        if not summary:
            return None

        # parse the expression
        my.vars = my.get_vars()
 
        expression, title = my.get_expression(summary)
        try:
            result = Search.eval(expression, sobjects=sobjects, vars=my.vars)
        except Exception, e:
            print "WARNING: ", e.message
            result = 0
            title = ''

        div = DivWdg()
        div.add(str(result))
        div.add_style("text-align: right")

        return div, result



    def get_expression(my, summary):
        if summary == 'total':
            expression = '@SUM(.%s)' % my.get_name()
            title = "Total: "
        elif summary == 'average':
            expression = '@AVG(.%s)' % my.get_name()
            title = "Avg: "
        else:
Beispiel #27
0
    def get_upload_wdg(my):
        widget = Widget()

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

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

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

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

        table = Table()
        table.add_style("margin: 10px 20px")
        table.add_col().set_attr('width','140')
        table.add_col().set_attr('width','400')
        
        table.add_row()
        table.add_header("Search Type: ").set_attr('align','left')
        table.add_cell(name_input)
        table.add_row()
        table.add_header("Title: ").set_attr('align','left')
        table.add_cell(title)
        table.add_row()
        table.add_header("Description: ").set_attr('align','left')
        table.add_cell(description)
        new_search_type_div.add(table)
        new_search_type_div.add_style("display: none")
        #widget.add(new_search_type_div)


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

        my.search_type = search_type_select.get_value()
        if my.search_type:
            sobj = SObjectFactory.create(my.search_type)
            required_columns = sobj.get_required_columns()
            
            widget.add(SpanWdg("Required Columns: ", css='med'))
            if not required_columns:
                required_columns = ['n/a']
            widget.add(SpanWdg(', '.join(required_columns), css='med'))

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

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

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


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

        return widget
    def get_display(my):
        sobject = my.get_current_sobject()

        column =  my.kwargs.get('column')
        if column:
            name = column
        else:
            name = my.get_name()
        
        value = my.get_value(name=name)

        if sobject:
            data_type = SearchType.get_column_type(sobject.get_search_type(), name)
        else:
            data_type = 'text'

        if type(value) in types.StringTypes:
            wiki = WikiUtil()
            value = wiki.convert(value) 
        if name == 'id' and value == -1:
            value = ''

        elif data_type in ["timestamp","time"] or name == "timestamp":
            if value == 'now':
                value = ''
            elif value:
                # This date is assumed to be GMT
                date = parser.parse(value)
                # convert to user timezone
                if not SObject.is_day_column(name):
                    date = my.get_timezone_value(date)
                try:
                    encoding = locale.getlocale()[1]		
                    value = date.strftime("%b %d, %Y - %H:%M").decode(encoding)
                except:
                    value = date.strftime("%b %d, %Y - %H:%M")

            else:
                value = ''
        else:
            if isinstance(value, Widget):
                return value
            elif not isinstance(value, basestring):
                try:
                    value + 1
                except TypeError:
                    value = str(value)
                #else:
                #    value_wdg.add_style("float: right")
                #    value_wdg.add_style("padding-right: 3px")



        if sobject and SearchType.column_exists(sobject.get_search_type(), name):
            value_wdg = DivWdg()
            value_wdg.add_update( {
                'search_key': sobject.get_search_key(),
                'column': name
            } )
            # don't call str() to prevent utf-8 encode error
            value_wdg.add(value)
            return value_wdg

        return value
Beispiel #29
0
    def get_display(my):

        my.aspect = my.get_option('aspect')
        if not my.aspect:
            my.aspect = "width"

        search_key = my.get_option('search_key')
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            my.set_sobject(sobject)

        if not my.is_preprocess_run:
            my.preprocess()

        # get the set size
        icon_size = my.get_option("icon_size")
        if icon_size:
            my.set_icon_size(icon_size)
        # get the real size
        icon_size = my.get_icon_size()

        min_size = my.get_option("min_icon_size")
        if not min_size:
            min_size = 45

        sobject = my.get_current_sobject()
        # get it from the web container
        if not sobject:
            web = WebContainer.get_web()
            search_type = web.get_form_value("search_type")
            search_code = web.get_form_value("search_code")
            search_id = web.get_form_value("search_id")
            icon_size = web.get_form_value("icon_size")
            if icon_size:
                my.icon_size = icon_size
            if search_type and search_code:
                sobject = Search.get_by_code(search_type, search_code)
                my.set_sobject(sobject)
            elif search_type and search_id:
                sobject = Search.get_by_id(search_type, search_id)
                my.set_sobject(sobject)
            else:
                return my.get_no_icon_wdg()
        elif sobject.get_id() == -1:
            div = DivWdg()
            div.add("&nbsp;")
            div.add_style("text-align: center")
            return div

        # if there is a redirect to the sobject (a relation), use that
        redirect = my.get_option("redirect")
        redirect_expr = my.get_option("redirect_expr")
        parser = ExpressionParser()

        if redirect and sobject:
            if redirect == "true":
                # use search_type and search_id pair
                # FIXME: go up a maximum of 2 .. this is not so stable as
                # the parent may have a similar relationship
                for i in range(0, 2):
                    if not sobject:
                        return my.get_no_icon_wdg()

                    if sobject.has_value("search_type"):
                        search_type = sobject.get_value("search_type")
                        # if search_type does not exist, just break out
                        if not search_type:
                            break

                        search_code = sobject.get_value("search_code",
                                                        no_exception=True)
                        if search_code:
                            sobject = Search.get_by_code(
                                search_type, search_code)
                        else:
                            search_id = sobject.get_value("search_id",
                                                          no_exception=True)
                            sobject = Search.get_by_id(search_type, search_id)
                        if sobject:
                            break

            elif redirect.count("|") == 2:
                search_type, col1, col2 = redirect.split("|")
                search = Search(search_type)
                search.add_filter(col1, sobject.get_value(col2))
                sobject = search.get_sobject()
                if not sobject:
                    return my.get_no_icon_wdg()

        elif redirect_expr and sobject:
            redirect_sobject = parser.eval(redirect_expr,
                                           sobjects=[sobject],
                                           single=True)
            if redirect_sobject:
                sobject = redirect_sobject
            else:
                return my.get_no_icon_wdg()

        # get the icon context from the sobject
        icon_context = my.get_option("icon_context")
        if not icon_context:
            icon_context = sobject.get_icon_context(my.context)

        # try to get an icon first
        if isinstance(sobject, Snapshot):
            snapshot = sobject
            # check if the sobject actually exists
            try:
                snapshot.get_sobject()
            except SObjectNotFoundException, e:
                return IconWdg('sobject n/a for snapshot code[%s]' %
                               snapshot.get_code(),
                               icon=IconWdg.ERROR)
            except SearchException, e:
                return IconWdg('parent for snapshot [%s] not found' %
                               snapshot.get_code(),
                               icon=IconWdg.ERROR)
Beispiel #30
0
    def get_title(my, sobject):
        div = DivWdg()

        div.add_class("spt_tile_title")

        div.add_color("background", "background3")
        div.add_style("padding: 5px")
        div.add_style("height: 16px")


        detail_div = DivWdg()
        div.add(detail_div)
        detail_div.add_class("spt_tile_detail")
        detail_div.add_style("float: right")
        detail_div.add_style("margin-top: -2px")

        detail = IconButtonWdg(title="Detail", icon=IconWdg.ZOOM)
        detail_div.add(detail)


        header_div = DivWdg()
        header_div.add_class("spt_tile_select")
        header_div.add_class("hand")
        div.add(header_div)
        header_div.add_class("SPT_DTS")
        header_div.add_style("overflow-x: hidden")

        from pyasm.widget import CheckboxWdg
        checkbox = CheckboxWdg("select")
        checkbox.add_class("spt_tile_checkbox")

        title = sobject.get_name()
        if not title:
            title = sobject.get_code()
      
        table = Table()
        header_div.add(table)
        header_div.add_style("position: relative")

        table.add_cell(checkbox)

        title_div = DivWdg()
        td = table.add_cell(title_div)
        title_div.add(title)
        title_div.add_style("height: 15px")
        title_div.add_style("left: 25px")
        title_div.add_style("top: 3px")
        title_div.add_style("position: absolute")
        title_div.add_attr("title", title)
        #title_div.add_style("white-space", "nowrap")
        #td.add_style("overflow: hidden")
        title_div.add("<br clear='all'/>")


        description = sobject.get_value("description", no_exception=True)
        if description:
            div.add_attr("title", sobject.get_code())



        return div