Esempio n. 1
0
    def get_display(my):

        top = my.top

        if not HelpWdg.exists():
            return top

        alias = my.kwargs.get("alias")
        description = my.kwargs.get("description")
        if not description:
            description = "Show Help"

        if my.kwargs.get("use_icon"):
            help_button = SingleButtonWdg(title='Help',
                                          icon=IconWdg.HELP_BUTTON,
                                          show_arrow=False)
        else:
            help_button = ActionButtonWdg(title="?",
                                          tip=description,
                                          size='small')
        top.add(help_button)

        if not my.cbjs_action:
            my.cbjs_action = '''
            spt.help.set_top();
            spt.help.load_alias(bvr.alias);
            '''

            help_button.add_behavior({
                'type': 'click_up',
                'alias': alias,
                'cbjs_action': my.cbjs_action
            })

        return top
Esempio n. 2
0
    def get_display(my):

        top = my.top

        if not HelpWdg.exists():
            return top

        alias = my.kwargs.get("alias")
        description = my.kwargs.get("description")
        if not description:
            description = "Show Help"

        if my.kwargs.get("use_icon"):
            help_button = SingleButtonWdg(title="Help", icon=IconWdg.HELP_BUTTON, show_arrow=False)
        else:
            help_button = ActionButtonWdg(title="?", tip=description, size="small")
        top.add(help_button)

        if not my.cbjs_action:
            my.cbjs_action = """
            spt.help.set_top();
            spt.help.load_alias(bvr.alias);
            """

            help_button.add_behavior({"type": "click_up", "alias": alias, "cbjs_action": my.cbjs_action})

        return top
Esempio n. 3
0
 def get_display(my):
     widget = DivWdg()
     from tactic.ui.widget import SingleButtonWdg
     button = SingleButtonWdg(title='Report a Bug or Request a Feature', icon=IconWdg.TAG_ORANGE, show_arrow=False)
     button.add_behavior(my.get_launch_behavior())
     widget.add(button)
     return widget
Esempio n. 4
0
    def get_display(my):

        top = my.top

        if not HelpWdg.exists():
            return top

        alias = my.kwargs.get("alias")
        description = my.kwargs.get("description")
        if not description:
            description = "Show Help"

        if my.kwargs.get("use_icon"):
            help_button = SingleButtonWdg(title='Help', icon=IconWdg.HELP_BUTTON, show_arrow=False)
        else:
            help_button = ActionButtonWdg(title="?", tip=description, size='small')
        top.add(help_button)

        if not my.cbjs_action:
            my.cbjs_action = '''
            spt.help.set_top();
            spt.help.load_alias(bvr.alias);
            '''

            help_button.add_behavior( {
                'type': 'click_up',
                'alias': alias,
                'cbjs_action': my.cbjs_action
            } )


        return top
Esempio n. 5
0
    def get_display(my):
        security = Environment.get_security()
        if security.check_access("builtin", "view_site_admin", "allow"):
            menus = [
                my.get_main_menu(),
                my.get_add_menu(),
                my.get_edit_menu(),
                my.get_tools_menu(),
                my.get_help_menu()
            ]
        else:
            menus = [
                my.get_main_menu(),
                my.get_edit_menu(),
                my.get_help_menu()
            ]
        """
        btn_dd = DivWdg()
        btn_dd.add_styles("width: 36px; height: 18px; padding: none; padding-top: 1px;")

        btn_dd.add( "<img src='/context/icons/common/transparent_pixel.gif' alt='' " \
                   # "title='TACTIC Actions Menu' class='tactic_tip' " \
                    "style='text-decoration: none; padding: none; margin: none; width: 4px;' />" )
        btn_dd.add( "<img src='/context/icons/silk/cog.png' alt='' " \
                "title='TACTIC Actions Menu' class='tactic_tip' " \
                    "style='text-decoration: none; padding: none; margin: none;' />" )
        btn_dd.add( "<img src='/context/icons/silk/bullet_arrow_down.png' alt='' " \
                "title='TACTIC Actions Menu' class='tactic_tip' " \
                    "style='text-decoration: none; padding: none; margin: none;' />" )
        """

        from tactic.ui.widget import SingleButtonWdg
        btn_dd = SingleButtonWdg(title='Global Options',
                                 icon=IconWdg.GEAR,
                                 show_arrow=True)

        #btn_dd.add_behavior( { 'type': 'hover',
        #            'mod_styles': 'background-image: url(/context/icons/common/gear_menu_btn_bkg_hilite.png); ' \
        #                            'background-repeat: no-repeat;' } )
        smenu_set = SmartMenu.add_smart_menu_set(btn_dd,
                                                 {'DG_TABLE_GEAR_MENU': menus})
        SmartMenu.assign_as_local_activator(btn_dd, "DG_TABLE_GEAR_MENU", True)
        return btn_dd
Esempio n. 6
0
    def get_middle_wdg(self):
        div = DivWdg()
        #button = ActionButtonWdg(title="<<<")
        #div.add(button)

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

        div.add_color("background", "background")
        div.add_style("width: 35px")
        div.add_style("height: 100%")
        div.add_style("padding: 15px")

        button = SingleButtonWdg(icon=IconWdg.ARROW_RIGHT)
        div.add(button)

        return div
Esempio n. 7
0
    def get_display(my):
        if my.is_refresh:
            top = Widget()
            my.add(top)
        else:
            container = DivWdg()
            my.add(container)
            #parent = SearchKey.get_by_search_key(my.search_key)
            top = DivWdg()
            container.add(top)
            my.set_as_panel(top)
            top.add_style("margin-top: -2px")

            top.add_class("spt_uber_notes_top")

        from tactic.ui.app import HelpButtonWdg
        help_button = HelpButtonWdg(alias="note-sheet-widget")
        top.add(help_button)
        help_button.add_style("float: right")

        table_id = 'sub_table'
        view = 'table'
        span = DivWdg(css='spt_input_group')
        top.add(span)

        span.add_border()
        span.add_style("height: 27px")
        span.add_style("padding: 5px")

        button_div = DivWdg()
        span.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-right: 10px")

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

        from tactic.ui.widget import SingleButtonWdg
        refresh = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
        table.add_cell(refresh)
        refresh.add_style("float: left")
        refresh.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var tbody = top.getElements('.spt_table_tbody')[2];
            var values = spt.api.Utility.get_input_values(tbody);
            spt.panel.refresh(top, values, false);
        '''
        })

        save = SingleButtonWdg(title="Save", icon=IconWdg.SAVE)
        table.add_cell(save)
        save.add_style("float: left")
        save.add_behavior({
            'type':
            'click_up',
            'update_current_only':
            True,
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var table = top.getElement(".spt_table");
            bvr.src_el = table;
            spt.dg_table.update_row(evt, bvr)
            '''
        })

        process = SingleButtonWdg(title="Show Processes",
                                  icon=IconWdg.PROCESS,
                                  show_arrow=True)
        table.add_cell(process)

        from tactic.ui.container import DialogWdg
        process_dialog = DialogWdg(display=False)
        span.add(process_dialog)
        process_dialog.set_as_activator(process)
        process_dialog.add_title("Processes")

        process_div = DivWdg()
        process_dialog.add(process_div)
        #process_div.add_style("padding: 5px")
        process_div.add_color("background", "background")
        process_div.add_color("color", "color")
        process_div.add_border()

        refresh = ActionButtonWdg(title="Refresh")
        refresh.add_style('margin: 0 auto 10px auto')
        process_div.add(refresh)
        refresh.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var tbody = top.getElements('.spt_table_tbody')[2];
            var values = spt.api.Utility.get_input_values(tbody);
            spt.panel.refresh(top, values, false);
        '''
        })
        process_div.add("<hr/>")

        selected_process_names = []
        step = 0

        for idx, value in enumerate(my.process_names):
            checkbox_name = 'note_process_cb'
            if my.child_mode:
                selected_process_names.append(value)
                #break
            cb = CheckboxWdg(checkbox_name, label=value)

            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.set_option('value', value)
            #cb.set_persistence()

            cb.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                    spt.input.save_selected(bvr, '%s','%s');
                ''' % (checkbox_name, key)
            })

            # only 1 is selected in child_mode
            if cb.is_checked():
                selected_process_names.append(value)

            if idx == 0 or idx == 10 * step:
                # add a new inner div
                inner_div = my._get_inner_div()
                process_div.add(inner_div, 'inner%s' % step)
                step += 1

            inner_div.add(cb)

            inner_div.add("<br/>")

        # if less than 10, make it wider
        if len(my.process_names) < 10:
            inner_div.add_style('width: 100px')

        # add a master private checkbox
        if not my.child_mode:
            checkbox_name = 'note_master_private_cb'
            cb = CheckboxWdg(checkbox_name, label='make notes private')
            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.add_behavior({
                'type':
                'click_up',
                'propagate_evt':
                True,
                'cbjs_action':
                '''
                    var top = bvr.src_el.getParent(".spt_uber_notes_top");
                    var tbody = top.getElements('.spt_table_tbody')[2];
                    var inputs = spt.api.Utility.get_inputs(tbody,'is_private');
                    for (var i = 0; i < inputs.length; i++)
                        inputs[i].checked = bvr.src_el.checked;
                    spt.input.save_selected(bvr, '%s','%s');
                    ''' % (checkbox_name, key)
            })

            cb_span = DivWdg(cb, css='small')
            cb_span.add_styles(
                'border-left: 1px dotted #bbb; margin-left: 10px')
            span.add(cb_span)

        main_config_view = my._get_main_config(view, selected_process_names)

        sobject_dict = {}

        # TODO: do a union all search or by order number = 1
        for value in selected_process_names:
            search = Search('sthpw/note')
            search.add_filter('project_code', Project.get_project_code())
            search.add_filter('context', value)
            search.add_filter('search_type', my.parent_search_type)
            search.add_filter('search_id', my.parent_search_id)
            search.add_order_by('timestamp desc')
            search.add_limit(1)
            sobject = search.get_sobject()
            if sobject:
                sobject_dict[value] = sobject
        #sobjects = search.get_sobjects()
        # virtual sobject for placeholder, we can put more than 1 maybe?
        sobject = SearchType.create('sthpw/note')

        edit_config = my._get_edit_config('edit', selected_process_names)
        edit_configs = {'sthpw/note': edit_config}
        Container.put("CellEditWdg:configs", edit_configs)

        table = TableLayoutWdg(table_id=table_id,
                               search_type='sthpw/note',
                               view='table',
                               config=main_config_view,
                               aux_info={
                                   'sobjects': sobject_dict,
                                   'parent': my.parent
                               },
                               mode="simple",
                               show_row_select=False,
                               show_insert=False,
                               show_commit_all=True,
                               show_refresh='false',
                               state={'parent_key': my.search_key})
        table.set_sobject(sobject)

        top.add(table)

        return super(NoteSheetWdg, my).get_display()
Esempio n. 8
0
    def get_display(my):


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

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

        button = SingleButtonWdg(title="Advanced Security", icon=IconWdg.LOCK)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.startup.SecurityWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("Security", "Security", class_name)
            '''
        } )



        button = SingleButtonWdg(title="Add", tip="Add New User", icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        top.add("<br clear='all'/>")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.panel.EditWdg';
            var kwargs = {
                search_type: "sthpw/login",
                view: "edit",
            }
            var popup = spt.panel.load_popup("Create New User", class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_panel_user_top");
            popup.on_save_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )




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

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

            return top




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


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


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




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





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

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

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

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

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

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

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

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

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


                '''
            } )

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

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

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

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




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

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

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

                '''
            } )

        return top
Esempio n. 9
0
    def get_display(my):

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

        title = DivWdg()
        title.add("Advanced Project Setup Tools")
        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 10px -10px")

        top.add(title)
        from tactic.ui.widget import TitleWdg
        subtitle = TitleWdg(name_of_title='',
                            help_alias='project-startup-configuration')
        top.add(subtitle)

        title.add_gradient("background", "background3", 5, -10)
        top.add("<br/>")

        content = DivWdg()
        top.add(content)
        """
        desc = DivWdg()
        content.add(desc)
        desc.add_style("text-align: left")
        desc.add_style("padding-left: 15px")
        desc.center()
        desc.add("The following tools are used for advanced project configuration.<br/><br/>")
        desc.add_style("width: 600px")
        """

        button_div = DivWdg()
        button = SingleButtonWdg(title="Project Startup", icon=IconWdg.HOME)
        button_div.add(button)
        button_div.add_style("float: left")
        button_div.add_style("margin-top: -10px")
        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: 'project-startup-configuration'
            };
            spt.tab.add_new("_startup", "Startup", class_name, kwargs);
        
            '''
        })
        content.add(button_div)

        table = Table()
        content.add(table)
        table.add_color("color", "color")
        table.add_row()
        table.center()

        # Schema Editor
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Create Schema"

        description = '''The schema is a collection of nodes that layout the basic components of a project. Each node represents a separate list of items (sType) used in this project: ie Assets, Shots, Artwork, etc.'''

        #image = "<img src='/context/icons/64x64/schema_64.png'/>"
        image = "<img src='/context/images/getting_started_schema.png'/>"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.tools.SchemaToolWdg';
        var kwargs = {
            help_alias: 'project-schema'    
        };
        spt.tab.add_new("create_schema", "Create Schema", class_name, kwargs);
        '''
        }
        schema_wdg = my.get_main_section_wdg(title, description, image,
                                             behavior)
        td.add(schema_wdg)

        # Workflow
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Create Workflow"
        image = "<img src='/context/images/getting_started_pipeline.png'/>"

        description = "Pipelines define how particular items of an sType will move through its lifecycle. Creating pipelines will also allow you to set up automatic triggers and notifications for each process."

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.tools.PipelineToolWdg';
        var kwargs = {
            help_alias: 'project-workflow'
        };
        spt.tab.add_new("create_workflow", "Create Workflow", class_name, kwargs);
        '''
        }
        pipeline_wdg = my.get_main_section_wdg(title, description, image,
                                               behavior)
        td.add(pipeline_wdg)

        # Sidebar
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Side Bar"

        #image = "<img src='/context/icons/64x64/sidebar_64.png'/>"
        image = "<img src='/context/images/getting_started_sidebar.png'/>"

        description = "The Side Bar can be easily configured to show specific views of your project to each user."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ManageViewPanelWdg';
        var kwargs = {
            help_alias: 'managing-sidebar'
        };
        spt.tab.add_new("manage_project_views", "Manage Side Bar", class_name, kwargs);
        '''
        }

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

        tr = table.add_row()

        # Manage View
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Views"

        image = IconWdg("Manage Views", IconWdg.LIST_01)
        div = DivWdg(image)
        image = div

        description = "Manage the views within the project."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.manager.ViewManagerWdg';
        var kwargs = {
            help_alias: 'view-manager'
            };
        spt.tab.add_new("manage_views", "Manage Views", class_name, kwargs);
        '''
        }

        manage_view_wdg = my.get_small_section_wdg(title, description, image,
                                                   behavior)
        td.add(manage_view_wdg)

        # Naming Conventions
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Naming Conventions"

        image = IconWdg("Naming Conventions", IconWdg.FOLDERS_01)
        div = DivWdg(image)
        image = div

        description = "Setup custom Directory and File naming conventions."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'config/naming',
            help_alias: 'project-automation-file-naming'
	};
        spt.tab.add_new("naming_conventions", "Naming Conventions", class_name, kwargs);
        '''
        }

        naming_wdg = my.get_small_section_wdg(title, description, image,
                                              behavior)
        td.add(naming_wdg)

        # Users
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Security"

        image = IconWdg("Manage Security", IconWdg.LOCK_32_01)
        div = DivWdg(image)
        image = div

        description = "Manage users and group permissions"
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.SecurityWdg';
        var kwargs = { };
        spt.tab.add_new("manage_security", "Manage Security", class_name, kwargs);

        '''
        }

        users_wdg = my.get_small_section_wdg(title, description, image,
                                             behavior)
        td.add(users_wdg)

        tr = table.add_row()

        # Script Editor
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Script Editor"

        image = IconWdg("Script Editor", IconWdg.SCRIPT_EDITOR_01)
        div = DivWdg(image)
        image = div

        description = "Edit and Create custom Python and Javascipt tools, triggers and scripts."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        
	var title = "TACTIC Script Editor"
	var class_name = "tactic.ui.app.ShelfEditWdg"
        spt.panel.load_popup(title, class_name, {}, {"load_once": true} )
        
        '''
        }

        script_editor_wdg = my.get_small_section_wdg(title, description, image,
                                                     behavior)
        td.add(script_editor_wdg)

        # Project Settings
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Project Settings"

        image = IconWdg("Project Settings", IconWdg.CONFIGURE_02)
        div = DivWdg(image)
        image = div

        description = "Setting for the current project."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'config/prod_setting',
            help_alias: 'main'            
	};
        spt.tab.add_new("project_settings", "Project Settings", class_name, kwargs);
        '''
        }

        prod_settings_wdg = my.get_small_section_wdg(title, description, image,
                                                     behavior)
        td.add(prod_settings_wdg)

        # Widget Config
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Widget Config"

        image = IconWdg("Widget Config", IconWdg.WIDGET_CONFIG_01)
        div = DivWdg(image)
        image = div

        description = "Modify the base widget configurations for the project."
        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'config/widget_config',
            help_alias: 'tactic-widgets'
	};
        spt.tab.add_new("widget_config", "Widget Config", class_name, kwargs);
        '''
        }

        config_wdg = my.get_small_section_wdg(title, description, image,
                                              behavior)
        td.add(config_wdg)

        # Quicklinks

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

        div = DivWdg()
        title = DivWdg()
        div.add(title)
        div.add_color("background", "background")
        div.add_style("margin: 0px 10px 15px 10px")

        title.add("Quick Links")
        title.add_style("font-size: 16px")
        title.add_style("padding: 5px")
        title.add_gradient("background", "background")
        title.add_border()
        title.set_round_corners(corners=['TL', 'TR'])

        content_wdg = DivWdg()
        div.add(content_wdg)
        content_wdg.add_border()
        content_wdg.add_style("padding: 20px")

        content_wdg.add(
            "<div style='font-size: 12px'>The following links will help you find out more information on how to set up or use TACTIC.</div>"
        )
        content_wdg.add("<hr/>")

        hover = title.get_color("background", -10)

        link_div = DivWdg()
        link_div.add_style("padding: 10px")
        content_wdg.add(link_div)
        icon = IconWdg("TACTIC Documentation", IconWdg.JUMP)
        link_div.add(icon)

        link = HtmlElement.href("TACTIC Documentation",
                                "/doc/",
                                target="_blank")
        link.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.help.set_top();
            spt.help.load_alias("main");
            '''
        })

        link.add_behavior({
            'type':
            'hover',
            'color':
            hover,
            'cbjs_action_over':
            '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
            'cbjs_action_out':
            '''
        bvr.src_el.setStyle("background", "");
        '''
        })
        link_div.add(link)
        link.add_color("color", "color")
        link_div.add("<br/>" * 2)

        icon = IconWdg("Southpaw Web Site", IconWdg.JUMP)
        link_div.add(icon)
        link = HtmlElement.href("Southpaw Web Site",
                                "http://www.southpawtech.com",
                                target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link.add_behavior({
            'type':
            'hover',
            'color':
            hover,
            'cbjs_action_over':
            '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
            'cbjs_action_out':
            '''
        bvr.src_el.setStyle("background", "");
        '''
        })

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

        icon = IconWdg("TACTIC Community", IconWdg.JUMP)
        link_div.add(icon)
        link = HtmlElement.href("TACTIC Community",
                                "http://community.southpawtech.com",
                                target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link.add_behavior({
            'type':
            'hover',
            'color':
            hover,
            'cbjs_action_over':
            '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
            'cbjs_action_out':
            '''
        bvr.src_el.setStyle("background", "");
        '''
        })

        td.add(div)

        return top
Esempio n. 10
0
    def get_display(my):

        web = WebContainer.get_web()

        
        tactic_header = Table()
        tactic_header.add_row()
        tactic_header.add_color("color", "color2")


        # tactic logo and release info
        skin = web.get_skin()
        src = '/context/skins/' + skin + '/images/tactic_logo.png'
        img = HtmlElement.img(src)
        img.add_class('hand')
        img.add_attr('title', 'Go to home page')
        img.add_behavior({'type': 'click_up', 'cbjs_action': "window.location='/tactic/'"})

        rel_div = DivWdg()
        rel_div.add("&nbsp;"*3)
        rel_div.add("Release: %s" %Environment.get_release_version() )
        rel_div.add_style("font-size: 9px")
        # Need this to override the above color in add_looks
        rel_div.add_color("color", "color2")

        tactic_wdg = Table()

        tactic_wdg.add_style("width: 180px")
        tactic_wdg.add_row()
        td = tactic_wdg.add_cell( img )
        td.set_style("width:100px")
        tactic_wdg.add_row()
        td = tactic_wdg.add_cell( rel_div )
        td.set_style("text-align: left") 

        td = tactic_header.add_cell( tactic_wdg )
       
        # add the project thumb and title
        project = Project.get()

        if my.show_project:
            thumb_div = DivWdg()
            td = tactic_header.add_cell( thumb_div )
            thumb_div.add_style("height: 28px")
            thumb_div.add_style("overflow: hidden")
            thumb_div.add_border(modifier=-10)
            thumb_div.add_style("-moz-border-radius: 3px")

            thumb = ThumbWdg()
            thumb_div.add(thumb)
            thumb.set_sobject(project)
            thumb.set_icon_size("45")
            td.set_style("vertical-align: top; padding-right:14px;padding-left: 3px")

            td = tactic_header.add_cell( project.get_value("title") )
            #td.add_looks( "fnt_title_1" )
            td.add_style("font-size: 20px")
            td.add_style("white-space: nowrap")
            td.add_style("padding-left: 14px")

            # project selection 
            td = tactic_header.add_cell()
            project_div = DivWdg()
            project_div.add_style("margin-top: -5px")
            project_div.add(ProjectSelectWdg() )
            td.add( project_div )
            td.set_style("padding-left: 14px")
             

            # Global Actions Gear Menu (contains links to Documentation) ...
            action_bar_btn_dd = PageHeaderGearMenuWdg()
            action_div = DivWdg(action_bar_btn_dd)
            action_div.add_style("margin-top: -5px")
            td = tactic_header.add_cell( action_div )

            if PrefSetting.get_value_by_key('subscription_bar') == 'true':
                from message_wdg import SubscriptionBarWdg
                sub = SubscriptionBarWdg(mode='popup')
                tactic_header.add_cell(sub)

        # user login

        # user
        user = Environment.get_login()
        full_name = user.get_full_name()
        user_div = SpanWdg( HtmlElement.b( "%s&nbsp;&nbsp;" % full_name) , css='hand')       
        user_div.set_style("padding-right:10px")

        # signout
        login = Environment.get_security().get_login()
        search_key = SearchKey.get_by_sobject(login)
        span = SpanWdg()
        span.add( user_div )
        user_div.add_attr('spt_nudge_menu_vert', '20')
       
        td = tactic_header.add_cell(span)       
        td.set_style("width:100%; text-align:right; white-space: nowrap")



        from tactic.ui.widget import SingleButtonWdg
        button = SingleButtonWdg(title='My Account', icon=IconWdg.USER, show_arrow=True)
        button_div = DivWdg(button)
        button_div.add_style("margin-top: -5px")
        button.add_attr('spt_nudge_menu_horiz', '-80')
        button.add_attr('spt_nudge_menu_vert', '10')

        td = tactic_header.add_cell(button_div)
    

        menus = my.get_smart_menu()
        # TODO: this part seems redundant to attach to both
        SmartMenu.add_smart_menu_set(user_div, [menus])
        SmartMenu.assign_as_local_activator(user_div, None, True)

        SmartMenu.add_smart_menu_set(button, [menus])
        SmartMenu.assign_as_local_activator(button, None, True)

   


        td.set_style("width:100%;")
        button = SingleButtonWdg(title='Help', icon=IconWdg.HELP_BUTTON, show_arrow=False)
        #button.add_behavior( {
        #'type': 'click_up',
        #'cbjs_action': '''
        #window.open("/doc/")
        #'''
        #} )

        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.named_events.fire_event("show_help")
        '''
        } )


        from tactic.ui.container import DialogWdg
        help_dialog = DialogWdg(z_index=900, show_pointer=False)
        td.add(help_dialog)
        help_dialog.add_title("Help")
        help_dialog.add_class("spt_help")


        # container for help
        help_div = DivWdg()
        help_dialog.add(help_div)

        from help_wdg import HelpWdg
        help_wdg = HelpWdg()
        help_div.add(help_wdg)


        button_div = DivWdg(button)
        button_div.add_style("margin-top: -5px")
        td = tactic_header.add_cell(button_div)
        td.set_style("width:100%; text-align:right; white-space: nowrap")


        # Layout the Main Header Table
        main_div = DivWdg()

        # TEST: NEW LAYOUT
        if Config.get_value("install", "layout") == "fixed":
            main_div.add_style("position: fixed")
            main_div.add_style("z-index: 100")
            main_div.add_style("width: 100%")

        license = Environment.get_security().get_license()

        if not license.is_licensed():
            from tactic.ui.app import LicenseManagerWdg
            license_manager = LicenseManagerWdg(use_popup=True)
            main_div.add(license_manager)

        

        # create the header table
        tactic_header_div = DivWdg()
        tactic_header_div.add(tactic_header)
        tactic_header_div.add_gradient("background", "background2", 10, -10)

        main_div.add(tactic_header_div)

        main_div.add( my.get_js_popup() )


        """
        main_div.add( HelpPopupWdg() )

        # FIXME: is this even used at all?
        action_bar_popup = PopupWdg( id="ActionBarWdg_popup", allow_page_activity=True, width="636px" )
        action_bar_popup.add_title( "TACTIC&trade; Action Bar" )
        action_bar_popup.add( ActionBarWdg() )
        main_div.add( action_bar_popup )
        """

        # FIXME(?): does this CommonPopup need to be at z_start=300? By default popups will be at z_start=200
        popup = PopupWdg( id="CommonPopup", allow_page_activity=True, width="600px", z_start=300 )
        popup.add('Tools', 'title')

        main_div.add( popup )

        
        return main_div
Esempio n. 11
0
    def get_display(my):

        top = my.top

        button_div = DivWdg()
        top.add(button_div)
        button_div.add_class("spt_buttons_top")
        button_div.add_border()

        button_div.add_style("margin-bottom: 0px")
        button_div.add_style("width: 1200px")
        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);

            '''
        } )


        top_class = my.kwargs.get("top_class")
        list_class = my.kwargs.get("list_class")
        height = my.kwargs.get("height")
        assert(top_class)
        assert(list_class)
        assert(height)

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

        button.add_behavior( {
            'type': 'click_up',
            'top_class': top_class,
            'list_class': list_class,
            'height': height,
            'cbjs_action': '''
            var top = bvr.src_el.getParent("."+bvr.top_class);
            var element = top.getElement("."+bvr.list_class);

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            expand = buttons.getElement(".spt_expand");
            new Fx.Tween(element).start('margin-top', "-"+bvr.height+"px");
            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")
        top.add(button_div)
        button.add_style("float: left")
        button.add_behavior( {
            'type': 'click_up',
            'top_class': top_class,
            'list_class': list_class,
            'cbjs_action': '''
            var top = bvr.src_el.getParent("."+bvr.top_class);
            var element = top.getElement("."+bvr.list_class);

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

        return top
Esempio n. 12
0
    def get_display(my):

        top = my.top

        #help_div = DivWdg()
        help_div = top
        #top.add(help_div)
        help_div.add_class("spt_help_top")
        help_div.set_id("spt_help_top")

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

        if show_title:
            title_wdg = DivWdg()
            help_div.add(title_wdg)
            title_wdg.add_style("font-size: 12px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_gradient("background", "background", 0, -20)
            title_wdg.add_style("padding: 3px")
            #title_wdg.add_style("margin-top: 8px")
            title_wdg.add_style("margin-bottom: 5px")
            title_wdg.add_style("height: 26px")
            title_wdg.add_style("padding: 6 0 0 6")
            title_wdg.set_round_corners(corners=['TL','TR'])

            icon = IconWdg("Close", IconWdg.KILL)
            title_wdg.add(icon)
            icon.add_style("float: right")
            title_wdg.add("Help")



        help_div.set_round_corners()
        help_div.add_color("color", "color2")
        help_div.add_color("background", "background")
        help_div.add_border()



        shelf_div = DivWdg()
        help_div.add(shelf_div)
        shelf_div.add_style("padding: 5px")
        shelf_div.add_gradient("background", "background")
        shelf_div.add_style("height: 25px")

        from tactic.ui.widget import SingleButtonWdg

        button = SingleButtonWdg(title="Documentation Main Page", icon=IconWdg.HOME)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_alias("main")
        '''
        } )




        button = SingleButtonWdg(title="Edit Help", icon=IconWdg.EDIT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.app.HelpEditWdg';

        var element_name = spt.help.get_view();
        if (!element_name) {
          element_name = "default";
        }
        var kwargs = {
          view: element_name
        }

        spt.tab.add_new("help_edit", "Help Edit", class_name, kwargs);
            
        '''
        } )



        button = SingleButtonWdg(title="Go Back One Page", icon=IconWdg.ARROW_LEFT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_prev();
        '''
        } )

        button = SingleButtonWdg(title="Go Forward One Page", icon=IconWdg.ARROW_RIGHT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_next();
        '''
        } )



        button = SingleButtonWdg(title="Documentation Downloads", icon=IconWdg.DOWNLOAD)
        shelf_div.add(button)
        button.add_style("float: right")
        button.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.help.set_top();
        spt.help.load_alias("pdf")
        '''
        } )


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



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


        help_div.add_behavior( {
        'type': 'listen',
        'event_name': 'tab|select',
        'cbjs_action': '''

        var content = bvr.src_el.getElement(".spt_help_content");
        var options = bvr.firing_data;
        var element_name = options.element_name;
        var alias = options.alias;

        if (!alias) {
            alias = options.element_name;
        }

        spt.help.set_top();
        if (spt.help.is_visible()) {
            spt.help.load_alias(alias);
        }
        else {
            spt.help.set_view(alias);
        }
        '''

        } )


        help_div.add_behavior( {
        'type': 'listen',
        'event_name': 'show_help',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_help");
        var content = top.getElement(".spt_help_content");
        var firing_data = bvr.firing_data;
        var class_name = firing_data.class_name;
        if (!class_name) {
            class_name = 'tactic.ui.app.HelpContentWdg';
        }

        if (top.getStyle("display") != 'none') {
            spt.hide(top);
            return;
        }

        spt.help.set_top()

        // get the help view
        var help_view = spt.help.get_view();
        var html = firing_data.html;
        if (html) {
            spt.help.load_html(html);    
        }
        else {
            if (!help_view) {
                help_view = 'default'    
            }
            spt.help.load_alias(help_view);
        }

        var size = $(window).getSize();

        var dialog = bvr.src_el.getParent(".spt_dialog_content");

        dialog.setStyle("height", size.y - 100);
        dialog.setStyle("width", 650);

        var top = bvr.src_el.getParent(".spt_dialog_top");
        top.setStyle("left", size.x - 660);
        top.setStyle("top", 40);

        spt.show(top);
        '''
        } )






        content = DivWdg()
        help_div.add(content)
        content.add_class("spt_help_content");
        content.add_style("overflow_x: auto")
        content.add_style("overflow_y: auto")
        content.add_style("margin-bottom: 10px")
        #content.add_style("border: solid 1px blue")
        content.add_style("height: 98%")


        #key = "schema_editor"
        #search = Search("config/doc")
        #search.add_filter("code", key)
        #doc = search.get_sobject()
        #doc_html = doc.get_value("doc")
        #help_div.add(doc_html)


        return top
Esempio n. 13
0
    def get_display(self):
        if self.is_refresh:
            top = Widget()
            self.add(top)
        else:
            container = DivWdg()
            self.add(container)
            #parent = SearchKey.get_by_search_key(self.search_key)
            top = DivWdg()
            container.add(top)
            self.set_as_panel(top)
            top.add_style("margin-top: -2px")
            
            top.add_class("spt_uber_notes_top")


        from tactic.ui.app import HelpButtonWdg
        help_button = HelpButtonWdg(alias="note-sheet-widget")
        top.add(help_button)
        help_button.add_style("float: right")

        table_id = 'sub_table'
        view = 'table'
        span = DivWdg(css='spt_input_group')
        top.add(span)

        span.add_border()
        span.add_style("height: 27px")
        span.add_style("padding: 5px")

        button_div = DivWdg()
        span.add(button_div)
        button_div.add_style("float: left")
        button_div.add_style("margin-right: 10px")


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

        from tactic.ui.widget import SingleButtonWdg
        refresh = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
        table.add_cell(refresh)
        refresh.add_style("float: left")
        refresh.add_behavior({
        'type': 'click_up',
        'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var tbody = top.getElements('.spt_table_tbody')[2];
            var values = spt.api.Utility.get_input_values(tbody);
            spt.panel.refresh(top, values, false);
        '''
        }) 


        save = SingleButtonWdg(title="Save", icon=IconWdg.SAVE)
        table.add_cell(save)
        save.add_style("float: left")
        save.add_behavior( {
            'type': 'click_up',
            'update_current_only': True,
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var table = top.getElement(".spt_table");
            bvr.src_el = table;
            spt.dg_table.update_row(evt, bvr)
            '''
        })


        process = SingleButtonWdg(title="Show Processes", icon=IconWdg.PROCESS, show_arrow=True)
        table.add_cell(process)

        from tactic.ui.container import DialogWdg
        process_dialog = DialogWdg(display=False)
        span.add(process_dialog)
        process_dialog.set_as_activator(process)
        process_dialog.add_title("Processes")

        process_div = DivWdg()
        process_dialog.add(process_div)
        #process_div.add_style("padding: 5px")
        process_div.add_color("background", "background")
        process_div.add_color("color", "color")
        process_div.add_border()

        refresh = ActionButtonWdg(title="Refresh")
        refresh.add_style('margin: 0 auto 10px auto')
        process_div.add(refresh)
        refresh.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_uber_notes_top");
            var tbody = top.getElements('.spt_table_tbody')[2];
            var values = spt.api.Utility.get_input_values(tbody);
            spt.panel.refresh(top, values, false);
        '''
        } )
        process_div.add("<hr/>")


        selected_process_names = []
        step = 0
        
        for idx, value in enumerate(self.process_names):
            checkbox_name = 'note_process_cb'
            if self.child_mode:
                selected_process_names.append(value)
                #break
            cb = CheckboxWdg(checkbox_name, label=value)

           
            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.set_option('value', value)
            #cb.set_persistence()

            cb.add_behavior({
                'type': 'click_up',
                'cbjs_action': '''
                    spt.input.save_selected(bvr, '%s','%s');
                ''' % (checkbox_name, key)
            }) 

            # only 1 is selected in child_mode
            if cb.is_checked():
                selected_process_names.append(value)


            if idx == 0 or idx == 10 * step:
                # add a new inner div
                inner_div = self._get_inner_div()
                process_div.add(inner_div, 'inner%s'%step)
                step += 1
                
            inner_div.add(cb)

            inner_div.add("<br/>")
            

        # if less than 10, make it wider
        if len(self.process_names) < 10:
            inner_div.add_style('width: 100px')

        # add a master private checkbox
        if not self.child_mode:
            checkbox_name = 'note_master_private_cb'
            cb = CheckboxWdg(checkbox_name, label='make notes private')
            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.add_behavior({ 
                'type': 'click_up',
                'propagate_evt': True,
                'cbjs_action': '''
                    var top = bvr.src_el.getParent(".spt_uber_notes_top");
                    var tbody = top.getElements('.spt_table_tbody')[2];
                    var inputs = spt.api.Utility.get_inputs(tbody,'is_private');
                    for (var i = 0; i < inputs.length; i++)
                        inputs[i].checked = bvr.src_el.checked;
                    spt.input.save_selected(bvr, '%s','%s');
                    '''%(checkbox_name, key)
                    })

            cb_span = DivWdg(cb, css='small')
            cb_span.add_styles('border-left: 1px dotted #bbb; margin-left: 10px')
            span.add(cb_span)

        main_config_view = self._get_main_config(view, selected_process_names)
        
        sobject_dict = {}

        # TODO: do a union all search or by order number = 1
        for value in selected_process_names:
            search = Search('sthpw/note')
            search.add_filter('project_code', Project.get_project_code())
            search.add_filter('context', value)
            search.add_filter('search_type',self.parent_search_type)
            search.add_filter('search_id',self.parent_search_id)
            search.add_order_by('timestamp desc')
            search.add_limit(1)
            sobject = search.get_sobject()
            if sobject:
                sobject_dict[value] = sobject
        #sobjects = search.get_sobjects()
        # virtual sobject for placeholder, we can put more than 1 maybe?
        sobject = SearchType.create('sthpw/note')

        edit_config = self._get_edit_config('edit', selected_process_names)
        edit_configs = {'sthpw/note': edit_config}
        Container.put("CellEditWdg:configs", edit_configs)

        table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view='table',
            config=main_config_view, aux_info={'sobjects': sobject_dict, 'parent': self.parent}, mode="simple", show_row_select=False, show_insert=False, show_commit_all=True, show_refresh='false', state={'parent_key': self.search_key} )
        table.set_sobject(sobject)

        top.add(table)


        return super(NoteSheetWdg, self).get_display()
Esempio n. 14
0
    def get_shelf_wdg(self):

        process = self.get_value("process")
        versions = self.get_value("versions")

        div = DivWdg()

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

        button = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
        filter_table.add_cell(button)
        filter_table.add_cell("&nbsp;" * 5)
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.panel.refresh(bvr.src_el);
            '''
        })

        # get all of the pipelnes for this search type
        pipeline_code = self.sobject.get_value("pipeline_code",
                                               no_exception=True)
        processes = []
        if pipeline_code:
            pipeline = Pipeline.get_by_code(pipeline_code)
            if pipeline:
                process_names = pipeline.get_process_names()
                processes.extend(process_names)

        processes.insert(0, "all")

        filter_table.add_cell("Process: ")
        select = SelectWdg("process")
        select.add_style("width: 200px")
        if process != 'all':
            select.set_value(process)

        select.set_option("values", processes)

        filter_table.add_cell(select)

        filter_table.add_cell("&nbsp;" * 10)

        filter_table.add_cell("Versions: ")
        select = SelectWdg("versions")
        select.add_style("width: 200px")
        select.set_option("values", "latest|current|today|last 10|all")
        if versions:
            select.set_value(versions)
        filter_table.add_cell(select)

        asset_dir = Environment.get_asset_dir()

        select = IconButtonWdg(tip="Toggle Selection",
                               icon=IconWdg.SELECT,
                               show_arrow=False)
        div.add(select)
        select.add_style("float: right")
        select.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top_class = 'spt_sobject_dir_list_top'
            var toggle_state = bvr.src_el.getAttribute('toggle');
            if (toggle_state && toggle_state=='true')
                bvr.src_el.setAttribute('toggle','false');
            else
                bvr.src_el.setAttribute('toggle','true');

            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            
            toggle_state = bvr.src_el.getAttribute('toggle');
            if (toggle_state == 'true')
                spt.selection.select_all_items();
            else
                spt.selection.unselect_all_items();

            '''
        })

        show = IconButtonWdg(tip="Switch View",
                             icon=IconWdg.VIEW,
                             show_arrow=False)
        div.add(show)
        show.add_style("float: right")
        show.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top_class = 'spt_sobject_dir_list_top'
            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            var els = top.getElements(".spt_file_dir_item");
            for (var i = 0; i < els.length; i++) {
                var el = els[i];
                if (el.getStyle("display") == "none") {
                    els[i].setStyle("display", "");
                }
                else {
                    els[i].setStyle("display", "none");
                }
            }
            var els = top.getElements(".spt_file_item");
            for (var i = 0; i < els.length; i++) {
                var el = els[i];
                if (el.getStyle("padding-left") == "6px") {
                    var padding = el.getAttribute("spt_padding_left");
                    el.setStyle("padding-left", padding);
                }
                else {
                    el.setStyle("padding-left", "6px");
                }

            }


            '''
        })

        gear = IconButtonWdg(tip="Download",
                             icon=IconWdg.DOWNLOAD,
                             show_arrow=False)
        div.add(gear)
        gear.add_style("float: right")
        gear.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            spt.app_busy.show('Select a folder to download to...','');
            var top_class = 'spt_sobject_dir_list_top';
            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            var items = spt.selection.get_selected();
            
       
            setTimeout( function() {
                var applet = spt.Applet.get();
                var select_dir =true;
                var dir = applet.open_file_browser('', select_dir);
                if (dir.length == 0)
                    dir = applet.get_current_dir();
                else 
                    dir = dir[0];

                if (!dir) {
                    spt.alert("No folder selected to copy to.");
                    spt.app_busy.hide();
                    return;
                }
                if (items.length == 0){
                    spt.alert("Please select at least one file to download.");
                    spt.app_busy.hide();
                    return;
                }
                

                var asset_dir = '%s';
                for (var i = 0; i < items.length; i++) {
                    var path = items[i].getAttribute("spt_path");
                    var env = spt.Environment.get();
                    var server_url = env.get_server_url();
                    var url = server_url + "/assets/" + path.replace(asset_dir, "");
                    var parts = path.split("/");
                    var filename = parts[parts.length-1];
                    spt.app_busy.show("Downloading file", filename);
                    applet.download_file(url, dir + "/" + filename);
                }
                spt.app_busy.hide();
                if (dir)
                    spt.notify.show_message("Download to '" + dir + "' completed.")
            }, 100);

            ''' % asset_dir
        })

        return div
Esempio n. 15
0
    def get_display(my):

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


        title = DivWdg()
        title.add("Advanced Project Setup Tools")
        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 10px -10px")

        top.add(title)
        from tactic.ui.widget import TitleWdg
        subtitle = TitleWdg(name_of_title='',help_alias='project-startup-configuration')
        top.add(subtitle)

        title.add_gradient("background", "background3", 5, -10)
        top.add("<br/>")


        content = DivWdg()
        top.add(content)

	

        """
        desc = DivWdg()
        content.add(desc)
        desc.add_style("text-align: left")
        desc.add_style("padding-left: 15px")
        desc.center()
        desc.add("The following tools are used for advanced project configuration.<br/><br/>")
        desc.add_style("width: 600px")
        """

        button_div = DivWdg()
        button = SingleButtonWdg(title="Project Startup", icon=IconWdg.HOME)
        button_div.add(button)
        button_div.add_style("float: left")
	button_div.add_style("margin-top: -10px")
        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: 'project-startup-configuration'
            };
            spt.tab.add_new("_startup", "Startup", class_name, kwargs);
        
            '''
        }) 
        content.add(button_div)

        table = Table()
        content.add(table)
        table.add_color("color", "color")
        table.add_row()
        table.center()



        # Schema Editor
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Create Schema"

        description = '''The schema is a collection of nodes that layout the basic components of a project. Each node represents a separate list of items (sType) used in this project: ie Assets, Shots, Artwork, etc.'''

	#image = "<img src='/context/icons/64x64/schema_64.png'/>"
	image = "<img src='/context/images/getting_started_schema.png'/>"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.tools.SchemaToolWdg';
        var kwargs = {
            help_alias: 'project-schema'    
        };
        spt.tab.add_new("create_schema", "Create Schema", class_name, kwargs);
        '''
        }
        schema_wdg = my.get_main_section_wdg(title, description, image, behavior)
        td.add(schema_wdg)


        # Workflow
        td = table.add_cell()
        td.add_style("vertical-align: top")
        td.add_style("padding: 3px")
        title = "Create Workflow"
        image = "<img src='/context/images/getting_started_pipeline.png'/>"

        description = "Pipelines define how particular items of an sType will move through its lifecycle. Creating pipelines will also allow you to set up automatic triggers and notifications for each process."

        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.tools.PipelineToolWdg';
        var kwargs = {
            help_alias: 'project-workflow'
        };
        spt.tab.add_new("create_workflow", "Create Workflow", class_name, kwargs);
        '''
        }
        pipeline_wdg = my.get_main_section_wdg(title, description, image, behavior)
        td.add(pipeline_wdg)


        # Sidebar
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Side Bar"

	#image = "<img src='/context/icons/64x64/sidebar_64.png'/>"
        image = "<img src='/context/images/getting_started_sidebar.png'/>"

	description = "The Side Bar can be easily configured to show specific views of your project to each user."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ManageViewPanelWdg';
        var kwargs = {
            help_alias: 'managing-sidebar'
        };
        spt.tab.add_new("manage_project_views", "Manage Side Bar", class_name, kwargs);
        '''
        }

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


 
        tr = table.add_row()

        # Manage View
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Views"

        image = IconWdg("Manage Views", IconWdg.LIST_01)
        div = DivWdg(image)
        image = div

        description = "Manage the views within the project."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.manager.ViewManagerWdg';
        var kwargs = {
            help_alias: 'view-manager'
            };
        spt.tab.add_new("manage_views", "Manage Views", class_name, kwargs);
        '''
        }

        manage_view_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(manage_view_wdg)



        # Naming Conventions
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Naming Conventions"

        image = IconWdg("Naming Conventions", IconWdg.FOLDERS_01)
        div = DivWdg(image)
        image = div

        description = "Setup custom Directory and File naming conventions."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'config/naming',
            help_alias: 'project-automation-file-naming'
	};
        spt.tab.add_new("naming_conventions", "Naming Conventions", class_name, kwargs);
        '''
        }

        naming_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(naming_wdg)




        # Users
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Manage Security"

        image = IconWdg("Manage Security", IconWdg.LOCK_32_01)
        div = DivWdg(image)
        image = div

        description = "Manage users and group permissions"
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.startup.SecurityWdg';
        var kwargs = { };
        spt.tab.add_new("manage_security", "Manage Security", class_name, kwargs);

        '''
        }

        users_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(users_wdg)


        tr = table.add_row()




        # Script Editor 
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Script Editor"

        image = IconWdg("Script Editor", IconWdg.SCRIPT_EDITOR_01)
        div = DivWdg(image)
        image = div

        description = "Edit and Create custom Python and Javascipt tools, triggers and scripts."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        
	var title = "TACTIC Script Editor"
	var class_name = "tactic.ui.app.ShelfEditWdg"
        spt.panel.load_popup(title, class_name, {}, {"load_once": true} )
        
        '''
        }

        script_editor_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(script_editor_wdg)




        # Project Settings
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Project Settings"

        image = IconWdg("Project Settings", IconWdg.CONFIGURE_02)
        div = DivWdg(image)
        image = div

        description = "Setting for the current project."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'prod/prod_setting',
            help_alias: 'main'            
	};
        spt.tab.add_new("project_settings", "Project Settings", class_name, kwargs);
        '''
        }

        prod_settings_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(prod_settings_wdg)


        # Widget Config
        td = table.add_cell()
        td.add_style("padding: 3px")
        td.add_style("vertical-align: top")
        title = "Widget Config"

        image = IconWdg("Widget Config", IconWdg.WIDGET_CONFIG_01)
        div = DivWdg(image)
        image = div

        description = "Modify the base widget configurations for the project."
        behavior = {
        'type': 'click_up',
        'cbjs_action': '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.panel.ViewPanelWdg';
        var kwargs = {
	    'view': 'table',
            'search_type': 'config/widget_config',
            help_alias: 'tactic-widgets'
	};
        spt.tab.add_new("widget_config", "Widget Config", class_name, kwargs);
        '''
        }

        config_wdg = my.get_small_section_wdg(title, description, image, behavior)
        td.add(config_wdg)



        # Quicklinks

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


        div = DivWdg()
        title = DivWdg()
        div.add(title)
        div.add_color("background", "background")
        div.add_style("margin: 0px 10px 15px 10px")


        title.add("Quick Links")
        title.add_style("font-size: 16px")
        title.add_style("padding: 5px")
        title.add_gradient("background", "background")
        title.add_border()
        title.set_round_corners(corners=['TL','TR'])

        content_wdg = DivWdg()
        div.add(content_wdg)
        content_wdg.add_border()
        content_wdg.add_style("padding: 20px")

        content_wdg.add("<div style='font-size: 12px'>The following links will help you find out more information on how to set up or use TACTIC.</div>")
        content_wdg.add("<hr/>")

        hover = title.get_color("background", -10)


        link_div = DivWdg()
        link_div.add_style("padding: 10px")
        content_wdg.add(link_div)
        icon = IconWdg("TACTIC Documentation", IconWdg.JUMP)
        link_div.add(icon)

        link = HtmlElement.href("TACTIC Documentation", "/doc/", target="_blank")
        link.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.help.set_top();
            spt.help.load_alias("main");
            '''
        } )

        link.add_behavior( {
        'type': 'hover',
        'color': hover,
        'cbjs_action_over': '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
        'cbjs_action_out': '''
        bvr.src_el.setStyle("background", "");
        '''
        } )
        link_div.add(link)
        link.add_color("color", "color")
        link_div.add("<br/>"*2)

        icon = IconWdg("Southpaw Web Site", IconWdg.JUMP)
        link_div.add(icon)
        link = HtmlElement.href("Southpaw Web Site", "http://www.southpawtech.com", target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link.add_behavior( {
        'type': 'hover',
        'color': hover,
        'cbjs_action_over': '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
        'cbjs_action_out': '''
        bvr.src_el.setStyle("background", "");
        '''
        } )


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


        icon = IconWdg("TACTIC Community", IconWdg.JUMP)
        link_div.add(icon)
        link = HtmlElement.href("TACTIC Community", "http://community.southpawtech.com", target="_blank")
        link_div.add(link)
        link.add_color("color", "color")
        link.add_behavior( {
        'type': 'hover',
        'color': hover,
        'cbjs_action_over': '''
        bvr.src_el.setStyle("background", bvr.color);
        ''',
        'cbjs_action_out': '''
        bvr.src_el.setStyle("background", "");
        '''
        } )


        td.add(div)


        return top
Esempio n. 16
0
    def get_display(my):

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


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



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


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

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

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

            '''
        } )

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

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


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



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



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



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



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

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


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



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

            table.add_cell(title)

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



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



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

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

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

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


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

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

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

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

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


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

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

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

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

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

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

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

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


            """
            td = table.add_cell()
            button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

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

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

                '''
            } )
            """





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

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

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

                '''
            } )



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

                '''
            } )





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

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




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


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

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






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

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


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

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


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

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





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

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


                '''
            } )


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


        columns_wdg = DivWdg()
        top.add(columns_wdg)


        return top
Esempio n. 17
0
    def get_display(my):

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

        top.add_class("spt_reports_top")


        title = DivWdg()
        title.add("Searchable Lists")
        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")

        top.add(title)
        title.add_gradient("background", "background3", 5, -10)
        top.add("<br/>")

        button_div = DivWdg()
        top.add(button_div)
        button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP)
        button_div.add(button)
        top.add(button_div)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_reports_top");
            var element = top.getElement(".spt_reports_list");
            spt.toggle_show_hide(element)

            '''
        } )

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

        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")
        element_names = config.get_element_names()

        for element_name in element_names:
            print "element_name: ", element_name
            attrs = config.get_element_attributes(element_name)
            report_data = {}
            kwargs = config.get_display_options(element_name)
            class_name = kwargs.get('class_name')

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

            reports.append(report_data)
        """

        project = Project.get()
        project_code = project.get_code()
        search_type_objs = project.get_search_types()

        filtered = [] 
        for search_type_obj in search_type_objs:
            search_type = search_type_obj.get_value("search_type")

            # FIXME: this code is also present 
            from pyasm.security import get_security_version
            security_version = get_security_version()
            if security_version >= 2 and not search_type.startswith("sthpw/") and not search_type.startswith("config/"):
                security = Environment.get_security()

                table = search_type_obj.get_value("table_name")

                default = "deny"
                key  = { "element": "%s_list" % table }
                key2 = { "element": "%s_list" % table, "project": project_code }
                key3 = { "element": "*" }
                key4 = { "element": "*", "project": project_code }
                keys = [key, key2, key3, key4]
                if not security.check_access("link", keys, "view", default=default):
                    continue

                key = { "code": search_type }
                key2 = { "code": "*" }
                keys = [key, key2]
                if not security.check_access("search_type", keys, "view", default=default):
                    continue
                

                filtered.append(search_type_obj)


        search_type_objs = filtered

        for search_type_sobj in search_type_objs:
            description = search_type_sobj.get_value("description")
            search_type = search_type_sobj.get_value("search_type")



            search = Search(search_type)
            count = search.get_count()

            title_div = DivWdg()
            items_div = DivWdg()
            title_div.add(items_div)
            items_div.add_style("font-size: 9px")
            items_div.add_style("font-weight: italic")
            items_div.add_style("float: right")
            items_div.add("%s item/s" % count)
            title_div.add(search_type_sobj.get_title())

            description_div = DivWdg()
            description_div.add(description)
            description_div.add_style("padding: 5px")
            if not description:
                description_div.add("<br/>(No description)")
                description_div.add_style("font-style: italic")
                description_div.add_style("opacity: 0.3")


            report_data = {
                'title': search_type_sobj.get_title(),
                'title_wdg': title_div,
                'class_name': 'tactic.ui.panel.ViewPanelWdg',
                'kwargs': {
                        'search_type': search_type,
                        'view': 'table',
                        'simple_search_view': 'simple_search'
                    },
                'description': description_div,
                'search_type': search_type_sobj
            }
            reports.append(report_data)


        # create a bunch of panels
        list_div = DivWdg()
        top.add(list_div)
        list_div.add_class("spt_reports_list")


        table = Table()
        list_div.add(table)
        table.add_color("color", "color")
        table.add_style("margin-bottom: 5px")
        table.center()

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


        for i, report in enumerate(reports):

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

            td = table.add_cell()
            td.add_style("vertical-align: top")
            td.add_style("padding: 3px")

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

            #image = "<img src='/context/images/getting_started_schema.png'/>"
            image = "<img src='/context/images/getting_started_pipeline.png'/>"


            thumb_div = DivWdg()
            image = thumb_div
            thumb_div.add_border()
            thumb_div.set_box_shadow("1px 1px 1px 1px")

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




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

            var top = bvr.src_el.getParent(".spt_reports_top");
            //spt.tab.set_main_body_tab();
            spt.tab.set_tab_top(top);
            var kwargs = {};
            spt.tab.add_new(bvr.title, bvr.title, bvr.class_name, bvr.kwargs);
            '''
            }
            title_wdg = report.get("title_wdg")
            schema_wdg = my.get_section_wdg(title_wdg, description, image, behavior)
            td.add(schema_wdg)



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



        return top
Esempio n. 18
0
    def get_display(my):

        top = my.top

        #help_div = DivWdg()
        help_div = top
        #top.add(help_div)
        help_div.add_class("spt_help_top")
        help_div.set_id("spt_help_top")

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

        if show_title:
            title_wdg = DivWdg()
            help_div.add(title_wdg)
            title_wdg.add_style("font-size: 12px")
            title_wdg.add_style("font-weight: bold")
            title_wdg.add_gradient("background", "background", 0, -20)
            title_wdg.add_style("padding: 3px")
            #title_wdg.add_style("margin-top: 8px")
            title_wdg.add_style("margin-bottom: 5px")
            title_wdg.add_style("height: 26px")
            title_wdg.add_style("padding: 6 0 0 6")
            title_wdg.set_round_corners(corners=['TL', 'TR'])

            icon = IconWdg("Close", IconWdg.KILL)
            title_wdg.add(icon)
            icon.add_style("float: right")
            title_wdg.add("Help")

        help_div.set_round_corners()
        help_div.add_color("color", "color2")
        help_div.add_color("background", "background")
        help_div.add_border()

        shelf_div = DivWdg()
        help_div.add(shelf_div)
        shelf_div.add_style("padding: 5px")
        shelf_div.add_gradient("background", "background")
        shelf_div.add_style("height: 25px")

        from tactic.ui.widget import SingleButtonWdg

        button = SingleButtonWdg(title="Documentation Main Page",
                                 icon=IconWdg.HOME)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_alias("main")
        '''
        })

        button = SingleButtonWdg(title="Edit Help", icon=IconWdg.EDIT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.tab.set_main_body_tab();
        var class_name = 'tactic.ui.app.HelpEditWdg';

        var element_name = spt.help.get_view();
        if (!element_name) {
          element_name = "default";
        }
        var kwargs = {
          view: element_name
        }

        spt.tab.add_new("help_edit", "Help Edit", class_name, kwargs);
            
        '''
        })

        button = SingleButtonWdg(title="Go Back One Page",
                                 icon=IconWdg.ARROW_LEFT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_prev();
        '''
        })

        button = SingleButtonWdg(title="Go Forward One Page",
                                 icon=IconWdg.ARROW_RIGHT)
        shelf_div.add(button)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_next();
        '''
        })

        button = SingleButtonWdg(title="Documentation Downloads",
                                 icon=IconWdg.DOWNLOAD)
        shelf_div.add(button)
        button.add_style("float: right")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.help.set_top();
        spt.help.load_alias("pdf")
        '''
        })

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

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

        help_div.add_behavior({
            'type':
            'listen',
            'event_name':
            'tab|select',
            'cbjs_action':
            '''

        var content = bvr.src_el.getElement(".spt_help_content");
        var options = bvr.firing_data;
        var element_name = options.element_name;
        var alias = options.alias;

        if (!alias) {
            alias = options.element_name;
        }

        spt.help.set_top();
        if (spt.help.is_visible()) {
            spt.help.load_alias(alias);
        }
        else {
            spt.help.set_view(alias);
        }
        '''
        })

        help_div.add_behavior({
            'type':
            'listen',
            'event_name':
            'show_help',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_help");
        var content = top.getElement(".spt_help_content");
        var firing_data = bvr.firing_data;
        var class_name = firing_data.class_name;
        if (!class_name) {
            class_name = 'tactic.ui.app.HelpContentWdg';
        }

        if (top.getStyle("display") != 'none') {
            spt.hide(top);
            return;
        }

        spt.help.set_top()

        // get the help view
        var help_view = spt.help.get_view();
        var html = firing_data.html;
        if (html) {
            spt.help.load_html(html);    
        }
        else {
            if (!help_view) {
                help_view = 'default'    
            }
            spt.help.load_alias(help_view);
        }

        var size = $(window).getSize();

        var dialog = bvr.src_el.getParent(".spt_dialog_content");

        dialog.setStyle("height", size.y - 100);
        dialog.setStyle("width", 650);

        var top = bvr.src_el.getParent(".spt_dialog_top");
        top.setStyle("left", size.x - 660);
        top.setStyle("top", 40);

        spt.show(top);
        '''
        })

        content = DivWdg()
        help_div.add(content)
        content.add_class("spt_help_content")
        content.add_style("position: relative")
        content.add_style("overflow_x: auto")
        content.add_style("overflow_y: auto")
        content.add_style("margin-bottom: 10px")
        #content.add_style("border: solid 1px blue")
        content.add_style("height: 98%")

        #key = "schema_editor"
        #search = Search("config/doc")
        #search.add_filter("code", key)
        #doc = search.get_sobject()
        #doc_html = doc.get_value("doc")
        #help_div.add(doc_html)

        return top
Esempio n. 19
0
    def get_display(my):

        top = my.top
        top.add_color("background", "background")
        top.add_class("spt_pipelines_top")
        my.set_as_panel(top)

        inner = DivWdg()
        top.add(inner)

        search_type = my.kwargs.get("search_type")
        pipeline_code = my.kwargs.get("pipeline_code")

        if search_type:
            search = Search("sthpw/pipeline")
            search.add_filter("search_type", search_type)
            pipelines = search.get_sobjects()
        else:
            pipeline = Pipeline.get_by_code(pipeline_code)
            if pipeline:
                pipelines = [pipeline]
            else:
                pipelines = []

        if not pipelines:
            div = DivWdg()
            inner.add(div)
            inner.add_style("padding: 50px")
            div.add_border()
            div.add_color("color", "color3")
            div.add_color("background", "background3")
            div.add_style("width: 400px")
            div.add_style("height: 100px")
            div.add_style("padding: 30px")

            icon = IconWdg("WARNING", IconWdg.WARNING)
            div.add(icon)
            div.add(
                "<b>This Searchable Type does not have pipelines defined.</b>")
            div.add("<br/>" * 2)

            div.add(
                "<b style='padding-left: 35px'>Click Create to add one...</b>")
            div.add("<br/>" * 2)

            button_div = DivWdg()
            div.add(button_div)

            button = ActionButtonWdg(title="Create", tip="Create pipeline")
            button_div.add(button)
            button.add_style("margin: auto")
            button.add_behavior({
                'type':
                'click_up',
                'search_type':
                search_type,
                'cbjs_action':
                '''
                var server = TacticServerStub.get();

                var cmd = 'tactic.ui.startup.PipelineCreateCbk';
                var kwargs = {
                    search_type: bvr.search_type
                }
                server.execute_cmd(cmd, kwargs)

                var top = bvr.src_el.getParent(".spt_pipelines_top");
                spt.panel.refresh(top);
                '''
            })

            return top

        # get the defalt task statuses
        task_pipeline = Pipeline.get_by_code("task")
        if task_pipeline:
            statuses = task_pipeline.get_process_names()
        else:
            statuses = ['Pending', 'In Progress', 'Complete']
        statuses_str = ",".join(statuses)

        pipelines_div = DivWdg()
        inner.add(pipelines_div)
        pipelines_div.add_style("font-size: 12px")
        pipelines_div.add_style("padding: 10px")

        buttons_div = DivWdg()
        pipelines_div.add(buttons_div)

        button = SingleButtonWdg(title="Save Pipelines", icon=IconWdg.SAVE)
        buttons_div.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'default_statuses':
            statuses_str,
            'cbjs_action':
            '''
        spt.app_busy.show("Saving Pipeline...")

        setTimeout(function() {
            try {
                var top = bvr.src_el.getParent(".spt_pipelines_top");
                // get all the pipeline divs
                var pipeline_els = top.getElements(".spt_pipeline_top");
                var data = {};
                for ( var i = 0; i < pipeline_els.length; i++) {
                    var pipeline_code = pipeline_els[i].getAttribute("spt_pipeline_code");
                    var values = spt.api.Utility.get_input_values(pipeline_els[i]);
                    data[pipeline_code] = values;
                }


                var class_name = 'tactic.ui.startup.PipelineEditCbk';
                var kwargs = {
                    data: data
                }
                var server = TacticServerStub.get();
                server.execute_cmd(class_name, kwargs);
            } catch(e) {
                spt.alert(spt.exception.handler(e));
            }
            spt.app_busy.hide();
        }
        , 100);

        '''
        })

        buttons_div.add("<br clear='all'/>")
        buttons_div.add_style("margin-bottom: 5px")

        for pipeline in pipelines:
            pipeline_div = DivWdg()
            pipelines_div.add(pipeline_div)
            pipeline_div.add_class("spt_pipeline_top")

            code = pipeline.get_code()
            pipeline_div.add_attr("spt_pipeline_code", code)

            title = DivWdg()
            pipeline_div.add(title)
            title.add("Pipeline: ")
            title.add(code)
            title.add_style("padding: 5px")
            title.add_gradient("background", "background", -10)
            title.add_style("font-weight: bold")
            title.add_style("margin: -10 -10 5 -10")

            header_wdg = DivWdg()
            pipeline_div.add(header_wdg)
            header_wdg.add_color("background", "background", -5)

            headers = ['Process', 'Description', 'Task Status']
            widths = ['90px', '170px', '200px']
            for header, width in zip(headers, widths):
                th = DivWdg()
                header_wdg.add(th)
                th.add("<b>%s</b>" % header)
                th.add_style("float: left")
                th.add_style("width: %s" % width)
                th.add_style("padding: 3px")
            header_wdg.add("<br clear='all'/>")

            # get all of the process sobjects from this pipeline
            pipeline_code = pipeline.get_code()
            search = Search("config/process")
            search.add_filter("pipeline_code", pipeline.get_code())
            process_sobjs = search.get_sobjects()

            process_sobj_dict = {}
            for process_sobj in process_sobjs:
                process = process_sobj.get_value("process")
                process_sobj_dict[process] = process_sobj

            from tactic.ui.container import DynamicListWdg
            dyn_list = DynamicListWdg()
            pipeline_div.add(dyn_list)
            pipeline_div.add_style("width: 725px")

            processes = pipeline.get_process_names()
            if not processes:
                processes.append("")
                processes.append("")
                processes.append("")

            processes.insert(0, "")

            for i, process in enumerate(processes):

                if process == '':
                    process_name = ''
                    description = ''
                else:
                    process_sobj = process_sobj_dict.get(process)
                    if process_sobj:
                        process_name = process_sobj.get_value("process")
                        description = process_sobj.get_value("description")
                    else:
                        if isinstance(process, basestring):
                            process_name = process
                        else:
                            process_name = process.get_name()
                        deccription = ''

                # get the task pipeline for this process
                if process_name:
                    process = pipeline.get_process(process_name)
                    task_pipeline_code = process.get_task_pipeline()
                    if task_pipeline_code != "task":
                        task_pipeline = Search.get_by_code(
                            "sthpw/pipeline", task_pipeline_code)
                    else:
                        task_pipeline = None
                else:
                    task_pipeline_code = "task"
                    task_pipeline = None

                process_div = DivWdg()
                process_div.add_style("float: left")
                process_div.add_class("spt_process_top")

                if i == 0:
                    dyn_list.add_template(process_div)
                else:
                    dyn_list.add_item(process_div)

                #process_div.add_style("padding-left: 10px")
                #process_div.add_style("margin: 5px")

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

                text = NewTextWdg("process")
                table.add_cell(text)
                text.add_style("width: 95px")
                text.set_value(process_name)
                text.add_class("spt_process")

                # the template has a border
                if i == 0:
                    text.add_style("border: solid 1px #AAA")

                text = NewTextWdg("description")
                table.add_cell(text)
                text.add_style("width: 175px")
                text.set_value(description)
                # the template has a border
                if i == 0:
                    text.add_style("border: solid 1px #AAA")

                text = NewTextWdg("task_status")
                table.add_cell(text)
                text.add_style("width: 325px")

                #text.set_value(statuses_str)
                if task_pipeline:
                    statuses = task_pipeline.get_process_names()
                    text.set_value(",".join(statuses))
                else:
                    text.set_value("(default)")
                    #text.add_style("opacity: 0.5")

                text.add_style("border-style: none")

                text.add_behavior({
                    'type':
                    'click_up',
                    'statuses':
                    statuses_str,
                    'cbjs_action':
                    '''
                if (bvr.src_el.value == '(default)') {
                    bvr.src_el.value = bvr.statuses;
                }
                '''
                })

                table.add_cell("&nbsp;" * 2)

                button = IconButtonWdg(tip="Trigger", icon=IconWdg.ARROW_OUT)
                table.add_cell(button)
                button.add_behavior({
                    'type':
                    'click_up',
                    'search_type':
                    search_type,
                    'pipeline_code':
                    pipeline_code,
                    'cbjs_action':
                    '''
                    var top = bvr.src_el.getParent(".spt_process_top");
                    var process_el = top.getElement(".spt_process");

                    var process = process_el.value;
                    if (process == "") {
                        alert("Process value is empty");
                        return;
                    }

                    var class_name = 'tactic.ui.tools.TriggerToolWdg';
                    var kwargs = {
                        mode: "pipeline",
                        process: process,
                        pipeline_code: bvr.pipeline_code
                    };
                    spt.panel.load_popup("Trigger", class_name, kwargs);
     
                    '''
                })
                """
                button = IconButtonWdg(tip="Edit", icon=IconWdg.EDIT)
                table.add_cell(button)
                button.add_behavior( {
                    'type': 'click_up',
                    'search_type': search_type,
                    'pipeline_code': pipeline_code,
                    'cbjs_action': '''
                    var top = bvr.src_el.getParent(".spt_process_top");
                    var process_el = top.getElement(".spt_process");

                    var process = process_el.value;
                    if (process == "") {
                        alert("Process value is empty");
                        return;
                    }

                    var class_name = 'tactic.ui.panel.EditWdg';
                    var kwargs = {
                        expression: "@SOBJECT(config/process['process','"+process+"'])"
                    }
                    spt.panel.load_popup("Trigger", class_name, kwargs);
     
                    '''
                } )
                """

                table.add_cell("&nbsp;" * 3)

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

        if my.kwargs.get("is_refresh"):
            return inner
        else:
            return top
Esempio n. 20
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_class("spt_reports_top")
        my.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 = my.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 = my.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(my),
            '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 my.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 = my.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 my.kwargs.get("is_refresh") in ['true', True]:
            return inner
        else:
            return top
Esempio n. 21
0
    def get_display(my):

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


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



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


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

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

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

            '''
        } )

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

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


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



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



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



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



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

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


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



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

            table.add_cell(title)

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



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



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

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

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

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


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

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

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

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

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


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

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

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

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

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

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

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

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


            """
            td = table.add_cell()
            button = IconButtonWdg(title="Check-in", icon=IconWdg.PUBLISH)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_type': search_type,
                'title': title,
                'cbjs_action': '''

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

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

                '''
            } )
            """





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

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

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

                '''
            } )



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

                '''
            } )





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

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




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


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

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






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

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


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

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


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

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





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

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


                '''
            } )


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


        columns_wdg = DivWdg()
        top.add(columns_wdg)


        return top
Esempio n. 22
0
    def get_display(self):

        top = self.top

        button_div = DivWdg()
        top.add(button_div)
        button_div.add_class("spt_buttons_top")
        button_div.add_border()

        button_div.add_style("margin-bottom: 0px")
        button_div.add_style("width: 1200px")
        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);

            '''
        })

        top_class = self.kwargs.get("top_class")
        list_class = self.kwargs.get("list_class")
        height = self.kwargs.get("height")
        assert (top_class)
        assert (list_class)
        assert (height)

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

        button.add_behavior({
            'type':
            'click_up',
            'top_class':
            top_class,
            'list_class':
            list_class,
            'height':
            height,
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent("."+bvr.top_class);
            var element = top.getElement("."+bvr.list_class);

            var buttons = bvr.src_el.getParent(".spt_buttons_top");
            expand = buttons.getElement(".spt_expand");
            new Fx.Tween(element).start('margin-top', "-"+bvr.height+"px");
            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")
        top.add(button_div)
        button.add_style("float: left")
        button.add_behavior({
            'type':
            'click_up',
            'top_class':
            top_class,
            'list_class':
            list_class,
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent("."+bvr.top_class);
            var element = top.getElement("."+bvr.list_class);

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

        return top
Esempio n. 23
0
    def get_display(my):

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

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

        button = SingleButtonWdg(title="Advanced Security", icon=IconWdg.LOCK)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.startup.SecurityWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("Security", "Security", class_name)
            '''
        })

        button = SingleButtonWdg(title="Add",
                                 tip="Add New User",
                                 icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        top.add("<br clear='all'/>")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.panel.EditWdg';
            var kwargs = {
                search_type: "sthpw/login",
                view: "edit",
            }
            var popup = spt.panel.load_popup("Create New User", class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_panel_user_top");
            popup.on_save_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        })

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

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

            return top

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

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

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

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

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

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

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

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

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

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

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

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

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


                '''
            })

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

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

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

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

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

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

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

                '''
            })

        return top
Esempio n. 24
0
    def get_shelf_wdg(my):

        process = my.get_value("process")
        versions = my.get_value("versions")

        div = DivWdg()

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


        button = SingleButtonWdg(title="Refresh", icon=IconWdg.REFRESH)
        filter_table.add_cell(button)
        filter_table.add_cell("&nbsp;"*5)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.panel.refresh(bvr.src_el);
            '''
        } )

        # get all of the pipelnes for this search type
        pipeline_code = my.sobject.get_value("pipeline_code", no_exception=True)
        processes = []
        if pipeline_code:
            pipeline = Pipeline.get_by_code(pipeline_code)
            if pipeline:
                process_names = pipeline.get_process_names()
                processes.extend(process_names)

        processes.insert(0, "all")



        filter_table.add_cell("Process: ")
        select = SelectWdg("process")
        select.add_style("width: 200px")
        if process != 'all':
            select.set_value(process)

        select.set_option("values", processes)

        filter_table.add_cell(select)



        filter_table.add_cell("&nbsp;"*10)

        filter_table.add_cell("Versions: ")
        select = SelectWdg("versions")
        select.add_style("width: 200px")
        select.set_option("values", "latest|current|today|last 10|all")
        if versions:
            select.set_value(versions)
        filter_table.add_cell(select)


        asset_dir = Environment.get_asset_dir()

        select = IconButtonWdg( tip="Toggle Selection", icon=IconWdg.SELECT, show_arrow=False )
        div.add(select)
        select.add_style("float: right")
        select.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top_class = 'spt_sobject_dir_list_top'
            var toggle_state = bvr.src_el.getAttribute('toggle');
            if (toggle_state && toggle_state=='true')
                bvr.src_el.setAttribute('toggle','false');
            else
                bvr.src_el.setAttribute('toggle','true');

            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            
            toggle_state = bvr.src_el.getAttribute('toggle');
            if (toggle_state == 'true')
                spt.selection.select_all_items();
            else
                spt.selection.unselect_all_items();

            '''
            } )



        show = IconButtonWdg( tip="Switch View", icon=IconWdg.VIEW, show_arrow=False )
        div.add(show)
        show.add_style("float: right")
        show.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top_class = 'spt_sobject_dir_list_top'
            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            var els = top.getElements(".spt_file_dir_item");
            for (var i = 0; i < els.length; i++) {
                var el = els[i];
                if (el.getStyle("display") == "none") {
                    els[i].setStyle("display", "");
                }
                else {
                    els[i].setStyle("display", "none");
                }
            }
            var els = top.getElements(".spt_file_item");
            for (var i = 0; i < els.length; i++) {
                var el = els[i];
                if (el.getStyle("padding-left") == "6px") {
                    var padding = el.getAttribute("spt_padding_left");
                    el.setStyle("padding-left", padding);
                }
                else {
                    el.setStyle("padding-left", "6px");
                }

            }


            '''
        } )






        gear = IconButtonWdg( tip="Download", icon=IconWdg.DOWNLOAD, show_arrow=False )
        div.add(gear)
        gear.add_style("float: right")
        gear.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.app_busy.show('Select a folder to download to...','');
            var top_class = 'spt_sobject_dir_list_top';
            var top = bvr.src_el.getParent("."+top_class);
            spt.selection.set_top(top);
            var items = spt.selection.get_selected();
            
       
            setTimeout( function() {
                var applet = spt.Applet.get();
                var select_dir =true;
                var dir = applet.open_file_browser('', select_dir);
                if (dir.length == 0)
                    dir = applet.get_current_dir();
                else 
                    dir = dir[0];

                if (!dir) {
                    spt.alert("No folder selected to copy to.");
                    spt.app_busy.hide();
                    return;
                }
                if (items.length == 0){
                    spt.alert("Please select at least one file to download.");
                    spt.app_busy.hide();
                    return;
                }
                

                var asset_dir = '%s';
                for (var i = 0; i < items.length; i++) {
                    var path = items[i].getAttribute("spt_path");
                    var env = spt.Environment.get();
                    var server_url = env.get_server_url();
                    var url = server_url + "/assets/" + path.replace(asset_dir, "");
                    var parts = path.split("/");
                    var filename = parts[parts.length-1];
                    spt.app_busy.show("Downloading file", filename);
                    applet.download_file(url, dir + "/" + filename);
                }
                spt.app_busy.hide();
                if (dir)
                    spt.notify.show_message("Download to '" + dir + "' completed.")
            }, 100);

            ''' % asset_dir
 
        } )

        return div
Esempio n. 25
0
    def get_display(self):

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

        top.add_class("spt_reports_top")


        title = DivWdg()
        title.add("Searchable Lists")
        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")

        top.add(title)
        title.add_gradient("background", "background3", 5, -10)
        top.add("<br/>")

        button_div = DivWdg()
        top.add(button_div)
        button = SingleButtonWdg(title="Collapse", icon=IconWdg.ARROW_UP)
        button_div.add(button)
        top.add(button_div)
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_reports_top");
            var element = top.getElement(".spt_reports_list");
            spt.toggle_show_hide(element)

            '''
        } )

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

        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")
        element_names = config.get_element_names()

        for element_name in element_names:
            print "element_name: ", element_name
            attrs = config.get_element_attributes(element_name)
            report_data = {}
            kwargs = config.get_display_options(element_name)
            class_name = kwargs.get('class_name')

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

            reports.append(report_data)
        """

        project = Project.get()
        project_code = project.get_code()
        search_type_objs = project.get_search_types()

        filtered = [] 
        for search_type_obj in search_type_objs:
            search_type = search_type_obj.get_value("search_type")

            # FIXME: this code is also present 
            from pyasm.security import get_security_version
            security_version = get_security_version()
            if security_version >= 2 and not search_type.startswith("sthpw/") and not search_type.startswith("config/"):
                security = Environment.get_security()

                table = search_type_obj.get_value("table_name")

                default = "deny"
                key  = { "element": "%s_list" % table }
                key2 = { "element": "%s_list" % table, "project": project_code }
                key3 = { "element": "*" }
                key4 = { "element": "*", "project": project_code }
                keys = [key, key2, key3, key4]
                if not security.check_access("link", keys, "view", default=default):
                    continue

                key = { "code": search_type }
                key2 = { "code": "*" }
                keys = [key, key2]
                if not security.check_access("search_type", keys, "view", default=default):
                    continue
                

                filtered.append(search_type_obj)


        search_type_objs = filtered

        for search_type_sobj in search_type_objs:
            description = search_type_sobj.get_value("description")
            search_type = search_type_sobj.get_value("search_type")



            search = Search(search_type)
            count = search.get_count()

            title_div = DivWdg()
            items_div = DivWdg()
            title_div.add(items_div)
            items_div.add_style("font-size: 9px")
            items_div.add_style("font-weight: italic")
            items_div.add_style("float: right")
            items_div.add("%s item/s" % count)
            title_div.add(search_type_sobj.get_title())

            description_div = DivWdg()
            description_div.add(description)
            description_div.add_style("padding: 5px")
            if not description:
                description_div.add("<br/>(No description)")
                description_div.add_style("font-style: italic")
                description_div.add_style("opacity: 0.3")


            report_data = {
                'title': search_type_sobj.get_title(),
                'title_wdg': title_div,
                'class_name': 'tactic.ui.panel.ViewPanelWdg',
                'kwargs': {
                        'search_type': search_type,
                        'view': 'table',
                        'simple_search_view': 'simple_search'
                    },
                'description': description_div,
                'search_type': search_type_sobj
            }
            reports.append(report_data)


        # create a bunch of panels
        list_div = DivWdg()
        top.add(list_div)
        list_div.add_class("spt_reports_list")


        table = Table()
        list_div.add(table)
        table.add_color("color", "color")
        table.add_style("margin-bottom: 5px")
        table.center()

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


        for i, report in enumerate(reports):

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

            td = table.add_cell()
            td.add_style("vertical-align: top")
            td.add_style("padding: 3px")

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

            #image = "<img src='/context/images/getting_started_schema.png'/>"
            image = "<img src='/context/images/getting_started_pipeline.png'/>"


            thumb_div = DivWdg()
            image = thumb_div
            thumb_div.add_border()
            thumb_div.set_box_shadow("1px 1px 1px 1px")

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




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

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



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



        return top