Beispiel #1
0
    def get_search_wdg(my):
        filter_div = DivWdg()
        filter_div.add_style("width: 200px")

        search_button = ActionButtonWdg(title='Search',
                                        tip='Run search with this criteria')

        if my.run_search_bvr:
            run_search_bvr = my.run_search_bvr
        else:
            # cbjs works better than cbfn here
            run_search_bvr = {
                'type': 'click_up',
                'new_search': True,
                'cbjs_action': 'spt.dg_table.search_cbk(evt, bvr)',
                'panel_id': my.prefix,
            }

        search_button.add_behavior(run_search_bvr)

        # add a listener for other widgets to call Run Search
        listen_bvr = run_search_bvr.copy()
        listen_bvr['type'] = 'listen'
        listen_bvr['event_name'] = 'search_%s' % my.search_type

        # needed for CgApp loader
        search_button.add_behavior(listen_bvr)

        clear_button = ActionButtonWdg(title='Clear',
                                       tip='Clear all search criteria')
        clear_button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.api.Utility.clear_inputs(bvr.src_el.getParent(".spt_search"), '.spt_input:not(select.spt_search_filter_mode)');
        '''
        })
        #    {'label': 'Clear', 'tip': 'Clear all search criteria', 'width': 45,
        #        'bvr': {'cbjs_action': 'spt.api.Utility.clear_inputs(bvr.src_el.getParent(".spt_search"))'} }
        #]
        #txt_btn_set = TextBtnSetWdg(buttons=buttons_list, spacing=6, size='small', side_padding=4 )

        filter_div.add(search_button)
        search_button.add_style("float: left")
        filter_div.add(clear_button)
        clear_button.add_style("float: left")
        filter_div.add("<br clear='all'/>")

        return filter_div
Beispiel #2
0
    def get_search_wdg(self):
        search_div = DivWdg()

        if self.kwargs.get('run_search_bvr'):
            run_search_bvr = self.kwargs.get('run_search_bvr')
        else:
            run_search_bvr = {
                'type': 'click_up',
                'cbjs_action': '''
                spt.simple_search.hide();
                spt.dg_table.search_cbk(evt, bvr);
                ''',
                'new_search': True,
                'panel_id': self.prefix
            }

        title = "Apply"

        button = ActionButtonWdg(title=title,
                                 tip='Run search with this criteria')
        search_div.add(button)
        #button.add_style("margin-top: -7px")
        button.add_behavior(run_search_bvr)

        return search_div
    def get_advanced_definition_wdg(my):
        # add the advanced entry
        advanced = DivWdg()
        advanced.add_style("margin-top: 10px")
        advanced.add_style("padding: 10px")
        advanced.add_border()
        title = DivWdg()
        title.add_style("color: black")
        title.add("Advanced - XML Column Definition")
        title.add_style("margin-top: -23")
        advanced.add(title)
        advanced.add("<br/>")

        input = TextAreaWdg("config_xml")
        input.set_id("config_xml")
        input.set_option("rows", "10")
        input.set_option("cols", "70")
        input.set_value(my.config_string)
        advanced.add(input)
        advanced.add(HtmlElement.br(2))

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

        button = ActionButtonWdg(title="Save Definition")
        #button = ProdIconButtonWdg("Save Definition")
        button.add_event("onclick", "spt.custom_project.save_definition_cbk()")
        button_div.add(button)
        button_div.add_style("margin-left: 130px")
        advanced.add(button_div)

        return advanced
Beispiel #4
0
    def get_tools_wdg(self):

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

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

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

            spt.panel.refresh(bvr.src_el);

            '''
        } )



        return div
    def get_checkin(my):
        '''the button which initiates the checkin'''
        # create the button with the javascript function
        widget = Widget()
        #button = TextBtnWdg(label=my.PUBLISH_BUTTON, size='large', width='100', side_padding='20', vert_offset='-5')
        #button.get_top_el().add_class('smaller')
        button = ActionButtonWdg(title=my.PUBLISH_BUTTON,
                                 tip='Publish the selected assets')
        button.add_style('margin-bottom: 10px')
        #button.add_color("background", "background")

        hidden = HiddenWdg(my.PUBLISH_BUTTON, '')
        button.add(hidden)
        '''
        status_sel = SelectWdg('checkin_status', label='Status: ')
        status_sel.set_option('setting', 'checkin_status')
        status_sel.set_persist_on_submit()
        status_sel.add_empty_option('-- Checkin Status --')
        widget.add(status_sel)
        '''
        widget.add(button)

        # custom defined
        server_cbk = "pyasm.prod.web.AssetCheckinCbk"
        #TODO: make other Publish Buttons call their own handle_input function
        exec(Common.get_import_from_class_path(server_cbk))
        exec(
            "%s.handle_input(button, my.search_type, my.texture_search_type)" %
            server_cbk)

        return widget
Beispiel #6
0
 def handle_sidebar_clear(self, top):
     top.add(DivWdg('Clear Side Bar Cache ', css='spt_info_title'))
     table = Table()
     table.add_color("color", "color")
     table.add_style("margin: 10px")
     top.add(table)
     table.add_row()
     td = table.add_cell("Clear the Side Bar Cache for all users")
     td.add_style("width: 250px")
     button = ActionButtonWdg(title='Run')
     table.add_cell(button)
     button.add_behavior({
         'type':
         'click_up',
         'cbjs_action':
         '''
         try {
         var s = TacticServerStub.get();
         s.execute_cmd('tactic.ui.app.ClearSideBarCache');
         
         } catch(e) {
             spt.alert(spt.exception.handler(e));
         }
         spt.info('Side Bar cache cleared.')
     '''
     })
Beispiel #7
0
    def handle_python_script_test(self, top):
        top.add(DivWdg('Python Script Test', css='spt_info_title'))
        table = Table(css='script')
        table.add_color("color", "color")
        table.add_style("margin: 10px")
        table.add_style("width: 100%")
        top.add(table)
        table.add_row()
        td = table.add_cell("Script Path: ")
        td.add_style("width: 150px")
        text = TextWdg('script_path')
        td = table.add_cell(text)
        button = ActionButtonWdg(title='Run')
        table.add_cell(button)
        button.add_style("float: right")
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
             var s = TacticServerStub.get();
             try {
                var path =  bvr.src_el.getParent('.script').getElement('.spt_input').value;
                if (! path)
                    throw('Please enter a valid script path');
                s.execute_cmd('tactic.command.PythonCmd', {script_path: path});
             } catch(e) {
                spt.alert(spt.exception.handler(e));
             }

        '''
        })
Beispiel #8
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
Beispiel #9
0
    def get_save_button(my, checkin_keys):
        save_button = ActionButtonWdg(
            title="Save >>", tip="Save configuration and start using TACTIC")

        save_button.add_style("float: right")
        save_button.add_behavior({
            'type':
            'click_up',
            'os':
            os.name,
            'checkin_options':
            checkin_keys,
            'cbjs_action':
            '''
            spt.app_busy.show("Saving configuration. Please wait...")
            var top = bvr.src_el.getParent(".spt_db_config_top");
            var values = spt.api.Utility.get_input_values(top, null, false);
            var class_name = 'tactic.ui.startup.DbConfigSaveCbk';
            var server = TacticServerStub.get();
            var kwargs = {checkin_options:bvr.checkin_options};
            try {
                var ret_val = server.execute_cmd(class_name, kwargs, values);
                var info = ret_val.info;
            }
            catch(e) {
                log.critical(spt.exception.handler(e));
                //FIXME: recognize it's a 502 which is normal and pass , otherwise throw the error
                //spt.error(spt.exception.handler(e));
                //spt.app_busy.hide();
                //return;
            }

           
            
            // This means TACTIC was restarted
            
            if (typeof(info) == 'undefined' || bvr.os == 'nt' ) {
                spt.app_busy.show("Restarting TACTIC ...");
                var id = setInterval( function() {
                    var ping_rtn =  server.ping();
                    if (ping_rtn) {
                        window.location = '/tactic';
                        clearInterval(id);
                    }
                  
                }, 5000 );

            }
            else if (info.error) {
                spt.alert(info.error);
                spt.app_busy.hide();
            }
            else {
                window.location = '/tactic';
            }

            '''
        })
        return save_button
Beispiel #10
0
    def get_display(self):

        top = self.top

        upload = Html5UploadWdg(name="formxyz")
        top.add(upload)
        upload_id = upload.get_upload_id()

        color = self.kwargs.get("color")
        width = self.kwargs.get("width")

        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(title="Upload", color=color, width=width)
        top.add(button)
        button.add_behavior({
            'type':
            'click_up',
            'upload_id':
            upload_id,
            'cbjs_action':
            '''

            // set the form
            spt.html5upload.form = $(bvr.upload_id);

            // set an action for completion
            var upload_complete = function(evt) {
                var search_key = "sthpw/login?code=admin";
                var server = TacticServerStub.get();
                var file = spt.html5upload.get_file();
                if (file) {
                   file_name = file.name;
                     
                   server.simple_checkin(search_key, "icon", file_name, {mode:'uploaded'});
                }
                else 
                  alert('Error: file object cannot be found.')

            }

            var upload_progress = function(evt) {
                var percent = Math.round(evt.loaded * 100 / evt.total);
            }

            var onchange = function () {
                spt.html5upload.upload_file( {
                  upload_complete: upload_complete,
                  upload_progress: upload_progress 
                } );
            }


  
            spt.html5upload.select_file( onchange);

            '''
        })

        return top
Beispiel #11
0
    def get_error_wdg(my):
        div = DivWdg()
        error_div = DivWdg()
        error_div.add("Error %s" % my.status)
        div.add(error_div)
        error_div.add_style("font-size: 18px")
        error_div.add_style("font-weight: bold")
        error_div.add_style("padding: 10px")
        error_div.add_style("width: auto")
        error_div.add_gradient("background", "background")
        error_div.add_border()
        error_div.add_style("margin-left: 5px")
        error_div.add_style("margin-right: 5px")
        error_div.add_style("margin-top: -10px")

        div.add("<br/>")

        span = DivWdg()
        #span.add_color("color", "color")
        span.add_style("color", "#FFF")
        if my.status == 404:
            span.add(
                HtmlElement.b(
                    "You have tried to access a url that is not recognized."))
        else:
            span.add(HtmlElement.b(my.message))
        span.add(HtmlElement.br(2))

        web = WebContainer.get_web()
        root = web.get_site_root()
        if my.message.startswith('No project ['):
            label = 'You may need to correct the default_project setting in the TACTIC config.'
        else:
            label = "Go to the Main page for a list of valid projects"
        span.add(label)
        div.add(span)
        div.add(HtmlElement.br())

        from tactic.ui.widget import ActionButtonWdg
        button_div = DivWdg()
        button_div.add_style("width: 90px")
        button_div.add_style("margin: 0px auto")

        div.add(button_div)
        button = ActionButtonWdg(title="Go to Main",
                                 tip='Click to go to main page')
        button_div.add(button)

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        document.location = '/';
        '''
        })
        button.add_event("onmouseup", "document.location='/'")

        return div
Beispiel #12
0
    def get_activator_wdg(self, title):

        color = self.kwargs.get("color")
        width = self.kwargs.get("width")

        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(title=title,
                                 color=color,
                                 width=width,
                                 size='b')
        return button
Beispiel #13
0
    def get_display(my):

        search_key = ''
        sobj = my.get_current_sobject()

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

        span = ActionButtonWdg(title="Email Test")
        #span = ProdIconButtonWdg('Email Test')
        top.add(span)
        span.add_behavior(my.get_behavior(sobj))

        return top
Beispiel #14
0
    def get_add_chat_wdg(my):

        div = DivWdg()
        div.add_border()
        div.add_style("padding: 20px")
        div.add_class("spt_add_chat_top")

        table = Table()
        table.add_style("width: auto")
        div.add(table)
        table.add_row()

        text = TextInputWdg(title="user", icon="USER_ADD")
        table.add_cell(text)
        text.add_class("spt_add_chat_user")

        add_button = ActionButtonWdg(title="Start Chat")
        table.add_cell(add_button)
        add_button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_add_chat_top");
            var el = top.getElement(".spt_add_chat_user");
            var user = el.value;
            if (!user) {
                alert("Specify a valid user to chat with");
                return;
            }

            // new chat
            var server = TacticServerStub.get();
            var category = "chat";

            var class_name = 'tactic.ui.app.ChatCmd';
            var kwargs = {
                users: [user]
            }
            server.execute_cmd(class_name, kwargs);

            spt.panel.refresh(bvr.src_el);
            '''
        })

        return div
Beispiel #15
0
    def get_display(my):
        alias = my.kwargs.get("alias")

        div = DivWdg()
        div.add_style("padding: 15px")
        div.add_style("margin: 10px")
        div.add_border()
        div.add_color("background", "background", -5)
        div.add_style("text-align: center")
        div.add_style("font-weight: bold")

        icon = IconWdg("WARNING", IconWdg.HELP_MISSING)
        div.add(icon)
        div.add("Add custom documentation page by clicking the Create button")

        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(title="Create",
                                 tip="Create docs for this view")
        div.add(button)
        button.add_style("margin-right: auto")
        button.add_style("margin-left: auto")
        button.add_style("margin-top: 15px")
        button.add_style("margin-bottom: 15px")
        # FIXME: copied code from above
        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);
            
        '''
        })
        return div
Beispiel #16
0
    def get_search_wdg(my):
        search_div = DivWdg()

        if my.kwargs.get('run_search_bvr'):
            run_search_bvr = my.kwargs.get('run_search_bvr')
        else:
            run_search_bvr = {
                'type':         'click_up',
                'cbjs_action':  'spt.dg_table.search_cbk(evt, bvr)',
                'new_search':   True,
                'panel_id':     my.prefix
            }

        button = ActionButtonWdg(title='Search', tip='Run search with this criteria' )
        search_div.add(button)
        #button.add_style("margin-top: -7px")
        button.add_behavior( run_search_bvr )

        return search_div
Beispiel #17
0
    def get_display(my):

        top = my.top
        top.add_class("spt_db_config_top")
        top.add_style("width: 430px")
        top.add_style("min-height: 500")
        top.add_style("padding: 15px")
        top.add_style("margin-left: auto")
        top.add_style("margin-right: auto")
        top.add_color("background", "background", -10)
        top.add_border()

        title_wdg = DivWdg()
        top.add(title_wdg)
        title_wdg.add("System Configuration Setup")
        title_wdg.add_style("font-size: 20px")

        top.add("<hr/>")

        top.add("<i style='opacity: 0.5'>%s</i><br/>" %
                Config.get_config_path())
        top.add("<br/>")

        checkin_keys = Config.get_section_values('checkin')
        checkin_keys = checkin_keys.keys()
        save_button = my.get_save_button(checkin_keys)
        top.add(save_button)
        vendor = Config.get_value("database", "vendor")

        title_wdg = DivWdg()
        top.add(title_wdg)
        title_wdg.add("<b>Database Setup</b>")
        title_wdg.add_style("margin-bottom: 10px")

        db_select = SelectWdg("database/vendor")
        db_select.set_option("labels",
                             "SQLite|PostgreSQL|MySQL|Oracle|SQLServer")
        db_select.set_option("values",
                             "Sqlite|PostgreSQL|MySQL|Oracle|SQLServer")

        db_select.set_value(vendor)

        db_select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''

        var key;
        if (bvr.src_el.value == 'Sqlite') {
            key = 'Sqlite';
        }
        else if (bvr.src_el.value == 'MySQL') {
            key = 'MySQL';
        }
        else {
            key = 'Other';
        }
        var top = bvr.src_el.getParent(".spt_db_config_top");
        var options_els = top.getElements(".spt_db_options");
        for (var i = 0; i < options_els.length; i++) {
            var vendor = options_els[i].getAttribute("spt_vendor");
            if (vendor == key) {
                spt.show(options_els[i]);
            }
            else {
                spt.hide(options_els[i]);
            }

        }
        '''
        })

        option_div = DivWdg()
        top.add(option_div)
        option_div.add("Vendor: ")
        option_div.add(db_select)
        option_div.add_style("margin: 20px")

        sqlite_wdg = my.get_sqlite_wdg()
        option_div.add(sqlite_wdg)
        mysql_wdg = my.get_mysql_wdg()
        option_div.add(mysql_wdg)
        otherdb_wdg = my.get_otherdb_wdg()
        option_div.add(otherdb_wdg)

        if vendor == 'Sqlite':
            sqlite_wdg.add_style("display", "")
            otherdb_wdg.add_style("display: none")
            mysql_wdg.add_style("display: none")

        if vendor == 'MySQL':
            mysql_wdg.add_style("display", "")
            otherdb_wdg.add_style("display: none")
            sqlite_wdg.add_style("display: none")

        else:
            otherdb_wdg.add_style("display", "")
            mysql_wdg.add_style("display: none")
            sqlite_wdg.add_style("display: none")

        test_button = ActionButtonWdg(title=" Test ",
                                      tip="Test connecting to database")
        option_div.add(test_button)
        test_button.add_style("margin-left: auto")
        test_button.add_style("margin-right: auto")
        test_button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_db_config_top");
        var values = spt.api.Utility.get_input_values(top, null, false);
        var class_name = 'tactic.ui.startup.DbConfigCbk';
        var server = TacticServerStub.get();
        var kwargs = {};
        var ret_val = server.execute_cmd(class_name, kwargs, values);
        var info = ret_val.info;
        if (info.error) {
            spt.error(info.error);
        }
        else {
            spt.info("Connection to database successful");
        }
        '''
        })

        #
        # Install
        #
        top.add("<hr/>")

        top.add("<br/>")

        title = "Installation"

        category = "install"

        options = ['default_project']

        if 'tmp_dir' not in options:
            options.append('tmp_dir')

        top.add(my.configure_category(title, category, options))

        top.add("<hr/>")

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

        title = "Asset Management Setup"
        category = "checkin"

        options = checkin_keys[:]

        my._remove_item_from_list(options, 'win32_server_handoff_dir')
        my._remove_item_from_list(options, 'linux_server_handoff_dir')

        if os.name == "nt":
            options.append('win32_server_handoff_dir')
        else:
            options.append('linux_server_handoff_dir')

        top.add(my.configure_category(title, category, options))

        top.add("<hr/>")
        top.add("<br/>")

        title = "Mail Server"
        category = "services"
        options = [
            'mailserver', 'mail_user', 'mail_password', 'mail_port',
            'mail_tls_enabled', 'mail_sender_disabled'
        ]
        top.add(my.configure_category(title, category, options))

        top.add("<hr/>")

        title = "Services"
        category = "services"
        options = [
            'process_count', 'process_time_alive', 'thread_count',
            'python_path'
        ]
        top.add(my.configure_category(title, category, options))

        top.add("<hr/>")

        title = "Look and Feel"
        category = "look"
        options = ['palette']
        top.add(my.configure_category(title, category, options))

        #wizard_wdg = WizardWdg()
        #top.add(wizard_wdg)
        #wizard_wdg.add(DivWdg("cow"), "cow")
        #wizard_wdg.add(DivWdg("pig"), "pig")
        #wizard_wdg.add(DivWdg("dog"), "dog")
        return top
Beispiel #18
0
    def get_display(my):
        top = my.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("width", "400px")
        top.add_border()
        top.add_class("spt_delete_project_tool_top")

        project_code = my.kwargs.get("project_code")
        if project_code:
            project = Project.get_by_code(project_code)
        else:
            search_key = my.kwargs.get("search_key")
            project = Search.get_by_search_key(search_key)
            if project:
                project_code = project.get_code()

        title_wdg = DivWdg()

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

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

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

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

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

        assert project_code
        assert project

        content.add("<br/>")

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

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

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

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

        search_types = project.get_search_types()

        related_types = []

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

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

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

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

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

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

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

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

        content.add("<br/>" * 2)
        content.add("<b>Do you wish to continue deleting? </b>")
        radio = RadioWdg("mode")
        radio.add_class("spt_mode_radio")
        radio.set_value("delete")
        content.add(radio)
        content.add("<br/>" * 2)

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

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

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

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

        button = ActionButtonWdg(title="Delete")
        buttons.add_cell(button)

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

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

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

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


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



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

                    var top = bvr.src_el.getParent(".spt_popup");
                    spt.popup.destroy(top);
                    server.finish();
                }
                catch(e) {
                    error_message = spt.exception.handler(e);
                }

                
                spt.app_busy.hide();

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

                    spt.tab.set_main_body_tab();
                    spt.tab.reload_selected();
                }
                else {
                    if (error_message.test(/does not exist/))
                        error_message += '. You are advised to sign out and log in again.';
                    spt.error(error_message);
                }
            }, 100);
       
        '''
        })

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

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

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

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

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

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

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

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

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

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

        title_wdg = DivWdg()

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

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

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

        content.add("<br/>")

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

        content.add("<br/>")

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

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

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

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

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

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

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

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

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

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

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

        spt.app_busy.hide();

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

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

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

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

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

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

        my.search_keys = search_keys

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

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

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

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

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

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

        if valid_related_ctr > 0:
            icon = IconWdg("WARNING", IconWdg.WARNING)
            icon.add_style("float: left")
            content.add(icon)
            content.add(
                "<div><b>WARNING: By selecting the related items above, you can delete them as well when deleting this sObject.</b></div>"
            )
            content.add("<br/>" * 2)
        else:
            # changed the heading to say no dependencies
            content.add("The item to be deleted has no dependencies.<br/>",
                        'heading')

        content.add("There are %s items to be deleted" % len(my.search_keys))
        content.add("<br/>" * 2)

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

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

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

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

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

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

        var server = TacticServerStub.get();
        try {
            server.start({'title': 'Delete sObject', 'description': 'Delete sObject [' + bvr.search_keys + ']'});
            server.execute_cmd(class_name, kwargs);
            server.finish();

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

            del_trigger();

            spt.popup.destroy(popup);


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

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

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

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

        return top
Beispiel #21
0
    def get_category_wdg(self, category, mode="new"):

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

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

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

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


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

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



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

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

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

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

            size = 60

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

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

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

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

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

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

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

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

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

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

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

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

            
            






            ss.append(subscription)

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

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


        return div
Beispiel #22
0
    def get_chat_wdg(self, key, interval=False):

        div = DivWdg()
        div.add_class("spt_chat_session_top")
        div.add_color("background", "background")

        title_wdg = DivWdg()
        div.add(title_wdg)
        title_wdg.add_color("background", "background3")
        title_wdg.add_style("padding: 5px")
        title_wdg.add_style("font-weight: bold")
        title_wdg.add_border()

        icon = IconButtonWdg(title="Remove Chat", icon=IconWdg.DELETE)
        icon.add_style("float: right")
        icon.add_style("margin-top: -5px")
        title_wdg.add(icon)
        icon.add_behavior( {
            'type': 'click_up',
            'key': key,
            'cbjs_action': '''
            var server = TacticServerStub.get();

            var top = bvr.src_el.getParent(".spt_chat_session_top");
            spt.behavior.destroy_element(top);
            '''
        } )


        current_user = Environment.get_user_name()
        logins = Search.eval("@SOBJECT(sthpw/subscription['message_code','%s'].sthpw/login)" % key)
        for login in logins:
            if login.get_value("login") == current_user:
                continue

            thumb = ThumbWdg()
            thumb.set_icon_size(45)
            thumb.set_sobject(login)
            thumb.add_style("float: left")
            thumb.add_style("margin: -5px 10px 0px -5px")
            title_wdg.add(thumb)
            title_wdg.add(login.get_value("display_name"))

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


        history_div = DivWdg()
        div.add(history_div)
        history_div.add_class("spt_chat_history")
        history_div.add_style("width: auto")
        history_div.add_style("height: auto")
        history_div.add_style("max-height: 400px")
        history_div.add_style("padding: 5px")
        history_div.add_class("spt_resizable")

        history_div.add_border()
        history_div.add_style("overflow-y: auto")
        #history_div.add_style("font-size: 0.9em")


        search = Search("sthpw/message_log")
        search.add_filter("message_code", key)
        search.add_order_by("timestamp")
        message_logs = search.get_sobjects()
        last_login = None;
        last_date = None;
        for message_log in message_logs:

            login = message_log.get("login")
            message = message_log.get("message")
            timestamp = message_log.get_datetime_value("timestamp")
            #timestamp = timestamp.strftime("%b %d, %Y - %H:%M")
            timestamp_str = timestamp.strftime("%H:%M")
            date_str = timestamp.strftime("%b %d, %Y")

        

            if login != last_login:

                table = Table()
                history_div.add(table)
                table.add_row()
                table.add_style("width: 100%")
                table.add_style("margin-top: 15px")

                login_sobj = Search.get_by_code("sthpw/login", login)
                thumb_div = DivWdg()
                td = table.add_cell()
                td.add_style("vertical-align: top")
                td.add_style("width: 75px")

                thumb_div = DivWdg()
                td.add(thumb_div)
                thumb_div.add_style("overflow: hidden")

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


                display_name = login_sobj.get("display_name")

                td = table.add_cell()
                td.add_style("padding-top: 3px")
                
                name_div = DivWdg()
                td.add(name_div)
                name_div.add_style("color", "#214e75")
                name_div.add_style("font-size", "1.3em")
                name_div.add(display_name)


            msg = "";
            msg += "<table style='margin-top: 5px; font-size: 1.0em; width: 100%'>";


            if date_str != last_date:
                msg += "<tr><td colspan='2' style='text-align: right'><br/><b style='font-size: 1.0em'>"+date_str+"</b></td></tr>";
                last_login = None

            msg += "<tr><td>"
            msg += message.replace("\n",'<br/>')
            msg += "</td><td style='vertical-align: top; text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top; opacity: 0.7;'>";
            msg += timestamp_str;
            msg += "</td></tr></table>";

            td.add(msg)

            

            last_login = login
            last_date = date_str

        history_div.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            bvr.src_el.scrollTop = bvr.src_el.scrollHeight;
            '''
        } )


        if message_logs:
            last_message = message_logs[-1].get("message")
            last_login = message_logs[-1].get("login")
        else:
            last_message = ""
            last_login = ""
        div.add_attr("spt_last_message", last_message)
        div.add_attr("spt_last_login", last_login)




        if interval:

            div.add_behavior( {
            'type': 'load',
            'key': key,
            'cbjs_action': r'''
            var text_el = bvr.src_el.getElement(".spt_chat_text");
            var history_el = bvr.src_el.getElement(".spt_chat_history");
            var callback = function(message) {
                //history_el.setStyle("background", "red");
                var login = message.login;
                var timestamp = message.timestamp;
                if (timestamp) {
                    var parts = timestamp.split(" ");
                    parts = parts[1].split(".");
                    timestamp = parts[0];
                }
                else {
                    timestamp = "";
                }

                var tmp = message.message || "";

                var last_message = bvr.src_el.getAttribute("spt_last_message");
                var last_login = bvr.src_el.getAttribute("spt_last_login");
                if (tmp == last_message && login == last_login) {
                    return;
                }
                bvr.src_el.setAttribute("spt_last_message", tmp);
                bvr.src_el.setAttribute("spt_last_login", login);

                var msg = "";
                msg += "<table style='margin-top: 5px; font-size: 1.0em; width: 100%'><tr><td>";
                if (login != last_login) {
                    msg += "<b>"+login+"</b><br/>";
                }
                msg += tmp.replace(/\n/g,'<br/>');
                msg += "</td><td style='text-align: right; margin-bottom: 5px; width: 75px; vertical-align: top'>";
                msg += timestamp;
                msg += "</td></tr></table>";

                if (msg == history_el.last_msg) {
                    return;
                }
                history_el.innerHTML =  history_el.innerHTML + msg;

                // remember last message
                history_el.last_msg = msg;


                history_el.scrollTop = history_el.scrollHeight;
            }
            spt.message.set_interval(bvr.key, callback, 3000, bvr.src_el);
            '''
            } )

        text = TextAreaWdg("chat")
        div.add(text)
        text.add_class("spt_chat_text")
        text.add_style("width: 100%")
        text.add_style("padding: 5px")
        #text.add_style("margin-top: -1px")
        text.add_style("margin-top: 5px")
        
        text.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        bvr.src_el.addEvent("keydown", function(e) {

        var keys = ['tab','keys(control+enter)', 'enter'];
        var key = e.key;
        var input = bvr.src_el
        if (keys.indexOf(key) > -1) e.stop();

        if (key == 'tab') {
        }
        else if (key == 'enter') {
            if (e.control == false) {
                pass;
            }
            else {
                 // TODO: check if it's multi-line first 
                 //... use ctrl-ENTER for new-line, regular ENTER (RETURN) accepts value
                //var tvals = parse_selected_text(input);
                //input.value = tvals[0] + "\\n" + tvals[1];
                //spt.set_cursor_position( input, tvals[0].length + 1 );
            }
        }
        } )
        '''
        } )



        button = ActionButtonWdg(title="Send")
        div.add(button)
        button.add_style("float: right")
        button.add_style("margin: 5px")
        button.add_behavior( {
        'type': 'click_up',
        'key': key,
        'cbjs_action': '''

        var top = bvr.src_el.getParent(".spt_chat_session_top");
        var text_el = top.getElement(".spt_chat_text");
        var message = text_el.value;
        if (!message) {
            return;
        }

        var history_el = top.getElement(".spt_chat_history");

        var category = "chat";
        var server = TacticServerStub.get();

        var key = bvr.key;
        var last_message = server.log_message(key, message, {category:category, status:"in_progress"});

        text_el.value = "";

            '''
        } )

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


        return div
Beispiel #23
0
    def get_display(my):
        widget = DivWdg(id='new_item_panel')
        widget.add_class("new_item_panel")
        widget.add_class("spt_new_item_top")

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

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

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

            div.add_style("width: 350px")

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

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

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

            div.add(HtmlElement.br(2))

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

            div.add("<hr/>")

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

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

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

        elif my.type == 'new_link':

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

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

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

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

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

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

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

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

            #security = Environment.get_security()
            #if security.check_access("builtin", "view_site_admin", "allow"):
            #    select_mode =  SearchTypeSelectWdg.ALL
            #else:
            #    select_mode =  SearchTypeSelectWdg.ALL_BUT_STHPW
            #select = SearchTypeSelectWdg(name='new_search_type', \
            #    mode=select_mode)

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

            div.add(HtmlElement.br())

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

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

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

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

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

            item_div = DivWdg(css='spt_new_item')
            item_div.add_style('display: none')
            div.add(HtmlElement.br())
            div.add(item_div)
            # since it's automated, this button is not needed
            """ 
            save_div = SpanWdg(css='med hand')
            save_div.add(IconWdg('Save', IconWdg.SAVE))
        
            bvr = { "type": "click_up",\
                'cbjs_action': "spt.side_bar.manage_section_action_cbk({"\
                "'value':'save_separator'},'%s');" %my.view}
            save_div.add_behavior(bvr)
            div.add(save_div)
            """
        widget.add(div)
        return widget
Beispiel #24
0
    def get_action_wdg(my, name):
        '''get the action widget for ui option of note entry'''

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

        # note options

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

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

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

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

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

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

        if not sobject:

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

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

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

            my.parent_key = SearchKey.get_by_sobject(parent)

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

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

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

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

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

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

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

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

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

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

        return note_wdg
Beispiel #25
0
    def get_bottom_wdg(self):
        from tactic.ui.widget import ActionButtonWdg
        div = DivWdg()
        div.add_style("margin-top: 10px")

        back = ActionButtonWdg(title="< Back", tip="Go back to last page")
        div.add(back)
        back.add_class("spt_wizard_back")
        back.add_style("float: left")

        # FIXME: need to do this because set_style is not the same element as
        # add class
        back.add_behavior({
            'type':
            'load',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_wizard_top");
        var back = top.getElement(".spt_wizard_back");
        back.setStyle("display", "none");
        '''
        })

        back.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_wizard_top");
        var pages = top.getElements(".spt_wizard_page");
        var on_dots = top.getElements(".spt_wizard_on_dot");
        var off_dots = top.getElements(".spt_wizard_off_dot");

        // check boundary
        if (pages[0].hasClass("spt_wizard_selected")) {
            return;
        }

        var selected_index = 0;
        for (var i = 0; i < pages.length; i++) {
            var page = pages[i];
            var on_dot = on_dots[i];
            var off_dot = off_dots[i];
            if (page.hasClass("spt_wizard_selected")) {
                page.removeClass("spt_wizard_selected");
                selected_index = i;
            }
            page.setStyle("display", "none");
            on_dot.setStyle("display", "none");
            off_dot.setStyle("display", "");
        }

        if (selected_index == 1) {
            var back = top.getElement(".spt_wizard_back");
            back.setStyle("display", "none");
        }
        if (selected_index == pages.length-1) {
            var next = top.getElement(".spt_wizard_next");
            next.setStyle("display", "");
        }

        var page = pages[selected_index-1];
        page.setStyle("display", "");
        page.addClass("spt_wizard_selected");
        var on_dot = on_dots[selected_index-1];
        var off_dot = off_dots[selected_index-1];
        on_dot.setStyle("display", "");
        off_dot.setStyle("display", "none");

        '''
        })

        if self.submit_button:
            submit = self.submit_button
        else:
            submit_title = self.kwargs.get("submit_title")
            command = self.kwargs.get("command")
            script = self.kwargs.get("script")
            jsscript = self.kwargs.get("jsscript")

            if not submit_title:
                submit_title = "Submit"
            submit = ActionButtonWdg(title="%s >>" % submit_title,
                                     tip=submit_title)
            submit.add_class("spt_wizard_submit")
            submit.add_behavior({
                'type':
                'click_up',
                'command':
                command,
                'script':
                script,
                'jsscript':
                jsscript,
                'cbjs_action':
                '''
            var top = bvr.src_el.getParent(".spt_wizard_top");

            var values = spt.api.Utility.get_input_values(top);

            var server = TacticServerStub.get();
            try {
                if (bvr.command) {
                    spt.app_busy.show("Executing ...", "");
                    server.execute_cmd(bvr.command, values);
                }
                else if (bvr.jsscript) {
                    var values = spt.api.get_input_values(top, null, false);
                    spt.CustomProject.run_script_by_path(bvr.jsscript, values);
                }
                else if (bvr.script) {
                    var values = spt.api.get_input_values(top, null, false);
                    server.execute_python_script(bvr.script, {values:values});
                }
                else {
                    alert("No script or command defined");
                }
            }
            catch(e) {
                console.log(e);
                var xml = spt.parse_xml(e);
                var node = xml.getElementsByTagName("string")[0];
                if (node) {
                    var error = node.textContent;
                    spt.error("Error: " + error);
                    spt.app_busy.hide();
                }
                else {
                    alert(e);
                }
                throw(e);
            }
            spt.app_busy.hide();

            '''
            })

        div.add(submit)
        submit.add_style("float: right")

        next = ActionButtonWdg(title="Next >", tip="Go to next page")
        div.add(next)
        next.add_class("spt_wizard_next")
        next.add_style("float: right")

        next.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_wizard_top");
        var pages = top.getElements(".spt_wizard_page");
        var on_dots = top.getElements(".spt_wizard_on_dot");
        var off_dots = top.getElements(".spt_wizard_off_dot");


        // check boundary
        if (pages[pages.length-1].hasClass("spt_wizard_selected")) {
            return;
        }

        var selected_index = 0;
        for (var i = 0; i < pages.length; i++) {
            var page = pages[i];
            var on_dot = on_dots[i];
            var off_dot = off_dots[i];
            if (page.hasClass("spt_wizard_selected")) {
                page.removeClass("spt_wizard_selected");
                selected_index = i;
            }

            page.setStyle("display", "none");
            on_dot.setStyle("display", "none");
            off_dot.setStyle("display", "");
        }

        if (selected_index == pages.length-2) {
            var next = top.getElement(".spt_wizard_next");
            next.setStyle("display", "none");
        }
        if (selected_index == 0) {
            var back = top.getElement(".spt_wizard_back");
            back.setStyle("display", "");
        }

        var page = pages[selected_index+1];
        page.setStyle("display", "");
        page.addClass("spt_wizard_selected");
        var on_dot = on_dots[selected_index+1];
        var off_dot = off_dots[selected_index+1];
        on_dot.setStyle("display", "");
        off_dot.setStyle("display", "none");

        '''
        })

        div.add("<br clear='all'/>")
        return div
Beispiel #26
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()
Beispiel #27
0
    def get_display(self):
        self.check()
        if self.is_refresh:
            div = Widget()
        else:
            div = DivWdg()
            self.set_as_panel(div)
            div.add_style('padding', '6px')
            min_width = '400px'
            div.add_style('min-width', min_width)
            div.add_color('background', 'background')
            div.add_class('spt_add_task_panel')
            div.add_style("padding: 20px")

        from tactic.ui.app import HelpButtonWdg
        help_button = HelpButtonWdg(alias="creating-tasks")
        div.add(help_button)
        help_button.add_style("float: right")
        help_button.add_style("margin-top: -5px")

        if not self.search_key_list:
            msg_div = DivWdg()
            msg_table = Table()
            msg_div.add(msg_table)
            msg_table.add_row()
            msg_table.add_cell(IconWdg("No items selected", IconWdg.WARNING))
            msg_table.add_cell(
                'Please select at least 1 item to add tasks to.')

            msg_div.add_style('margin: 10px')
            msg_table.add_style("font-weight: bold")
            div.add(msg_div)
            return div

        msg_div = DivWdg()
        msg_div.add_style('margin-left: 4px')
        div.add(msg_div, 'info')
        msg_div.add('Total: %s item/s to add tasks to' %
                    len(self.search_key_list))
        div.add(HtmlElement.br())
        hint = HintWdg('Tasks are added according to the assigned pipeline.')
        msg_div.add(" &nbsp; ")
        msg_div.add(hint)
        msg_div.add(HtmlElement.br())

        option_div = DivWdg(css='spt_ui_options')
        #option_div.add_style('margin-left: 12px')

        sel = SelectWdg('pipeline_mode', label='Create tasks by: ')
        sel.set_option('values', ['simple process', 'context', 'standard'])
        sel.set_option('labels',
                       ['process', 'context', 'all contexts in process'])
        sel.set_persistence()
        sel.add_behavior({
            'type': 'change',
            'cbjs_action': 'spt.panel.refresh(bvr.src_el)'
        })

        option_div.add(sel)

        value = sel.get_value()
        # default to simple process
        if not value:
            value = 'simple process'
        msg = ''
        if value not in ['simple process', 'context', 'standard']:
            value = 'simple process'

        if value == 'context':
            msg = 'In context mode, a single task will be created for each selected context.'
        elif value == 'simple process':
            msg = 'In process mode, a single task will be created for each selected process.'

        elif value == 'standard':
            msg = 'In this mode, a task will be created for all contexts of each selected process.'

        option_div.add(HintWdg(msg))
        div.add(option_div)
        div.add(HtmlElement.br())

        title = DivWdg('Assigned Pipelines')
        title.add_style('padding: 6px')
        title.add_color('background', 'background2')
        title.add_color('color', 'color', +120)
        div.add(title)

        content_div = DivWdg()
        content_div.add_style('min-height', '150px')
        div.add(content_div)
        content_div.add_border()

        filtered_search_key_list = []
        for sk in self.search_key_list:
            id = SearchKey.extract_id(sk)
            if id == '-1':
                continue
            filtered_search_key_list.append(sk)

        sobjects = SearchKey.get_by_search_keys(filtered_search_key_list)
        skipped = []
        pipeline_codes = []
        for sobject in sobjects:
            if isinstance(sobject, Task):
                msg_div = DivWdg(
                    'WARNING: Creation of task for [Task] is not allowed.')
                msg_div.add_style('margin-left: 10px')
                div.add(msg_div, 'info')
                return div
            pipeline_code = sobject.get_value('pipeline_code',
                                              no_exception=True)
            if not pipeline_code:
                skipped.append(sobject)
            if pipeline_code not in pipeline_codes:
                pipeline_codes.append(pipeline_code)

        pipelines = Search.get_by_code('sthpw/pipeline', pipeline_codes)
        if pipelines == None:
            pipelines = []
        #if not pipelines:
        #    msg_div = DivWdg('WARNING: No Pipelines found for selected.')
        #    msg_div.add_style('margin-left: 10px')
        #    div.add(msg_div, 'info')
        #    return div

        # expand the width according to num of pipelines
        content_div.add_style('min-width', len(pipelines) * 250)
        mode_cb = SelectWdg('pipeline_mode')
        mode_cb.set_persistence()
        mode = mode_cb.get_value()
        if 'context' == mode:
            mode = 'context'
        else:
            mode = 'process'

        show_subpipeline = True
        min_height = '150px'

        # create a temp default pipeline
        if not pipelines:
            pipeline = SearchType.create("sthpw/pipeline")
            pipeline.set_value("code", "__default__")
            pipeline.set_value(
                "pipeline", '''
<pipeline>
    <process name='publish'/>
</pipeline>
            ''')
            # FIXME: HACK to initialize virtual pipeline
            pipeline.set_pipeline(pipeline.get_value("pipeline"))
            pipelines = [pipeline]

        for pipeline in pipelines:
            name = pipeline.get_value("name")
            if not name:
                name = pipeline.get_code()
            span = SpanWdg("Pipeline: %s" % name)
            span.add_style('font-weight: bold')
            v_div = FloatDivWdg(span)
            v_div.add_style('margin: 20px')
            v_div.add_style('min-height', min_height)
            v_div.add(HtmlElement.br(2))
            content_div.add(v_div)
            processes = pipeline.get_processes(recurse=show_subpipeline,
                                               type=['manual', 'approval'])

            cb_name = '%s|task_process' % pipeline.get_code()
            master_cb = CheckboxWdg('master_control')
            master_cb.set_checked()
            master_cb.add_behavior({
                'type':
                'click_up',
                'propagate_evt':
                True,
                'cbjs_action':
                '''
                    var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_add_task_panel'),'%s');
                    for (var i = 0; i < inputs.length; i++)
                        inputs[i].checked = bvr.src_el.checked;
                        ''' % cb_name
            })
            toggle_div = DivWdg()
            toggle_div.add(SpanWdg(master_cb, css='small'))
            label = HtmlElement.i('toggle all')
            label.add_style('color: #888')
            toggle_div.add_styles(
                'border-bottom: 1px solid #888; width: 170px')
            toggle_div.add(label)
            v_div.add(toggle_div)
            process_names = []

            for process in processes:
                process_labels = []
                if process.is_from_sub_pipeline():
                    process_name = process.get_full_name()
                else:
                    process_name = process.get_name()

                process_label = process.get_label()
                if not process_label:
                    process_label = ''
                if mode == 'context':
                    contexts = pipeline.get_output_contexts(process.get_name())

                    labels = contexts
                    if process.is_from_sub_pipeline():
                        labels = [
                            '%s/%s' % (process.parent_pipeline_code, x)
                            for x in contexts
                        ]

                    for x in labels:
                        process_labels.append(process_label)

                    # prepend process to contexts in this mode to ensure uniqueness
                    contexts = ['%s:%s' % (process_name, x) for x in contexts]
                else:
                    contexts = [process_name]
                    labels = contexts

                    process_labels.append(process_label)

                for idx, context in enumerate(contexts):
                    cb = CheckboxWdg(cb_name)
                    cb.set_checked()
                    cb.set_option('value', context)
                    v_div.add(SpanWdg(cb, css='small'))
                    if mode == 'context':
                        span = SpanWdg(process_name, css='med')
                        #span.add_color('color','color')
                        v_div.add(span)
                    v_div.add(SpanWdg(labels[idx]))
                    process_label = process_labels[idx]
                    if process_label:
                        v_div.add(SpanWdg("(%s)" % process_label, css='small'))
                    v_div.add(HtmlElement.br())

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

        skipped = []

        if True:
            div.add("<br/>")
            btn = ActionButtonWdg(title='Add Tasks')
            btn.add_behavior({
                'type': 'click_up',
                'post_event': 'search_table_%s' % self.table_id,
                'cbjs_action': '''
            spt.dg_table.add_task_selected(bvr);
            ''',
                'search_key_list': self.search_key_list
            })
            cb = CheckboxWdg('skip_duplicated', label='Skip Duplicates')
            cb.set_checked()
            option_div = DivWdg(cb)
            option_div.add_style('width', '130px')
            option_div.add_style('align: left')
            div.add(option_div)
            div.add(HtmlElement.br())
            btn.add_style("float: right")
            div.add(btn)
            div.add(HtmlElement.br(clear="all"))

        if skipped:
            content_div.add(HtmlElement.br())
            skip_div = DivWdg('Missing pipeline code (Skipped)')
            skip_div.add_style('text-decoration: underline')
            content_div.add(skip_div)
            content_div.add(HtmlElement.br())
            item_div = DivWdg()
            item_div.add_style('margin-left: 10px')
            content_div.add(item_div)
        for skip in skipped:
            item_div.add(skip.get_code())
            item_div.add(HtmlElement.br())

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

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

        top.add_color("background", "background")
        top.add_style("padding: 30px")
        top.add_style("width: 300px")

        icon = IconWdg("Not signed in", IconWdg.WARNING)
        top.add(icon)

        top.add("You are not signed into Perforce.")
        top.add("<br/>" * 2)

        table = Table()
        top.add(table)

        from tactic.ui.input import TextInputWdg, PasswordInputWdg

        table.add_row()
        td = table.add_cell("Port: ")
        td.add_style("width: 75px")

        text = TextInputWdg(name="port")
        td = table.add_cell(text)
        td.add_style("vertical-align: top")
        text.set_value("1666")

        table.add_row()
        td = table.add_cell("Login: "******"vertical-align: top")
        td.add_style("width: 75px")

        text = TextInputWdg(name="user")
        td = table.add_cell(text)
        td.add_style("vertical-align: top")
        user = Environment.get_user_name()
        text.set_value(user)

        table.add_row()

        td = table.add_cell("Password: "******"vertical-align: top")

        text = PasswordInputWdg(name="password")
        table.add_cell(text)

        tr = table.add_row()
        table.add_row_cell("&nbsp;")

        tr = table.add_row()
        tr.add_class("spt_workspaces")
        #tr.add_style("display: none")
        td = table.add_cell("Workspace: ")
        td.add_style("vertical-align: top")

        workspaces = my.kwargs.get("workspaces")
        td = table.add_cell()
        button = ActionButtonWdg(width='55', title="Lookup")
        td.add(button)
        button.add_style("float: right")

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            try {
                var workspaces = spt.scm.get_workspaces();

                var clients = [];
                for (var i = 0; i < workspaces.length; i++) {
                    clients.push(workspaces[i].client);
                }
                clients = clients.join("|");
                var kwargs = {
                    workspaces: clients
                }
                spt.scm.show_login(kwargs);
            }
            catch(e) {
                spt.scm.signout_user();
                spt.scm.show_login();
            }
            '''
        })

        if not workspaces:
            text = TextInputWdg(name="workspace")
            text.add_style("width: 165px")
            td.add(text)

        else:
            select = SelectWdg("workspace")
            td.add(select)
            select.set_option("values", workspaces)

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

        button = ActionButtonWdg(title="Sign In >>", size='medium')
        top.add(button)
        button.add_style("float: right")

        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_sign_in_top");
            var values = spt.api.get_input_values(top);

            var port = values.port[0];
            var user = values.user[0];
            var password = values.password[0];
            var client = values.workspace[0];


            if (!port) {
                alert("No port specified");
                return;
            }
            if (!user) {
                alert("No user specified");
                return;
            }
            if (!client) {
                alert("No workspace specified");
                return;
            }



            // login in user
            spt.scm.port = port;
            spt.scm.user = user;
            spt.scm.password = password;

            // test the connection
            var ping = spt.scm.ping();
            if (ping != "OK") {
                alert("Cannot connect to Perforce")
                spt.scm.signout_user();
                spt.scm.show_login();
            }
            else {
                spt.scm.client = client;

                // close the popup
                var popup = bvr.src_el.getParent(".spt_popup");
                if (popup) {
                    spt.popup.destroy(popup);
                }

                // NOTE: this is global: find a check-in widget and refresh
                var checkin_el = $(document.body).getElement(".spt_checkin_top");
                spt.panel.refresh(checkin_el);
            }

            '''
        })

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

        return top
    def get_simple_definition_wdg(my):

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

        title.add("Column Definition")

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

        detail_wdg.add(HtmlElement.br(2))

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

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

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

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

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

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

        detail_wdg.add(nullable)

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

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

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

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

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


            '''
        })

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

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

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

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

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

        return detail_wdg
Beispiel #30
0
    def get_display(my):

        my.sobject = my.kwargs.get("sobject")
        search_key = my.sobject.get_search_key()

        top = DivWdg()
        top.add_class("spt_checkin_publish")
        top.add_style("padding: 10px")

        margin_top = '60px'
        top.add_style("margin-top", margin_top)
        top.add_style("position: relative")

        current_changelist = WidgetSettings.get_value_by_key(
            "current_changelist")
        current_branch = WidgetSettings.get_value_by_key("current_branch")
        current_workspace = WidgetSettings.get_value_by_key(
            "current_workspace")

        top.add("Branch: %s<br/>" % current_branch)
        top.add("Changelist: %s<br/>" % current_changelist)
        top.add("Workspace: %s<br/>" % current_workspace)
        top.add("<br/>")

        checked_out_div = DivWdg()
        checkbox = CheckboxWdg("editable")
        top.add(checked_out_div)
        checkbox.add_class("spt_checkin_editable")
        checked_out_div.add(checkbox)
        checked_out_div.add("Leave files editable")

        top.add("<br/>")

        top.add("Publish Description<br/>")
        text = TextAreaWdg("description")
        # this needs to be set or it will stick out to the right
        text.add_style("width: 220px")
        text.add_class("spt_checkin_description")
        top.add(text)

        # add as a note
        note_div = DivWdg()
        top.add(note_div)
        note_div.add_class("spt_add_note")
        checkbox = CheckboxWdg("add_note")

        web = WebContainer.get_web()
        browser = web.get_browser()
        if browser in ['Qt']:
            checkbox.add_style("margin-top: -4px")
            checkbox.add_style("margin-right: 3px")
            note_div.add_style("margin-top: 3px")

        checkbox.add_class("spt_checkin_add_note")
        note_div.add(checkbox)
        note_div.add("Also add as note")

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

        button = ActionButtonWdg(title="Check-in",
                                 icon=IconWdg.PUBLISH,
                                 size='medium')
        top.add(button)

        my.repo_type = 'perforce'
        if my.repo_type == 'perforce':

            # the depot is set per project (unless overridden)
            project = my.sobject.get_project()
            depot = project.get_value("location", no_exception=True)
            if not depot:
                depot = project.get_code()

            asset_dir = Environment.get_asset_dir()
            sandbox_dir = Environment.get_sandbox_dir()

            changelist = WidgetSettings.get_value_by_key("current_changelist")
            button.add_behavior({
                'type':
                'click_up',
                'depot':
                depot,
                'changelist':
                changelist,
                'sandbox_dir':
                sandbox_dir,
                'search_key':
                search_key,
                'cbjs_action':
                '''

            var paths = spt.checkin.get_selected_paths();
            spt.app_busy.show("Checking in "+paths.length+" file/s into Perforce");
            var top = bvr.src_el.getParent(".spt_checkin_top");
            var description = top.getElement(".spt_checkin_description").value;
            var add_note = top.getElement(".spt_checkin_add_note").value;
            var editable = top.getElement(".spt_checkin_editable").value;

            if (editable == 'on') {
                editable = true;
            }
            else {
                editable = false;
            }

            var process = top.getElement(".spt_checkin_process").value;

            // check into TACTIC
            var server = TacticServerStub.get();

            var revisions = [];
            server.start({description: "File Check-in"});

            try {

            var top = bvr.src_el.getParent(".spt_checkin_top");
            var el = top.getElement(".spt_mode");
            var mode = el.value;

            // check-in the changelist
            var changelist = 'default';
            if (mode == 'changelist') {
                var scm_info = spt.scm.run("commit_changelist", [changelist, description]);

                for ( var i = 1; i < scm_info.length-1; i++) {
                    // the first item is the changelist number
                    //console.log(scm_info[i]);

                    var action = scm_info[i];
                    revision = action.rev;
                    revisions.push(revision);

                    // Do an inplace check-in into TACTIC
                    var path = action.depotFile;

                    var parts = path.split("/");
                    var filename = parts[parts.length-1];
                    var context = process + "/" + filename;

                    var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} );
                }

            }
            else {

                // check in all of the files
                for ( var i = 0; i < paths.length; i++) {
                    var path = paths[i];
                    var scm_info = spt.scm.run("commit_file", [path, description, editable]);
                    // the first item is the changelist number
                    var action = scm_info[1];
                    revision = action.rev;
                    revisions.push(revision);

                    var parts = path.split("/");
                    var filename = parts[parts.length-1];
                    var context = process + "/" + filename;

                    //path = path.replace(bvr.sandbox_dir, "//"+bvr.depot);
                    // NOTE: this assumes project == depot
                    path = path.replace(bvr.sandbox_dir, "//");

                    // Do an inplace check-in into TACTIC
                    var snapshot = server.simple_checkin(bvr.search_key, context, path, {description: description, mode: "perforce", version: revision} );
                }
            }


            if (add_note == 'on') {
                var note = [];
                note.push('CHECK-IN');
                for (var i = 0; i < paths.length; i++) { 
                    var parts = paths[i].split("/");
                    var filename = parts[parts.length-1];
                    note.push(filename+' (v'+revisions[i]+')');
                }
                note.push(': ');
                note.push(description);

                note = note.join(" ");
                server.create_note(bvr.search_key, note, {process: process});
            }
            server.finish({description: "File Check-in ["+paths.length+" file/s]"});
            spt.panel.refresh(top);

            }
            catch(e) {
              spt.error("Error detected: " + e.msg)
              //console.log(e);
              server.abort();
            }

            spt.app_busy.hide();
            '''
            })
        else:
            button.add_behavior(behavior)

        button.add_style("margin-right: auto")
        button.add_style("margin-left: auto")
        button.add_style("margin-top: 20px")
        button.add_style("margin-bottom: 20px")

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

        hidden = HiddenWdg("checkin_type")
        top.add(hidden)
        hidden.add_class("spt_checkin_type")

        grey_out_div = DivWdg()
        top.add(grey_out_div)
        grey_out_div.add_class("spt_publish_disable")
        grey_out_div.add_style("position: absolute")
        grey_out_div.add_style("left: 0px")
        grey_out_div.add_style("top: 10px")
        grey_out_div.add_style("opacity: 0.6")
        grey_out_div.add_color("background", "background")
        grey_out_div.add_style("height: 100%")
        grey_out_div.add_style("width: 100%")
        #grey_out_div.add_border()

        return top