def get_timecode_textbox(self, name, width=200, line_data=None):
        timecode_textbox = TextInputWdg()
        timecode_textbox.set_id(name)
        timecode_textbox.set_name(name)
        timecode_textbox.add_style('width', '{0}px'.format(width))

        timecode_textbox.add_behavior(get_add_colons_for_time_behavior())

        if line_data:
            timecode_textbox.set_value(line_data)

        return timecode_textbox
Ejemplo n.º 2
0
def get_text_input_wdg(name, data, width=200, timecode=False):
    textbox_wdg = TextInputWdg()
    textbox_wdg.set_id(name)
    textbox_wdg.set_name(name)
    textbox_wdg.add_style('width', '{0}px'.format(width))

    if timecode:
        textbox_wdg.add_behavior(get_add_colons_for_time_behavior())

    if data:
        textbox_wdg.set_value(data)

    return textbox_wdg
Ejemplo n.º 3
0
def get_text_input_wdg(name, data, width=200, timecode=False):
    textbox_wdg = TextInputWdg()
    textbox_wdg.set_id(name)
    textbox_wdg.set_name(name)
    textbox_wdg.add_style('width', '{0}px'.format(width))

    if timecode:
        textbox_wdg.add_behavior(get_add_colons_for_time_behavior())

    if data:
        textbox_wdg.set_value(data)

    return textbox_wdg
Ejemplo n.º 4
0
    def get_text_input_for_element_eval_line_wdg(name,
                                                 data,
                                                 is_checked,
                                                 width=200,
                                                 timecode=False):
        textbox_wdg = TextInputWdg()
        textbox_wdg.set_id(name)
        textbox_wdg.set_name(name)
        textbox_wdg.add_style('width', '{0}px'.format(width))

        if not is_checked:
            textbox_wdg.add_style('font-weight', 'bold')

        if timecode:
            textbox_wdg.add_behavior(get_add_colons_for_time_behavior())

        if data:
            textbox_wdg.set_value(data)

        return textbox_wdg
Ejemplo n.º 5
0
    def get_display(self):

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

        inner = DivWdg()
        top.add(inner)


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

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


        if not pipelines:
            div = DivWdg()
            inner.add(div)
            inner.add_style("padding: 50px")
            div.add_border()
            div.add_color("color", "color3")
            div.add_color("background", "background3")
            div.add_style("width: 400px")
            div.add_style("height: 100px")
            div.add_style("padding: 30px")
           
            icon = IconWdg("WARNING", IconWdg.WARNING)
            div.add(icon)
            div.add("<b>This Searchable Type does not have pipelines defined.</b>")
            div.add("<br/>"*2)

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

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

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

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

            return top



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



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

        buttons_div = DivWdg()
        pipelines_div.add(buttons_div)

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

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


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

        '''
        } )


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




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


            code = pipeline.get_code()
            label = '%s  (%s)' %(pipeline.get('name'), code)
            pipeline_div.add_attr("spt_pipeline_code", code)

            title = DivWdg()
            pipeline_div.add(title)
            title.add("Pipeline: ")
            
            title.add(label)
            title.add_style("padding: 8px 10px")
            title.add_color("background", "background3")
            title.add_style("font-weight: bold")
            title.add_style("margin: -10 -10 5 -10")


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

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



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

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


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

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

            processes.insert(0, "")

            for i, process in enumerate(processes):

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

                process_type = 'manual'
                process_xpos = ''
                process_ypos = ''
                # get the task pipeline for this process
                if process_name:
                    process = pipeline.get_process(process_name)
                    process_type = process.get_type()
                    process_xpos = process.get_attribute('xpos')
                    process_ypos = process.get_attribute('ypos')

                    task_pipeline_code = process.get_task_pipeline()
                    if task_pipeline_code != "task":
                        task_pipeline = Search.get_by_code("sthpw/pipeline", task_pipeline_code)
                    else:
                        task_pipeline = None
                else:
                    task_pipeline_code = "task"
                    task_pipeline = None

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


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

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

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

                text = TextInputWdg(name="process")
                process_cell = table.add_cell(text)
                text.add_style("width: 95px")
                text.add_style("margin: 5px")
                text.set_value(process_name)
                text.add_class("spt_process")

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

                hidden = HiddenWdg(name='process_type')
                hidden.set_value(process_type)
                process_cell.add(hidden)

                hidden = HiddenWdg(name='process_xpos')
                hidden.set_value(process_xpos)
                process_cell.add(hidden)

                hidden = HiddenWdg(name='process_ypos')
                hidden.set_value(process_ypos)
                process_cell.add(hidden)


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

                
                if process_type in ['manual','approval']:
                    read_only = False
                else:
                    read_only = True
                text = TextInputWdg(name="task_status", read_only=read_only)

                table.add_cell(text)
                text.add_style("width: 325px")
                text.add_style("margin: 5px")

                #text.set_value(statuses_str)
                    #text.add_style("opacity: 0.5")
                

                text.add_style("border-style: none")
                if process_type in ['manual','approval']:
                    if task_pipeline:
                        statuses = task_pipeline.get_process_names()
                        text.set_value(",".join(statuses))
                    else:
                        text.set_value("(default)")
                    text.add_behavior( {
                    'type': 'click_up',
                    'statuses': statuses_str,
                    'cbjs_action': '''
                    if (bvr.src_el.value == '(default)') {
                        bvr.src_el.value = bvr.statuses;
                    }
                    '''
                    } )

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

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

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

                    var class_name = 'tactic.ui.tools.TriggerToolWdg';
                    var kwargs = {
                        mode: "pipeline",
                        process: process,
                        pipeline_code: bvr.pipeline_code
                    };
                    spt.panel.load_popup("Trigger", class_name, kwargs);
     
                    '''
                } )

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

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

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

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


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



        if self.kwargs.get("is_refresh"):
            return inner
        else:
            return top
Ejemplo n.º 6
0
    def get_base_dir_wdg(my):

        div = DivWdg()

        title = DivWdg()
        div.add(title)
        title.add("Sync Project Import: ")
        title.add_style("font-size: 14px")
        title.add_style("font-weight: bold")

        div.add("<br/>")

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

        is_local = False

        if is_local:
            button = ActionButtonWdg(title="Browse")
            div.add(button)
            button.add_style("float: right")
            button.add_style("margin-top: -5px")
            button.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                var applet = spt.Applet.get();
                var files = applet.open_file_browser();
                if (!files.length) {
                    return;
                }

                var file = files[0];

                var top = bvr.src_el.getParent(".spt_sync_import_top");
                var el = top.getElement(".spt_sync_base_dir");
                el.value = file;

                '''
            })

        div.add("Share Location: ")

        text = TextInputWdg(name="base_dir")
        div.add(text)
        text.add_class("spt_sync_base_dir")
        text.add_style("width: 300px")
        if base_dir:
            text.set_value(base_dir)

        text.add_behavior({
            'type':
            'blur',
            'is_local':
            is_local,
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_sync_import_top");
            var applet = spt.Applet.get();

            var value = bvr.src_el.value;
            var manifest_path = value + "/tactic.txt";


            if (!value) {
                return;
            }

            if (bvr.is_local) {

                if (!applet.exists(value)) {
                    alert('Share folder does not exist.');
                    return;
                }
                if (!applet.exists(manifest_path)) {
                    alert('Cannot find manifest file.');
                    return;
                }

                var data = applet.read_file(manifest_path);
                var json = JSON.parse(data);
                data = JSON.stringify(json);
                top.setAttribute("spt_data", data)
            }

            top.setAttribute("spt_base_dir", value)

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

        return div
Ejemplo n.º 7
0
    def get_display(self):

        top = self.top
        top.add_color("background", "background")
        top.add_class("spt_columns_top")
        self.set_as_panel(top)
        top.add_style("padding: 10px")

        search_type = self.kwargs.get("search_type")
        search_type_obj = SearchType.get(search_type)

        inner = DivWdg()
        top.add(inner)
        inner.add_style("width: 800px")

        #text = TextWdg("search_type")
        text = HiddenWdg("search_type")
        inner.add(text)
        text.set_value(search_type)

        title_wdg = DivWdg()
        inner.add(title_wdg)
        title_wdg.add( search_type_obj.get_title() )
        title_wdg.add(" <i style='font-size: 9px;opacity: 0.5'>(%s)</i>" % search_type)
        title_wdg.add_style("padding: 5px")
        title_wdg.add_color("background", "background3")
        title_wdg.add_color("color", "color3")
        title_wdg.add_style("margin: -10px -10px 10px -10px")
        title_wdg.add_style("font-weight: bold")





        shelf_wdg = DivWdg()
        inner.add(shelf_wdg)
        shelf_wdg.add_style("height: 35px")
        button = ActionButtonWdg(title='Create', color="default", icon="BS_SAVE")
        shelf_wdg.add(button)
        shelf_wdg.add_style("float: right")




        button.add_behavior( {
            'type': 'click_up',
            'search_type': search_type,
            'cbjs_action': '''
            var class_name = 'tactic.ui.startup.ColumnEditCbk';
            var top = bvr.src_el.getParent(".spt_columns_top");

            var elements = top.getElements(".spt_columns_element");

            var values = [];
            for (var i = 0; i < elements.length; i++ ) {
                var data = spt.api.Utility.get_input_values(elements[i], null, false);
                values.push(data)
            }

            var kwargs = {
                search_type: bvr.search_type,
                values: values
            }


            var server = TacticServerStub.get();
            try {
                server.execute_cmd(class_name, kwargs);

                var names = [];
                for (var i = 0; i < values.length; i++) {
                    var name = values[i].name;
                    name = name.strip();
                    if (name == '') { continue; }
                    names.push(name);
                }

                // Unless there is a table here, we should not do this.
                // Better handled with a callback
                //spt.table.add_columns(names)

                // prevent grabbing all values, pass in a dummy one
                spt.panel.refresh(top, {'refresh': true});

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

            '''
        } )
        

        # add the headers
        table = Table()
        inner.add(table)
        table.add_style("width: 100%")
        tr = table.add_row()
        tr.add_color("background", "background", -5)
        th = table.add_header("Column Name")
        th.add_style("width: 190px")
        th.add_style("text-align: left")
        th.add_style("padding: 8px 0px")
        th = table.add_header("Format")
        th.add_style("text-align: left")
        th.add_style("padding: 8px 0px")


        from tactic.ui.container import DynamicListWdg
        dyn_list = DynamicListWdg()
        inner.add(dyn_list)


        from tactic.ui.manager import FormatDefinitionEditWdg

        for i in range(0, 4):
            column_div = DivWdg()
            column_div.add_class("spt_columns_element")
            if i == 0:
                dyn_list.add_template(column_div)
            else:
                dyn_list.add_item(column_div)

            column_div.add_style("padding: 3px")
            column_div.add_style("float: left")

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

            from tactic.ui.input import TextInputWdg
            text_wdg = TextInputWdg(name="name", height="30px", width="170px")
            text_wdg.add_class("form-control")
            text_wdg.add_class("display: inline-block")
            td = table.add_cell(text_wdg)
            text_wdg.add_behavior( {
                'type': 'blur',
                'cbjs_action': '''
                var value = bvr.src_el.value;
                var code = spt.convert_to_alpha_numeric(value);
                bvr.src_el.value = code;
                '''
            } )

            option = {
            'name': '_dummy',
            'values': 'integer|float|percent|currency|date|time|scientific|boolean|text|timecode',
            }
            format_wdg = FormatDefinitionEditWdg(option=option)

            td = table.add_cell(format_wdg)
            td.add_style("width: 550px")
            td.add_style("padding-left: 10px")


        # show the current columns
        title_wdg = DivWdg()
        inner.add(title_wdg)
        title_wdg.add_style("margin-top: 25px")
        title_wdg.add("<b>Existing Columns</b>")
        title_wdg.add_style("padding: 5px")
        title_wdg.add_style("margin: 20px -10px 10px -10px")

        inner.add("<hr/>")


        config = WidgetConfigView.get_by_search_type(search_type, "definition")
        element_names = config.get_element_names()

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

        tr = table.add_row()
        tr.add_color("background", "background", -5)
        th = table.add_header("Column")
        th.add_style("text-align: left")
        th.add_style("padding: 5px 0px")
        th = table.add_header("Data Type")
        th.add_style("text-align: left")
        th.add_style("padding: 5px 0px")
        th = table.add_header("Format")
        th.add_style("text-align: left")
        th.add_style("padding: 5px 0px")
        th = table.add_header("Edit")
        th.add_style("text-align: left")
        th.add_style("padding: 5px 0px")

        count = 0
        for element_name in element_names:
            display_class = config.get_display_handler(element_name)

            if display_class != 'tactic.ui.table.FormatElementWdg':
                continue

            table.add_row()

            display_options = config.get_display_options(element_name)
            format = display_options.get("format")
            if not format:
                format = '<i>text</i>'
            data_type = display_options.get("type")

            table.add_cell(element_name)
            table.add_cell(data_type)
            table.add_cell(format)

            td = table.add_cell()
            button = IconButtonWdg(title="Edit Definition", icon="BS_EDIT")
            td.add(button)

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

            var class_name = 'tactic.ui.manager.ElementDefinitionWdg';
            var kwargs = {
                search_type: bvr.search_type,
                view: 'definition',
                element_name: bvr.element_name
            };
            spt.panel.load_popup("Element Definition", class_name, kwargs);
            '''
            } )

            count += 1


        if not count:
            table.add_row()
            td = table.add_cell()
            td.add_style("height: 80px")
            td.add("No existing columns found")
            td.add_style("text-align: center")
            td.add_color("background", "background", -2)





        if self.kwargs.get("is_refresh"):
            return inner
        else:
            return top
Ejemplo n.º 8
0
    def get_base_dir_wdg(self):

        div = DivWdg()

        title = DivWdg()
        div.add(title)
        title.add("Sync Project Import: ")
        title.add_style("font-size: 14px")
        title.add_style("font-weight: bold")

        div.add("<br/>")


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

        is_local = False

        if is_local:
            button = ActionButtonWdg(title="Browse")
            div.add(button)
            button.add_style("float: right")
            button.add_style("margin-top: -5px")
            button.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                var applet = spt.Applet.get();
                var files = applet.open_file_browser();
                if (!files.length) {
                    return;
                }

                var file = files[0];

                var top = bvr.src_el.getParent(".spt_sync_import_top");
                var el = top.getElement(".spt_sync_base_dir");
                el.value = file;

                '''
            } )



        div.add("Share Location: ")


        text = TextInputWdg(name="base_dir")
        div.add(text)
        text.add_class("spt_sync_base_dir")
        text.add_style("width: 300px")
        if base_dir:
            text.set_value(base_dir)


        text.add_behavior( {
            'type': 'blur',
            'is_local': is_local,
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_sync_import_top");
            var applet = spt.Applet.get();

            var value = bvr.src_el.value;
            var manifest_path = value + "/tactic.txt";


            if (!value) {
                return;
            }

            if (bvr.is_local) {

                if (!applet.exists(value)) {
                    alert('Share folder does not exist.');
                    return;
                }
                if (!applet.exists(manifest_path)) {
                    alert('Cannot find manifest file.');
                    return;
                }

                var data = applet.read_file(manifest_path);
                var json = JSON.parse(data);
                data = JSON.stringify(json);
                top.setAttribute("spt_data", data)
            }

            top.setAttribute("spt_base_dir", value)

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

        return div
Ejemplo n.º 9
0
    def get_display(self):

        top = self.top
        top.add_color("background", "background")
        top.add_class("spt_columns_top")
        self.set_as_panel(top)
        top.add_style("padding: 10px")

        search_type = self.kwargs.get("search_type")
        search_type_obj = SearchType.get(search_type)

        inner = DivWdg()
        top.add(inner)
        inner.add_style("width: 800px")

        #text = TextWdg("search_type")
        text = HiddenWdg("search_type")
        inner.add(text)
        text.set_value(search_type)

        title_wdg = DivWdg()
        inner.add(title_wdg)
        title_wdg.add(search_type_obj.get_title())
        title_wdg.add(" <i style='font-size: 9px;opacity: 0.5'>(%s)</i>" %
                      search_type)
        title_wdg.add_style("padding: 5px")
        title_wdg.add_color("background", "background3")
        title_wdg.add_color("color", "color3")
        title_wdg.add_style("margin: -10px -10px 10px -10px")
        title_wdg.add_style("font-weight: bold")

        shelf_wdg = DivWdg()
        inner.add(shelf_wdg)
        shelf_wdg.add_style("height: 35px")
        button = ActionButtonWdg(title='Create',
                                 color="default",
                                 icon="BS_SAVE")
        shelf_wdg.add(button)
        shelf_wdg.add_style("float: right")

        button.add_behavior({
            'type':
            'click_up',
            'search_type':
            search_type,
            'cbjs_action':
            '''
            var class_name = 'tactic.ui.startup.ColumnEditCbk';
            var top = bvr.src_el.getParent(".spt_columns_top");

            var elements = top.getElements(".spt_columns_element");

            var values = [];
            for (var i = 0; i < elements.length; i++ ) {
                var data = spt.api.Utility.get_input_values(elements[i], null, false);
                values.push(data)
            }

            var kwargs = {
                search_type: bvr.search_type,
                values: values
            }


            var server = TacticServerStub.get();
            try {
                server.execute_cmd(class_name, kwargs);

                var names = [];
                for (var i = 0; i < values.length; i++) {
                    var name = values[i].name;
                    name = name.strip();
                    if (name == '') { continue; }
                    names.push(name);
                }

                // Unless there is a table here, we should not do this.
                // Better handled with a callback
                //spt.table.add_columns(names)

                // prevent grabbing all values, pass in a dummy one
                spt.panel.refresh(top, {'refresh': true});

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

            '''
        })

        # add the headers
        table = Table()
        inner.add(table)
        table.add_style("width: 100%")
        tr = table.add_row()
        tr.add_color("background", "background", -5)
        th = table.add_header("Column Name")
        th.add_style("width: 190px")
        th.add_style("text-align: left")
        th.add_style("padding: 8px 0px")
        th = table.add_header("Format")
        th.add_style("text-align: left")
        th.add_style("padding: 8px 0px")

        from tactic.ui.container import DynamicListWdg
        dyn_list = DynamicListWdg()
        inner.add(dyn_list)

        from tactic.ui.manager import FormatDefinitionEditWdg

        for i in range(0, 4):
            column_div = DivWdg()
            column_div.add_class("spt_columns_element")
            if i == 0:
                dyn_list.add_template(column_div)
            else:
                dyn_list.add_item(column_div)

            column_div.add_style("padding: 3px")
            column_div.add_style("float: left")

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

            from tactic.ui.input import TextInputWdg
            text_wdg = TextInputWdg(name="name", height="30px", width="170px")
            text_wdg.add_class("form-control")
            text_wdg.add_class("display: inline-block")
            td = table.add_cell(text_wdg)
            text_wdg.add_behavior({
                'type':
                'blur',
                'cbjs_action':
                '''
                var value = bvr.src_el.value;
                var code = spt.convert_to_alpha_numeric(value);
                bvr.src_el.value = code;
                '''
            })

            option = {
                'name':
                '_dummy',
                'values':
                'integer|float|percent|currency|date|time|scientific|boolean|text|timecode',
            }
            format_wdg = FormatDefinitionEditWdg(option=option)

            td = table.add_cell(format_wdg)
            td.add_style("width: 550px")
            td.add_style("padding-left: 10px")

        # show the current columns
        title_wdg = DivWdg()
        inner.add(title_wdg)
        title_wdg.add_style("margin-top: 25px")
        title_wdg.add("<b>Existing Columns</b>")
        title_wdg.add_style("padding: 5px")
        title_wdg.add_style("margin: 20px -10px 10px -10px")

        inner.add("<hr/>")

        config = WidgetConfigView.get_by_search_type(search_type, "definition")
        element_names = config.get_element_names()

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

        tr = table.add_row()
        tr.add_color("background", "background", -5)
        th = table.add_header("Column")
        th.add_style("text-align: left")
        th.add_style("padding: 5px 0px")
        th = table.add_header("Data Type")
        th.add_style("text-align: left")
        th.add_style("padding: 5px 0px")
        th = table.add_header("Format")
        th.add_style("text-align: left")
        th.add_style("padding: 5px 0px")
        th = table.add_header("Edit")
        th.add_style("text-align: left")
        th.add_style("padding: 5px 0px")

        count = 0
        for element_name in element_names:
            display_class = config.get_display_handler(element_name)

            if display_class != 'tactic.ui.table.FormatElementWdg':
                continue

            table.add_row()

            display_options = config.get_display_options(element_name)
            format = display_options.get("format")
            if not format:
                format = '<i>text</i>'
            data_type = display_options.get("type")

            table.add_cell(element_name)
            table.add_cell(data_type)
            table.add_cell(format)

            td = table.add_cell()
            button = IconButtonWdg(title="Edit Definition", icon="BS_EDIT")
            td.add(button)

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

            var class_name = 'tactic.ui.manager.ElementDefinitionWdg';
            var kwargs = {
                search_type: bvr.search_type,
                view: 'definition',
                element_name: bvr.element_name
            };
            spt.panel.load_popup("Element Definition", class_name, kwargs);
            '''
            })

            count += 1

        if not count:
            table.add_row()
            td = table.add_cell()
            td.add_style("height: 80px")
            td.add("No existing columns found")
            td.add_style("text-align: center")
            td.add_color("background", "background", -2)

        if self.kwargs.get("is_refresh"):
            return inner
        else:
            return top
Ejemplo n.º 10
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()
        td = table.add_cell("Workspace: ")
        td.add_style("vertical-align: top")
        text = TextInputWdg(name="workspace")
        td = table.add_cell(text)
        text.add_class("spt_workspace")


        text.add_behavior( {
            'type': 'load',
            '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];

            // TODO: get the workspaces and use this as a list
            // For now, just fill it in with the first one
            if (!client) {
                var workspaces = spt.scm.get_workspaces();
                if (workspaces.length > 0) {
                    var workspace = workspaces[0];
                    var Root = workspace.root;
                    // TODO: make sure Root == snapshot_dir

                    console.log("workspace");
                    console.log(workspace);

                    var client = workspace.client;
                    var workspace_el = top.getElement(".spt_workspace");
                    workspace_el.value = client;
                }
                return;
            }
            ''' } )




        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 (!client) {
                alert("No client selected");
                return;
            }

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



            // test the connection
            var ping = spt.scm.ping();
            if (ping != "OK") {
                spt.scm.show_login();
                return;
            }


            // check the workspaces
            if (!spt.scm.check_workspace()) {
                alert("There was a problem with the given workspace");
                spt.scm.show_login();
                return;
            }

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