예제 #1
0
    def get_display(self):

        top = self.top

        height = self.get_option('height')
        if not height:
            height = 300

        inner = DivWdg()
        top.add(inner)
        inner.add_style("overflow-y: auto")
        inner.add_style("overflow-x: hidden")
        inner.add_style("min-width: 300px")
        inner.add_style("max-width: 300px")
        inner.add_style("max-height: %s" % height)
        inner.add_style("margin-right: -3px")
        
        sobject = self.get_current_sobject()

        data = sobject.get_json_value( self.get_name() )
        if not data:
            data = {}

        keys = data.keys()
        keys.sort()

        for key in keys:
            value = data.get(key)
            inner.add("%s = %s<br/>"% (key, value))



        return top
예제 #2
0
    def get_save_wdg(my):

        from tactic.ui.container import DialogWdg
        dialog = DialogWdg(display=False, width=200, offset={'x':0,'y':50}, show_pointer=False)
        dialog_id = dialog.get_id()

        title = 'Save a New View'

        dialog.add_title(title)

        div = DivWdg()
        dialog.add(div)
        div.add_style("padding: 5 5 5 20")
        div.add_color("background", "background")

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


        from tactic.ui.panel import ViewPanelSaveWdg
        save_wdg = ViewPanelSaveWdg(
            search_type=my.kwargs.get("search_type"),
            dialog_id=dialog_id,
            table_id=my.table_id
        )
        div.add(save_wdg)

        return dialog
예제 #3
0
    def get_display(my):

        dd_activator = DivWdg()

        if my.style:
            dd_activator.add_styles( my.style )

        dd_activator.add_style( "width: %spx" % my.width )
        dd_activator.add_class("SPT_DTS");

        if my.nudge_menu_horiz != 0:
            dd_activator.set_attr("spt_nudge_menu_horiz", my.nudge_menu_horiz)

        if my.nudge_menu_vert != 0:
            dd_activator.set_attr("spt_nudge_menu_vert", my.nudge_menu_vert)

        # Generate button ...
        #
        table = Table()
        table.add_row()
        table.add_styles("width: 100%; padding: 0px; margin: 0px;")
        td = table.add_cell()
        td.add_looks("menu border curs_default")
        td.add_styles( "padding: 0px; width: 100%; overflow: hidden; height: 12px; max-height: 12px;" )

        title_div = DivWdg()
        title_div.add_styles( "padding: 0px; margin-left: 4px; margin-top: 1px;" )
        if my.icon_path:
            img = HtmlElement.img()
            img.set_attr("src", my.icon_path)
            img.set_attr("title", my.title)
            img.add_styles("padding: 0px; padding-bottom: 1px; margin: 0px; text-decoration: none;")
            title_div.add(img)
            title_div.add_looks("menu")
        else:
            title_div.add(my.title)
            title_div.add_looks("menu fnt_text")

        td.add( title_div )

        td = table.add_cell()
        # -- Example of setting only some of the borders with dotted style ...
        # td.add_looks( "menu_btn_icon clear_borders border_bottom border_right dotted" )
        td.add_looks( "menu_btn_icon border curs_default" )
        td.add_styles( "padding: 0px; text-align: center; overflow: hidden; " \
                       "width: 15px; min-width: 15px;" \
                       "height: 12px; max-height: 12px;" )

        arrow_img = HtmlElement.img("/context/icons/silk/_spt_bullet_arrow_down_dark_8x8.png")
        arrow_img.add_styles( "border: 0px; margin-left: 1px; margin-top: 0px;" )
        td.add( arrow_img )

        dd_activator.add(table)

        dd_activator.add( my.kwargs.get("smart_menu_set") )
        dd_activator.add_class("SPT_SMENU_ACTIVATOR")
        dd_activator.add_behavior( { 'type': 'click_up', 'activator_type' : 'smart_menu',
                                     'cbjs_action': 'spt.smenu.show_on_dropdown_click_cbk( evt, bvr )' } )

        return dd_activator
예제 #4
0
    def get_display(my):

        search_key = my.kwargs.get('parent_key')

        div = DivWdg()

        if not search_key:
            div.add("Search Key for SObjectHeaderHdg is empty")
            return div

        sobject = Search.get_by_search_key( search_key )
        if not sobject:
            div.add("SObject with Search Key [%s] does not exist" % search_key)
            return div


        search_type_obj = sobject.get_search_type_obj()
        title = search_type_obj.get_title()
        title_wdg = DivWdg()
        title_wdg.add_style("font-size: 1.8em")

        name = sobject.get_display_value()
        title_wdg.add("%s: %s" % (title, name ))

        div.add(title_wdg)
        div.add(HtmlElement.hr())

        return div
예제 #5
0
파일: web_tools.py 프로젝트: mincau/TACTIC
 def generate_div(self):
     ''' this is meant to be called to get the container div for the 
         ajax widget '''
     div = DivWdg()
     div.set_id(self.display_id)
     div.add_style("display: block")
     return div
예제 #6
0
    def get_menu_item(my, element_name, display_handler):

        content = DivWdg()
        content.add_attr("spt_element_name", element_name)
        content.add_class("hand")

        # add the drag/drop behavior
        behavior = {
            "type": "drag",
            "mouse_btn": "LMB",
            "modkeys": "",
            "src_el": "@",
            "cbfn_setup": "spt.side_bar.pp_setup",
            "cbfn_motion": "spt.side_bar.pp_motion",
            "cbfn_action": "spt.side_bar.pp_action",
        }
        content.add_behavior(behavior)

        content.set_id("manage_%s" % element_name)
        content.add_style("position: relative")
        content.add_style("margin: 3px")
        content.add_style("left: 0")
        content.add_style("top: 0")
        content.add_style("z-index: 100")
        if display_handler == "SeparatorWdg":
            content.add(HtmlElement.hr())
        else:
            content.add(element_name)

        return content
예제 #7
0
    def get_section_wdg(my, view, editable=True, default=False):

        title = ""
        if editable:
            edit_mode = "edit"
        else:
            edit_mode = "read"
        kwargs = {
            "title": title,
            "config_search_type": my.search_type,
            "view": view,
            "width": "300",
            "mode": edit_mode,
            "default": str(default),
        }
        if view in ["definition", "custom_definition"]:
            kwargs["recurse"] = "false"

        from view_section_wdg import ViewSectionWdg

        section_wdg = ViewSectionWdg(**kwargs)
        class_path = Common.get_full_class_name(section_wdg)

        section_div = DivWdg(css="spt_panel")
        section_div.add_style("display: block")
        section_div.set_attr("spt_class_name", class_path)
        for name, value in kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        section_div.add(section_wdg)
        return section_div
예제 #8
0
    def get_search_wdg(self):
        filter_div = DivWdg()
        filter_div.add_style("width: 100px")

        buttons_list = [
            {'label': 'Run Search', 'tip': 'Run search with this criteria' },
        ]

        txt_btn_set = TextBtnSetWdg( position='', buttons=buttons_list, spacing=6, size='large', side_padding=4 )
        run_search_bvr = {
            'type':         'click_up',
            'cbjs_action':  '''
                spt.app_busy.show('Search ...', 'Searching Active Directory for matching users.');
                setTimeout( function() {
                var top = bvr.src_el.getParent('.ad_search_wdg_top');
                var values = spt.api.Utility.get_input_values(top);
                spt.panel.refresh(top, values);
                spt.app_busy.hide();
                }, 100);
            '''
        }
        txt_btn_set.get_btn_by_label('Run Search').add_behavior( run_search_bvr )
        #filter_div.add( txt_btn_set )

        div = DivWdg()
        div.add_behavior(run_search_bvr)
        button = ProdIconButtonWdg("Run Search")
        button.add_behavior(run_search_bvr)

        div.add(button)
        filter_div.add(div)
        return filter_div
예제 #9
0
    def get_category_wdg(self, paths, title=None, tags={}):
        div = DivWdg()

        if not paths:
            paths = []

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

        if not title:
            title = "Paths"

        count = len(paths)
        div.add("%s (%s)<hr/>" % (title, count) )
        if not paths:
            div.add("-- None --<br/>")

        paths_div = DivWdg()
        div.add(paths_div)
        paths_div.add_style("max-height: 500px")
        paths_div.add_style("overflow-y: auto")
        paths_div.add_style("overflow-x: auto")

        for path in paths:
            path_div = DivWdg()
            paths_div.add(path_div)
            rel_path = path.replace("%s/" % base_dir, "")
            path_div.add(rel_path)

            if tags:
                path_tags = tags.get(path)
                path_div.add( "&nbsp;"*10)
                path_div.add(path_tags['sobject'])

        return div
예제 #10
0
    def get_section_wdg(self, view, editable=True, default=False):

        title = ""
        target_id = "sobject_relation"
        if editable:
            edit_mode = 'edit'
        else:
            edit_mode = 'read'
        kwargs = {
            'title': title,
            'config_search_type': self.search_type,
            'view': view,
            'target_id': target_id,
            'width': '300',
            'prefix': 'manage_side_bar',
            'mode': edit_mode,
            'default': str(default)
        }
        if view in ["definition", "custom_definition"]:
            kwargs['recurse'] = "false"

        section_wdg = ViewSectionWdg(**kwargs)
        class_path = Common.get_full_class_name(section_wdg)

        section_div = DivWdg()
        section_div.add_style("display: block")
        section_div.set_attr('spt_class_name', class_path)
        for name, value in kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        section_div.add(section_wdg)
        return section_div
예제 #11
0
    def get_tables_wdg(my):
        
        div = DivWdg()
        div.set_name("Tables")

        div.add("In order to fully register a database, you must bind it to a TACTIC project")
        div.add("<br/>")



        project_code = "mongodb"
        database = "test_database"

        db_resource = DbResource(
                server='localhost',
                vendor='MongoDb',
                database=database
        )


        try:
            connect = DbContainer.get(db_resource)
        except Exception, e:
            div.add("Could not connect")
            div.add_style("padding: 30px")
            div.add("<br/>"*2)
            div.add(str(e))
            return div
예제 #12
0
class ProgressWdg(BaseRefreshWdg):
    '''A simple widget which displays the progress and an upload'''

    def init(self):
        self.progress_div = DivWdg()
        self.progress_id = self.progress_div.set_unique_id()


    def get_progress_id(self):
        return self.progress_id


    def get_display(self):
        top = self.top
        top.add_class("spt_progress_top")
        top.add_style("height: 10px")
        top.add_style("width: 200px")
        top.add_style("overflow: hidden")
        top.add_border()

        top.add(self.progress_div)
        self.progress_div.add_style("width: 0%")
        self.progress_div.add_gradient("background", "background2", 20)
        self.progress_div.add_style("height: 100%")
        self.progress_div.add("&nbsp;")
        self.progress_div.add('<img height="10px" src="/context/icons/common/indicator_snake.gif" border="0"/>')

        return top
예제 #13
0
    def get_header_wdg(my):
        outer = DivWdg()

        div = DivWdg()
        outer.add(div)
        div.add_color("background", "background3")
        div.add_style("padding: 5px")
        div.add_border()

        table = Table()
        table.add_style("margin-left: auto")
        table.add_style("margin-right: auto")
        table.add_color("color", "color")
        table.add_style("font-size: 1.5em")
        table.add_style("font-weight: bold")

        table.add_row()

        # add the month navigators
        date_str = "%s, %s" % (my.MONTHS[my.month - 1], my.year)
        month_wdg = DivWdg()
        month_wdg.add_style("width: 150px")
        month_wdg.add(date_str)

        prev_month_wdg = my.get_prev_month_wdg()
        next_month_wdg = my.get_next_month_wdg()

        table.add_cell(prev_month_wdg)
        td = table.add_cell(month_wdg)
        td.add_style("text-align: center")
        table.add_cell(next_month_wdg)

        div.add(table)

        return outer
예제 #14
0
    def get_bottom_wdg(my):
        # check if the user has enabled it 
        info = my.check_bottom_wdg()
        if info.get('check') == False:
            return None

        
        title = info.get('title')
        result = info.get('result')

        div = DivWdg()
        div.add(title)
        div.add(str(result))
        div.add_style("text-align: right")
        div.add_class( "spt_%s_expr_bottom" % (my.get_name()) )


        # DEPRECATED until we have a better solution
        # add a listener
        '''
        for sobject in sobjects:
            if sobject.is_insert():
                continue

            # DISABLE this for simple
            #if my.enable_eval_listener:
            #    my.add_js_expression(div, sobject, expression)
        '''

        return div
예제 #15
0
    def get_section_wdg(self, view, title='', editable=True, default=False):
        '''editable really means draggable'''
        if not title:
            title = view 
        target_id = "sobject_relation"
        if editable:
            edit_mode = 'edit'
        else:
            edit_mode = 'read'

        kwargs = {
            'title': title,
            'view': view,
            'target_id': target_id,
            'width': '300',
            'prefix': 'manage_side_bar',
            'mode': edit_mode,
            'default': str(default),
            'config_search_type': self.search_type
        }
        if view == "database_definition":
            kwargs['recurse'] = "false"

        id = "ManageSearchTypeMenuWdg_" + view
        section_div = DivWdg(id=id, css='spt_panel')
        section_div.add_style("display: block")
        section_div.set_attr('spt_class_name', "tactic.ui.panel.ManageSearchTypeMenuWdg")
        for name, value in kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        section_wdg = ManageSearchTypeMenuWdg(**kwargs)
        section_div.add(section_wdg)
        return section_div
예제 #16
0
    def add_header(my, table, sobj_title):
        tr, th = table.add_row_cell()

        title_str = my.kwargs.get("title")

        if not title_str:
            if my.mode == 'insert':
                action = 'Add New Item'
            elif my.mode == 'edit':
                action = 'Save Changes'
            else:
                action = my.mode
            
            title_str =  action.capitalize() + " to " + sobj_title
            if my.mode == 'edit':
                title_str = '%s (%s)' %(title_str, my.sobjects[0].get_code())
            

        title_div = DivWdg()
        title_div.add_style("font-weight: bold")
        title_div.set_attr('title', my.view)
        th.add(title_div)
        title_div.add(title_str)
        #th.add_color("background", "background3")
        if my.color_mode == "default":
            th.add_color("border-color", "table_border", default="border")
            th.add_style("border-width: 1px")
            th.add_style("border-style: solid")
        th.set_attr("colspan", "2")
        th.add_style("height: 30px")
        th.add_style("padding: 3px 10px")

        th.add("<hr/>")
예제 #17
0
    def get_display(my):
        
        widget = DivWdg()

        if my.kwargs.get("is_refresh") == 'true':
            from tactic.ui.widget import TitleWdg
            title = TitleWdg(name_of_title='Import CSV',help_alias='importing-csv-data')
            widget.add(title)

        widget.add_style('padding: 10px')
        widget.add_style('font-size: 12px')
        #widget.add_border()
        widget.add_color('color','color') 
        widget.add_color('background','background') 
        widget.add_class("spt_import_top")
       

        inner = DivWdg()
        widget.add(inner)
        inner.add( my.get_first_row_wdg() )
        inner.add(ProgressWdg())

        if my.is_refresh:
            return inner
        else:
            return widget
예제 #18
0
    def get_display(my):

        sobject = my.get_current_sobject()

        name = my.get_name()

        top = DivWdg()

        if sobject.is_insert():
            top.add_style("opacity: 0.3")
        else:
            # this gives the swap it's behaviors, so will be disabled
            # on insert
            top.add_class("spt_hidden_row_%s" % name)


        label = my.get_option("label")
        if label:
            label = Search.eval(label, sobject)
        else:
            label = None
        icon = my.get_option("icon")

        swap = SwapDisplayWdg(title=label, icon=icon, show_border=True)
        swap.set_behavior_top(my.layout)

        top.add(swap)

        return top
예제 #19
0
    def get_group_bottom_wdg(my, sobjects):

        expression = my.get_option("group_bottom")
        if not expression:
            return None

        # parse the expression
        my.vars = my.get_vars()

        parser = ExpressionParser()
        result = parser.eval(expression, sobjects=sobjects, vars=my.vars)

        format_str = my.kwargs.get("display_format")
        if format_str:
            from tactic.ui.widget import FormatValueWdg

            format_wdg = FormatValueWdg(format=format_str, value=result)
            result = format_wdg
        else:
            result = str(result)

        div = DivWdg()
        div.add(result)
        div.add_style("text-align: right")
        # div.add_class( "spt_%s_expr_bottom" % (my.get_name()) )

        # add a listener
        # for sobject in sobjects:
        #    if sobject.is_insert():
        #        continue
        #
        #    if my.enable_eval_listener:
        #        my.add_js_expression(div, sobject, expression)

        return div
예제 #20
0
    def get_section_wdg(my, view, title="", editable=True, default=False):
        """editable really means draggable"""
        if not title:
            title = view
        target_id = "sobject_relation"
        if editable:
            edit_mode = "edit"
        else:
            edit_mode = "read"

        kwargs = {
            "title": title,
            "view": view,
            "target_id": target_id,
            "width": "300",
            "prefix": "manage_side_bar",
            "mode": edit_mode,
            "default": str(default),
            "config_search_type": my.search_type,
        }
        if view == "database_definition":
            kwargs["recurse"] = "false"

        id = "ManageSearchTypeMenuWdg_" + view
        section_div = DivWdg(id=id, css="spt_panel")
        section_div.add_style("display: block")
        section_div.set_attr("spt_class_name", "tactic.ui.panel.ManageSearchTypeMenuWdg")
        for name, value in kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        section_wdg = ManageSearchTypeMenuWdg(**kwargs)
        section_div.add(section_wdg)
        return section_div
예제 #21
0
    def get_item_div(my, sobjects, related_type):
        item_div = DivWdg()
        item_div.add_style("margin: 15px 10px")

        sobject = sobjects[0]

        checkbox = CheckboxWdg('related_types')
        item_div.add(checkbox)
        checkbox.set_attr("value", related_type)
        if related_type in ["sthpw/snapshot", "sthpw/file"]:
            checkbox.set_checked()

        item_div.add(" ")
        item_div.add(related_type)
        item_div.add(": ")

        if related_type.startswith("@SOBJECT"):
            related_sobjects = Search.eval(related_type, [sobject], list=True)
        else:
            try:
                related_sobjects = []
                for sobject in sobjects:
                    sobjs = sobject.get_related_sobjects(related_type)
                    related_sobjects.extend(sobjs)

            except Exception, e:
                print "WARNING: ", e
                related_sobjects = []
예제 #22
0
    def get_save_wdg(my):

        # add the popup
        popup = PopupWdg(id="save_search_wdg")
        popup.add("Save Search", "title")

        div = DivWdg()
        div.add("Save current search as: ")

        text = TextWdg("save_search_text")
        text.set_id("save_search_text")
        div.add(text)

        save_button = ButtonWdg("Save Search")
        behavior = {"type": "click", "mouse_btn": "LMB", "cbjs_action": "spt.dg_table.save_search_cbk(evt, bvr);"}
        save_button.add_behavior(behavior)

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

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

        popup.add(div, "content")

        return popup
예제 #23
0
    def get_section_wdg(my, sobject):

        parent_key = SearchKey.get_by_sobject(sobject)

        section_id = "wow"
        title = ""
        view = "children"
        target_id = "sobject_relation"

        kwargs = {
            'section_id': section_id,
            'title': title,
            'view': view,
            'target_id': target_id,
            'width': '125',
            'parent_key': parent_key
        }
        section_div = DivWdg()
        section_div.add_style("display: block")
        section_div.set_id(section_id)
        section_div.set_attr('spt_class_name', "tactic.ui.panel.ChildrenBookmarkMenuWdg")
        for name, value in kwargs.items():
            if name == "config":
                continue
            section_div.set_attr("spt_%s" % name, value)

        section_wdg = SObjectChildrenMenuWdg(**kwargs)
        section_div.add(section_wdg)
        return section_div
예제 #24
0
    def get_schedule_wdg(my):

        div = DivWdg()
        div.add_style("width: 500px")
        div.add_style("height: 500px")
        div.add("Click on a user to display their schedule")
        return div
예제 #25
0
    def get_group_bottom_wdg(self, sobjects):

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

        # parse the expression
        self.vars = self.get_vars()
 
        expression, title = self.get_expression(summary)
        try:
            result = Search.eval(expression, sobjects=sobjects, vars=self.vars)
        except Exception as e:
            print("WARNING: ", e.message)
            result = "Calculation Error"
            title = ''
        """
        widget_type = self.get_option("type")
        
        if widget_type in ['date','time']:
            name = self.get_name()
            if not SObject.is_day_column(name):
                result = SPTDate.convert_to_local(result)
                result= str(result)
        """
        format = self.get_option('format')
        formatted_result = self.get_format_value( result, format )

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

        return div, result
예제 #26
0
    def get_display(self):

        top = self.top

        height = self.get_option('height')
        if not height:
            height = 300

        inner = DivWdg()
        top.add(inner)
        inner.add_style("overflow-y: auto")
        inner.add_style("overflow-x: hidden")
        inner.add_style("width: 100%")
        inner.add_style("max-height: %s" % height)
        inner.add_style("margin-right: -3px")
        
        sobject = self.get_current_sobject()

        column = self.get_option("column")
        if not column:
            column = self.get_name()

        if sobject:
            html = sobject.get_json_value( column ) or ""
        else:
            html = ""


        inner.add(html)

        return top
예제 #27
0
파일: share_wdg.py 프로젝트: blezek/TACTIC
    def get_tools_wdg(my):

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

        div.add("This tool will export out a version of the project")

        button = ActionButtonWdg(title="Export")
        div.add(button)
        button.add_behavior( {
            'type': 'click_up',
            'server': my.server_code,
            'cbjs_action': '''
            var class_name = 'tactic.ui.sync.SyncCreateTemplateCmd';
            var kwargs = {
                server: bvr.server
            }
            spt.app_busy.show("Exporting project ...");
            var server = TacticServerStub.get();
            server.execute_cmd(class_name, kwargs);
            spt.app_busy.hide();

            spt.panel.refresh(bvr.src_el);

            '''
        } )



        return div
예제 #28
0
파일: search_wdg.py 프로젝트: mincau/TACTIC
    def get_save_wdg(self):

        div = DivWdg()
        div.add("Save current search as: ")

        text = TextWdg("save_search_text")
        text.set_id("save_search_text")
        div.add(text)



        save_button = ButtonWdg("Save Search")
        behavior = {
            'cbjs_action':  'spt.table.save_search();'
        }
        save_button.add_behavior( behavior )


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

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

        return div
예제 #29
0
class IframePlainWdg(IframeWdg):
    ''' a plain iframe to be opened within an iframe '''
    
    def init(self):
        self.img_span_name = self.generate_unique_id('loadingplain')
        self.name = "iframeplain_%s" % (self.generate_unique_id())
        self.iframe = HtmlElement.iframe()
        self.iframe.set_id(self.name)
        self.iframe.set_attr('name',self.name)
        self.div = DivWdg(css='iframe_plain')
        self.div.add_style('display','none')
        self.div.set_id("iframeplain_cont_%s" % (self.generate_unique_id()))
        self.div.add(self.iframe)
        self.add(self.div)
        self.add(self._get_loading_span())
        
    def get_on_script(self, src, dynamic_element=[]):
        '''A script to display the iframe. this is not called on init'''
        scripts = []
        
        cont_on_script = "toggle_display('%s')" %self.div.get_id()
        iframe_script = "IframeLoader_display('%s','%s','%s','%s')" % \
            (self.img_span_name, self.name, src, '||'.join(dynamic_element))
        
        scripts.append(iframe_script)
        scripts.append(cont_on_script)
        
        resize_iframe = IframeWdg.get_resize_script(self.name, self.width)
     
        scripts.append(resize_iframe)
        return ";".join(scripts)

    def get_off_script(self):
        return "toggle_display('%s')" %self.div.get_id()
예제 #30
0
    def get_license_info_wdg(self):
        div = DivWdg()

        license = Environment.get_security().get_license()
        if self.first_error:
            return div
        #if not license.is_licensed():
        #    return div

        msg = DivWdg()
        div.add(msg)
        msg.add("The following describes the details of the installed license:<br/><br/>")


        info_wdg = DivWdg()
        div.add(info_wdg)
        info_wdg.add_style("margin: 10px 30px")
        info_wdg.add_style("font-size: 12px")

        version = license.get_data("tactic_version")
        if version:
            info_wdg.add("TACTIC Version: ")
            if version == "ALL":
                version = "ALL (Open Source)"
            info_wdg.add(version)
            info_wdg.add(HtmlElement.br(2))


        company = license.get_data("company")
        info_wdg.add("Licensed To: ")
        if company.find("Southpaw EPL") != -1:
            company = SpanWdg("<a name='license'>Eclipse Public License v1.0</a> &nbsp;")
            icon = IconWdg("EPL v1.0", IconWdg.ZOOM)
            company.add(icon)
            company.add_class("hand")
            company.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                    spt.help.load_alias("license")
                '''
            } )
        info_wdg.add(company)
        info_wdg.add(HtmlElement.br(2))

        info_wdg.add("Max Users: ")
        info_wdg.add(license.get_data("max_users") )
        info_wdg.add(HtmlElement.br(2))

        info_wdg.add("Current Users: ")
        info_wdg.add(license.get_current_users() )
        info_wdg.add(HtmlElement.br(2))

        info_wdg.add("Expiry Date: ")
        expiry_date = license.get_data("expiry_date")
        if not expiry_date:
            expiry_date = "Permanent"
        info_wdg.add(expiry_date)
        info_wdg.add(HtmlElement.br(2))

        return div
예제 #31
0
    def get_display(my):
        web = WebContainer.get_web()

        database = Project.get_project_code()

        if my.is_aux_title == 'true':
            return HtmlElement.b("Add Property for %s [%s]" \
                %(SearchType.get(my.search_type).get_title(), my.search_type))

        if not my.view:
            my.view = get_template_view()

        # show current custom
        div = DivWdg(id="add_property_wdg")
        div.add_class("spt_panel")

        div.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''

spt.custom_property_adder = {}


// Called when a type selection is made when creating a new property type
spt.custom_property_adder.property_type_select_cbk = function(el) {
    var panel = el.getParent(".spt_panel");
    var kwargs = { top_el: panel };

    spt.simple_display_hide('.foreign_key_options', kwargs);
    spt.simple_display_hide('.list_options', kwargs);
    spt.simple_display_hide('.button_options', kwargs);


    if (el.value == "foreign_key") {
        spt.simple_display_show('.foreign_key_options', kwargs);
    }
    else if (el.value == "list") {
        spt.simple_display_show('.list_options', kwargs);
    }
    else if (el.value == "button") {
        spt.simple_display_show('.button_options', kwargs);
    }
}




// called when the mode of "add property" is switched"
spt.custom_property_adder.switch_property_mode = function(evt, bvr) {
    var src_el = bvr.src_el;
    var value = src_el.value;

    var panel = src_el.getParent(".spt_panel")

    var element = panel.getElement(".spt_custom_simple")
    spt.simple_display_hide(element);
    //var element = panel.getElement(".spt_custom_widget")
    //spt.simple_display_hide(element);
    var element = panel.getElement(".spt_custom_xml")
    spt.simple_display_hide(element);

    var element = panel.getElement(".spt_custom_" + value)
    spt.simple_display_show(element);
}


spt.custom_property_adder.add_property_cbk = function(evt, bvr) {

    var search_type = bvr['search_type'];
    var view = bvr['view'];
    var exit = bvr['exit'];

    var panel = bvr.src_el.getParent(".spt_panel");
    var popup = bvr.src_el.getParent(".spt_popup");

    var mode = panel.getElement(".spt_custom_mode").value;
    var input_top = panel.getElement(".spt_custom_"+mode);
    var values = spt.api.Utility.get_input_values(input_top);

    // add the mode value
    values['custom_mode'] = mode;

    var class_name = "tactic.ui.app.CustomPropertyAdderCbk";
    var options = {
        'search_type': search_type,
        'view': view
    };

    var server = TacticServerStub.get();
    try {
        server.start({title:"Add new property"});
        var response = server.execute_cmd(class_name, options, values);
        if (exit == "true") {

            $('add_property_wdg').setStyle("display", "none");
            // this may or may not exist
            if (popup)
                spt.popup.close(popup);
        }
        else {
            // erase all of the inputs
            for (var i = 0; i < input_list.length; i++) {
                var filter = input_list[i];
                filter.value = "";
            }
        }
        var st_view = "definition";
        spt.panel.refresh("ManageSearchTypeMenuWdg_" + st_view);

        var st_view = 'db_column';
        spt.panel.refresh("ManageSearchTypeMenuWdg_" + st_view);
    }
    catch (e) {
        server.abort();
        alert(spt.exception.handler(e));
    }

}


            '''
        })

        div.add_style("padding: 10px")
        div.add_color("color", "color")
        div.add_color("background", "background")
        div.add_border()

        div.add(my.get_new_custom_widget(my.search_type, my.view))

        return div
예제 #32
0
    def get_display(self):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        top.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
            spt.named_events.fire_event("side_bar|hide", {} );
            '''
        })

        project = Project.get()

        title = TitleWdg(title='Client Home')
        top.add(title)

        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        security = Environment.get_security()
        view_side_bar = security.check_access("builtin",
                                              "view_side_bar",
                                              "allow",
                                              default='allow')
        if view_side_bar:
            button_div = DivWdg()
            shelf.add(button_div)
            button_div.add_style("float: left")
            button_div.add_style("margin-top: -3px")

            button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
            button_div.add(button)
            shelf.add("Toggle Side Bar")
            button.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })

            shelf.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            })
            shelf.add_class("hand")
        else:
            shelf.add("&nbsp;")

        search_wdg = DivWdg()
        search_wdg.add_class("spt_main_top")
        top.add(search_wdg)
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 10px auto")
        search_wdg.add_style("width: 430px")
        search_wdg.add("Search: ")
        search_wdg.add("&nbsp;" * 3)

        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'table',
                    'keywords': keywords,
                    'simple_search_view': 'simple_search',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''

        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk)
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")
        search_wdg.add(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")

        button = ActionButtonWdg(title="Search")
        #search_wdg.add(button)
        button.add_style("float: right")
        #button.add_style("margin-top: -28px")

        icon_div = DivWdg()
        search_wdg.add(icon_div)
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 3px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        icon_div.add_style("float: right")
        icon_div.add_style("margin-top: -5px")
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior({
            'type':
            'mouseover',
            'color':
            over_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        })
        icon_div.add_behavior({
            'type':
            'mouseout',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click_up',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'table',
                'keywords': keywords,
                'simple_search_view': 'simple_search',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        })

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")

        # create a bunch of panels
        table = Table()
        table.add_color("color", "color")
        table.add_style("margin-bottom: 20px")
        table.center()
        top.add(table)
        table.add_row()

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "My Approvals"
        description = '''View all pending items for approval<br/><br/>
        '''
        #image = "<img src='/context/images/getting_started_pipeline.png'/>"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
            search_type: 'sthpw/sobject_list',
            view: 'client_approval',
            show_shelf: false,
            show_select: false,
            element_names: ['preview', 'name', 'description', 'task_pipeline_vertical','notes'],
            is_editable: false,
            //expression: "@SOBJECT(sthpw/task['project_code','fickle3'].fickle3/cars.sthpw/sobject_list)"
        };
        spt.tab.add_new("approvals", "Approvals", class_name, kwargs);
        '''
        }
        config_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(config_wdg)

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "My Dashboard"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.'''

        # read the config file
        from pyasm.widget import WidgetConfig
        tmp_path = __file__
        dir_name = os.path.dirname(tmp_path)
        file_path = "%s/../config/dashboard-conf.xml" % (dir_name)
        config = WidgetConfig.get(file_path=file_path, view="definition")

        #element_name = "self_dashboard"
        element_name = "self_dashboard"
        attrs = config.get_element_attributes(element_name)
        dashboard_data = {}
        kwargs = config.get_display_options(element_name)
        class_name = kwargs.get('class_name')

        dashboard_data['class_name'] = class_name
        dashboard_data['kwargs'] = kwargs
        dashboard_data['title'] = attrs.get("title")
        dashboard_data['description'] = attrs.get("description")
        dashboard_data['image'] = attrs.get("image")

        behavior = {
            'type':
            'click_up',
            'dashboard':
            dashboard_data,
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("self_dashboard", "My Dashboard", bvr.dashboard.class_name, bvr.dashboard.kwargs);
        '''
        }
        pipeline_wdg = self.get_section_wdg(title, description, image,
                                            behavior)
        td.add(pipeline_wdg)

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "My Reports"
        image = "<img src='/context/icons/64x64/report_64.png'/>"
        description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("reports", "Reports", class_name, kwargs);
        //spt.panel.load_popup("Reports", class_name, kwargs);
        '''
        }

        side_bar_wdg = self.get_section_wdg(title, description, image,
                                            behavior)
        td.add(side_bar_wdg)
        """
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
	title = "Documentation"

        description = '''TACTIC Documentation.
        <br/><br/>
        * Project Setup Documentation<br/>
        <br/>
        * End User Documentation<br/>
        <br/>
        * Developer Documentation<br/>
        <br/>
        * System Administrator Documentation<br/>
        <br/>
        '''
        image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.load_alias("main")
        '''
        }
        doc_wdg = self.get_section_wdg(title, description, image, behavior)
        td.add(doc_wdg)
        """

        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>" * 2)

        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)

        return top
예제 #33
0
    def get_display(my):
        top = my.top
        top.add_class("spt_script_editor_top")
        """
        top.add_class("SPT_CHANGE")
        top.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            register_change = function(bvr) {
                var change_top = bvr.src_el.getParent(".SPT_CHANGE"); 
                change_top.addClass("SPT_HAS_CHANGES");
                change_top.update_change(change_top, bvr);
            }

            has_changes = function(bvr) {
                var change_top = bvr.src_el.getParent(".SPT_CHANGE"); 
                return change_top.hasClass("SPT_HAS_CHANGES");
            }

            bvr.src_el.update_change = function(top, bvr) {
                change_el = top.getElement(".spt_change_element");
                change_el.setStyle("display", "");
            }
            '''
        } )
        """

        change_div = DivWdg()
        top.add(change_div)
        #change_div.add("CHANGES!!!")
        change_div.add_style("display: none")
        change_div.add_class("spt_change_element")

        top.add_class("spt_panel")
        top.add_class("spt_js_editor")
        top.add_attr("spt_class_name", Common.get_full_class_name(my))
        top.add_color("background", "background")
        top.add_style("padding", "10px")

        div = DivWdg()
        top.add(div)

        # if script_path
        script_path = my.kwargs.get("script_path")
        search_key = my.kwargs.get("search_key")
        if script_path:
            search = Search("config/custom_script")
            dirname = os.path.dirname(script_path)
            basename = os.path.basename(script_path)

            search.add_filter("folder", dirname)
            search.add_filter("title", basename)
            script_sobj = search.get_sobject()
        elif search_key:
            script_sobj = Search.get_by_search_key(search_key)
        else:
            script_sobj = None

        if script_sobj:
            script_code = script_sobj.get_value("code")
            script_folder = script_sobj.get_value("folder")
            script_name = script_sobj.get_value("title")
            script_value = script_sobj.get_value("script")
            script_language = script_sobj.get_value("language")
        else:
            script_code = ''
            script_folder = ''
            script_name = ''
            script_value = ''

        editor = AceEditorWdg(custom_script=script_sobj)
        my.editor_id = editor.get_editor_id()

        if not Container.get_dict("JSLibraries", "spt_script_editor"):
            div.add_behavior({
                'type': 'load',
                'cbjs_action': my.get_onload_js()
            })

        # create the insert button
        help_button_wdg = DivWdg()
        div.add(help_button_wdg)
        help_button_wdg.add_style("float: right")
        help_button = ActionButtonWdg(title="?",
                                      tip="Script Editor Help",
                                      size='s')
        help_button_wdg.add(help_button)

        help_button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''spt.help.load_alias("tactic-script-editor")'''
        })

        # create the insert button
        add_button_wdg = DivWdg()
        add_button_wdg.add_style("float: right")
        add_button = ActionButtonWdg(title="Manage")
        add_button.add_behavior({
            'type': 'click_up',
            'cbfn_action': 'spt.popup.get_widget',
            'options': {
                'class_name': 'tactic.ui.panel.ViewPanelWdg',
                'title': 'Manage: [%s]' % my.search_type
            },
            'args': {
                'search_type': my.search_type,
                'view': 'table',
                'show_shelf': False,
                'element_names':
                ['folder', 'title', 'description', 'language'],
            },
        })

        add_button_wdg.add(add_button)
        div.add(add_button_wdg)

        button_div = editor.get_buttons_wdg()
        div.add(button_div)
        """
        button_div = DivWdg()
        #div.add(button_div)

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

        button = ActionButtonWdg(title="Run")
        button.add_style("float: left")
        button.add_style("margin: 0 10 3")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            //var editor = $('shelf_script');
            var value = editAreaLoader.getValue('shelf_script')
            eval( value )
            '''
        } )
        button_div.add(button)


        button = ActionButtonWdg(title="Save")
        button.add_style("float: left")
        button.add_style("margin: 0 10 3")
        #button = ProdIconButtonWdg("Save")
        #button.add_style("margin: 5 10")
        behavior = {
            'type': 'click_up',
            'cbfn_action': 'spt.script_editor.save_script_cbk'
        }
        button.add_behavior(behavior)
        button_div.add(button)


        button = ActionButtonWdg(title="Clear")
        button.add_style("float: left")
        button.add_style("margin: 0 10 3")
        #button = ProdIconButtonWdg("Clear")
        #button.add_style("margin: 5 10")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.api.Utility.clear_inputs( bvr.src_el.getParent('.spt_js_editor') );
            editAreaLoader.setValue('shelf_script', '');

            '''
        } )

        button_div.add(button)
        """

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

        save_wdg = DivWdg()
        div.add(save_wdg)
        save_wdg.add_style("padding: 2px 5px 6px 5px")
        #save_wdg.add_color("background", "background", -5)

        # script code
        save_span = Table()
        save_wdg.add(save_span)
        save_span.add_row()

        code_span = SpanWdg()
        code_span.add("<b>Code: &nbsp;</b>")
        td = save_span.add_cell(code_span)
        td.add_style("display: none")
        code_text = TextInputWdg(name="shelf_code")
        code_text.add_style("display: inline")
        code_text.add_style("width: 100px")
        code_text.set_value(script_code)
        code_text.add_attr("readonly", "true")
        code_text.set_id("shelf_code")
        code_text.add_class("spt_code")
        td = save_span.add_cell(code_text)
        td.add_style("padding-top: 10px")

        td.add_style("display: none")

        save_span.add_cell("&nbsp;&nbsp;")

        # script name (path??)
        td = save_span.add_cell("<b>Script Path: &nbsp;</b>")
        td.add_style("padding-top: 10px")
        save_text = TextInputWdg(name="shelf_folder")
        save_text.add_style("width: 250px")
        save_text.set_id("shelf_folder")
        save_text.add_class("spt_folder")
        save_text.set_value(script_folder)
        td = save_span.add_cell(save_text)
        td.add_style("padding-top: 10px")

        td = save_span.add_cell("&nbsp; / &nbsp;")
        td.add_style("padding-top: 10px")
        td.add_style("font-size: 1.5em")
        save_text = TextInputWdg(name="shelf_title")
        save_text.add_style("width: 350px")
        save_text.add_attr("size", "40")
        save_text.set_id("shelf_title")
        save_text.add_class("spt_title")
        save_text.set_value(script_name)
        td = save_span.add_cell(save_text)
        td.add_style("padding-top: 10px")

        from tactic.ui.container import ResizableTableWdg
        table = ResizableTableWdg()
        table.add_row()

        td = table.add_cell(resize=False)
        td.add_style("vertical-align: top")

        td.add(editor)

        text = TextAreaWdg("shelf_script")

        td = table.add_cell()
        td.add_style('vertical-align: top')
        td.add(my.get_script_wdg())

        table.add_row(resize=False)

        div.add(table)

        if my.kwargs.get("is_refresh"):
            return div
        else:
            return top
예제 #34
0
    def get_display(self):

        top = DivWdg()
        name = self.get_name()
        top.add_class("spt_note_input_top")

        context = self.get_option("context")
        if not context:
            context = name

        sobject = self.get_option("sobject")
        if not sobject:
            search_key = self.get_option("search_key")
            sobject = Search.get_by_search_key(search_key)
        else:
            search_key = sobject.get_search_key()

        if search_key or (sobject and not sobject.is_insert()):

            search = Search("sthpw/note")
            #search.add_relationship_filters(self.filtered_parents, type='hierarchy')
            search.add_parent_filter(sobject)
            search.add_filter("context", context)
            search.add_order_by("process")
            search.add_order_by("context")
            search.add_order_by("timestamp desc")
            search.add_filter("context", context)

            count = search.get_count()
            last_note = search.get_sobject()
        else:
            last_note = None
            count = 0

        #if not last_note:
        #    last_note = SearchType.create("sthpw/note")
        #    last_note.set_value("login", "")
        #    last_note.set_value("timestamp", "")
        #    last_note.set_value("note", "")

        if last_note:
            last_div = DivWdg()
            top.add(last_div)

            table = Table()
            table.add_style("width: 100%")
            table.add_attr("cellpadding", "0px")
            table.add_attr("cellspacing", "0px")
            last_div.add(table)
            table.add_row()
            td = table.add_cell()
            td.add_style("vertical-align: top")
            td.add_style("padding: 5px 15px 10px 5px")
            table.add_border()
            table.add_color("background", "background", -5)

            note_str = last_note.get_value("note")
            login = last_note.get_value("login")
            if not login:
                login = "******"
            date = last_note.get_datetime_value("timestamp")
            if date:
                date_str = "<i style='font-size: 0.8em'>%s</i>" % date.strftime(
                    "%Y-%m-%d")
            else:
                date_str = ""

            login = "******" % login
            td.add("%s - %s<br/>" % (date_str, login))

            note_str_div = DivWdg()
            note_str_div.add(note_str)
            note_str_div.add_style("padding: 10px 15px 10px 10px")

            #td = table.add_cell( note_str_div )
            td.add(note_str_div)
            #td.add_style("vertical-align: top")
            #td.add_style("padding: 10px 15px 10px 10px")
            """
            td.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_note_input_top");
                var text_el = top.getElement(".spt_add_entry");
                text_el.setStyle("display", "");

                '''
            } )
            """

            # log
            if count == 0:
                td = table.add_cell("")
            elif count == 1:
                td = table.add_cell(
                    "<i style='font-size: 0.8em'>More...><br/>(%s entry)</i>" %
                    count)
            else:
                td = table.add_cell(
                    "<i style='font-size: 0.8em'>More...><br/>(%s entries)</i>"
                    % count)
            td.add_style("vertical-align: top")
            td.add_style("padding: 3px")
            td.add_class("hand")

            td.add_behavior({
                'type':
                'click_up',
                'search_key':
                search_key,
                'context':
                context,
                'cbjs_action':
                '''

                var class_name = 'tactic.ui.input.note_input_wdg.NoteHistoryWdg';
                var kwargs = {
                    search_key: bvr.search_key,
                    context: bvr.context
                }
                spt.panel.load_popup("Notes Log", class_name, kwargs);
                
                '''
            })

        name = self.get_input_name()
        text = TextAreaWdg(name)
        top.add(text)
        text.add_style("width: 100%")
        text.add_class("spt_add_entry")
        """
        if search_key and not sobject.is_insert():
            from tactic.ui.widget import DiscussionWdg
            discussion_wdg = DiscussionWdg(search_key=search_key, context_hidden=False, show_note_expand=False, show_add=False)
            top.add(discussion_wdg)
        """

        return top
예제 #35
0
    def get_display(self):

        top = self.top
        top.add_class("spt_switcher_top")
        '''
        This supports supports two menu definitions:
        menu - specifies a view for SideBarWdg which will be ingected as menu 
        config_xml - specifies menu entries. For example:

        <display class="tactic.ui.widget.LayoutSwitcherWdg">
          <!-- config_xml -->
          <config>
            <!-- Menu item 1 -->
            <element name="self_tasks_default" title="My Tasks" target=spt_my_tasks_table_top">
              <display class="tactic.ui.panel.ViewPanelWdg">
                <search_type>sthpw/task</search_type>
                <show_shelf>false</show_shelf>
                <view>my_tasks_default</view>
              </display>
            </element>
            <!-- Menu item 2 -->
            <element ... >
              <display ... >
              </display>
            </element>
          </config>
        </display>

        target - specifies target div to load views when using "menu" kwarg
        use_href - updates address bar hash (this is TODO)
        '''

        menu = self.kwargs.get("menu")
        config_xml = self.kwargs.get("config_xml")
        target = self.kwargs.get("target")

        #default
        default_layout = self.kwargs.get("default_layout")

        # find the save state value, if state is to be saved
        save_state = self.kwargs.get("save_state")

        if save_state in [False, 'false']:
            save_state = None
            show_first = False
        else:
            show_first = True

        state_value = None
        if save_state:
            state_value = WidgetSettings.get_value_by_key(save_state)
        elif default_layout:
            state_value = default_layout

        title = self.kwargs.get("title")
        if not title and state_value:
            title = state_value
        if not title:
            title = "Switch Layout"

        mode = self.kwargs.get("mode")
        if mode == "button":
            color = self.kwargs.get("color") or "default"
            activator = DivWdg(
                "<button class='btn btn-%s dropdown-toggle' style='width: 160px'><span class='spt_title'>%s</span> <span class='caret'></span></button>"
                % (color, title))
        elif mode == "div":
            color = self.kwargs.get("color") or ""
            background = self.kwargs.get("background") or "transparent"
            activator = DivWdg(
                "<button class='btn dropdown-toggle' style='width: 160px; background: %s; color: %s; font-weight: bold'><span class='spt_title'>%s</span> <span class='caret'></span></button>"
                % (background, color, title))

        else:
            activator = IconButtonWdg(name="Layout Switcher",
                                      icon="BS_TH_LIST")

        top.add(activator)
        activator.add_class("spt_switcher_activator")
        activator.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var activator = bvr.src_el;
            var top = activator.getParent(".spt_switcher_top");
            var menu = top.getElement(".spt_switcher_menu");
            
            if (top.hasClass("spt_selected")) {
                top.removeClass("spt_selected");
                menu.setStyle("display", "none");    
            } else {
                top.addClass("spt_selected");
                menu.setStyle("display", "");
                var pos = activator.getPosition();
                var button_size = activator.getSize();
                var menu_size = menu.getSize();
                var offset = {
                    x: button_size.x - menu_size.x,
                    y: button_size.y
                }
                menu.position({position: 'upperleft', relativeTo: activator, offset: offset});

                spt.body.add_focus_element(menu);

                var pointer = menu.getElement(".spt_switcher_popup_pointer");
                pointer.setStyle("margin-left", menu_size.x - button_size.x);

            } 
            '''
        })

        outer_wdg = DivWdg()
        top.add(outer_wdg)

        # menu_wdg

        menu_wdg = DivWdg()
        outer_wdg.add(menu_wdg)
        menu_wdg.add_color("color", "color")
        menu_wdg.add_color("background", "background")
        menu_wdg.add_border()
        menu_wdg.add_class("spt_switcher_menu")
        menu_wdg.add_style("display: none")
        menu_wdg.add_style("margin-top", "20px")
        menu_wdg.add_style("position", "absolute")
        menu_wdg.add_style("z-index", "101")
        menu_wdg.add_behavior({
            'type':
            'mouseleave',
            'cbjs_action':
            '''
            var menu = bvr.src_el;
            var top = menu.getParent(".spt_switcher_top");
            top.removeClass("spt_selected");
            menu.setStyle("display", "none")
            '''
        })

        border_color = menu_wdg.get_color("border")

        # Pointer under activator
        pointer_wdg = DivWdg()
        menu_wdg.add(pointer_wdg)
        pointer_wdg.add('''
            <div class="spt_switcher_first_arrow_div"> </div>
            <div class="spt_switcher_second_arrow_div"> </div>
        ''')
        pointer_wdg.add_class("spt_switcher_popup_pointer")

        style = HtmlElement.style('''
            .spt_switcher_menu .spt_switcher_popup_pointer {
                z-index: 10;
                position: absolute;
                top: -15px;
                right: 15px;
            }

            .spt_switcher_menu .spt_switcher_first_arrow_div {
                border-color: rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) %s;
                top: -15px;
                z-index: 1;
                border-width: 0 15px 15px;
                height: 0;
                width: 0;
                border-style: dashed dashed solid;
                left: 15px;
            }

            .spt_switcher_menu .spt_switcher_second_arrow_div{
                border-color: rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) #fff;
                z-index: 1;
                border-width: 0 15px 15px;
                height: 0;
                width: 0;
                border-style: dashed dashed solid;
                margin-top: -14px;
                position: absolute;
                left: 0px;
                top: 15px;
            }
        ''' % border_color)
        pointer_wdg.add(style)

        if menu:
            from tactic.ui.panel import SimpleSideBarWdg
            simple_sidebar = SimpleSideBarWdg(view=menu,
                                              search_type="SidebarWdg",
                                              target=target)
            menu_wdg.add(simple_sidebar)
        else:
            style = self.get_style()
            top.add(style)

            self.view = 'tab'
            config = WidgetConfig.get(view=self.view, xml=config_xml)
            element_names = config.get_element_names()

            if not element_names:
                outer_wdg.add_style("display: none")

            if not state_value:
                if not element_names:
                    state_value = ""
                else:
                    state_value = element_names[0]

            for element_name in element_names:

                item_div = DivWdg()
                menu_wdg.add(item_div)
                item_div.add_class("spt_switcher_item")
                item_div.add_class("tactic_hover")

                item_div.add_style("width: 100%")

                attrs = config.get_element_attributes(element_name)
                title = attrs.get("title")
                if not title:
                    title = Common.get_display_title(element_name)

                for name, value in attrs.items():
                    if name in ['title', 'class']:
                        continue
                    item_div.add_attr(name, value)

                css_class = attrs.get("class")
                if css_class:
                    item_div.add_class(css_class)

                item_div.add(title)
                item_div.add_attr("spt_title", title)

                target = attrs.get("target")
                if not target:
                    target = "spt_content"

                display_class = config.get_display_handler(element_name)
                display_options = config.get_display_options(element_name)

                if show_first != False:
                    if element_name == state_value:
                        item_div.add_behavior({
                            'type':
                            'load',
                            'cbjs_action':
                            '''
                            bvr.src_el.click();
                            '''
                        })

                if display_class:
                    item_div.add_behavior({
                        'type':
                        'click_up',
                        'display_class':
                        display_class,
                        'display_options':
                        display_options,
                        'element_name':
                        element_name,
                        'target':
                        target,
                        'save_state':
                        save_state,
                        'cbjs_action':
                        '''
                        var menu_item = bvr.src_el;
                        var top = menu_item.getParent(".spt_switcher_top");
                        var menu = menu_item.getParent(".spt_switcher_menu");
                        
                        // Get target class
                        var target_class = bvr.target;
                        if (target_class.indexOf(".") != -1) {
                            var parts = target_class.split(".");
                            target_class = parts[1]; 
                            target_top_class = parts[0];
                        }
                        else {
                            target_top_class = null;
                        }
                    
                        if (target_top_class) {
                            var target_top = bvr.src_el.getParent("."+target_top_class);
                        }
                        else {
                            var target_top = $(document.body);
                        }
                        var target = target_top.getElement("."+target_class);
                        if (target) {
                            spt.panel.load(target, bvr.display_class, bvr.display_options);
                        }

                        menu.setStyle("display", "none");
                        top.removeClass("spt_selected");

                        var title = bvr.src_el.getAttribute("spt_title");

                        var title_el = top.getElement(".spt_title");
                        if (title_el)
                            title_el.innerHTML = title

                        if (bvr.save_state) {
                            var server = TacticServerStub.get()
                            server.set_widget_setting(bvr.save_state, bvr.element_name);
                        }

                        '''
                    })

        return top
예제 #36
0
    def get_section_wdg(self, title, description, image, behavior):

        section_wdg = DivWdg()
        section_wdg.set_round_corners()
        section_wdg.add_border()
        section_wdg.add_class("spt_report_top")
        section_wdg.add_style("width: 200px")
        section_wdg.add_style("height: 100px")
        section_wdg.add_style("overflow: hidden")
        section_wdg.add_style("margin: 10px")
        section_wdg.set_box_shadow("0px 0px 10px")

        title_wdg = DivWdg()
        section_wdg.add(title_wdg)
        title_wdg.add(title)
        title_wdg.add_style("height: 20px")
        title_wdg.add_style("padding: 3px")
        title_wdg.add_style("margin-top: 3px")
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_gradient("background", "background")

        button = IconButtonWdg(title="Options",
                               icon=IconWdg.ARROWHEAD_DARK_DOWN)
        title_wdg.add(button)
        button.add_style("float: right")

        # set up menus
        menu = self.get_menu()
        SmartMenu.add_smart_menu_set(button, {'MENU_ITEM': menu})
        SmartMenu.assign_as_local_activator(button, "MENU_ITEM", True)

        section_wdg.add_color("background", "background")
        #section_wdg.add_gradient("background", "background", 0, -3)
        section_wdg.add_behavior({
            'type':
            'hover',
            'add_color_modifier':
            -5,
            'cb_set_prefix':
            'spt.mouse.table_layout_hover',
        })

        desc_div = DivWdg()
        desc_div.add(description)
        desc_div.add_style("padding: 5px 10px 10px 5px")

        div = DivWdg()
        section_wdg.add(div)
        div.add_style("padding: 3px")
        div.add_style("margin: 5px")
        div.add_style("width: 65px")
        div.add_style("height: 50px")
        div.add_style("float: left")
        div.add(image)
        section_wdg.add(desc_div)
        div.add_style("overflow: hidden")

        section_wdg.add_behavior(behavior)
        section_wdg.add_class("hand")

        return section_wdg
예제 #37
0
    def get_display(self):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        top.add_class("spt_reports_top")
        self.set_as_panel(top)

        inner = DivWdg()
        top.add(inner)

        title = DivWdg()
        title.add("Reports")
        title.add_style("font-size: 18px")
        title.add_style("font-weight: bold")
        title.add_style("text-align: center")
        title.add_style("padding: 10px")
        title.add_style("margin: -10px -10px 0px -10px")

        inner.add(title)
        title.add_gradient("background", "background3", 5, -10)

        from tactic.ui.widget import TitleWdg
        subtitle = TitleWdg(name_of_title='List of Built in Reports',
                            help_alias='main')
        inner.add(subtitle)
        inner.add("<br/>")

        button_div = DivWdg()
        inner.add(button_div)
        button_div.add_class("spt_buttons_top")
        button_div.add_style("margin-top: -5px")
        button_div.add_style("margin-bottom: 30px")
        button_div.add_border()

        button_div.add_style("margin-top: -15px")
        button_div.add_style("margin-bottom: 0px")
        button_div.add_style("width: 100%")
        button_div.add_style("height: 33px")
        button_div.add_color("background", "background2")
        button_div.add_style("margin-left: auto")
        button_div.add_style("margin-right: auto")

        button = SingleButtonWdg(title="Collapse", icon=IconWdg.HOME)
        button_div.add(button)
        button.add_style("float: left")
        button.add_style("left: 5px")
        button.add_style("top: 5px")

        # FIXME: get home for the user
        #home = 'tactic.ui.startup.ContentCreatorWdg'
        home = 'tactic.ui.startup.MainWdg'

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.tab.set_main_body_tab();
            var class_name = 'tactic.ui.startup.MainWdg';
            var kwargs = {
                help_alias: 'main'
                };
            spt.tab.add_new("_startup", "Startup", class_name, kwargs);

            '''
        })
        """
        button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP)
        button_div.add(button)
        button.add_class("spt_collapse")
        inner.add(button_div)
        button.add_style("float: left")
        button.add_style("left: 5px")
        button.add_style("top: 5px")

        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_reports_top");
            var element = top.getElement(".spt_reports_list");

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            expand = buttons.getElement(".spt_expand");
            new Fx.Tween(element).start('margin-top', "-400px");
            expand.setStyle("display", "");
            bvr.src_el.setStyle("display", "none");
            '''
        } )

        button = SingleButtonWdg(title="Expand", icon=IconWdg.ARROW_DOWN)
        button.add_style("display: none")
        button.add_class("spt_expand")
        button_div.add(button)
        button.add_style("left: 5px")
        button.add_style("top: 5px")
        inner.add(button_div)
        button.add_style("float: left")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_reports_top");
            var element = top.getElement(".spt_reports_list");

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            collapse = buttons.getElement(".spt_collapse");
            new Fx.Tween(element).start('margin-top', "0px");
            collapse.setStyle("display", "");
            bvr.src_el.setStyle("display", "none");
            '''
        } )
        """

        reports = []

        # read the config file
        from pyasm.widget import WidgetConfig
        tmp_path = __file__
        dir_name = os.path.dirname(tmp_path)
        file_path = "%s/../config/reports-conf.xml" % (dir_name)
        config = WidgetConfig.get(file_path=file_path, view="definition")

        category = self.kwargs.get('category')

        # get all of the configs from the database
        if not category or category in ["custom_reports", "custom_charts"]:
            search = Search("config/widget_config")
            search.add_op("begin")
            if category == "custom_reports":
                search.add_filter("widget_type", "report")
            elif category == "custom_charts":
                search.add_filter("widget_type", "chart")
            elif not category:
                search.add_filters("widget_type", ["chart", "report"])

            search.add_op("or")
            db_configs = search.get_sobjects()
        else:
            db_configs = []

        element_names = self.kwargs.get("element_names")
        if element_names is None:
            element_names = config.get_element_names()

        project = Project.get()

        for element_name in element_names:
            key = {'project': project.get_code(), 'element': element_name}
            key2 = {'project': project.get_code(), 'element': '*'}
            key3 = {'element': element_name}
            key4 = {'element': '*'}
            keys = [key, key2, key3, key4]
            if not top.check_access("link", keys, "view", default="deny"):
                continue

            attrs = config.get_element_attributes(element_name)
            report_data = {}
            kwargs = config.get_display_options(element_name)
            class_name = kwargs.get('class_name')

            # the straight xml definition contains the sidebar class_name
            # with LinkWdg ... we shouldn't use this, so build the
            # element from scratch
            #xml = config.get_element_xml(element_name)
            from pyasm.search import WidgetDbConfig
            xml = WidgetDbConfig.build_xml_definition(class_name, kwargs)

            report_data['class_name'] = class_name
            report_data['kwargs'] = kwargs
            report_data['title'] = attrs.get("title")
            report_data['description'] = attrs.get("description")
            report_data['image'] = attrs.get("image")
            report_data['xml'] = xml

            reports.append(report_data)

        for db_config in db_configs:
            element_name = db_config.get_value("view")
            key = {'project': project.get_code(), 'element': element_name}
            key2 = {'project': project.get_code(), 'element': '*'}
            key3 = {'element': element_name}
            key4 = {'element': '*'}
            keys = [key, key2, key3, key4]
            if not top.check_access("link", keys, "view", default="deny"):
                continue

            report_data = {}
            view = db_config.get_value("view")
            kwargs = {'view': view}
            parts = view.split(".")
            title = Common.get_display_title(parts[-1])

            xml = db_config.get_value("config")

            report_data['class_name'] = "tactic.ui.panel.CustomLayoutWdg"
            report_data['kwargs'] = kwargs
            report_data['title'] = title
            report_data['description'] = title
            report_data['image'] = None
            report_data['xml'] = xml
            report_data['widget_type'] = db_config.get_value("widget_type")
            if report_data['widget_type'] == 'report':
                report_data['category'] = "custom_reports"
            elif report_data['widget_type'] == 'chart':
                report_data['category'] = "custom_charts"

            reports.append(report_data)
        """
        report_data = {
            'title': 'Tasks Completed This Week',
            'class_name': 'tactic.ui.panel.ViewPanelWdg',
            'kwargs': {
                    'search_type': 'sthpw/task',
                    'view': 'table'
                },
        }
        reports.append(report_data)
        """
        if category == 'list_item_reports' or not category:
            search_types = Project.get().get_search_types()
            for search_type in search_types:
                base_key = search_type.get_base_key()

                key = {'project': project.get_code(), 'code': base_key}
                key2 = {'project': project.get_code(), 'code': '*'}
                key3 = {'code': base_key}
                key4 = {'code': '*'}
                keys = [key, key2, key3, key4]
                if not top.check_access(
                        "search_type", keys, "view", default="deny"):
                    continue

                if not SearchType.column_exists(base_key, "pipeline_code"):
                    continue

                thumb_div = DivWdg()
                image = thumb_div
                thumb_div.add_border()
                thumb_div.set_box_shadow("1px 1px 1px 1px")
                thumb_div.add_style("width: 60px")

                thumb = ThumbWdg()
                thumb_div.add(thumb)
                thumb.set_sobject(search_type)
                thumb.set_icon_size(60)

                report_data = {
                    'title': '%s Workflow Status' % search_type.get_title(),
                    'description': 'Number of items in each process',
                    'class_name':
                    'tactic.ui.report.stype_report_wdg.STypeReportWdg',
                    'kwargs': {
                        'search_type': base_key
                    },
                    'image': thumb_div
                }
                reports.append(report_data)

                report_data = {
                    'title': '%s Labor Cost Report' % search_type.get_title(),
                    'description': 'Labor Cost Breakdown for each Item',
                    'class_name': 'tactic.ui.panel.ViewPanelWdg',
                    'kwargs': {
                        'search_type':
                        search_type.get_code(),
                        'view':
                        "table",
                        'show_header':
                        False,
                        'mode':
                        'simple',
                        'element_names':
                        "preview,code,title,cost_breakdown,bid_hours,bid_cost,actual_hours,actual_cost,overbudget,variance"
                    },
                    'image': IconWdg("", IconWdg.REPORT_03)
                }
                reports.append(report_data)

        table2 = Table()
        inner.add(table2)
        table2.add_style("width: 100%")

        categories_div = DivWdg()
        td = table2.add_cell(categories_div)
        td.add_style("vertical-align: top")
        td.add_style("width: 200px")
        td.add_color("background", "background3")
        td.add_border()

        #categories_div.add_style("margin: -1px 0px 0px -1px")
        categories_div.add_style("padding-top: 10px")
        #categories_div.add_style("float: left")
        categories_div.add_color("color", "color3")

        categories = config.get_all_views()
        categories.insert(-1, "list_item_reports")
        categories.insert(-1, "custom_charts")
        categories.insert(-1, "custom_reports")

        table_div = DivWdg()
        td = table2.add_cell(table_div)
        td.add_style("vertical-align: top")
        table_div.add_class("spt_reports_list")
        table_div.add_border()
        table_div.add_color("background", "background", -5)

        table_div.add_style("min-height: 500px")

        for i, category in enumerate(categories):

            if i == len(categories) - 1:
                categories_div.add("<hr/>")

            config.set_view(category)
            element_names = config.get_element_names()

            if category == "definition":
                title = "All Reports"
            else:
                title = Common.get_display_title(category)

            category_div = DivWdg()
            categories_div.add(category_div)
            category_div.add(title)
            category_div.add_style("padding: 5px")
            category_div.add_class("hand")

            category_div.add_behavior({
                'type':
                'click_up',
                'category':
                category,
                'element_names':
                element_names,
                'class_name':
                Common.get_full_class_name(self),
                'cbjs_action':
                '''
            var kwargs = {
                is_refresh: true,
                category: bvr.category,
                element_names: bvr.element_names
            }

            //spt.panel.refresh(top, kwargs);
            var top = bvr.src_el.getParent(".spt_reports_top");
            spt.panel.load(top, bvr.class_name, kwargs);
            '''
            })

            bgcolor = category_div.get_color("background3", -10)
            category_div.add_behavior({
                'type':
                'mouseover',
                'bgcolor':
                bgcolor,
                'cbjs_action':
                '''
            bvr.src_el.setStyle("background", bvr.bgcolor);
            '''
            })
            category_div.add_behavior({
                'type':
                'mouseout',
                'bgcolor':
                bgcolor,
                'cbjs_action':
                '''
            bvr.src_el.setStyle("background", "");
            '''
            })

        # create a bunch of panels
        table = Table()
        table_div.add(table)
        table.add_color("color", "color")
        table.add_style("margin-top: 20px")
        table.center()
        table_div.add_style("margin: -3px -3px -1px -2px")

        if not reports:
            tr = table.add_row()
            td = table.add_cell()
            td.add("There are no reports defined.")
            td.add_style("padding: 50px")

            if self.kwargs.get("is_refresh") in ['true', True]:
                return inner
            else:
                return top

        for i, report in enumerate(reports):

            #if i == 0 or i%4 == 0:
            if i % 3 == 0:
                tr = table.add_row()

            td = table.add_cell()
            td.add_style("vertical-align: top")
            td.add_style("padding: 3px")
            title = report
            #description = '''The schema is used to layout the basic components of your project.  Each component represents a list of items that you use in your business everyday.'''

            description = report.get("title")

            # Each node will contain a list of "items" and will be stored as a table in the database.'''

            class_name = report.get("class_name")
            kwargs = report.get("kwargs")
            title = report.get("title")
            description = report.get("description")
            widget_type = report.get("widget_type")

            image = report.get("image")
            icon = report.get("icon")
            xml = report.get("xml")

            if image:
                div = DivWdg()
                if isinstance(image, basestring):
                    image = image.upper()
                    image = eval("IconWdg('', IconWdg.%s)" % image)
                    div.add_style("margin-left: 15px")
                    div.add_style("margin-top: 5px")
                else:
                    image = image
                div.add(image)
                image = div

            elif icon:
                icon = icon.upper()
                image = eval("IconWdg('', IconWdg.%s)" % icon)

            else:
                div = DivWdg()
                """
                import random
                num = random.randint(0,3)
                if num == 1:
                    image = IconWdg("Bar Chart", IconWdg.GRAPH_BAR_01)
                elif num == 2:
                    image = IconWdg("Bar Chart", IconWdg.GRAPH_LINE_01)
                else:
                    image = IconWdg("Bar Chart", IconWdg.GRAPH_BAR_02)
                """

                if widget_type == "chart":
                    image = IconWdg("Chart", IconWdg.GRAPH_BAR_02)
                else:
                    image = IconWdg("No Image", IconWdg.WARNING)
                div.add_style("margin-left: 15px")
                div.add_style("margin-top: 5px")
                div.add(image)
                image = div

            behavior = {
                'type':
                'click_up',
                'title':
                title,
                'class_name':
                class_name,
                'kwargs':
                kwargs,
                'cbjs_action':
                '''

            spt.tab.set_main_body_tab();
            //var top = bvr.src_el.getParent(".spt_reports_top");
            //spt.tab.set_tab_top(top);
            spt.tab.add_new(bvr.title, bvr.title, bvr.class_name, bvr.kwargs);
            '''
            }
            schema_wdg = self.get_section_wdg(title, description, image,
                                              behavior)

            schema_wdg.add_behavior({
                'type':
                'load',
                'title':
                title,
                'class_name':
                class_name,
                'xml':
                xml,
                'kwargs':
                kwargs,
                'cbjs_action':
                '''
                var report_top = bvr.src_el;
                report_top.kwargs = bvr.kwargs;
                report_top.class_name = bvr.class_name;
                report_top.element_name = bvr.title;
                report_top.xml = bvr.xml;
            '''
            })

            td.add(schema_wdg)

        inner.add("<br/>")

        #from tactic.ui.container import TabWdg
        #tab = TabWdg(show_add=False)
        #inner.add(tab)

        if self.kwargs.get("is_refresh") in ['true', True]:
            return inner
        else:
            return top
예제 #38
0
    def get_section_wdg(self, title, description, image, behavior):

        section_wdg = DivWdg()
        section_wdg.set_round_corners()
        section_wdg.add_border()
        section_wdg.add_style("width: 225px")
        section_wdg.add_style("height: 200px")
        section_wdg.add_style("overflow: hidden")
        section_wdg.add_style("margin: 10px")
        section_wdg.set_box_shadow("2px 2px 2px 2px")

        title_wdg = DivWdg()
        section_wdg.add(title_wdg)
        title_wdg.add(title)
        title_wdg.add_style("height: 20px")
        title_wdg.add_style("padding: 3px")
        title_wdg.add_style("margin-top: 3px")
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_style("text-align: center")
        title_wdg.add_gradient("background", "background")

        section_wdg.add_color("background", "background")
        section_wdg.add_behavior({
            'type':
            'hover',
            'add_color_modifier':
            -3,
            'cb_set_prefix':
            'spt.mouse.table_layout_hover',
        })

        section_wdg.add_behavior({
            'type':
            'click',
            'cbjs_action':
            '''
        bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
        '''
        })
        section_wdg.add_behavior({
            'type':
            'mouseout',
            'cbjs_action':
            '''
        bvr.src_el.setStyle("box-shadow", "2px 2px 2px 2px #999");
        ''',
        })

        desc_div = DivWdg()
        desc_div.add(description)
        desc_div.add_style("padding: 5px 10px 10px 10px")
        desc_div.add_style("font-size: 1.1em")

        div = DivWdg()
        section_wdg.add(div)
        div.add_style("padding: 3px")
        div.add_style("margin: 10px")
        div.add_style("width: 209px")
        div.add_style("height: 64px")
        div.add_style("text-align: center")
        div.add(image)
        #div.set_box_shadow("1px 1px 1px 1px")
        section_wdg.add(desc_div)
        div.add_style("overflow: hidden")

        section_wdg.add_behavior(behavior)
        section_wdg.add_class("hand")

        return section_wdg
예제 #39
0
    def handle_simple_mode(my, custom_table, mode):

        tbody = custom_table.add_tbody()
        tbody.add_class("spt_custom_simple")
        if mode != 'simple':
            tbody.add_style('display: none')

        name_text = TextWdg("custom_name")
        name_text.add_class("spt_input")
        tr = custom_table.add_row()
        tr.add_color("background", "background", -7)
        td = custom_table.add_cell("Name: ")
        td.add_style("min-width: 150px")
        custom_table.add_cell(name_text)

        # add title
        custom_table.add_row()
        title_wdg = TextWdg("custom_title")
        title_wdg.add_attr("size", "50")
        custom_table.add_cell("Title: ")
        custom_table.add_cell(title_wdg)

        # add description
        tr = custom_table.add_row()
        tr.add_color("background", "background", -7)
        description_wdg = TextAreaWdg("custom_description")
        custom_table.add_cell("Description: ")
        custom_table.add_cell(description_wdg)

        type_select = SelectWdg("custom_type")
        type_select.add_class("spt_input")
        #type_select.add_empty_option("-- Select --")
        type_select.set_option(
            "values",
            "string|text|integer|float|boolean|currency|date|foreign_key|list|button|empty"
        )
        type_select.set_option(
            "labels",
            "String(db)|Text(db)|Integer(db)|Float(db)|Boolean(db)|Currency(db)|Date(db)|Foreign Key(db)|List(db)|Button|Empty"
        )
        #type_select.set_option("labels", "String|Integer|Boolean|Currency|Timestamp|Link|Foreign Key|List|Checkbox|Text|Number|Date|Date Range")
        tr = custom_table.add_row()
        custom_table.add_cell("Property Type: ")
        td = custom_table.add_cell(type_select)
        type_select.add_event(
            "onchange",
            "spt.custom_property_adder.property_type_select_cbk(this)")

        # extra info for foreign key
        custom_table.add_row()
        div = DivWdg()
        div.add_class("foreign_key_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Relate to: ")
        search_type_select = SearchTypeSelectWdg(
            "foreign_key_search_select",
            mode=SearchTypeSelectWdg.CURRENT_PROJECT)
        div.add(search_type_select)
        td.add(div)

        # extra info for list
        custom_table.add_row()
        div = DivWdg()
        div.add_class("list_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Values: ")
        search_type_text = TextWdg("list_values")
        div.add(search_type_text)
        td.add(div)

        # extra info for button
        custom_table.add_row()
        div = DivWdg()
        div.add_class("button_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")

        class_path = "tactic.ui.table.ButtonElementWdg"
        button = Common.create_from_class_path(class_path)
        args_keys = button.get_args_keys()

        div.add("Options")
        div.add(HtmlElement.br())

        for key in args_keys.keys():
            div.add("Name: ")
            option_name_text = TextWdg("option_name")
            option_name_text.add_attr("readonly", "true")
            option_name_text.set_value(key)
            div.add(option_name_text)

            div.add(" &nbsp; ")

            div.add("Value: ")
            input = button.get_input_by_arg_key(key)
            div.add(input)

            #option_value_text = TextWdg("option_value")
            #div.add(option_value_text)
            div.add(HtmlElement.br())
        td.add(div)

        # is searchable checkbox
        tr = custom_table.add_row()
        tr.add_color("background", "background", -7)
        current_searchable_wdg = CheckboxWdg("is_searchable")
        #current_view_wdg.set_checked()
        custom_table.add_cell("Is Searchable? ")
        td = custom_table.add_cell(current_searchable_wdg)

        custom_table.close_tbody()
예제 #40
0
    def get_display(self):

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

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

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

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

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

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

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

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

        table2.add_row()

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

        #th.add_class('center_content')

        table2.add_row()

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

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

        #box.add(script)

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

        return widget
예제 #41
0
    def get_header_wdg(my):

        div = DivWdg()

        if my.collection_key:

            button = IconButtonWdg(
                title='Remove Selected Items from Collection', icon="BS_MINUS")
            div.add(button)
            button.add_style("display: inline-block")
            button.add_style("vertical-align: top")

            button.add_behavior({
                'type':
                'click_up',
                'collection_key':
                my.collection_key,
                'cbjs_action':
                '''
                var search_keys = spt.table.get_selected_search_keys(false);

                if (search_keys.length == 0) {
                    spt.notify.show_message("Nothing selected to remove");
                    return;
                }
                var ok = null;
                var cancel = function() { return };
                var msg = "Are you sure you wish to remove the selected Assets from the Collection?";

                var ok = function() {
                    var cls = 'tactic.ui.panel.CollectionRemoveCmd';
                    var kwargs = {
                        collection_key: bvr.collection_key,
                        search_keys: search_keys,
                    }
                    var server = TacticServerStub.get();
                    try {
                        server.execute_cmd(cls, kwargs);
                        spt.table.remove_selected();
                    } catch(e) {
                        spt.alert(spt.exception.handler(e));
                    }
                }
                
                spt.confirm(msg, ok, cancel);

                '''
            })

            button = IconButtonWdg(title='Delete Collection', icon="BS_TRASH")
            #button = ActionButtonWdg(title='Delete Collection', icon="BS_TRASH")
            div.add(button)
            button.add_style("display: inline-block")
            button.add_style("vertical-align: top")

            button.add_behavior({
                'type':
                'click_up',
                'collection_key':
                my.collection_key,
                'cbjs_action':
                '''
                var ok = null;
                var cancel = function() { return };
                var msg = "Are you sure you wish to delete the Collection?";

                var ok = function() {
                    var cls = 'tactic.ui.panel.CollectionDeleteCmd';
                    var kwargs = {
                        collection_key: bvr.collection_key,
                    }
                    var server = TacticServerStub.get();
                    try {
                        server.execute_cmd(cls, kwargs);
                    } catch(e) {
                        spt.alert(e);
                        return;
                    }

                    var top = bvr.src_el.getParent(".spt_collection_top");
                    if (top) {
                        var layout = top.getParent(".spt_layout");
                        spt.table.set_layout(layout);
                    }

                    spt.table.run_search();
                }

                spt.confirm(msg, ok, cancel);
                '''
            })
        """
        button = IconButtonWdg(title='Download Selected Items', icon="BS_DOWNLOAD")
        div.add(button)
        button.add_style("display: inline-block")
        button.add_style("vertical-align: top")

        text_div = DivWdg()
        div.add(text_div)
        text_div.add_style("width: 200px")
        text = LookAheadTextInputWdg(
            name="name",
            icon="BS_SEARCH",
            icon_pos="right",
            width="100%"
        ) 
        text_div.add(text)
        text_div.add_style("display: inline-block")
        """

        div.add_style("width: auto")
        div.add_style("float: right")

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

        return div
예제 #42
0
    def handle_widget_mode(my, custom_table, mode):

        tbody = custom_table.add_tbody()
        tbody.add_class("spt_custom_widget")
        if mode != 'widget':
            tbody.add_style('display: none')

        # add the name
        name_text = TextWdg("custom_name")
        name_text.add_class("spt_input")
        custom_table.add_row()
        custom_table.add_cell("Name: ")
        custom_table.add_cell(name_text)

        # add title
        custom_table.add_row()
        title_wdg = TextWdg("custom_title")
        title_wdg.add_attr("size", "50")
        custom_table.add_cell("Title: ")
        custom_table.add_cell(title_wdg)

        # add description
        custom_table.add_row()
        description_wdg = TextAreaWdg("custom_description")
        custom_table.add_cell("Description: ")
        custom_table.add_cell(description_wdg)

        # add widget class
        custom_table.add_row()
        class_wdg = TextWdg("custom_class")
        class_wdg.add_attr("size", "50")
        custom_table.add_cell("Widget Class: ")
        custom_table.add_cell(class_wdg)

        # add options
        custom_table.add_row()
        td = custom_table.add_cell()
        td.add("Options")
        td = custom_table.add_cell()

        div = DivWdg()
        div.set_id("another_list_options")
        div.add_style("display: block")
        div.add_style("margin-top: 10px")
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg

        div.add("Name: ")
        option_name_text = TextWdg("option_name")
        div.add(option_name_text)

        div.add(" &nbsp; ")

        div.add("Value: ")
        option_value_text = TextWdg("option_value")
        div.add(option_value_text)

        td.add(div)
        td.add(div)
        td.add(div)

        custom_table.close_tbody()
예제 #43
0
    def get_collection_wdg(my):

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

        title_div = DivWdg("Collection Manager")
        div.add(title_div)
        div.add_class("spt_collection_left")
        title_div.add_style("font-size: 1.2em")
        title_div.add_style("font-weight: bold")

        div.add("<hr/>")

        # Shelf
        shelf_div = DivWdg()
        div.add(shelf_div)
        shelf_div.add_style("float: right")
        shelf_div.add_style("margin-bottom: 15px")

        #button = IconButtonWdg(title='Delete Selected Collection', icon="BS_TRASH")
        #shelf_div.add(button)
        #button.add_style("display: inline-block")
        #button.add_style("width: auto")

        button = IconButtonWdg(title='Add New Collection', icon="BS_PLUS")
        shelf_div.add(button)
        button.add_style("display: inline-block")
        button.add_style("vertical-align: top")

        insert_view = "edit_collection"

        button.add_behavior({
            'type':
            'click_up',
            'insert_view':
            insert_view,
            'search_type':
            my.search_type,
            'cbjs_action':
            '''
                kwargs = {
                  search_type: bvr.search_type,
                  mode: 'insert',
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  num_columns: 2,
                  default: {
                    _is_collection: true
                  }
                };
                var popup = spt.panel.load_popup('Add New Collection', 'tactic.ui.panel.EditWdg', kwargs);
            '''
        })
        text_div = DivWdg()
        shelf_div.add(text_div)

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_collection_left");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");

            var num_result = 0;
            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].attributes[0].value.toLowerCase();

                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, display all
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "block";
                }
            }

        '''

        filters = []
        filters.append(("_is_collection", True))
        filters.append(("status", "Verified"))
        text = LookAheadTextInputWdg(
            search_type="workflow/asset",
            column="name",
            width="100%",
            hint_text="Enter terms to filter collections...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True)
        text.add_class("spt_main_search")

        text_div.add(text)
        text_div.add_style("width: 270px")
        text_div.add_style("display: inline-block")

        # Asset Library folder access
        div.add("<br clear='all'/>")
        asset_lib_div = DivWdg()
        div.add(asset_lib_div)
        folder_icon = IconWdg(icon="FOLDER_2", width='30px')

        asset_lib_div.add(folder_icon)
        asset_lib_div.add_style("margin: 5px 0px 5px -5px")
        asset_lib_div.add_style("height: 20px")
        asset_lib_div.add_style("padding-top: 5px")
        asset_lib_div.add_style("padding-bottom: 5px")
        asset_lib_div.add_style("font-weight: bold")

        asset_lib_div.add("Asset Library")
        asset_lib_div.add_class("tactic_hover")
        asset_lib_div.add_class("hand")
        asset_lib_div.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
                var top = bvr.src_el.getParent(".spt_collection_top");
                var content = top.getElements(".spt_collection_content");

                spt.panel.refresh(top);
                '''
        })

        # collection
        search = Search(my.search_type)
        search.add_filter("_is_collection", True)
        collections = search.get_sobjects()

        collections_div = DivWdg()
        collections_div.add_class("spt_collection_list")
        div.add(collections_div)
        collections_div.add_style("margin: 5px 0px 5px -5px")

        from tactic.ui.panel import ThumbWdg2

        parts = my.search_type.split("/")
        collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])

        collections_div.add_relay_behavior({
            'type':
            'mouseup',
            'search_type':
            my.search_type,
            'collection_type':
            collection_type,
            'bvr_match_class':
            'spt_collection_item',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_collection_top");
            var content = top.getElement(".spt_collection_content");

            
            var list = bvr.src_el.getParent(".spt_collection_list");
            var items = list.getElements(".spt_collection_item");
            for (var i = 0; i < items.length; i++) {
                items[i].setStyle("background", "");
                items[i].setStyle("box-shadow", "");
            }
            bvr.src_el.setStyle("background", "#EEE");
            var collection_key = bvr.src_el.getAttribute("spt_collection_key");
            var collection_code = bvr.src_el.getAttribute("spt_collection_code");
            var collection_path = bvr.src_el.getAttribute("spt_collection_path");

            var expr = "@SEARCH("+bvr.collection_type+"['parent_code','"+collection_code+"']."+bvr.search_type+")";

            var parent_dict = {};
            var parent_collection = bvr.src_el.getParent(".spt_subcollection_wdg");
            var path = collection_path.substring(0, collection_path.lastIndexOf("/"));
            if (parent_collection) {
                for (var i = 0; i < collection_path.split("/").length - 1; i++) {
                    var n = path.lastIndexOf("/");
                    var collection_name = path.substring(n+1);                
                    path = path.substring(0, n);

                    var parent_key = parent_collection.getAttribute("spt_parent_key");
                    parent_dict[collection_name] = parent_key;
                    parent_collection = parent_collection.getParent(".spt_subcollection_wdg");
                    
                }
            }            

            var cls = "tactic.ui.panel.CollectionContentWdg";
            var kwargs = {
                collection_key: collection_key,
                path: collection_path,
                search_type: bvr.search_type,
                show_shelf: false,
                show_search_limit: true,
                expression: expr,
                parent_dict: parent_dict
            }
            spt.panel.load(content, cls, kwargs);

            bvr.src_el.setStyle("box-shadow", "0px 0px 3px rgba(0,0,0,0.5)");

            // hide the bottom show_search_limit when clicking into a collection
            var panel = bvr.src_el.getParent(".spt_panel");
            var search_limit_div = panel.getElements(".spt_search_limit_top");
            if (search_limit_div.length == 2){
                search_limit_div[1].setStyle("visibility", "hidden");
            }
            '''
        })

        collections_div.add_relay_behavior({
            'type':
            'mouseup',
            'search_type':
            my.search_type,
            'bvr_match_class':
            'spt_collection_open',
            'cbjs_action':
            '''
            var item = bvr.src_el.getParent(".spt_collection_div_top");
            var next = item.getNext();

            if (bvr.src_el.hasClass("spt_open")) {
                next.innerHTML = "";
                bvr.src_el.setStyle("opacity", 1.0);
                bvr.src_el.removeClass("spt_open");
            }
            else {
                var collection_key = bvr.src_el.getAttribute("spt_collection_key");
                var collection_path = bvr.src_el.getAttribute("spt_collection_path");

                var cls = "tactic.ui.panel.CollectionListWdg";
                var kwargs = {
                    parent_key: collection_key,
                    path: collection_path,
                }
                spt.panel.load(next, cls, kwargs, null, {show_loading: false});

                bvr.src_el.setStyle("opacity", 0.3);
                bvr.src_el.addClass("spt_open");

                evt.stopPropagation();
            }



            '''
        })

        for collection in collections:

            collection_wdg = CollectionItemWdg(
                collection=collection, path=collection.get_value("name"))
            collections_div.add(collection_wdg)
            collection_wdg.add_class("spt_collection_div")

            subcollection_wdg = DivWdg()
            collections_div.add(subcollection_wdg)
            subcollection_wdg.add_class("spt_subcollection_wdg")
            subcollection_wdg.add_style("padding-left: 15px")

        return div
예제 #44
0
    def get_new_custom_widget(my, search_type, view):

        div = DivWdg()
        div.add_style('width: 500px')

        mode_select = SelectWdg("custom_mode")
        mode_select.add_class("spt_custom_mode")
        mode_select.set_option("values", "simple|xml")
        mode_select.set_option("labels", "Simple|XML")
        mode_select.add_class("spt_input")
        behavior = {
            'type': 'change',
            'cbfn_action': 'spt.custom_property_adder.switch_property_mode'
        }
        mode_select.add_behavior(behavior)

        div.add("Mode: ")
        div.add(mode_select)
        div.add("<br/><br/>")

        custom_table = Table()
        custom_table.add_color("color", "color")

        custom_table.set_max_width()
        mode = "simple"
        my.handle_simple_mode(custom_table, mode)
        #my.handle_widget_mode(custom_table, mode)
        my.handle_xml_mode(custom_table, mode)
        div.add(custom_table)

        div.add("<br/>")

        custom_table = Table()
        custom_table.center()
        custom_table.add_row()

        from tactic.ui.widget import ActionButtonWdg
        submit = ActionButtonWdg(title="Add/Next")
        behavior = {
            'type': 'click',
            'mouse_btn': 'LMB',
            'cbfn_action': 'spt.custom_property_adder.add_property_cbk',
            'search_type': my.search_type,
            'view': view
        }
        submit.add_behavior(behavior)
        td = custom_table.add_cell(submit)

        behavior['exit'] = 'true'
        submit_exit = ActionButtonWdg(title="Add/Exit")
        submit_exit.add_behavior(behavior)
        custom_table.add_cell(submit_exit)

        cancel = ActionButtonWdg(title="Cancel")
        behavior = {
            'type': 'click_up',
            'cbjs_action': "spt.popup.close('New Table Column')"
        }
        cancel.add_behavior(behavior)
        custom_table.add_cell(cancel)

        div.add(custom_table)

        return div
예제 #45
0
    def get_display(my):

        collection = my.kwargs.get("collection")
        path = my.kwargs.get("path")

        search_type = collection.get_base_search_type()
        parts = search_type.split("/")
        collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])

        search = Search(collection_type)
        search.add_filter("parent_code", collection.get_value("code"))
        search.add_column("search_code")
        items = search.get_sobjects()
        codes = [x.get_value("search_code") for x in items]

        count = search.get_count()

        # find the children that are actually collections
        search = Search(search_type)
        search.add_filter("_is_collection", True)
        search.add_filters("code", codes)
        has_child_collections = search.get_count() > 0

        top = my.top
        collection_top = top
        collection_top.add_class("spt_collection_div_top")
        collection_div = DivWdg()

        name = collection.get_value("name")
        # Adding Collection title (without the number count) as an attribute
        collection_top.set_attr("collection_name", name)

        collection_top.add(collection_div)
        collection_top.add_class("tactic_hover")
        collection_top.add_class("hand")

        collection_div.add_class("spt_collection_item")
        collection_div.add_attr("spt_collection_key",
                                collection.get_search_key())
        collection_div.add_attr("spt_collection_code", collection.get_code())
        collection_div.add_attr("spt_collection_path", path)

        # This is for Drag and Drop from a tile widget
        collection_div.add_class("spt_tile_top")
        collection_div.add_attr("spt_search_key", collection.get_search_key())
        collection_div.add_attr("spt_search_code", collection.get_code())

        collection_div.add_style("height: 20px")
        collection_div.add_style("padding-top: 10px")

        if has_child_collections:
            icon_div = DivWdg()
            icon = IconWdg(name="View Collection", icon="BS_CHEVRON_DOWN")
            icon_div.add(icon)
            icon.add_style("float: right")
            icon.add_style("margin-top: -20px")
            collection_top.add(icon_div)
            icon_div.add_class("spt_collection_open")
            icon_div.add_attr("spt_collection_key",
                              collection.get_search_key())
            icon_div.add_attr("spt_collection_path", path)

        from tactic.ui.panel import ThumbWdg2
        thumb_wdg = ThumbWdg2()
        thumb_wdg.set_sobject(collection)
        collection_div.add(thumb_wdg)
        thumb_wdg.add_style("width: 45px")
        thumb_wdg.add_style("float: left")
        thumb_wdg.add_style("margin-top: -10px")

        if count:
            count_div = DivWdg()
            collection_div.add(count_div)
            #count_div.add_style("margin-top: -10px")
            #count_div.add_style("margin-left: -10px")

            count_div.add_style("width: 15px")
            count_div.add_style("height: 15px")
            count_div.add_style("font-size: 0.8em")
            count_div.add_style("border-radius: 10px")
            count_div.add_style("background: #DDD")
            count_div.add_style("position: absolute")
            count_div.add_style("text-align: center")
            count_div.add_style("margin-left: 23px")
            count_div.add_style("margin-top: -8px")
            count_div.add_style("box-shadow: 0px 0px 3px rgba(0,0,0,0.5)")

            count_div.add(count)
            #count_div.add_update( {
            #    'parent_key': collection.get_search_key(),
            #    'expression': "@COUNT(%s)" % collection_type,
            #} )

        name = collection.get_value("name")
        collection_div.add(name)

        return top
예제 #46
0
    def get_display(my):

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

        collection = Search.get_by_search_key(my.collection_key)

        top = my.top

        my.kwargs["scale"] = 75
        my.kwargs["show_scale"] = False
        my.kwargs["expand_mode"] = "plain"
        from tile_layout_wdg import TileLayoutWdg
        tile = TileLayoutWdg(**my.kwargs)
        parent_dict = my.kwargs.get("parent_dict")
        has_parent = False
        if parent_dict:
            has_parent = True

        path = my.kwargs.get("path")
        if collection and path:
            title_div = DivWdg()
            top.add(title_div)
            title_div.add_style("float: left")
            title_div.add_style("margin: 15px 0px 15px 30px")

            asset_lib_span_div = SpanWdg()
            title_div.add(asset_lib_span_div)

            icon = IconWdg(name="Asset Library", icon="BS_FOLDER_OPEN")

            asset_lib_span_div.add(icon)

            asset_lib_span_div.add(" <a><b>Asset Library</b></a> ")

            path = path.strip("/")
            parts = path.split("/")

            for idx, part in enumerate(parts):
                title_div.add(" / ")
                # the last spt_collection_link does not need a search_key
                if has_parent and (idx is not len(parts) - 1):
                    search_key = parent_dict.get(part)
                    title_div.add(
                        " <a class='spt_collection_link' search_key=%s><b>%s</b></a> "
                        % (search_key, part))
                else:
                    title_div.add(
                        " <a class='spt_collection_link'><b>%s</b></a> " %
                        part)
                title_div.add_style("margin-top: 10px")

            # Adding behavior to collections link

            parts = my.kwargs.get("search_type").split("/")
            collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])

            exists = SearchType.get(collection_type, no_exception=True)
            if not exists:
                title_div.add("SearchType %s is not registered." %
                              collection_type)
                return top

            # These behaviors are only activated if the view is within collection layout,
            # "is_new_tab" is a kwargs set to true, if opening a new tab
            if not my.kwargs.get("is_new_tab"):
                icon.add_class("hand")
                icon.add_behavior({
                    'type':
                    'mouseover',
                    'cbjs_action':
                    '''
                    bvr.src_el.setStyle('opacity', 1.0);
                    '''
                })
                icon.add_behavior({
                    'type':
                    'mouseout',
                    'cbjs_action':
                    '''
                    bvr.src_el.setStyle('opacity', 0.6);
                    '''
                })
                # make icon and All Assets title clickable to return to view all assets
                asset_lib_span_div.add_class("hand")
                asset_lib_span_div.add_behavior({
                    'type':
                    'click_up',
                    'cbjs_action':
                    '''
                    var top = bvr.src_el.getParent(".spt_collection_top");
                    var content = top.getElements(".spt_collection_content");

                    spt.panel.refresh(top);
                    '''
                })

                title_div.add_class("hand")
                title_div.add_relay_behavior({
                    'type':
                    'mouseup',
                    'search_type':
                    my.kwargs.get("search_type"),
                    'collection_type':
                    collection_type,
                    'bvr_match_class':
                    'spt_collection_link',
                    'cbjs_action':
                    '''

                    var top = bvr.src_el.getParent(".spt_collection_top");
                    var content = top.getElement(".spt_collection_content");

                    var collection_key = bvr.src_el.getAttribute("search_key");
                    if (!collection_key) {
                        spt.notify.show_message("Already in the Collection.");
                    } 
                    else {
                        var collection_code = collection_key.split("workflow/asset?project=workflow&code=")[1];
                        var collection_path = bvr.src_el.innerText;
                        var expr = "@SEARCH("+bvr.collection_type+"['parent_code','"+collection_code+"']."+bvr.search_type+")";

                        var cls = "tactic.ui.panel.CollectionContentWdg";
                        var kwargs = {
                            collection_key: collection_key,
                            path: collection_path,
                            search_type: bvr.search_type,
                            show_shelf: false,
                            show_search_limit: true,
                            expression: expr
                        }
                        spt.panel.load(content, cls, kwargs);

                        bvr.src_el.setStyle("box-shadow", "0px 0px 3px rgba(0,0,0,0.5)");
                    }

                    '''
                })

                #title_div.add("/ %s" % collection.get_value("name") )

        #scale_wdg = tile.get_scale_wdg()
        #top.add(scale_wdg)
        #scale_wdg.add_style("float: right")

        top.add(my.get_header_wdg())

        top.add(tile)

        return top
예제 #47
0
    def get_display(my):

        top = DivWdg()
        top.add_border()
        top.add_style("padding: 10px")
        top.add_color("color", "color")
        top.add_gradient("background", "background", 0, -5)
        #top.add_style("height: 550px")

        #top.add_behavior( {
        #    'type': 'load',
        #    'cbjs_action': '''
        #    spt.named_events.fire_event("side_bar|hide_now", {} );
        #    '''
        #} )

        project = Project.get()

        title = TitleWdg(title='Tools')
        top.add(title)

        shelf = DivWdg()
        top.add(shelf)
        shelf.add_style("margin-left: -8px")
        shelf.add_style("width: 130px")

        button_div = DivWdg()
        shelf.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -3px")
        """
        security = Environment.get_security()
        view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow')
        if view_side_bar:
            button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT)
            button_div.add(button)
            shelf.add("Toggle Side Bar")
            button.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            } )
            shelf.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                spt.named_events.fire_event("side_bar|toggle");
                '''
            } )
            shelf.add_class("hand")
        else:
            shelf.add("&nbsp;")

        """

        search_wdg = DivWdg()
        search_wdg.add_class("spt_main_top")
        top.add(search_wdg)
        search_wdg.add_style("padding: 10px")
        search_wdg.add_style("margin: 10px auto")
        search_wdg.add_style("width: 430px")
        search_wdg.add("Search: ")
        search_wdg.add("&nbsp;" * 3)

        custom_cbk = {}
        custom_cbk['enter'] = '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords != '') {
                var class_name = 'tactic.ui.panel.ViewPanelWdg';
                var kwargs = {
                    'search_type': 'sthpw/sobject_list',
                    'view': 'table',
                    'keywords': keywords,
                    'simple_search_view': 'simple_search',
                    //'show_shelf': false,
                }
                spt.tab.set_main_body_tab();
                spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            }
        '''

        from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg
        #text = TextInputWdg(name="search")
        text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk)
        #text = TextWdg("search")
        text.add_class("spt_main_search")
        text.add_style("width: 290px")
        search_wdg.add(text)
        search_wdg.add_style("font-weight: bold")
        search_wdg.add_style("font-size: 16px")

        button = ActionButtonWdg(title="Search")
        #search_wdg.add(button)
        button.add_style("float: right")
        #button.add_style("margin-top: -28px")

        icon_div = DivWdg()
        search_wdg.add(icon_div)
        icon_div.add_style("width: 38px")
        icon_div.add_style("height: 27px")
        icon_div.add_style("padding-top: 3px")
        icon_div.add_style("padding-left: 4px")
        icon_div.add_style("text-align: center")
        #icon_div.add_gradient("background", "background3", 15, -10)
        icon_div.add_color("background", "background3", 10)
        over_color = icon_div.get_color("background3", 0)
        out_color = icon_div.get_color("background3", 10)
        icon_div.set_round_corners(5)
        icon_div.set_box_shadow("1px 1px 1px 1px")
        icon = IconWdg("Search", IconWdg.SEARCH_32, width=24)
        icon_div.add(icon)
        icon_div.add_style("float: right")
        icon_div.add_style("margin-top: -5px")
        button = icon_div
        icon_div.add_class("hand")
        icon_div.add_behavior({
            'type':
            'mouseover',
            'color':
            over_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            '''
        })
        icon_div.add_behavior({
            'type':
            'mouseout',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background", bvr.color);
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-3");
            bvr.src_el.setStyle("margin-right", "-2");
            '''
        })
        icon_div.add_behavior({
            'type':
            'click_up',
            'color':
            out_color,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999");
            bvr.src_el.setStyle("margin-top", "-5");
            bvr.src_el.setStyle("margin-right", "0");
            '''
        })

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_main_top");
            var search_el = top.getElement(".spt_main_search");
            var keywords = search_el.value;

            if (keywords == '') {
                return;
            }

            var class_name = 'tactic.ui.panel.ViewPanelWdg';
            var kwargs = {
                'search_type': 'sthpw/sobject_list',
                'view': 'table',
                'keywords': keywords,
                'simple_search_view': 'simple_search',
                //'show_shelf': false,
            }
            spt.tab.set_main_body_tab();
            spt.tab.add_new("Search Results", "Search Results", class_name, kwargs);
            '''
        })

        #desc = DivWdg()
        #top.add(desc)
        #desc.add("Dashboard")
        #desc.add_style("width: 600px")

        # create a bunch of panels
        table = Table()
        table.add_color("color", "color")
        table.add_style("margin-bottom: 20px")
        table.center()
        top.add(table)
        table.add_row()

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Themes"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Themes define the look and feel of a project.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.themes_wdg.ThemesWdg';
        var kwargs = {
            help_alias: 'project-startup-dashboards'
            };
        spt.tab.set_main_body_tab();
        spt.tab.add_new("themes", "Themes", class_name, kwargs);
        '''
        }
        dashboard_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(dashboard_wdg)

        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Dashboards"
        image = "<img src='/context/icons/64x64/dashboard_64.png'/>"
        description = '''Dashboards display key project data in single views. Drill down further to work on tasks, make status changes or add notes.'''

        # read the config file
        #from pyasm.widget import WidgetConfig
        #tmp_path = __file__
        #dir_name = os.path.dirname(tmp_path)
        #file_path="%s/../config/dashboard-conf.xml" % (dir_name)
        #config = WidgetConfig.get(file_path=file_path, view="definition")

        # FIXME: this bypasses the link security
        #element_name = "dashboards"
        #attrs = config.get_element_attributes(element_name)
        #dashboard_data = {}
        #kwargs = config.get_display_options(element_name)
        #class_name = kwargs.get('class_name')

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.dashboards_wdg.DashboardsWdg';
        var kwargs = {
            help_alias: 'project-startup-dashboards'
            };
        spt.tab.set_main_body_tab();
        spt.tab.add_new("dashboards", "Dashboards", class_name, kwargs);
        '''
        }
        dashboard_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(dashboard_wdg)

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Reports"
        image = "<img src='/context/icons/64x64/report_64.png'/>"
        description = '''TACTIC provides a number of predefined reports that project managers can access instantly to get real-time analytics.'''

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        var class_name = 'tactic.ui.startup.reports_wdg.ReportsWdg';
        var kwargs = {};
        spt.tab.set_main_body_tab();
        spt.tab.add_new("reports", "Reports", class_name, kwargs);
        //spt.panel.load_popup("Reports", class_name, kwargs);
        '''
        }

        side_bar_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(side_bar_wdg)

        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Lists of Items"
        description = '''View all of the lists items for this project<br/><br/>
        '''
        image = "<img src='/context/icons/48x48/search_type_48.png'/>"
        #image = "<img src='/context/images/getting_started_pipeline.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.HomeWdg';
        var kwargs = {};
        spt.tab.add_new("lists", "Lists", class_name, kwargs);
        '''
        }
        config_wdg = my.get_section_wdg(title, description, image, behavior)
        td.add(config_wdg)

        tr, td = table.add_row_cell()
        td.add_style("font-size: 14px")
        td.add("<br/>" * 2)

        quick_links_wdg = QuickLinksWdg()
        td.add(quick_links_wdg)

        return top
예제 #48
0
    def get_display(my):
        search_type = my.kwargs.get("search_type")

        search = Search(search_type)
        if not search.column_exists("_is_collection"):
            return my.top

        search.add_filter("_is_collection", True)
        collections = search.get_sobjects()

        top = my.top
        top.add_class("spt_dialog")
        button = IconButtonWdg(title='Add to Collection',
                               icon="BS_TH_LARGE",
                               show_arrow=True)
        top.add(button)

        detail_wdg = DivWdg()
        top.add(detail_wdg)

        dialog = DialogWdg()
        top.add(dialog)

        dialog.set_as_activator(button, offset={'x': -25, 'y': 0})
        dialog.add_title("Collections")

        dialog.add(
            "<div style='margin: 10px'><b>Add selected items to a collection</b></div>"
        )

        add_div = DivWdg()
        dialog.add(add_div)
        icon = IconWdg(name="Add new collection", icon="BS_PLUS")
        icon.add_style("opacity: 0.6")
        icon.add_style("padding-right: 3px")
        add_div.add(icon)
        add_div.add("Create new Collection")
        add_div.add_style("text-align: center")
        add_div.add_style("background-color: #EEEEEE")
        add_div.add_style("padding: 5px")
        add_div.add_style("height: 20px")
        add_div.add_class("hand")

        insert_view = "edit_collection"

        add_div.add_behavior({
            'type':
            'click_up',
            'insert_view':
            insert_view,
            'cbjs_action':
            '''
                var top = bvr.src_el.getParent(".spt_table_top");
                var table = top.getElement(".spt_table");
                var search_type = top.getAttribute("spt_search_type");
                
                // Hide the dialog when popup loads.
                var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
                dialog_top.style.visibility = "hidden";

                kwargs = {
                  search_type: search_type,
                  mode: "insert",
                  view: bvr.insert_view,
                  save_event: bvr.event_name,
                  show_header: false,
                  'num_columns': 2,
                  default: {
                    _is_collection: true
                  }
                };
                spt.panel.load_popup("Add New Collection", "tactic.ui.panel.EditWdg", kwargs);
            '''
        })

        content_div = DivWdg()
        dialog.add(content_div)
        content_div.add_style("width: 270px")
        content_div.add_style("padding: 5px")
        content_div.add_style("padding-bottom: 0px")

        custom_cbk = {}
        custom_cbk['enter'] = '''

            var top = bvr.src_el.getParent(".spt_dialog");
            var input = top.getElement(".spt_main_search");
            var search_value = input.value.toLowerCase();
            var collections = top.getElements(".spt_collection_div");
            var num_result = 0;
            for (i = 0; i < collections.length; i++) {
                // Access the Collection title (without number count) 
                var collection_title = collections[i].attributes[0].value.toLowerCase();

                if (collection_title.indexOf(search_value) != '-1') {
                    collections[i].style.display = "block";
                    num_result += 1;
                }
                else {
                    collections[i].style.display = "none";
                }
            }
            // if no search results, display all
            if (num_result == 0) {
                for (i = 0; i < collections.length; i++) {
                    collections[i].style.display = "block";
                }
            }

        '''
        filters = []
        filters.append(("_is_collection", True))
        filters.append(("status", "Verified"))
        text = LookAheadTextInputWdg(
            search_type="workflow/asset",
            column="name",
            icon="BS_SEARCH",
            icon_pos="right",
            width="100%",
            hint_text="'Enter' to search for Colllection...",
            value_column="name",
            filters=filters,
            custom_cbk=custom_cbk,
            is_collection=True)
        text.add_class("spt_main_search")

        content_div.add(text)
        # set minimum if there is at least one collection
        if len(collections) > 0:
            content_div.add_style("min-height: 300")
        content_div.add_style("max-height: 300")
        content_div.add_style("overflow-y: auto")

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

        for collection in collections:

            search_type = collection.get_base_search_type()
            parts = search_type.split("/")
            collection_type = "%s/%s_in_%s" % (parts[0], parts[1], parts[1])
            search = Search(collection_type)
            search.add_filter("parent_code", collection.get_code())
            num_items = search.get_count()

            collection_div = DivWdg()
            collection_div.add_class("spt_collection_div")
            content_div.add(collection_div)
            collection_div.add_style("margin: 3px 5px 0px 5px")

            go_wdg = DivWdg()
            collection_div.add(go_wdg)
            go_wdg.add_style("float: right")

            icon = IconWdg(name="View Collection", icon="BS_CHEVRON_RIGHT")
            go_wdg.add(icon)
            #go_wdg.add_behavior( {
            #    'type': 'click_upX',
            #    'cbjs_action': '''
            #    alert("Not Implemented");
            #    '''
            #} )

            name = collection.get_value("name")
            # Adding Collection title (without the number count) as an attribute
            collection_div.set_attr("collection_name", name)

            if not name:
                name = collection.get_value("code")

            check_div = DivWdg()
            collection_div.add(check_div)

            check = CheckboxWdg("collection_key")
            check.add_class("spt_collection_checkbox")
            check_div.add(check)
            check_div.add_style("float: left")
            check_div.add_style("margin-right: 5px")
            check_div.add_style("margin-top: -3px")

            check.add_attr("collection_key", collection.get_search_key())

            info_div = DivWdg()
            collection_div.add(info_div)
            info_div.add(name)

            if num_items:
                info_div.add(" (%s)" % num_items)

            collection_div.add("<hr/>")

        add_button = DivWdg()
        add_button.add("Add")
        add_button.add_style("margin: 0px 10px 10px 10px")
        add_button.add_style("width: 50px")
        add_button.add_class("btn btn-primary")
        dialog.add(add_button)

        add_button.add_behavior({
            'type':
            'click',
            'cbjs_action':
            '''
            var search_keys = spt.table.get_selected_search_keys(false);

            if (search_keys.length == 0) {
                spt.notify.show_message("No assets selected.");
                return;
            }

            var top = bvr.src_el.getParent(".spt_dialog");
            var checkboxes = top.getElements(".spt_collection_checkbox");
            var cmd = "tactic.ui.panel.CollectionAddCmd";
            var server = TacticServerStub.get();
            var is_checked = false;

            var dialog_top = bvr.src_el.getParent(".spt_dialog_top");

            for (i = 0; i < checkboxes.length; i++) {
                var checked_collection_attr = checkboxes[i].attributes;
                var collection_key = checked_collection_attr[3].value;
                // Preventing a collection being added to itself, check if search_keys contain collection_key.
                if (search_keys.indexOf(collection_key) != -1) {
                    spt.notify.show_message("Collection cannot be added to itself.");
                    return;
                }

                if (checkboxes[i].checked == true) {
                    // if there is at least one checkbox selected, set is_checked to 'true'
                    is_checked = true;

                    var search_keys = spt.table.get_selected_search_keys(false);
                    var kwargs = {
                        collection_key: collection_key,
                        search_keys: search_keys
                    }
                    server.execute_cmd(cmd, kwargs);
                }
            }

            if (is_checked == false) {
                spt.notify.show_message("No collection selected.");
                return;
            }
            else {
                spt.notify.show_message("Assets added to Collection.");
                // refresh dialog_top, so users can see the number change in Collections
                spt.panel.refresh(dialog_top);
            }
            
            '''
        })

        return top
예제 #49
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_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 = my.kwargs.get("search_type")
        if not search_type:
            node_name = my.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
예제 #50
0
    def get_display(self):

        self.set_option('icon', "CONTENTS")

        sobject = self.get_current_sobject()
        search_type = sobject.get_search_type()

        context = self.get_option("context")
        if not context:
            context = "publish"

        process = self.get_option("process")
        if not process:
            process = "publish"

        if sobject.get_base_search_type() == "sthpw/snapshot":
            snapshot = sobject
            sobject = snapshot.get_parent()
            if sobject:
                search_type = sobject.get_search_type()
            else:
                top = DivWdg()
                return top

        else:
            if process:
                snapshot = Snapshot.get_latest_by_sobject(sobject,
                                                          process=process)
            else:
                snapshot = Snapshot.get_latest_by_sobject(sobject,
                                                          context=context)

        if not snapshot:
            top = DivWdg()
            return top

        top = DivWdg()
        icon = IconButtonWdg("Show Metadata",
                             eval("IconWdg.%s" % self.get_option('icon')))
        top.add(icon)
        top.add_style("text-align: center")

        lib_path = snapshot.get_lib_path_by_type("main")
        basename = os.path.basename(lib_path)
        dirname = os.path.dirname(lib_path)

        self.behavior['basename'] = basename
        self.behavior['dirname'] = dirname
        self.behavior['search_type'] = search_type

        cbjs_action = '''

        var class_name = 'tactic.ui.tools.repo_browser_wdg.RepoBrowserContentWdg';
        var kwargs = {
            basename: '%(basename)s',
            dirname: '%(dirname)s',
            search_type: '%(search_type)s'
        };

        //spt.tab.set_main_body_tab();
        //spt.tab.add_new("Detail", "Detail", class_name, kwargs);
        spt.panel.load_popup("Detail", class_name, kwargs);

        ''' % (self.behavior)

        self.behavior['type'] = 'click_up'
        self.behavior['cbjs_action'] = cbjs_action

        icon.add_behavior(self.behavior)

        return top
예제 #51
0
    def get_action_wdg(my):
       
        main_div = DivWdg(css="filter_box center_content")
        div = DivWdg()
        main_div.add(my.get_view_select())
        main_div.add(div)
        div.add_style('height', '16px')
        div.add_style('margin', '3px 0 3px 0')

        search_type = my.get_search_type()
         
        div.add(HtmlElement.b("Action: "))
        add_button = IconButtonWdg(my.ADD_BUTTON, IconWdg.ADD, long=True)
        behavior = {
            'type': 'click_up',
            'mouse_btn': 'LMB',
            'cbfn_action': 'spt.sobject_planner.action',
            'action': 'add',
            'search_type': search_type
        }
        add_button.add_behavior(behavior)


        retire_button = IconButtonWdg("Retire Instance",\
            IconWdg.RETIRE, long=True)
        behavior = {
            'type': 'click_up',
            'mouse_btn': 'LMB',
            'cbfn_action': 'spt.sobject_planner.action',
            'action': 'retire',
            'search_type': search_type
        }
        retire_button.add_behavior(behavior)


        delete_button = IconButtonWdg("Delete Instance",\
            IconWdg.DELETE, long=True)
        behavior = {
            'type': 'click_up',
            'mouse_btn': 'LMB',
            'cbfn_action': 'spt.sobject_planner.action',
            'action': 'delete',
            'search_type': search_type
        }
        delete_button.add_behavior(behavior)






        div.add(add_button)
        div.add(retire_button)
        div.add(delete_button)

        '''
        # add test popup
        from tactic.ui.container import PopupWdg
        from tactic.ui.panel import TableLayoutWdg
        popup = PopupWdg(id="planner", allow_page_activity=True)

        content = DivWdg()
        #content.add_style("height: 500px")
        #content.add_style("overflow: scroll")
        search_type = my.get_search_type()
        layout = TableLayoutWdg(search_type=search_type, view="planner_left")
        search = Search(search_type)
        layout.set_sobjects( search.get_sobjects() )
        content.add(layout)

        popup.add("Assets", "title")
        popup.add(content, "content")

        popup_button = IconButtonWdg("Popup",\
            IconWdg.DELETE, long=True)
        popup_button.add_event("onclick", "$('planner').setStyle('display','')")

        main_div.add(popup)
        main_div.add(popup_button)
        '''




        return main_div
예제 #52
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")

        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_gradient("background", "background", -10, -10)
            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 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)
예제 #53
0
    def get_content_wdg(my):

        div = DivWdg()
        div.add_class("spt_tool_top")

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

        td = table.add_cell()
        from table_layout_wdg import FastTableLayoutWdg

        kwargs = my.kwargs.copy()

        td.add_style("width: 1%")
        td.add_style("vertical-align: top")
        layout_div = DivWdg()
        layout_div.add_style("min-height: 500px")
        td.add(layout_div)

        element_names = my.kwargs.get("element_names")
        if not element_names:
            kwargs['element_names'] = [
                'name', 'description', 'detail', 'file_list', 'general_checkin'
            ]
        #kwargs['element_names'] = ['preview','name','detail', 'task_summary']

        kwargs['show_shelf'] = False
        kwargs['show_search_limit'] = False
        layout = FastTableLayoutWdg(**kwargs)
        layout_div.add(layout)
        #from tactic.ui.panel import TileLayoutWdg
        #layout = TileLayoutWdg(**my.kwargs)
        #layout_div.add(layout)

        td = table.add_cell()
        td.add_border(color="#EEE")
        td.add_style("vertical-align: top")

        content = DivWdg()
        td.add(content)
        content.add_class("spt_tool_content")
        #content.add_style("margin: -1px")

        no_content_wdg = DivWdg()
        content.add(no_content_wdg)
        no_content_wdg.add("<br/>" * 3)
        no_content_wdg.add("<i>-- No Content --</i>")
        #no_content_wdg.add_style("opacity: 0.5")
        no_content_wdg.add_style("margin: 30px auto")
        no_content_wdg.add_color("color", "color3")
        no_content_wdg.add_color("background", "background3")
        no_content_wdg.add_style("text-align", "center")
        no_content_wdg.add_style("padding-top: 20px")
        no_content_wdg.add_style("padding-bottom: 20px")
        no_content_wdg.add_style("width: 350px")
        no_content_wdg.add_style("height: 110px")
        no_content_wdg.add_border()

        return div
예제 #54
0
    def get_display(my):
        top = my.top
        my.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: 300px")
        top.add_border()

        search_key = my.kwargs.get("search_key")
        search_keys = my.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:
            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

        my.search_keys = search_keys

        title = DivWdg()
        top.add(title)
        title.add_color("background", "background", -10)
        if my.search_keys:
            title.add("Delete %s Items" % len(my.search_keys))
        else:
            title.add("Delete Item [%s]" % (sobject.get_code()))
        title.add_style("font-size: 14px")
        title.add_style("font-weight: bold")
        title.add_style("padding: 10px")

        content = DivWdg()
        top.add(content)
        content.add_style("padding: 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 = my.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("WARNING", IconWdg.WARNING)
            icon.add_style("float: left")
            content.add(icon)
            content.add(
                "<div><b>WARNING: By selecting the related items above, you can delete them as well when deleting this sObject.</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')

        content.add("There are %s items to be deleted" % len(my.search_keys))
        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: 75px')
        button = ActionButtonWdg(title="Delete")
        button_div.add(button)
        content.add(button_div)
        button.add_style("float: left")

        button.add_behavior({
            'type':
            'click_up',
            'search_keys':
            my.search_keys,
            'cbjs_action':
            '''
        spt.app_busy.show("Deleting");

        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();
        try {
            server.start({'title': 'Delete sObject', 'description': 'Delete sObject [' + bvr.search_keys + ']'});
            server.execute_cmd(class_name, kwargs);
            server.finish();

            // 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);


        }
        catch(e) {
            spt.alert(spt.exception.handler(e));
        }

        spt.app_busy.hide();
       
        '''
        })

        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();
        '''
        })

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

        return top
예제 #55
0
    def get_versions_wdg(self):

        div = DivWdg()
        div.add_class("spt_imports")

        title_wdg = DivWdg()
        div.add(title_wdg)
        title_wdg.add("Imports found:")
        title_wdg.add_style("padding: 0px 0px 8px 0px")

        base_dir = self.kwargs.get("base_dir")
        imports_dir = "%s/imports" % base_dir
        if not os.path.exists(imports_dir):
            imports_dir = base_dir

        basenames = os.listdir(imports_dir)
        basenames.sort()
        basenames.reverse()

        div.add_relay_behavior({
            'type':
            'mouseup',
            'bvr_match_class':
            "spt_import_item",
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_imports");
            var els = top.getElements(".spt_import_info");
            for ( var i = 0; i < els.length; i++) {
                spt.hide(els[i]);
            }

            var el = bvr.src_el.getElement(".spt_import_info");
            spt.show(el);
            '''
        })

        # find all the zip files
        count = 0
        for basename in basenames:
            if not basename.endswith(".txt"):
                continue
            if basename.find("-files-") != -1:
                continue
            if basename.find("-data-") != -1:
                continue

            version_wdg = DivWdg()
            div.add(version_wdg)
            version_wdg.add_style("padding: 3px 3px 3px 12px")
            version_wdg.add_class("spt_import_item")

            radio = RadioWdg("basename")
            version_wdg.add(radio)
            radio.set_option("value", basename)
            if not count:
                radio.set_checked()

            version_wdg.add(basename)

            version_wdg.add("<br/>")

            # add info
            path = "%s/%s" % (imports_dir, basename)
            f = open(path)
            data = f.read()
            f.close()

            data = jsonloads(data)

            table = Table()
            version_wdg.add(table)
            table.add_class("spt_import_info")
            if count:
                table.add_style("display: none")
            table.set_max_width()
            table.add_style("margin-left: 40px")
            table.add_style("margin-right: 20px")

            version_wdg.add(table)
            for name, value in self.data.items():
                name = Common.get_display_title(name)
                table.add_row()
                table.add_cell(name)
                table.add_cell(value)

            count += 1

        if count == 0:
            msg_wdg = DivWdg()
            div.add(msg_wdg)
            msg_wdg.add("<i>No imports found</i>")
            msg_wdg.add_border()
            msg_wdg.add_style("padding: 20px")
            msg_wdg.add_style("padding: 10px")
            msg_wdg.add_style("text-align: center")
            msg_wdg.add_color("background", "background", -10)

        return div
예제 #56
0
    def get_display(my):

        my.view_editable = True

        #if my.kwargs.get("do_search") != "false":
        #    my.handle_search()
        my._process_search_args()

        #my.kwargs['show_gear'] = 'false'

        from tile_layout_wdg import TileLayoutWdg
        my.tile_layout = TileLayoutWdg(search_type=my.search_type,
                                       expand_mode=my.expand_mode,
                                       process=my.process)

        # set the sobjects to all the widgets then preprocess
        for widget in my.widgets:
            widget.set_sobjects(my.sobjects)
            widget.set_parent_wdg(my)
            # preprocess the elements
            widget.preprocess()
        """
        # TEST code to return only the content
        temp = my.kwargs.get("temp")
        if temp:
            content = DivWdg()
            content.add( my.get_content_wdg() )
            return content
        """

        # extraneous variables inherited from TableLayoutWdg
        my.edit_permission = True

        top = my.top
        my.set_as_panel(top)
        top.add_class("spt_sobject_top")

        inner = DivWdg()
        top.add(inner)
        # This is handled elsewhere
        #inner.add_color("background", "background")
        inner.add_color("color", "color")
        inner.add_attr("spt_version", "2")
        inner.add_class("spt_table")
        inner.add_class("spt_layout")

        class_name = Common.get_full_class_name(my)
        inner.add_attr("spt_class_name", class_name)

        if not Container.get_dict("JSLibraries", "spt_html5upload"):
            from tactic.ui.input import Html5UploadWdg
            upload_wdg = Html5UploadWdg()
            inner.add(upload_wdg)
            my.upload_id = upload_wdg.get_upload_id()

            inner.add_attr('upload_id', my.upload_id)

        # this interferes with Html5Upload function on first load, commenting it out
        #thumb = ThumbWdg()
        #thumb.handle_layout_behaviors(inner)

        is_refresh = my.kwargs.get("is_refresh")
        if my.kwargs.get("show_shelf") not in ['false', False]:
            action = my.get_action_wdg()
            inner.add(action)

        info = my.search_limit.get_info()
        if info.get("count") == None:
            info["count"] = len(my.sobjects)

        search_limit_mode = my.kwargs.get('search_limit_mode')
        if not search_limit_mode:
            search_limit_mode = 'bottom'

        if search_limit_mode in ['top', 'both']:
            from tactic.ui.app import SearchLimitSimpleWdg
            limit_wdg = SearchLimitSimpleWdg(
                count=info.get("count"),
                search_limit=info.get("search_limit"),
                current_offset=info.get("current_offset"))
            inner.add(limit_wdg)

        content = DivWdg()
        inner.add(content)
        content.add(my.get_content_wdg())

        # NOTE: a lot of scaffolding to convince that search_cbk that this
        # is a proper layout
        top.add_class("spt_table_top")
        class_name = Common.get_full_class_name(my)
        top.add_attr("spt_class_name", class_name)

        # NOTE: adding a fake header to conform to a table layout.  Not
        # sure if this is the correct interface for this
        header_row_div = DivWdg()
        header_row_div.add_class("spt_table_header_row")
        content.add(header_row_div)
        content.add_class("spt_table_table")
        content.set_id(my.table_id)

        my.handle_load_behaviors(content)

        inner.add_class("spt_table_content")
        inner.add_attr("spt_search_type", my.kwargs.get('search_type'))
        inner.add_attr("spt_view", my.kwargs.get('view'))

        limit_span = DivWdg()
        inner.add(limit_span)
        limit_span.add_style("margin-top: 4px")
        limit_span.add_class("spt_table_search")
        limit_span.add_style("width: 250px")
        limit_span.add_style("margin: 5 auto")

        inner.add_attr("total_count", info.get("count"))

        if search_limit_mode in ['bottom', 'both']:
            from tactic.ui.app import SearchLimitSimpleWdg
            limit_wdg = SearchLimitSimpleWdg(
                count=info.get("count"),
                search_limit=info.get("search_limit"),
                current_offset=info.get("current_offset"),
            )
            inner.add(limit_wdg)

        my.add_layout_behaviors(inner)

        if my.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
예제 #57
0
    def get_script_wdg(my):

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

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

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

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

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

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

        paths = []
        scripts_dict = {}
        for script in scripts:
            path = "//%s/%s" % (script.get_value("folder"),
                                script.get_value("title"))
            paths.append(path)
            scripts_dict[path] = script
        dir_list_wdg = ScriptDirListWdg(paths=paths,
                                        base_dir="/",
                                        editor_id=my.editor_id,
                                        scripts=scripts_dict)
        inner.add(dir_list_wdg)
        """
        last_folder = ''
        for script in scripts:
            title = script.get_value("title")
            folder = script.get_value("folder")
            language = script.get_value("language", no_exception=True)
            if not language:
                language = 'javascript'

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


            last_folder = folder

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

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

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


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

        widget.add(script_div)

        return widget
예제 #58
0
    def get_display(self):
        top = self.top
        self.set_as_panel(top)
        top.add_class("spt_sync_import_top")
        top.add_style("width: 500px")
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("padding: 20px")

        inner = DivWdg()
        top.add(inner)

        inner.add(self.get_base_dir_wdg())

        is_refresh = self.kwargs.get("is_refresh") == 'true'

        base_dir = self.kwargs.get("base_dir")
        if base_dir:
            data = self.kwargs.get("data")
            if data:
                self.data = jsonloads(data)
            else:
                if not os.path.exists(base_dir):
                    msg_div = DivWdg()

                    inner.add("<br/>" * 2)
                    inner.add(msg_div)

                    msg_div.add_style("padding: 20px 20px 30px 20px")
                    msg_div.add_color("background", "background3")
                    msg_div.add_color("color", "color")
                    msg_div.add_border()

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

                    msg_div.add("<br/>")

                    msg_div.add("Base folder [%s] does not exist on server" %
                                base_dir)
                    if is_refresh:
                        return inner
                    else:
                        return top

                manifest_path = "%s/tactic.txt" % base_dir
                f = open(manifest_path)
                data = f.read()
                self.data = jsonloads(data)

                inner.add(self.get_import_wdg())

        else:
            self.data = {}

            msg_div = DivWdg()
            inner.add(msg_div)
            icon = IconWdg("", IconWdg.ARROW_UP)
            msg_div.add(icon)
            msg_div.add("Please browse or enter in a sync location")
            msg_div.add_style("padding: 20px")
            msg_div.add_style("margin: 30px")
            msg_div.add_style("text-align: center")
            msg_div.add_border()
            msg_div.add_color("background", "background3")
            msg_div.add_color("color", "color3")

        if self.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
예제 #59
0
    def get_display(my):
        web = WebContainer.get_web()

        top = my.top
        top.add_class("spt_ace_editor_top")

        script = my.kwargs.get("custom_script")
        if script:
            language = script.get_value("language")
        else:
            language = my.kwargs.get("language")
            if not language:
                language = 'javascript'

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

        show_options = my.kwargs.get("show_options")
        if show_options in ['false', False]:
            show_options = False
        else:
            show_options = True

        options_div = DivWdg()
        top.add(options_div)
        if not show_options:
            options_div.add_style("display: none")
        options_div.add_color("background", "background3")
        options_div.add_border()
        options_div.add_style("text-align: center")
        options_div.add_style("padding: 2px")

        select = SelectWdg("language")
        select.add_style("width: 100px")
        select.add_style("display: inline")
        options_div.add(select)
        select.add_class("spt_language")
        select.set_option("values",
                          "javascript|server_js|python|expression|xml")
        select.add_behavior({
            'type':
            'change',
            'editor_id':
            my.get_editor_id(),
            'cbjs_action':
            '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var value = bvr.src_el.value;
            spt.ace_editor.set_language(value);

            //register_change(bvr);

            '''
        })

        select = SelectWdg("font_size")
        select.add_style("width: 100px")
        select.add_style("display: inline")
        options_div.add(select)
        select.set_option("labels", "8 pt|9 pt|10 pt|11 pt|12 pt|14 pt|16 pt")
        select.set_option("values", "8 pt|9pt|10pt|11pt|12pt|14pt|16pt")
        select.set_value("10pt")
        select.add_behavior({
            'type':
            'click_up',
            'editor_id':
            my.get_editor_id(),
            'cbjs_action':
            '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var editor = spt.ace_editor.editor;
            var editor_id = spt.ace_editor.editor_id;

            var value = bvr.src_el.value;
            $(editor_id).setStyle("font-size", value)
            //editor.resize();
            '''
        })

        select = SelectWdg("keybinding")
        select.add_style("width: 100px")
        #options_div.add(select)
        select.set_option("labels", "Ace|Vim|Emacs")
        select.set_option("values", "ace|vim|emacs")
        select.set_value("10pt")
        select.add_behavior({
            'type':
            'change',
            'editor_id':
            my.get_editor_id(),
            'cbjs_action':
            '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var editor = spt.ace_editor.editor;
            var editor_id = spt.ace_editor.editor_id;

            var vim = require("ace/keyboard/keybinding/vim").Vim;
            editor.setKeyboardHandler(vim)
            '''
        })

        editor_div = DivWdg()
        top.add(editor_div)

        if code:
            load_div = DivWdg()
            top.add(load_div)
            readonly = my.kwargs.get("readonly")
            if readonly in ['true', True]:
                readonly = True
            else:
                readonly = False

            load_div.add_behavior({
                'type':
                'load',
                'code':
                code,
                'language':
                language,
                'editor_id':
                my.get_editor_id(),
                'readonly':
                readonly,
                'cbjs_action':
                '''
                spt.ace_editor.set_editor(bvr.editor_id);
                var func = function() {
                    var editor = spt.ace_editor.editor;
                    var document = editor.getSession().getDocument();
                    if (bvr.code) {
                        spt.ace_editor.set_value(bvr.code);
                    }
                    spt.ace_editor.set_language(bvr.language);
                    editor.setReadOnly(bvr.readonly);


                    var session = editor.getSession();
                    //session.setUseWrapMode(true);
                    //session.setWrapLimitRange(120, 120);
                };

                var editor = spt.ace_editor.editor;
                if (!editor) {
                    setTimeout( func, 1000);
                }
                else {
                    func();
                }

                '''
            })

        # theme
        select = SelectWdg("theme")
        select.add_style("width: 100px")
        select.add_style("display: inline")
        options_div.add(select)
        select.set_option(
            "labels", "Eclipse|Twilight|TextMate|Vibrant Ink|Merbivore|Clouds")
        select.set_option(
            "values", "eclipse|twilight|textmate|vibrant_ink|merbivore|clouds")
        select.set_value("twilight")
        select.add_behavior({
            'type':
            'change',
            'editor_id':
            my.get_editor_id(),
            'cbjs_action':
            '''
            spt.ace_editor.set_editor(bvr.editor_id);
            var editor = spt.ace_editor.editor;
            var editor_id = spt.ace_editor.editor_id;
            value = bvr.src_el.value;

            editor.setTheme("ace/theme/" + value);
            '''
        })

        editor_div = DivWdg()
        top.add(editor_div)

        my.text_area.add_style("margin-top: -1px")
        my.text_area.add_style("margin-bottom: 0px")
        my.text_area.add_color("background", "background")
        my.text_area.add_style("font-family: courier new")
        my.text_area.add_border()
        editor_div.add(my.text_area)
        my.text_area.add_style("position: relative")
        #text_area.add_style("margin: 20px")

        size = web.get_form_value("size")
        if size:
            width, height = size.split(",")
        else:
            width = my.kwargs.get("width")
            if not width:
                width = "650px"
            height = my.kwargs.get("height")
            if not height:
                height = "450px"
        my.text_area.add_style("width: %s" % width)
        my.text_area.add_style("height: %s" % height)

        bottom_div = DivWdg()
        top.add(bottom_div)
        bottom_div.add_color("background", "background3")
        bottom_div.add_border()
        bottom_div.add_style("text-align: center")
        bottom_div.add_style("padding: 2px")
        bottom_div.add_style("height: 20px")

        bottom_title = "Script Editor"
        bottom_div.add(bottom_title)

        icon = IconWdg("Resize Editor", IconWdg.RESIZE_CORNER)
        bottom_div.add(icon)
        icon.add_style("float: right")
        icon.add_style("margin-right: -4px")
        icon.add_style("cursor: se-resize")
        icon.add_behavior({
            'type': 'drag',
            "cb_set_prefix": 'spt.ace_editor.drag_resize',
        })

        #hidden = HiddenWdg("size")
        hidden = TextWdg("size")
        bottom_div.add(hidden)
        hidden.add_style("width: 85px")
        hidden.add_style("text-align: center")
        hidden.add_style("float: right")
        hidden.add_class("spt_size")
        hidden.set_value("%s,%s" % (width, height))

        theme = top.get_theme()
        if theme == 'dark':
            theme = 'twilight'
        else:
            theme = 'eclipse'

        print "theme: ", theme

        top.add_behavior({
            'type':
            'load',
            'unique_id':
            my.unique_id,
            'theme':
            theme,
            'cbjs_action':
            '''

if (typeof(ace) == 'undefined') {

// fist time loading
spt.ace_editor = {}
spt.ace_editor.editor = null;
spt.ace_editor.editor_id = bvr.unique_id;
spt.ace_editor.theme = bvr.theme;


spt.ace_editor.set_editor = function(editor_id) {
    spt.ace_editor.editor_id = editor_id;
    spt.ace_editor.editor = $(editor_id).editor;
}

spt.ace_editor.set_editor_top = function(top_el) {
    if (!top_el.hasClass("spt_ace_editor")) {
        top_el = top_el.getElement(".spt_ace_editor");
    }

    var editor_id = top_el.getAttribute("id");
    spt.ace_editor.set_editor(editor_id);
}




spt.ace_editor.get_editor = function() {
    return spt.ace_editor.editor;

}



spt.ace_editor.clear_selection = function() {
    var editor = spt.ace_editor.editor;
    editor.clearSelection();

}



spt.ace_editor.get_selection = function() {
    var editor = spt.ace_editor.editor;
    //return editor.getSelection();
    return editor.getCopyText();
}





spt.ace_editor.get_value = function() {
    var editor = spt.ace_editor.editor;
    var document = editor.getSession().getDocument()
    var value = document.getValue();
    return value;
}



spt.ace_editor.set_value = function(value) {
    var editor = spt.ace_editor.editor;
    var document = editor.getSession().getDocument()
    document.setValue(value);
    editor.gotoLine(2);
    editor.resize();
    editor.focus();
}

spt.ace_editor.goto_line = function(number) {
    var editor = spt.ace_editor.editor;
    var document = editor.getSession().getDocument()
    editor.gotoLine(2);
    editor.resize();
    editor.focus();
 

}


spt.ace_editor.insert = function(value) {
    var editor = spt.ace_editor.editor;
    var position = editor.getCursorPosition();
    var doc = editor.getSession().getDocument()
    doc.insertInLine(position, value);
}

 
spt.ace_editor.insert_lines = function(values) {
    var editor = spt.ace_editor.editor;
    var position = editor.getCursorPosition();
    var doc = editor.getSession().getDocument()
    doc.insertLines(position.row, values);
}



spt.ace_editor.get_document = function() {
    var document = spt.ace_editor.editor.getSession().getDocument()
    return document;

}




spt.ace_editor.set_language = function(value) {
    if (!value) {
        value = 'javascript';
    }

    var editor = spt.ace_editor.editor;
    var top = $(spt.ace_editor.editor_id).getParent(".spt_ace_editor_top");
    var lang_el = top.getElement(".spt_language");

    for ( var i = 0; i < lang_el.options.length; i++ ) {
        if ( lang_el.options[i].value == value ) {
            lang_el.options[i].selected = true;
            break;
        }
    }



    var session = editor.getSession();
    var mode;
    if (value == 'python') {
        mode = require("ace/mode/python").Mode;
    }
    else if (value == 'xml') {
        mode = require("ace/mode/xml").Mode;
    }
    else if (value == 'expression') {
        mode = require("ace/mode/xml").Mode;
    }
    else {
        mode = require("ace/mode/javascript").Mode;
    }
    session.setMode( new mode() );
}

spt.ace_editor.drag_start_x;
spt.ace_editor.drag_start_y;
spt.ace_editor.drag_size;
spt.ace_editor.drag_editor_el;
spt.ace_editor.drag_size_el;
spt.ace_editor.drag_resize_setup = function(evt, bvr, mouse_411)
{
    var editor = spt.ace_editor.editor;
    var editor_id = spt.ace_editor.editor_id;

    spt.ace_editor.drag_start_x = mouse_411.curr_x;
    spt.ace_editor.drag_start_y = mouse_411.curr_y;

    var editor_el = $(editor_id);
    spt.ace_editor.drag_editor_el = editor_el;
    spt.ace_editor.drag_size = editor_el.getSize();

    var top = bvr.src_el.getParent(".spt_ace_editor_top");
    spt.ace_editor.drag_size_el = top.getElement(".spt_size");
}


spt.ace_editor.drag_resize_motion = function(evt, bvr, mouse_411)
{
    var diff_x = parseFloat(mouse_411.curr_x - spt.ace_editor.drag_start_x);
    var diff_y = parseFloat(mouse_411.curr_y - spt.ace_editor.drag_start_y);

    var size = spt.ace_editor.drag_size;


    var editor_el = spt.ace_editor.drag_editor_el;

    var width = size.x + diff_x
    if (width < 300) {
        width = 300;
    }
    var height = size.y + diff_y
    if (height < 200) {
        height = 200;
    }

    editor_el.setStyle("width", width);
    editor_el.setStyle("height", height);

    spt.ace_editor.drag_size_el.value = width + "," + height;

    var editor = spt.ace_editor.editor;
    editor.resize();

}
    var js_files = [
        "ace/ace-0.2.0/src/ace.js",
        //"ace/ace-0.2.0/src/ace-uncompressed.js",
    ];


   

    var ace_setup =  function() {
        var editor = ace.edit(bvr.unique_id);
        spt.ace_editor.editor = editor;

        // put the editor into the dom
        spt.ace_editor.editor_id = bvr.unique_id;
        $(bvr.unique_id).editor = editor;

        editor.setTheme("ace/theme/" + spt.ace_editor.theme);
        var JavaScriptMode = require("ace/mode/javascript").Mode;
        editor.getSession().setMode(new JavaScriptMode())
    }

    


    spt.dom.load_js(js_files, function() { 
    
        ace; require; define; 

        var core_js_files = [
        "ace/ace-0.2.0/src/mode-javascript.js",
         "ace/ace-0.2.0/src/mode-xml.js",
            "ace/ace-0.2.0/src/mode-python.js",
             "ace/ace-0.2.0/src/theme-twilight.js",
               
            "ace/ace-0.2.0/src/theme-textmate.js",
            "ace/ace-0.2.0/src/theme-vibrant_ink.js",
            "ace/ace-0.2.0/src/theme-merbivore.js",
            "ace/ace-0.2.0/src/theme-clouds.js",
            "ace/ace-0.2.0/src/theme-eclipse.js"
        ];
        //var supp_js_files = [];
           
         
        

        spt.dom.load_js(core_js_files, ace_setup);
        //spt.dom.load_js(supp_js_files);      
        });
   

    





}
else {
    var editor = ace.edit(bvr.unique_id);
    editor.setTheme("ace/theme/" +  bvr.theme);
    var JavaScriptMode = require("ace/mode/javascript").Mode;
   
    editor.getSession().setMode(new JavaScriptMode())

    spt.ace_editor.editor_id = bvr.unique_id;
    spt.ace_editor.editor = editor;
    $(bvr.unique_id).editor = editor;

}
            '''
        })

        return top
예제 #60
0
    def get_import_wdg(self):
        div = DivWdg()

        if self.data:

            div.add("<br/>" * 2)
            div.add("The following TACTIC share was found: ")
            div.add("<br/>" * 2)

            data_input = TextAreaWdg("data")
            data_input.add_style("display: none")
            div.add(data_input)

            #print "xxxx: ", self.data
            data_str = jsondumps(self.data)
            #data_str = data_str.replace('"', "'")
            print "data: ", data_str
            data_input.set_value(data_str)

            table = Table()
            div.add(table)
            table.set_max_width()
            table.add_style("margin-left: 20px")
            table.add_style("margin-right: 20px")

            for name, value in self.data.items():
                name = Common.get_display_title(name)
                table.add_row()
                table.add_cell(name)
                table.add_cell(value)

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

            div.add(self.get_versions_wdg())

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

            # check to see if the project exists
            project_code = self.data.get("project_code")
            project_code = self.data.get("projects")
            project = Project.get_by_code(project_code)
            #if project:
            if False:
                msg_div = DivWdg()
                div.add(msg_div)
                msg_div.add_style("padding: 20px")
                msg_div.add_color("background", "background3")
                msg_div.add_color("color", "color")
                msg_div.add_border()

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

                msg_div.add(
                    "The project with code [%s] already exists.  You must remove the installed project before trying to import this one."
                    % project_code)
                return div

            if self.data.get("is_encrypted") == "true":
                div.add(
                    "The transactions in this share is encrypted.  Please provide an encryption key to decrypt the transactions<br/><br/>"
                )
                div.add("Encryption Key: ")
                text = TextWdg("encryption_key")
                div.add(text)
                div.add("<br/>" * 2)

            button = ActionButtonWdg(title="Import >>")
            button.add_style("float: right")
            div.add(button)
            div.add("<br/>" * 2)
            button.add_behavior({
                'type':
                'click_up',
                'project_code':
                project_code,
                'cbjs_action':
                '''
                spt.app_busy.show("Importing Project "+bvr.project_code+"...");
                var top = bvr.src_el.getParent(".spt_sync_import_top");
                var values = spt.api.Utility.get_input_values(top, null, false);
                var cmd = "tactic.ui.sync.SyncImportCmd";
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, values, {}, {use_transaction: false});
                spt.notify.show_message("Finished importing project");
                spt.app_busy.hide();
                document.location = '/tactic/'+bvr.project_code;
                '''
            })

        return div