Esempio n. 1
0
 def get_display(my):   
     from tactic.ui.widget import SObjectCheckinHistoryWdg
     from pyasm.web import DivWdg, HtmlElement, Table, Html, Widget
     new_number = 0
     if 'number' in my.kwargs.keys():
         new_number = int(my.kwargs.get('number'))
     table = Table()
     table.add_behavior(my.get_updater_behavior())
     table.add_style('width: 100%s;' % '%')
     table.add_row()
     mr_cell = table.add_cell('Inbox (%s)' % new_number)
     mr_cell.add_attr('class','inbox_counter')
     #mr_cell.add_behavior(my.get_updater_behavior())
     return table
Esempio n. 2
0
    def get_display(self):

        top = self.top
        self.set_as_panel(top)
        top.add_class("spt_ingestion_top")
        top.add_color("background", "background", -5)

        self.data = {}

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

        rules_div.add("Rules: ")

        rules_select = SelectWdg("rule_code")
        rule_code = self.get_value('rule_code')
        if rule_code:
            rules_select.set_value(rule_code)
        rules_select.set_option("query", "config/ingest_rule|code|title")
        rules_select.add_empty_option("-- New --")
        rules_div.add(rules_select)
        rules_select.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_ingestion_top");
        value = bvr.src_el.value;
        var class_name = 'tactic.ui.tools.IngestionToolWdg';
        spt.panel.load(top, class_name, {rule_code: value} );
        '''
        } )

        rules_div.add("<hr/>")

        # read from the database
        if rule_code:
            search = Search("config/ingest_rule")
            search.add_filter("code", rule_code)
            sobject = search.get_sobject()
        else:
            sobject = None
        if sobject:
            self.data = sobject.get_value("data")
            if self.data:
                self.data = jsonloads(self.data)

        session_code = self.kwargs.get("session_code")
        if session_code:
            session = Search.get_by_code("config/ingest_session", session_code)
        else:
            if sobject:
                session = sobject.get_related_sobject("config/ingest_session")
                print("sobject: ", sobject.get_code(), sobject.get_value("spt_ingest_session_code"))
                print("parent: ", session)
            else:
                session = None


        if not session:
            #session = SearchType.create("config/ingest_session")
            #session.set_value("code", "session101")
            #session.set_value("location", "local")
            ##session.set_value("base_dir", "C:")
            top.add("No session defined!!!")
            return top



        rule = ""
        filter = ""
        ignore = ""


        # get the base path
        if sobject:
            base_dir = sobject.get_value("base_dir")
        else:
            base_dir = ''

        #else:
        #    base_dir = self.get_value("base_dir")
        #if not base_dir:
        #    base_dir = ''

        if sobject:
            title = sobject.get_value("title")
        else:
            title = ''

        if sobject:
            code = sobject.get_value("code")
        else:
            code = ''


        file_list = self.get_value("file_list")
        scan_type = self.get_value("scan_type")
        action_type = self.get_value("action_type")
        rule = self.get_value("rule")
        if not rule:
            rule = base_dir

        # get the rule for this path
        checkin_mode = "dir"
        depth = 0

        table = Table()
        rules_div.add(table)
        table.add_color("color", "color")


        from tactic.ui.input.text_input_wdg import TextInputWdg


        # add the title
        table.add_row()
        td = table.add_cell()
        td.add("Title: ")
        td = table.add_cell()

        text = TextInputWdg(name="title")
        td.add(text)
        if title:
            text.set_value(title)
        text.add_class("spt_title")
        text.add_style("width: 400px")
        #text.add_color("background", "background", -10)

        # add the optional code
        table.add_row()
        td = table.add_cell()
        td.add("Code (optional): ")
        td = table.add_cell()

        text = TextInputWdg(name="code")
        td.add(text)
        if code:
            text.set_value(code)
            text.set_readonly()
            text.add_color("background", "background", -10)
        text.add_class("spt_code")
        text.add_style("width: 400px")





        table.add_row()
        td = table.add_cell()
        td.add_style("height: 10px")
        td.add("<hr/>")


        table.add_row()
        td = table.add_cell()
        td.add("<b>Scan:</b><br/>")
        td.add("The following information will be used to find the paths that will be operated on by the ingestion process<br/><br/>")


        # add a scan type
        table.add_row()
        td = table.add_cell()
        td.add("Type: ")
        select = SelectWdg("scan_type")
        select.add_class("spt_scan_type")
        td = table.add_cell()
        td.add(select)
        select.set_value( self.get_value("action") )
        labels = ['Simple List', 'Rule', 'Script']
        values = ['list', 'rule', 'script']
        select.set_option("values", values)
        select.set_option("labels", labels)
        if scan_type:
            select.set_value(scan_type)

        table.add_row() 
        table.add_cell("&nbsp;")

        select.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_ingestion_top");
        value = bvr.src_el.value;

        var elements = top.getElements(".spt_scan_list");
        for (var i = 0; i < elements.length; i++) {
          if (value == 'list')
            spt.show(elements[i]);
          else
            spt.hide(elements[i]);
        }

        var elements = top.getElements(".spt_scan_rule");
        for (var i = 0; i < elements.length; i++) {
          if (value == 'rule')
            spt.show(elements[i]);
          else
            spt.hide(elements[i]);
        }
        var elements = top.getElements(".spt_scan_script");
        for (var i = 0; i < elements.length; i++) {
          if (value == 'script')
            spt.show(elements[i]);
          else
            spt.hide(elements[i]);
        }

        '''
        } )

        # add in a list of stuff
        tbody = table.add_tbody()
        tbody.add_class("spt_scan_list")
        if scan_type != 'list':
            tbody.add_style("display: none")

        tr = table.add_row()
        td = table.add_cell()
        td.add("List of files: ")
        td = table.add_cell()

        text = TextAreaWdg(name="file_list")
        td.add(text)
        text.add_style("width: 400px")
        #text.set_readonly()
        #text.add_color("background", "background", -10)
        text.set_value(file_list)

        table.close_tbody()



        # add rule scan mode
        tbody = table.add_tbody()
        tbody.add_class("spt_scan_rule")
        if scan_type != 'rule':
            tbody.add_style("display: none")



        # add the path
        tr = table.add_row()
        td = table.add_cell()
        td.add("Starting Path: ")
        td = table.add_cell()

        hidden = HiddenWdg("session_code", session.get_code() )
        td.add(hidden)

        text = TextInputWdg(name="base_dir")
        td.add(text)
        text.set_value(base_dir)
        text.add_style("width: 400px")
        #text.set_readonly()
        #text.add_color("background", "background", -10)
        text.set_value(base_dir)



        # add rule
        tr = table.add_row()
        td = table.add_cell()
        td.add("Tag Rule: ")
        td = table.add_cell()

        text = TextInputWdg(name="rule")
        td.add(text)
        text.add_style("width: 400px")
        text.set_value(rule)


        tr = table.add_row()
        td = table.add_cell()
        td.add("Filter: ")
        td = table.add_cell()
        text = TextWdg("filter")
        td.add(text)
        text.set_value( self.get_value("filter") )
        text.add_style("width: 400px")
        text.add_style("padding: 2px")
        text.add_style("-moz-border-radius: 5px")




        tr = table.add_row()
        td = table.add_cell()
        td.add("Ignore: ")
        td = table.add_cell()
        text = TextWdg("ignore")
        td.add(text)
        text.set_value( self.get_value("ignore") )
        text.set_value(ignore)
        text.add_style("width: 400px")
        text.add_style("padding: 2px")
        text.add_style("-moz-border-radius: 5px")


        table.add_row()
        td = table.add_cell()
        td.add("Validation script: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 5px")
        td = table.add_cell()
        text = TextInputWdg(name="validation_script")
        text.set_value( self.get_value("validation_script") )
        text.add_style("width: 400px")
        td.add(text)

        icon = IconButtonWdg(title='Edit Validation Script', icon=IconWdg.EDIT)
        icon.add_style("float: right")
        td.add(icon)
        icon.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.named_events.fire_event("show_script_editor");

        var top = bvr.src_el.getParent(".spt_ingestion_top");
        var values = spt.api.Utility.get_input_values(top, null, false);

        var kwargs = {
            script_path: values.validation_script
        }
        setTimeout( function() {
        spt.js_edit.display_script_cbk(evt, kwargs)
        }, 500 );
        '''
        } )



        table.close_tbody()



        # add the script path
        tbody = table.add_tbody()
        tbody.add_class("spt_scan_script")
        if scan_type != 'script':
            tbody.add_style("display: none")


        tr = table.add_row()
        td = table.add_cell()
        td.add("Script Path: ")
        td = table.add_cell()

        text = TextInputWdg(name="script_path")
        td.add(text)
        text.add_style("width: 400px")


        table.close_tbody()



        table.add_row()
        td = table.add_cell("<hr/>")



        table.add_row()
        td = table.add_cell()
        td.add("<b>Action</b><br/>")
        td.add("The following information define the actions that will be used on each matched path<br/><br/>")


        # pick the type of action
        table.add_row()
        td = table.add_cell()
        td.add("Type: ")
        select = SelectWdg("action_type")
        td = table.add_cell()
        td.add(select)
        labels = ['Checkin', 'Ignore']
        values = ['checkin', 'ignore']
        select.set_option("values", values)
        select.set_option("labels", labels)
        select.add_empty_option("-- Select --")
        if action_type:
            select.set_value(action_type)

        select.add_behavior( {
        'type': 'change',
        'cbjs_action': '''
        var top = bvr.src_el.getParent(".spt_ingestion_top");
        value = bvr.src_el.value;

        var elements = top.getElements(".spt_action_ignore");
        for (var i = 0; i < elements.length; i++) {
          if (value == 'ignore')
            spt.show(elements[i]);
          else
            spt.hide(elements[i]);
        }

        var elements = top.getElements(".spt_action_checkin");
        for (var i = 0; i < elements.length; i++) {
          if (value == 'checkin')
            spt.show(elements[i]);
          else
            spt.hide(elements[i]);
        }

        '''
        } )



        table.add_row()
        td = table.add_cell("<br/>")



        # add the script path
        tbody = table.add_tbody()
        tbody.add_class("spt_action_checkin")
        if action_type != 'checkin':
            tbody.add_style("display: none")



        # add the checkin type
        table.add_row()
        td = table.add_cell()
        td.add("Action: ")
        select = SelectWdg("action")
        td = table.add_cell()
        td.add(select)
        select.set_value( self.get_value("action") )
        labels = ['File Checkin', 'Directory Checkin', 'Sequence Checkin']
        values = ['file', 'directory', 'sequence', 'ignore']
        select.set_option("values", values)
        select.set_option("labels", labels)





        table.add_row()
        td = table.add_cell()
        td.add("Mode: ")
        select = SelectWdg("mode")
        td = table.add_cell()
        td.add(select)
        labels = ['Copy', 'Move', 'In Place']
        values = ['copy', 'move', 'inplace']
        select.set_option("values", values)
        select.set_option("labels", labels)






        # add the search_type
        table.add_row()
        td = table.add_cell()
        td.add("sType: ")
        td = table.add_cell()
        select = SelectWdg("search_type")
        td.add(select)
        search_types = Project.get().get_search_types()
        values = [x.get_value("search_type") for x in search_types]
        select.set_option("values", values)

        search_type = self.kwargs.get("search_type")
        if search_type:
            select.set_value(search_type)



        # add the search_type
        table.add_row()
        td = table.add_cell()
        td.add("Context: ")
        td = table.add_cell()
        select = SelectWdg("context")
        td.add(select)
        select.set_option("values", ['publish', 'by rule', 'custom'])




        # add extra values
        extra_div = DivWdg()
        text = TextWdg("extra_name")
        text.add_attr("spt_is_multiple", "true")
        extra_div.add(text)
        extra_div.add(" = ")
        text = TextWdg("extra_value")
        extra_div.add(text)
        text.add_attr("spt_is_multiple", "true")

        template_div = DivWdg()
        text = TextWdg("extra_name")
        text.add_attr("spt_is_multiple", "true")
        template_div.add(text)
        template_div.add(" = ")
        text = TextWdg("extra_value")
        template_div.add(text)
        text.add_attr("spt_is_multiple", "true")


        table.close_tbody()



        table.add_row()
        td = table.add_cell("<br/>")

        table.add_row()
        td = table.add_cell()
        td.add("Extra Keywords: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 5px")
        td = table.add_cell()
        text = TextWdg("keywords")
        text.add_style("width: 300px")
        td.add(text)





        table.add_row()
        td = table.add_cell()
        td.add("Extra Values: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 5px")
        td = table.add_cell()
        extra_list = DynamicListWdg()
        td.add(extra_list)
        extra_list.add_item(extra_div)
        extra_list.add_template(template_div)


        table.add_row()
        table.add_cell("&nbsp;")



        table.add_row()
        td = table.add_cell()
        td.add("Process script: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 5px")
        td = table.add_cell()
        text = TextWdg("process_script")
        text.add_style("width: 300px")
        td.add(text)
        text.set_value( self.get_value("process_script") )


        icon = IconButtonWdg(title='Edit Process Script', icon=IconWdg.EDIT)
        icon.add_style("float: right")
        td.add(icon)
        icon.add_behavior( {
        'type': 'click_up',
        'cbjs_action': '''
        spt.named_events.fire_event("show_script_editor");

        var top = bvr.src_el.getParent(".spt_ingestion_top");
        var values = spt.api.Utility.get_input_values(top, null, false);

        var kwargs = {
            script_path: values.process_script
        }

        // need to wait for this
        setTimeout( function() {
        spt.js_edit.display_script_cbk(evt, kwargs)
        }, 500 );
        '''
        } )



        table.add_row()
        td = table.add_cell()
        td.add("Custom Naming: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 5px")
        td = table.add_cell()
        text = TextWdg("naming")
        text.add_style("width: 300px")
        td.add(text)




        table.add_row()
        td = table.add_cell()

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


        behavior = {
            'type': 'click_up',
            'cbjs_action': '''

            var top = bvr.src_el.getParent(".spt_ingestion_top");
            var values = spt.api.Utility.get_input_values(top, null, false);

            spt.app_busy.show("Scanning ...", values.base_dir);

            var class_name = 'tactic.ui.tools.IngestionProcessWdg';

            var server = TacticServerStub.get();
            values.mode = bvr.mode;

            values.is_local = 'true';

            // scan client side
            if (values.is_local == 'true') {
                var base_dir = values.base_dir;
                var applet = spt.Applet.get();
                var files = applet.list_recursive_dir(base_dir);
                // turn into a string
                var files_in_js = [];
                for (var i = 0; i < files.length; i++) {
                    var file = files[i].replace(/\\\\/g, "/");
                    files_in_js.push( file );
                }
                values.files = files_in_js;
                values.base_dir = base_dir;

                /*
                var server = TacticServerStub.get();
                var handoff_dir = server.get_handoff_dir();
                var applet = spt.Applet.get();
                for (var i = 0; i < files_in_js.length; i++) {
                    try {
                        var parts = files_in_js[i].split("/");
                        var filename = parts[parts.length-1];
                        spt.app_busy.show("Copying files to handoff", filename);
                        applet.copy_file(files_in_js[i], handoff_dir+"/"+filename);
                    } catch(e) {
                        log.error(e);
                    }

                }
                */
            }

            var info_el = top.getElement(".spt_info");
            spt.panel.load(info_el, class_name, values);
            spt.app_busy.hide();
            '''
        }


        # Save button
        button = ActionButtonWdg(title="Save", tip="Save Rule")
        td.add(button)
        button.add_style("float: right")
        behavior['mode'] = 'save'
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''

            var top = bvr.src_el.getParent(".spt_ingestion_top");
            var values = spt.api.Utility.get_input_values(top, null, false);
            spt.app_busy.show("Saving ...");

            var class_name = 'tactic.command.CheckinRuleSaveCmd';
            var server = TacticServerStub.get();
            server.execute_cmd(class_name, values);

            spt.panel.refresh(top, {});

            spt.app_busy.hide();

            '''
        } )



 
        # Scan button
        button = ActionButtonWdg(title="Scan", tip="Click to Scan")
        td.add(button)
        button.add_style("float: left")


        # set a limit
        #limit = TextWdg("limit")
        #td.add(limit)
        #text.add_style("float: left")


        behavior = behavior.copy()
        behavior['mode'] = 'scan'
        button.add_behavior(behavior)

        # Test button
        button = ActionButtonWdg(title="Test", tip="Do a test of this rule")
        td.add(button)
        behavior = behavior.copy()
        behavior['mode'] = 'test'
        button.add_behavior(behavior)
        button.add_style("float: left")




        # Ingest button
        button = ActionButtonWdg(title="Ingest", tip="Click to start ingesting")
        td.add(button)
        behavior = behavior.copy()
        behavior['mode'] = 'checkin'
        button.add_behavior(behavior)



        table.add_behavior( {
            'type': 'listen',
            'event_name': 'file_browser|select',
            'cbjs_action': '''
            var dirname = bvr.firing_data.dirname;
            var top = bvr.src_el.getParent(".spt_ingestion_top");
            var kwargs = {
              base_dir: dirname
            };

            spt.panel.load(top, top.getAttribute("spt_class_name"), kwargs);
            '''
        })


        top.add( self.get_info_wdg() )

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

        top = self.top
        self.set_as_panel(top)
        top.add_class("spt_ingestion_top")
        top.add_color("background", "background", -5)

        self.data = {}

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

        rules_div.add("Rules: ")

        rules_select = SelectWdg("rule_code")
        rule_code = self.get_value('rule_code')
        if rule_code:
            rules_select.set_value(rule_code)
        rules_select.set_option("query", "config/ingest_rule|code|title")
        rules_select.add_empty_option("-- New --")
        rules_div.add(rules_select)
        rules_select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_ingestion_top");
        value = bvr.src_el.value;
        var class_name = 'tactic.ui.tools.IngestionToolWdg';
        spt.panel.load(top, class_name, {rule_code: value} );
        '''
        })

        rules_div.add("<hr/>")

        # read from the database
        if rule_code:
            search = Search("config/ingest_rule")
            search.add_filter("code", rule_code)
            sobject = search.get_sobject()
        else:
            sobject = None
        if sobject:
            self.data = sobject.get_value("data")
            if self.data:
                self.data = jsonloads(self.data)

        session_code = self.kwargs.get("session_code")
        if session_code:
            session = Search.get_by_code("config/ingest_session", session_code)
        else:
            if sobject:
                session = sobject.get_related_sobject("config/ingest_session")
                print("sobject: ", sobject.get_code(),
                      sobject.get_value("spt_ingest_session_code"))
                print("parent: ", session)
            else:
                session = None

        if not session:
            #session = SearchType.create("config/ingest_session")
            #session.set_value("code", "session101")
            #session.set_value("location", "local")
            ##session.set_value("base_dir", "C:")
            top.add("No session defined!!!")
            return top

        rule = ""
        filter = ""
        ignore = ""

        # get the base path
        if sobject:
            base_dir = sobject.get_value("base_dir")
        else:
            base_dir = ''

        #else:
        #    base_dir = self.get_value("base_dir")
        #if not base_dir:
        #    base_dir = ''

        if sobject:
            title = sobject.get_value("title")
        else:
            title = ''

        if sobject:
            code = sobject.get_value("code")
        else:
            code = ''

        file_list = self.get_value("file_list")
        scan_type = self.get_value("scan_type")
        action_type = self.get_value("action_type")
        rule = self.get_value("rule")
        if not rule:
            rule = base_dir

        # get the rule for this path
        checkin_mode = "dir"
        depth = 0

        table = Table()
        rules_div.add(table)
        table.add_color("color", "color")

        from tactic.ui.input.text_input_wdg import TextInputWdg

        # add the title
        table.add_row()
        td = table.add_cell()
        td.add("Title: ")
        td = table.add_cell()

        text = TextInputWdg(name="title")
        td.add(text)
        if title:
            text.set_value(title)
        text.add_class("spt_title")
        text.add_style("width: 400px")
        #text.add_color("background", "background", -10)

        # add the optional code
        table.add_row()
        td = table.add_cell()
        td.add("Code (optional): ")
        td = table.add_cell()

        text = TextInputWdg(name="code")
        td.add(text)
        if code:
            text.set_value(code)
            text.set_readonly()
            text.add_color("background", "background", -10)
        text.add_class("spt_code")
        text.add_style("width: 400px")

        table.add_row()
        td = table.add_cell()
        td.add_style("height: 10px")
        td.add("<hr/>")

        table.add_row()
        td = table.add_cell()
        td.add("<b>Scan:</b><br/>")
        td.add(
            "The following information will be used to find the paths that will be operated on by the ingestion process<br/><br/>"
        )

        # add a scan type
        table.add_row()
        td = table.add_cell()
        td.add("Type: ")
        select = SelectWdg("scan_type")
        select.add_class("spt_scan_type")
        td = table.add_cell()
        td.add(select)
        select.set_value(self.get_value("action"))
        labels = ['Simple List', 'Rule', 'Script']
        values = ['list', 'rule', 'script']
        select.set_option("values", values)
        select.set_option("labels", labels)
        if scan_type:
            select.set_value(scan_type)

        table.add_row()
        table.add_cell("&nbsp;")

        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_ingestion_top");
        value = bvr.src_el.value;

        var elements = top.getElements(".spt_scan_list");
        for (var i = 0; i < elements.length; i++) {
          if (value == 'list')
            spt.show(elements[i]);
          else
            spt.hide(elements[i]);
        }

        var elements = top.getElements(".spt_scan_rule");
        for (var i = 0; i < elements.length; i++) {
          if (value == 'rule')
            spt.show(elements[i]);
          else
            spt.hide(elements[i]);
        }
        var elements = top.getElements(".spt_scan_script");
        for (var i = 0; i < elements.length; i++) {
          if (value == 'script')
            spt.show(elements[i]);
          else
            spt.hide(elements[i]);
        }

        '''
        })

        # add in a list of stuff
        tbody = table.add_tbody()
        tbody.add_class("spt_scan_list")
        if scan_type != 'list':
            tbody.add_style("display: none")

        tr = table.add_row()
        td = table.add_cell()
        td.add("List of files: ")
        td = table.add_cell()

        text = TextAreaWdg(name="file_list")
        td.add(text)
        text.add_style("width: 400px")
        #text.set_readonly()
        #text.add_color("background", "background", -10)
        text.set_value(file_list)

        table.close_tbody()

        # add rule scan mode
        tbody = table.add_tbody()
        tbody.add_class("spt_scan_rule")
        if scan_type != 'rule':
            tbody.add_style("display: none")

        # add the path
        tr = table.add_row()
        td = table.add_cell()
        td.add("Starting Path: ")
        td = table.add_cell()

        hidden = HiddenWdg("session_code", session.get_code())
        td.add(hidden)

        text = TextInputWdg(name="base_dir")
        td.add(text)
        text.set_value(base_dir)
        text.add_style("width: 400px")
        #text.set_readonly()
        #text.add_color("background", "background", -10)
        text.set_value(base_dir)

        # add rule
        tr = table.add_row()
        td = table.add_cell()
        td.add("Tag Rule: ")
        td = table.add_cell()

        text = TextInputWdg(name="rule")
        td.add(text)
        text.add_style("width: 400px")
        text.set_value(rule)

        tr = table.add_row()
        td = table.add_cell()
        td.add("Filter: ")
        td = table.add_cell()
        text = TextWdg("filter")
        td.add(text)
        text.set_value(self.get_value("filter"))
        text.add_style("width: 400px")
        text.add_style("padding: 2px")
        text.add_style("-moz-border-radius: 5px")

        tr = table.add_row()
        td = table.add_cell()
        td.add("Ignore: ")
        td = table.add_cell()
        text = TextWdg("ignore")
        td.add(text)
        text.set_value(self.get_value("ignore"))
        text.set_value(ignore)
        text.add_style("width: 400px")
        text.add_style("padding: 2px")
        text.add_style("-moz-border-radius: 5px")

        table.add_row()
        td = table.add_cell()
        td.add("Validation script: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 5px")
        td = table.add_cell()
        text = TextInputWdg(name="validation_script")
        text.set_value(self.get_value("validation_script"))
        text.add_style("width: 400px")
        td.add(text)

        icon = IconButtonWdg(title='Edit Validation Script', icon=IconWdg.EDIT)
        icon.add_style("float: right")
        td.add(icon)
        icon.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.named_events.fire_event("show_script_editor");

        var top = bvr.src_el.getParent(".spt_ingestion_top");
        var values = spt.api.Utility.get_input_values(top, null, false);

        var kwargs = {
            script_path: values.validation_script
        }
        setTimeout( function() {
        spt.js_edit.display_script_cbk(evt, kwargs)
        }, 500 );
        '''
        })

        table.close_tbody()

        # add the script path
        tbody = table.add_tbody()
        tbody.add_class("spt_scan_script")
        if scan_type != 'script':
            tbody.add_style("display: none")

        tr = table.add_row()
        td = table.add_cell()
        td.add("Script Path: ")
        td = table.add_cell()

        text = TextInputWdg(name="script_path")
        td.add(text)
        text.add_style("width: 400px")

        table.close_tbody()

        table.add_row()
        td = table.add_cell("<hr/>")

        table.add_row()
        td = table.add_cell()
        td.add("<b>Action</b><br/>")
        td.add(
            "The following information define the actions that will be used on each matched path<br/><br/>"
        )

        # pick the type of action
        table.add_row()
        td = table.add_cell()
        td.add("Type: ")
        select = SelectWdg("action_type")
        td = table.add_cell()
        td.add(select)
        labels = ['Checkin', 'Ignore']
        values = ['checkin', 'ignore']
        select.set_option("values", values)
        select.set_option("labels", labels)
        select.add_empty_option("-- Select --")
        if action_type:
            select.set_value(action_type)

        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
        var top = bvr.src_el.getParent(".spt_ingestion_top");
        value = bvr.src_el.value;

        var elements = top.getElements(".spt_action_ignore");
        for (var i = 0; i < elements.length; i++) {
          if (value == 'ignore')
            spt.show(elements[i]);
          else
            spt.hide(elements[i]);
        }

        var elements = top.getElements(".spt_action_checkin");
        for (var i = 0; i < elements.length; i++) {
          if (value == 'checkin')
            spt.show(elements[i]);
          else
            spt.hide(elements[i]);
        }

        '''
        })

        table.add_row()
        td = table.add_cell("<br/>")

        # add the script path
        tbody = table.add_tbody()
        tbody.add_class("spt_action_checkin")
        if action_type != 'checkin':
            tbody.add_style("display: none")

        # add the checkin type
        table.add_row()
        td = table.add_cell()
        td.add("Action: ")
        select = SelectWdg("action")
        td = table.add_cell()
        td.add(select)
        select.set_value(self.get_value("action"))
        labels = ['File Checkin', 'Directory Checkin', 'Sequence Checkin']
        values = ['file', 'directory', 'sequence', 'ignore']
        select.set_option("values", values)
        select.set_option("labels", labels)

        table.add_row()
        td = table.add_cell()
        td.add("Mode: ")
        select = SelectWdg("mode")
        td = table.add_cell()
        td.add(select)
        labels = ['Copy', 'Move', 'In Place']
        values = ['copy', 'move', 'inplace']
        select.set_option("values", values)
        select.set_option("labels", labels)

        # add the search_type
        table.add_row()
        td = table.add_cell()
        td.add("sType: ")
        td = table.add_cell()
        select = SelectWdg("search_type")
        td.add(select)
        search_types = Project.get().get_search_types()
        values = [x.get_value("search_type") for x in search_types]
        select.set_option("values", values)

        search_type = self.kwargs.get("search_type")
        if search_type:
            select.set_value(search_type)

        # add the search_type
        table.add_row()
        td = table.add_cell()
        td.add("Context: ")
        td = table.add_cell()
        select = SelectWdg("context")
        td.add(select)
        select.set_option("values", ['publish', 'by rule', 'custom'])

        # add extra values
        extra_div = DivWdg()
        text = TextWdg("extra_name")
        text.add_attr("spt_is_multiple", "true")
        extra_div.add(text)
        extra_div.add(" = ")
        text = TextWdg("extra_value")
        extra_div.add(text)
        text.add_attr("spt_is_multiple", "true")

        template_div = DivWdg()
        text = TextWdg("extra_name")
        text.add_attr("spt_is_multiple", "true")
        template_div.add(text)
        template_div.add(" = ")
        text = TextWdg("extra_value")
        template_div.add(text)
        text.add_attr("spt_is_multiple", "true")

        table.close_tbody()

        table.add_row()
        td = table.add_cell("<br/>")

        table.add_row()
        td = table.add_cell()
        td.add("Extra Keywords: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 5px")
        td = table.add_cell()
        text = TextWdg("keywords")
        text.add_style("width: 300px")
        td.add(text)

        table.add_row()
        td = table.add_cell()
        td.add("Extra Values: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 5px")
        td = table.add_cell()
        extra_list = DynamicListWdg()
        td.add(extra_list)
        extra_list.add_item(extra_div)
        extra_list.add_template(template_div)

        table.add_row()
        table.add_cell("&nbsp;")

        table.add_row()
        td = table.add_cell()
        td.add("Process script: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 5px")
        td = table.add_cell()
        text = TextWdg("process_script")
        text.add_style("width: 300px")
        td.add(text)
        text.set_value(self.get_value("process_script"))

        icon = IconButtonWdg(title='Edit Process Script', icon=IconWdg.EDIT)
        icon.add_style("float: right")
        td.add(icon)
        icon.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        spt.named_events.fire_event("show_script_editor");

        var top = bvr.src_el.getParent(".spt_ingestion_top");
        var values = spt.api.Utility.get_input_values(top, null, false);

        var kwargs = {
            script_path: values.process_script
        }

        // need to wait for this
        setTimeout( function() {
        spt.js_edit.display_script_cbk(evt, kwargs)
        }, 500 );
        '''
        })

        table.add_row()
        td = table.add_cell()
        td.add("Custom Naming: ")
        td.add_style("vertical-align: top")
        td.add_style("padding-top: 5px")
        td = table.add_cell()
        text = TextWdg("naming")
        text.add_style("width: 300px")
        td.add(text)

        table.add_row()
        td = table.add_cell()

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

        behavior = {
            'type':
            'click_up',
            'cbjs_action':
            '''

            var top = bvr.src_el.getParent(".spt_ingestion_top");
            var values = spt.api.Utility.get_input_values(top, null, false);

            spt.app_busy.show("Scanning ...", values.base_dir);

            var class_name = 'tactic.ui.tools.IngestionProcessWdg';

            var server = TacticServerStub.get();
            values.mode = bvr.mode;

            values.is_local = 'true';

            // scan client side
            if (values.is_local == 'true') {
                var base_dir = values.base_dir;
                var applet = spt.Applet.get();
                var files = applet.list_recursive_dir(base_dir);
                // turn into a string
                var files_in_js = [];
                for (var i = 0; i < files.length; i++) {
                    var file = files[i].replace(/\\\\/g, "/");
                    files_in_js.push( file );
                }
                values.files = files_in_js;
                values.base_dir = base_dir;

                /*
                var server = TacticServerStub.get();
                var handoff_dir = server.get_handoff_dir();
                var applet = spt.Applet.get();
                for (var i = 0; i < files_in_js.length; i++) {
                    try {
                        var parts = files_in_js[i].split("/");
                        var filename = parts[parts.length-1];
                        spt.app_busy.show("Copying files to handoff", filename);
                        applet.copy_file(files_in_js[i], handoff_dir+"/"+filename);
                    } catch(e) {
                        log.error(e);
                    }

                }
                */
            }

            var info_el = top.getElement(".spt_info");
            spt.panel.load(info_el, class_name, values);
            spt.app_busy.hide();
            '''
        }

        # Save button
        button = ActionButtonWdg(title="Save", tip="Save Rule")
        td.add(button)
        button.add_style("float: right")
        behavior['mode'] = 'save'
        button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''

            var top = bvr.src_el.getParent(".spt_ingestion_top");
            var values = spt.api.Utility.get_input_values(top, null, false);
            spt.app_busy.show("Saving ...");

            var class_name = 'tactic.command.CheckinRuleSaveCmd';
            var server = TacticServerStub.get();
            server.execute_cmd(class_name, values);

            spt.panel.refresh(top, {});

            spt.app_busy.hide();

            '''
        })

        # Scan button
        button = ActionButtonWdg(title="Scan", tip="Click to Scan")
        td.add(button)
        button.add_style("float: left")

        # set a limit
        #limit = TextWdg("limit")
        #td.add(limit)
        #text.add_style("float: left")

        behavior = behavior.copy()
        behavior['mode'] = 'scan'
        button.add_behavior(behavior)

        # Test button
        button = ActionButtonWdg(title="Test", tip="Do a test of this rule")
        td.add(button)
        behavior = behavior.copy()
        behavior['mode'] = 'test'
        button.add_behavior(behavior)
        button.add_style("float: left")

        # Ingest button
        button = ActionButtonWdg(title="Ingest",
                                 tip="Click to start ingesting")
        td.add(button)
        behavior = behavior.copy()
        behavior['mode'] = 'checkin'
        button.add_behavior(behavior)

        table.add_behavior({
            'type':
            'listen',
            'event_name':
            'file_browser|select',
            'cbjs_action':
            '''
            var dirname = bvr.firing_data.dirname;
            var top = bvr.src_el.getParent(".spt_ingestion_top");
            var kwargs = {
              base_dir: dirname
            };

            spt.panel.load(top, top.getAttribute("spt_class_name"), kwargs);
            '''
        })

        top.add(self.get_info_wdg())

        return top
    def get_example_display(my):

        div = DivWdg()

        # Smart Menu data ...
        dog_menus = [ my.get_sm_dog_main_menu_details(),
                      my.get_sm_dog_submenu_one_details(),
                      my.get_sm_dog_submenu_two_details()
                    ]

        cat_menus = [ my.get_sm_cat_main_menu_details() ]

        SmartMenu.attach_smart_context_menu( div, { 'DOG': dog_menus, 'CAT': cat_menus }, False )



        table = Table(css="maq_view_table")
        table.set_id( "main_body_table" )
        table.add_class("spt_table")

        table.add_behavior( { "type": "smart_drag",
                              "bvr_match_class": "SPT_DO_RESIZE",
                              "cbjs_setup": 'spt.dg_table.resize_column_setup( evt, bvr, mouse_411 );',
                              "cbjs_motion": 'spt.dg_table.resize_column_motion( evt, bvr, mouse_411 );'
                             } )

        table.add_behavior( { "type": "smart_drag",
                              "bvr_match_class": "SPT_DO_DRAG",
                              "use_copy": 'true',
                              "use_delta": 'true', 'dx': 10, 'dy': 10,
                              "drop_code": 'TableExampleSwitchContents',
                              "cbjs_action": "spt.ui_play.drag_cell_drop_action( evt, bvr );",
                              "copy_styles": 'background: blue; opacity: .5; border: 1px solid black; text-align: left;'
                             } )

        row = table.add_row()
        for c in range(10):
            th = table.add_header()
            th.set_attr('col_idx', str(c))
            th.add_class("cell_left")
            th.add_styles("width: 150px; cursor: default;")

            # @@@
            th.add_behavior( {
                "type": "move",
                "cbjs_action": '''
                    // log.debug( "(x,y) = (" + mouse_411.curr_x + "," + mouse_411.curr_y + ")" );
                    spt.ui_play.header_half_move_cbk( evt, bvr, mouse_411 );
                ''',
                "cbjs_action_on": '''
                    // log.debug( "START MY MOVE!" );
                ''',
                "cbjs_action_off": '''
                    // log.debug( "DONE MY MOVE!" );
                    spt.ui_play.header_half_move_off_cbk( evt, bvr, mouse_411 );
                '''
            } )

            if (c%2):
                th.add("H%s (Cat)" % c)
            else:
                th.add("H%s (Dog)" % c)
            th_resize = table.add_cell()
            th_resize.set_attr('col_idx', str(c+1))
            th_resize.add_class("SPT_DO_RESIZE cell_right")
            th_resize.add_styles("width: 4px; cursor: col-resize;")

        for r in range(19):
            row = table.add_row()
            for c in range(10):
                col = table.add_cell()
                col.set_attr('col_idx', str(c))
                col.set_attr('SPT_ACCEPT_DROP', 'TableExampleSwitchContents')
                col.add_class("SPT_DO_DRAG cell_left")
                col.add_styles("cursor: pointer;")
                col.add("(%s,%s)" % (r,c))
                if (c % 2) == 0:
                    SmartMenu.assign_as_local_activator( col, "DOG" )
                else:
                    SmartMenu.assign_as_local_activator( col, "CAT" )
                resize = table.add_cell()
                resize.set_attr('col_idx', str(c+1))
                resize.add_class("SPT_DO_RESIZE cell_right")
                resize.add_styles("width: 6px; cursor: col-resize;")

        div.add( table )
        return div
Esempio n. 5
0
    def get_display(my):

        my.sobject = my.get_sobject()

        top = DivWdg()
        top.add_class("spt_detail_top")
        top.add_color("background", "background")
        top.add_color("color", "color")

        if not my.sobject:
            top.add("No SObject defined for this widget")
            return top

        if my.parent:
            my.search_type = my.parent.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.parent)
            top.add_attr("spt_parent_key", my.search_key) 
            my.pipeline_code = my.parent.get_value("pipeline_code", no_exception=True)
            my.full_search_type = my.parent.get_search_type()
        else:
            my.pipeline_code = my.sobject.get_value("pipeline_code", no_exception=True)
            my.search_type = my.sobject.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.sobject)
            my.full_search_type = my.sobject.get_search_type()

        if not my.pipeline_code:
            my.pipeline_code = 'default'


        top.add_style("text-align: left")
        my.set_as_panel(top)

        table = Table()
        #from tactic.ui.container import ResizableTableWdg
        #table = ResizableTableWdg()
        table.add_color("background", "background")
        table.add_color("color", "color")
        top.add(table)
        table.set_max_width()

        # add the title
        tr, td = table.add_row_cell()

        title_wdg = my.get_title_wdg()
        td.add(title_wdg)


        table.add_row()

        # left
        td = table.add_cell()
        td.add_style("width: 300px")
        td.add_style("min-width: 300px")
        td.add_style("vertical-align: top")


        div = DivWdg()
        td.add(div)
        div.add_class("spt_sobject_detail_top")

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

        from tactic.ui.panel import ThumbWdg2
        thumb = ThumbWdg2()
        # use a larger version for clearer display
        #thumb.set_icon_type('web')

        if my.parent:
            thumb.set_sobject(my.parent)
            search_key = my.parent.get_search_key()
        else:
            thumb.set_sobject(my.sobject)
            search_key = my.sobject.get_search_key()

        gallery_div = DivWdg()
        div.add( gallery_div )
        gallery_div.add_class("spt_tile_gallery")
 
        thumb_table.add_behavior( {
            'type': 'click_up',
            'search_key': search_key,
            'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_sobject_detail_top");
                var gallery_el = top.getElement(".spt_tile_gallery");

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

        # prefer to see the original image, then web
        #thumb.set_option('image_link_order', 'main|web|icon')
        #thumb.set_option("detail", "false")
        #thumb.set_option("icon_size", "100%")

        td = thumb_table.add_cell(thumb)
        td.add_style("vertical-align: top")
        td.add_style("width: auto")
        td.add_style("padding: 15px")

        sobject_info_wdg = my.get_sobject_info_wdg()
        sobject_info_wdg.add_style("width: 100%")


        td.add(sobject_info_wdg)

        if my.search_type == 'sthpw/task' and not my.parent:
            pass
        else:
            sobject_info_wdg = my.get_sobject_detail_wdg()
            td = table.add_cell()
            td.add(sobject_info_wdg)
            td.add_style("vertical-align: top")
            td.add_style("overflow: hidden")


        # right
        td = table.add_cell()
        td.add_style("text-align: left")
        td.add_style("vertical-align: top")
        td.add_class("spt_notes_wrapper")
        td.add_style("padding: 5px 5px")

        title_wdg = DivWdg()
        td.add(title_wdg)
        title_wdg.add_style("width: 100%")
        title_wdg.add("Notes")
        title_wdg.add("<hr/>")
        title_wdg.add_style("font-size: 1.2em")

        notes_div = DivWdg()
        td.add(notes_div)
        from tactic.ui.widget.discussion_wdg import DiscussionWdg
        discussion_wdg = DiscussionWdg(search_key=my.search_key, context_hidden=False, show_note_expand=False)
        notes_div.add(discussion_wdg)
        notes_div.add_style("min-width: 300px")
        notes_div.add_style("height: 200")
        notes_div.add_style("overflow-y: auto")
        notes_div.add_class("spt_resizable")



        # get the process
        if my.parent:
            process = my.sobject.get_value("process")
        else:
            process = ''



        # content
        tr = table.add_row()
        td = table.add_cell()
        td.add_attr("colspan", "5")
        #td.add_attr("colspan", "3")

        # create a state for tab.  The tab only passes a search key
        # parent key
        search_key = SearchKey.get_by_sobject(my.sobject)
        parent_key = ""
        if search_key.startswith("sthpw/"):
            parent = my.sobject.get_parent()
            if parent:
                parent_key = parent.get_search_key()

        state = {
            'search_key': search_key,
            'parent_key': parent_key,
            'process': process,
        }
        WebState.get().push(state)


        config_xml = my.get_config_xml()
        config = WidgetConfig.get(view="tab", xml=config_xml)


        if process:
            custom_view = "tab_config_%s" % process
        else:
            custom_view = "tab_config"
        search = Search("config/widget_config")
        search.add_filter("category", "TabWdg")
        search.add_filter("search_type", my.search_type)
        search.add_filter("view", custom_view)
        custom_config_sobj = search.get_sobject()
        if custom_config_sobj:
            custom_config_xml = custom_config_sobj.get_value("config")
            custom_config = WidgetConfig.get(view=custom_view, xml=custom_config_xml)
            config = WidgetConfigView(search_type='TabWdg', view=custom_view, configs=[custom_config, config])

        #menu = my.get_extra_menu()
        #tab = TabWdg(config=config, state=state, extra_menu=menu)
        tab = TabWdg(config=config, state=state, show_add=False, show_remove=False, tab_offset=5 )
        tab.add_style("margin: 0px -2px -2px -2px")
        td.add(tab)
        td.add_style("padding-top: 10px")

        return top
Esempio n. 6
0
class ResizableTableWdg(BaseRefreshWdg):
    def __init__(self, **kwargs):
        self.table = Table()
        self.table.add_style("border-collapse: collapse")
        self.table.add_style("padding: 0px")
        self.table.set_attr("cellpadding", "0px")
        self.table.set_attr("cellspacing", "0px")
        self.is_first_row = True
        self.hilight = self.table.get_color("background", -40)
        super(ResizableTableWdg, self).__init__(**kwargs)


    def set_style(self, name, value=None):
        self.table.set_style(name, value)

    def set_max_width(self):
        self.table.set_max_width()

    def add_class(self, name):
        self.table.add_class(name)

    def get_display(self):
        top = self.top

        self.table.add_class("spt_resizable_table_top")


        self.table.add_behavior( {
        'type': 'load',
        'cbjs_action': self.get_onload_js()
        } )


        self.table.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        var resizable_cells = bvr.src_el.getElements(".spt_resizable_cell");
        for (var i = 0; i < resizable_cells.length; i++) {
            var resizable_el = resizable_cells[i].getElement(".spt_resizable");
            if (!resizable_el) {
                continue;
            }

            var size = resizable_cells[i].getSize();

            resizable_el.setStyle("width", size.x);
            resizable_el.setAttribute("width", size.x);
        }
        '''
        } )


        top.add(self.table)

        return top


    def set_keep_table_size(self):
        self.table.add_class("spt_resizable_keep_size")


    def add_color(self, color, modifier=0):
        self.table.add_color(color, modifier)

    def add_border(self, modifier=0):
        self.table.add_border(modifier=modifier)

    def add_style(self, name, value=None):
        self.table.add_style(name, value=value)




    def add_row(self, resize=True):

        # add resize row
        if not self.is_first_row and resize == True:
            tr, td = self.table.add_row_cell()
            td.add_style("height: 3px")
            td.add_style("min-height: 3px")
            td.add_style("cursor: n-resize")

            tr.add_behavior( {
            'type': 'drag',
            'cb_set_prefix': 'spt.resizable_table.row_drag'
            } )

            tr.add_behavior( {
            'type': 'hover',
            'hilight': self.hilight,
            'cbjs_action_over': '''
            var color = bvr.src_el.getStyle("background-color");
            bvr.src_el.setStyle("background-color", bvr.hilight);
            bvr.src_el.setAttribute("spt_last_background", color);
            ''',
            'cbjs_action_out': '''
            var color = bvr.src_el.getAttribute("spt_last_background");
            bvr.src_el.setStyle("background-color", color);
            '''
            } )

            icon = IconWdg("Drag to Resize", IconWdg.RESIZE_VERTICAL)
            td.add(icon)
            td.add_style("text-align: center")

        content_tr = self.table.add_row()

        self.is_first_row = False
 
        return content_tr


    def add_resize_row(self):
        tr, td = self.table.add_row_cell()
        td.add_style("height: 3px")
        td.add_style("min-height: 3px")
        td.add_style("cursor: n-resize")

        tr.add_behavior( {
        'type': 'drag',
        'cb_set_prefix': 'spt.resizable_table.row_drag'
        } )

        tr.add_behavior( {
        'type': 'hover',
        'hilight': self.hilight,
        'cbjs_action_over': '''
        var color = bvr.src_el.getStyle("background-color");
        bvr.src_el.setStyle("background-color", bvr.hilight);
        bvr.src_el.setAttribute("spt_last_background", color);
        ''',
        'cbjs_action_out': '''
        var color = bvr.src_el.getAttribute("spt_last_background");
        bvr.src_el.setStyle("background-color", color);
        '''
        } )
        icon = IconWdg("Drag to Resize", IconWdg.RESIZE_VERTICAL)
        td.add(icon)

        return tr, td


    def add_cell(self, widget=None, resize=True, rowspan=1, colspan=1):
        td_content = self.table.add_cell()
        td_content.add_style("vertical-align: top")
        td_content.add_class("spt_resizable_cell")

        if rowspan > 1:
            td_content.add_attr("rowspan", rowspan+1)
        if colspan > 1:
            td_content.add_attr("colspan", colspan+1)



        if not resize:
            return td_content

        # add resize cell
        td = self.table.add_cell()
        td.add_style("width: 4px")
        td.add_style("min-width: 4px")
        td.add_style("cursor: e-resize")

        icon_div = DivWdg()
        icon_div.add_style("width: 4px")
        icon_div.add_style("overflow: hidden")
        icon = IconWdg("Drag to Resize", IconWdg.RESIZE_HORIZ)
        icon_div.add(icon)
        td.add(icon_div)

        td.add_style("vertical-align: middle")

        td.add_behavior( {
        'type': 'drag',
        'cb_set_prefix': 'spt.resizable_table.cell_drag'
        } )


        td.add_behavior( {
        'type': 'hover',
        'hilight': self.hilight,
        'cbjs_action_over': '''
        var color = bvr.src_el.getStyle("background-color");
        bvr.src_el.setStyle("background-color", bvr.hilight);
        bvr.src_el.setAttribute("spt_last_background", color);
        ''',
        'cbjs_action_out': '''
        var color = bvr.src_el.getAttribute("spt_last_background");
        bvr.src_el.setStyle("background-color", color);
        '''
        } )


        if rowspan > 1:
            td.add_attr("rowspan", rowspan+1)
        if colspan > 1:
            td.add_attr("colspan", colspan+1)



        if widget:
            td_content.add(widget)

        
        return td_content


    def get_onload_js(self):
        return r'''
Esempio n. 7
0
    def get_display(my):

        my.sobject = my.get_sobject()

        top = DivWdg()
        top.add_class("spt_detail_top")
        top.add_color("background", "background")
        top.add_color("color", "color")

        if not my.sobject:
            top.add("No SObject defined for this widget")
            return top

        if my.parent:
            my.search_type = my.parent.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.parent)
            top.add_attr("spt_parent_key", my.search_key)
            my.pipeline_code = my.parent.get_value("pipeline_code",
                                                   no_exception=True)
            my.full_search_type = my.parent.get_search_type()
        else:
            my.pipeline_code = my.sobject.get_value("pipeline_code",
                                                    no_exception=True)
            my.search_type = my.sobject.get_base_search_type()
            my.search_key = SearchKey.get_by_sobject(my.sobject)
            my.full_search_type = my.sobject.get_search_type()

        if not my.pipeline_code:
            my.pipeline_code = 'default'

        top.add_style("text-align: left")
        my.set_as_panel(top)

        table = Table()
        #from tactic.ui.container import ResizableTableWdg
        #table = ResizableTableWdg()
        table.add_color("background", "background")
        table.add_color("color", "color")
        top.add(table)
        table.set_max_width()

        table.add_row()

        if my.parent:
            code = my.parent.get_value("code", no_exception=True)
            name = my.parent.get_value("name", no_exception=True)
            search_type_obj = my.parent.get_search_type_obj()
        else:
            code = my.sobject.get_value("code", no_exception=True)
            name = my.sobject.get_value("name", no_exception=True)
            search_type_obj = my.sobject.get_search_type_obj()

        # add the title
        td = table.add_cell()
        td.add_attr("colspan", "3")
        title = DivWdg()

        search = Search("sthpw/snapshot")
        search.add_filter("search_type", "sthpw/search_type")
        search.add_filter("search_code", search_type_obj.get_value("code"))
        if search.get_sobject():
            thumb = ThumbWdg()
            title.add(thumb)
            thumb.set_icon_size(30)
            thumb.set_sobject(search_type_obj)
            thumb.add_style("float: left")

        td.add(title)

        title.add_color("background", "background3")
        title.add_style("height: 20px")
        title.add_style("padding: 6px")
        title.add_style("font-weight: bold")
        title.add_style("font-size: 1.4em")

        stype_title = search_type_obj.get_value("title")
        if stype_title:
            title.add("%s: " % stype_title)

        if name:
            title.add("%s" % name)
            if code:
                title.add(" <i style='font-size: 0.8; opacity: 0.7'>(%s)</i>" %
                          code)
        elif code:
            title.add("%s" % code)
        else:
            title.add("(No name)")

        title.add_border()

        table.add_row()

        # left
        td = table.add_cell()
        td.add_style("width: 300px")
        td.add_style("min-width: 300px")
        td.add_style("vertical-align: top")

        div = DivWdg()
        td.add(div)
        div.add_class("spt_sobject_detail_top")

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

        from tactic.ui.panel import ThumbWdg2
        thumb = ThumbWdg2()
        # use a larger version for clearer display
        #thumb.set_icon_type('web')

        if my.parent:
            thumb.set_sobject(my.parent)
            search_key = my.parent.get_search_key()
        else:
            thumb.set_sobject(my.sobject)
            search_key = my.sobject.get_search_key()

        gallery_div = DivWdg()
        div.add(gallery_div)
        gallery_div.add_class("spt_tile_gallery")

        thumb_table.add_behavior({
            'type':
            'click_up',
            'search_key':
            search_key,
            'cbjs_action':
            '''
                var top = bvr.src_el.getParent(".spt_sobject_detail_top");
                var gallery_el = top.getElement(".spt_tile_gallery");

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

        # prefer to see the original image, then web
        #thumb.set_option('image_link_order', 'main|web|icon')
        #thumb.set_option("detail", "false")
        #thumb.set_option("icon_size", "100%")

        td = thumb_table.add_cell(thumb)
        td.add_style("vertical-align: top")
        td.add_style("width: auto")
        td.add_style("padding: 15px")

        sobject_info_wdg = my.get_sobject_info_wdg()
        sobject_info_wdg.add_style("width: auto")

        td.add(sobject_info_wdg)

        if my.search_type == 'sthpw/task' and not my.parent:
            pass
        else:
            sobject_info_wdg = my.get_sobject_detail_wdg()
            td = table.add_cell()
            td.add(sobject_info_wdg)
            td.add_style("vertical-align: top")
            td.add_style("overflow: hidden")

        # right
        td = table.add_cell()
        td.add_style("text-align: left")
        td.add_style("vertical-align: top")
        td.add_class("spt_notes_wrapper")

        notes_div = DivWdg()
        td.add(notes_div)
        from tactic.ui.widget.discussion_wdg import DiscussionWdg
        discussion_wdg = DiscussionWdg(search_key=my.search_key,
                                       context_hidden=False,
                                       show_note_expand=False)
        notes_div.add(discussion_wdg)
        notes_div.add_style("min-width: 300px")
        notes_div.add_style("height: 200")
        notes_div.add_style("overflow-y: auto")
        notes_div.add_class("spt_resizable")

        # get the process
        if my.parent:
            process = my.sobject.get_value("process")
        else:
            process = ''

        # content
        tr = table.add_row()
        td = table.add_cell()
        td.add_attr("colspan", "5")
        #td.add_attr("colspan", "3")

        # create a state for tab.  The tab only passes a search key
        # parent key
        search_key = SearchKey.get_by_sobject(my.sobject)
        parent_key = ""
        if search_key.startswith("sthpw/"):
            parent = my.sobject.get_parent()
            if parent:
                parent_key = parent.get_search_key()

        state = {
            'search_key': search_key,
            'parent_key': parent_key,
            'process': process,
        }
        WebState.get().push(state)

        config_xml = my.get_config_xml()
        config = WidgetConfig.get(view="tab", xml=config_xml)

        if process:
            custom_view = "tab_config_%s" % process
        else:
            custom_view = "tab_config"
        search = Search("config/widget_config")
        search.add_filter("category", "TabWdg")
        search.add_filter("search_type", my.search_type)
        search.add_filter("view", custom_view)
        custom_config_sobj = search.get_sobject()
        if custom_config_sobj:
            custom_config_xml = custom_config_sobj.get_value("config")
            custom_config = WidgetConfig.get(view=custom_view,
                                             xml=custom_config_xml)
            config = WidgetConfigView(search_type='TabWdg',
                                      view=custom_view,
                                      configs=[custom_config, config])

        #menu = my.get_extra_menu()
        #tab = TabWdg(config=config, state=state, extra_menu=menu)
        tab = TabWdg(config=config,
                     state=state,
                     show_add=False,
                     show_remove=False,
                     tab_offset=5)
        tab.add_style("margin: 0px -2px -2px -2px")
        td.add(tab)
        td.add_style("padding-top: 10px")

        return top
Esempio n. 8
0
    def get_display(my):
        # specially made for "load" view
        if not my.view.endswith("load"):
            return DivWdg()



        widget = Widget()
        # first use
        filter_top = DivWdg(css="maq_search_bar")
        filter_top.add_color("background", "background2", -15)

        # so dg_table.search_cbk will obtain values from this widget
        filter_top.add_class('spt_table_search')
        filter_top.add_style("padding: 3px")

        # this is used by get_process() in LoaderWdg
        filter_top.add(HiddenWdg('prefix', 'view_action_option'))

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


        from tactic.ui.cgapp import SObjectLoadWdg, LoaderButtonWdg, LoaderElementWdg, IntrospectWdg

        # this contains the process filter and load options
        sobject_load = SObjectLoadWdg(search_type=my.search_type, load_options_class = my.load_options_class)
        filter_top.add(sobject_load)

       

        # set the process
        #class foo:
        #    def get_value(my):
        #        return "texture"
        #Container.put("process_filter", foo())

        filter_top.add( HtmlElement.br() )

        table = Table()
        table.add_class('spt_action_wdg')

        table.set_max_width()
        td = table.add_cell()       
     
        # create the loader button
        button = LoaderButtonWdg()


        # -------------
        # test an event mechanism
        event_name = '%s|load_snapshot' % my.search_type
        #event_name = 'load_snapshot'

        # get triggers with this event
        from pyasm.search import Search
        search = Search("config/client_trigger")
        search.add_filter("event", event_name)
        triggers = search.get_sobjects()

        if triggers:
            for trigger in triggers:
                #callback = trigger.get_value("custom_script_code")
                callback = trigger.get_value("callback")

                event_script = '''
                spt.app_busy.show("Loading ...", "Loading selected [%s] in to session");
                var script = spt.CustomProject.get_script_by_path("%s");
                bvr['script'] = script;
                spt.CustomProject.exec_custom_script(evt, bvr);
                spt.app_busy.hide();
                ''' % (my.search_type, callback)

                loader_script = '''spt.named_events.fire_event('%s', {})''' % event_name
                table.add_behavior( {
                    'type': 'listen',
                    'event_name': event_name,
                    'cbjs_action': event_script
                } )

        # test a passed in script path
        elif my.load_script_path:

            # an event is called
            event_name = 'load_snapshot'
            event_script = '''var script = spt.CustomProject.get_script_by_path("%s");spt.CustomProject.exec_script(script)''' % my.load+script_path

            loader_script = '''spt.named_events.fire_event('%s', {})''' % event_name
            table.add_behavior( {
                'type': 'listen',
                'event_name': event_name,
                'cbjs_action': event_script
            } )

        # end test
        # ---------------



        elif my.load_script:
            loader_script = my.load_script
        else:
            loader_script = LoaderElementWdg.get_load_script(my.search_type)

        #print LoaderElementWdg.get_load_script(my.search_type)
        
        # add the introspect button
        introspect_button = IntrospectWdg()
        introspect_button.add_style('float: left')
        introspect_button.add_style('margin-bottom: 6px')
        td.add(introspect_button)

        # to be attached
        smart_menu = LoaderElementWdg.get_smart_menu(my.search_type)
        button.set_load_script(loader_script)
        button.set_smart_menu(smart_menu)

        td.add(button)
        td.add_style('text-align','right')
        td.add_style('padding-right', '40px') 
        widget.add(filter_top)
        widget.add( HtmlElement.br() )
        widget.add(table)

        return widget
Esempio n. 9
0
 def get_display(my):   
     from uploader import CustomHTML5UploadButtonWdg
     from order_builder import OrderBuilderLauncherWdg
     my.sk = str(my.kwargs.get('sk'))
     my.groups = str(my.kwargs.get('groups'))
     my.user = str(my.kwargs.get('user'))
     my.code = my.sk.split('code=')[1]
     my.order_code = my.code
     wo_to_title_dict = {}
     order_hours = {'groups': {}, 'users': {}, 'eq': {}} 
     title_hours = {}
     sob_expr = "@SOBJECT(twog/order['code','%s'])" % my.code
     order = my.server.eval(sob_expr)[0]
     titles = my.server.eval("@SOBJECT(twog/title['order_code','%s'])" % my.code)
     work_orders = my.server.eval("@SOBJECT(twog/work_order['order_code','%s'])" % my.code)
     tasks = my.server.eval("@SOBJECT(sthpw/task['order_code','%s']['search_type','twog/proj?project=twog'])" % my.code)
     task_lookup = my.get_code_look_dict(tasks, 'code')
     equipment = my.server.eval("@SOBJECT(twog/work_order['order_code','%s'].twog/equipment_used)" % my.code)
     login_groups_rez = my.server.eval("@SOBJECT(sthpw/login_group)")
     for login_group in login_groups_rez:
         if login_group.get('login_group') not in my.login_group_rates.keys():
             hourly_rate = login_group.get('hourly_rate')
             if hourly_rate in [None,'']:
                 hourly_rate = 0
             else:
                 hourly_rate = float(hourly_rate)
             my.login_group_rates[login_group.get('login_group')] = hourly_rate
     wo_eq = my.get_fk_code_multi_look_dict(equipment, 'work_order_code')
     for work_order in work_orders:
         wo_code = work_order.get('code')
         title_code = work_order.get('title_code')
         if wo_code not in wo_to_title_dict.keys():
             wo_to_title_dict[wo_code] = title_code
         if title_code not in title_hours.keys():
             title_hours[title_code] = {'groups': {}, 'users': {}, 'eq': {}}
         task = task_lookup[work_order.get('task_code')]
         whs = my.server.eval("@SOBJECT(sthpw/work_hour['task_code','%s'])" % task.get('code'))
         #assined login group comes from the task
         assigned_login_group = task.get('assigned_login_group')
         if assigned_login_group not in order_hours['groups'].keys():
             order_hours['groups'][assigned_login_group] = {'actual': 0, 'actual_cost': 0, 'estimated': 0, 'estimated_cost': 0}
         if assigned_login_group not in title_hours[title_code]['groups'].keys():
             title_hours[title_code]['groups'][assigned_login_group] = {'actual': 0, 'actual_cost': 0, 'estimated': 0, 'estimated_cost': 0}
         estimated_work_hours = work_order.get('estimated_work_hours')
         if estimated_work_hours not in [None,'','N/A']:
             estimated_work_hours = float(estimated_work_hours)
         else:
             estimated_work_hours = 0
         title_hours[title_code]['groups'][assigned_login_group]['estimated'] = title_hours[title_code]['groups'][assigned_login_group]['estimated'] + estimated_work_hours 
         title_hours[title_code]['groups'][assigned_login_group]['estimated_cost'] = title_hours[title_code]['groups'][assigned_login_group]['estimated'] * my.login_group_rates[assigned_login_group] 
         order_hours['groups'][assigned_login_group]['estimated'] = order_hours['groups'][assigned_login_group]['estimated'] + estimated_work_hours 
         order_hours['groups'][assigned_login_group]['estimated_cost'] = order_hours['groups'][assigned_login_group]['estimated'] * my.login_group_rates[assigned_login_group] 
         for wh in whs:
             user = wh.get('login')
             straight_time = wh.get('straight_time')
             order_hours['groups'][assigned_login_group]['actual'] = order_hours['groups'][assigned_login_group]['actual'] + straight_time
             order_hours['groups'][assigned_login_group]['actual_cost'] = order_hours['groups'][assigned_login_group]['actual'] * my.login_group_rates[assigned_login_group] 
             title_hours[title_code]['groups'][assigned_login_group]['actual'] = title_hours[title_code]['groups'][assigned_login_group]['actual'] + straight_time
             title_hours[title_code]['groups'][assigned_login_group]['actual_cost'] = title_hours[title_code]['groups'][assigned_login_group]['actual'] * my.login_group_rates[assigned_login_group] 
             if user not in order_hours['users'].keys():
                 order_hours['users'][user] = 0
             order_hours['users'][user] = order_hours['users'][user] + straight_time
             if user not in title_hours[title_code]['users'].keys():
                 title_hours[title_code]['users'][user] = 0
             title_hours[title_code]['users'][user] = title_hours[title_code]['users'][user] + straight_time
         eqs = []
         try:
             eqs = wo_eq[wo_code]
         except:
             pass
         for eq in eqs:
             name = eq.get('name')
             units = eq.get('units')
             actual_duration = eq.get('actual_duration') 
             actual_cost = eq.get('actual_cost') 
             actual_quantity = eq.get('actual_quantity')
             expected_duration = eq.get('expected_duration')
             expected_cost = eq.get('expected_cost')
             expected_quantity = eq.get('expected_quantity')
             if name not in title_hours[title_code]['eq'].keys():
                 title_hours[title_code]['eq'][name] =  {'actual': {'hrs': 0, 'size': 0, 'tapes': 0, 'cost': 0}, 'details': [], 'estimated': {'hrs': 0, 'size': 0, 'tapes': 0, 'cost': 0}}
             if name not in order_hours['eq'].keys():
                 order_hours['eq'][name] = {'actual': {'hrs': 0, 'size': 0, 'tapes': 0, 'cost': 0}, 'details': [], 'estimated': {'hrs': 0, 'size': 0, 'tapes': 0, 'cost': 0}}
             if units in ['mb','gb','tb']:
                 new_gb = actual_duration
                 if new_gb in [None,'']:
                     new_gb = 0
                 if units == 'mb':
                     new_gb = new_gb/1000
                 if units == 'tb':
                     new_gb = new_gb * 1000
                 ex_gb = expected_duration
                 if ex_gb in [None,'']:
                     ex_gb = 0
                 if units == 'mb':
                     ex_gb = ex_gb/1000
                 if units == 'tb':
                     ex_gb = ex_gb * 1000
                 units = 'gb'
                 if actual_cost in [None,'']:
                     actual_cost = 0
                 if expected_cost in [None,'']:
                     expected_cost = 0
                 title_hours[title_code]['eq'][name]['actual']['size'] = new_gb + title_hours[title_code]['eq'][name]['actual']['size']
                 title_hours[title_code]['eq'][name]['actual']['cost'] = actual_cost + title_hours[title_code]['eq'][name]['actual']['cost']
                 order_hours['eq'][name]['actual']['size'] = new_gb + order_hours['eq'][name]['actual']['size']
                 order_hours['eq'][name]['actual']['cost'] = actual_cost + order_hours['eq'][name]['actual']['cost']
                 title_hours[title_code]['eq'][name]['estimated']['size'] = ex_gb + title_hours[title_code]['eq'][name]['estimated']['size']
                 title_hours[title_code]['eq'][name]['estimated']['cost'] = expected_cost + title_hours[title_code]['eq'][name]['estimated']['cost']
                 order_hours['eq'][name]['estimated']['size'] = ex_gb + order_hours['eq'][name]['estimated']['size']
                 order_hours['eq'][name]['estimated']['cost'] = expected_cost + order_hours['eq'][name]['estimated']['cost']
             elif units == 'length':
                 if expected_cost in [None,'']:
                     expected_cost = 0
                 if expected_quantity in [None,'',0]:
                     expected_quantity = 1
                 if actual_quantity in [None,'',0]:
                     actual_quantity = 1
                 if actual_cost in [None,'']:
                     actual_cost = expected_cost 
                 title_hours[title_code]['eq'][name]['actual']['tapes'] = title_hours[title_code]['eq'][name]['actual']['tapes'] + actual_quantity
                 title_hours[title_code]['eq'][name]['actual']['cost'] = actual_cost + title_hours[title_code]['eq'][name]['actual']['cost']
                 order_hours['eq'][name]['actual']['tapes'] = order_hours['eq'][name]['actual']['tapes'] + actual_quantity
                 order_hours['eq'][name]['actual']['cost'] = actual_cost + order_hours['eq'][name]['actual']['cost']
                 title_hours[title_code]['eq'][name]['estimated']['tapes'] = title_hours[title_code]['eq'][name]['estimated']['tapes'] + expected_quantity
                 title_hours[title_code]['eq'][name]['estimated']['cost'] = expected_cost + title_hours[title_code]['eq'][name]['estimated']['cost']
                 order_hours['eq'][name]['estimated']['tapes'] = order_hours['eq'][name]['estimated']['tapes'] + expected_quantity
                 order_hours['eq'][name]['estimated']['cost'] = expected_cost + order_hours['eq'][name]['estimated']['cost']
             elif units in ['items','hr']:
                 if actual_cost in [None,'']:
                     actual_cost = 0
                 if expected_cost in [None,'']:
                     expected_cost = 0
                 if expected_quantity in [None,'',0]:
                     expected_quantity = 0
                 if expected_duration in [None,'',0]:
                     expected_duration = 0
                 if actual_duration in [None,'',0]:
                     actual_duration = 0
                 expected_adder = 0
                 actual_adder = 0
                 if actual_quantity in [None,'',0] and units == 'items':
                     actual_quantity = expected_quantity
                 else:
                     actual_quantity = 0
                 if units == 'items':
                     expected_adder = expected_quantity
                     actual_adder = actual_quantity
                 else:
                     expected_adder = expected_duration
                     actual_adder = actual_duration
                    
                 title_hours[title_code]['eq'][name]['actual']['hrs'] = title_hours[title_code]['eq'][name]['actual']['hrs'] + actual_adder
                 title_hours[title_code]['eq'][name]['actual']['cost'] = actual_cost + title_hours[title_code]['eq'][name]['actual']['cost']
                 order_hours['eq'][name]['actual']['hrs'] = order_hours['eq'][name]['actual']['hrs'] + actual_adder
                 order_hours['eq'][name]['actual']['cost'] = actual_cost + order_hours['eq'][name]['actual']['cost']
                 title_hours[title_code]['eq'][name]['estimated']['hrs'] = title_hours[title_code]['eq'][name]['estimated']['hrs'] + expected_adder
                 title_hours[title_code]['eq'][name]['estimated']['cost'] = expected_cost + title_hours[title_code]['eq'][name]['estimated']['cost']
                 order_hours['eq'][name]['estimated']['hrs'] = order_hours['eq'][name]['estimated']['hrs'] + expected_adder
                 order_hours['eq'][name]['estimated']['cost'] = expected_cost + order_hours['eq'][name]['estimated']['cost']
             eq['units'] = units
             eq['actual_duration'] = actual_duration 
             eq['actual_quantity'] = actual_quantity 
             eq['actual_cost'] = actual_cost
             eq['expected_duration'] = expected_duration 
             eq['expected_quantity'] = expected_quantity 
             eq['expected_cost'] = expected_cost
             title_hours[title_code]['eq'][name]['details'].append(eq)
             order_hours['eq'][name]['details'].append(eq)
     widget = DivWdg()
     table = Table()
     otbl = Table()
     otbl.add_attr('cellspacing','3')
     otbl.add_attr('cellpadding','3')
     #otbl.add_attr('bgcolor','#d9edf7')
     otbl.add_style('background-color: #d9edf7;')
     otbl.add_style('border-bottom-right-radius', '10px')
     otbl.add_style('border-bottom-left-radius', '10px')
     otbl.add_style('border-top-right-radius', '10px')
     otbl.add_style('border-top-left-radius', '10px')
     hide_unhide_bvr = my.get_hide_unhide(order.get('code'))
     otbl.add_behavior(hide_unhide_bvr)
     botbl = Table()
     botbl.add_attr('cellspacing','3')
     botbl.add_attr('cellpadding','3')
     botbl.add_row()
     bo1 = botbl.add_cell("<b>Name:</b> %s " % order.get('name'))
     bo1.add_attr('nowrap','nowrap')
     bo2 = botbl.add_cell('<b>Scheduler:</b> %s ' % order.get('login'))
     bo2.add_attr('nowrap','nowrap')
     botbl.add_cell('<b>Sales Rep:</b> %s ' % order.get('sales_rep'))
     bo2.add_attr('nowrap','nowrap')
     botbl.add_row()
     bo3 = botbl.add_cell('<b>Code:</b> %s ' % my.code)
     bo3.add_attr('nowrap','nowrap')
     bo4 = botbl.add_cell('<b>PO#:</b> %s ' % order.get('po_number'))
     bo4.add_attr('nowrap','nowrap')
     bo5 = botbl.add_cell('<b>Classification:</b> %s ' % order.get('classification'))
     bo5.add_attr('nowrap','nowrap')
     botbl.add_row()
     uploader = CustomHTML5UploadButtonWdg(sk=order.get('__search_key__'))
     liltbl = Table()
     liltbl.add_row()
     liltbl.add_cell(uploader)
     ob_button = OrderBuilderLauncherWdg(code=my.code)
     liltbl.add_cell(ob_button)
     bo6 = botbl.add_cell(liltbl)
     bo7 = botbl.add_cell('<b>Client:</b> %s ' % order.get('client_name'))
     bo7.add_attr('nowrap','nowrap')
     
     client_rep = order.get('client_rep')
     cr = my.server.eval("@SOBJECT(twog/person['code','%s'])" % client_rep)
     if cr:
         cr = cr[0]
         client_rep = '%s %s' % (cr.get('first_name'), cr.get('last_name'))
     bo8 = botbl.add_cell('<b>Client Rep:</b> %s ' % client_rep)
     bo8.add_attr('nowrap','nowrap')
     dtbl = Table()
     dtbl.add_attr('cellspacing','3')
     dtbl.add_attr('cellpadding','3')
     dtbl.add_row()
     d1 = dtbl.add_cell('<b>Start Date:</b> %s ' % my.fix_date(order.get('start_date')))
     d1.add_attr('nowrap','nowrap')
     dtbl.add_row()
     d2 = dtbl.add_cell('<b>Due Date:</b> %s ' % my.fix_date(order.get('due_date')))
     d2.add_attr('nowrap','nowrap')
     dtbl.add_row()
     d3 = dtbl.add_cell('<b>Completion Date:</b> %s ' % my.fix_date(order.get('completion_date')))
     d3.add_attr('nowrap','nowrap')
     dtbl.add_row()
     d4 = dtbl.add_cell('<b>Billed Date:</b> %s ' % my.fix_date(order.get('billed_date')))
     d4.add_attr('nowrap','nowrap')
     dtbl.add_row()
     d5 = dtbl.add_cell('<b>Invoiced Date:</b> %s ' % my.fix_date(order.get('invoiced_date')))
     d5.add_attr('nowrap','nowrap')
     ctbl = Table()
     ctbl.add_attr('cellspacing','3')
     ctbl.add_attr('cellpadding','3')
     ctbl.add_row()
     c1 = ctbl.add_cell('<b>Completion Ratio:</b> %s/%s ' % (order.get('wo_completed'), order.get('wo_count')))
     c1.add_attr('nowrap','nowrap')
     ctbl.add_row()
     o_expected_cost = my.make_number(order.get('expected_cost'))
     o_actual_cost = my.make_number(order.get('actual_cost'))
     o_expected_price = my.make_number(order.get('expected_price'))
     o_actual_price = my.make_number(order.get('price'))
     c2 = ctbl.add_cell('<b>Expected Cost:</b> $%.2f ' % o_expected_cost)
     c2.add_attr('nowrap','nowrap')
     ctbl.add_row()
     c3 = ctbl.add_cell('<b>Actual Cost:</b> $%.2f ' % o_actual_cost)
     c3.add_attr('nowrap','nowrap')
     ctbl.add_row()
     c4 = ctbl.add_cell('<b>Expected Price:</b> $%.2f ' % o_expected_price)
     c4.add_attr('nowrap','nowrap')
     ctbl.add_row()
     c5 = ctbl.add_cell('<b>Actual Price:</b> $%.2f ' % o_actual_price)
     c5.add_attr('nowrap','nowrap')
     otbl.add_row()
     o1 = otbl.add_cell(botbl)
     o1.add_attr('valign','top')
     o2 = otbl.add_cell(dtbl)
     o2.add_attr('valign','top')
     o3 = otbl.add_cell(ctbl)
     o3.add_attr('valign','top')
     discuss = DiscussionWdg(search_key=my.sk,append_process='Client Services,Redelivery/Rejection Request,Redelivery/Rejection Completed',chronological=True)
     o4 = otbl.add_cell(discuss)
     o4.add_attr('valign','top')
     
     hide_row1 = otbl.add_row()
     hide_row1.add_attr('id','billing_%s' % order.get('code'))
     hide_row1.add_style('display: none;')
     order_hours_tbl = my.make_hours_tbl(order_hours, order.get('code'))
     tspan = otbl.add_cell(order_hours_tbl)
     tspan.add_attr('colspan','3')
     table.add_row()
     table.add_cell(otbl)
     #colors = ['#04f002','#0e9422']
     colors = ['#d9edcf','#e9edcf']
     i = 0
     for title in titles:
         title_full_name = title.get('title')
         title_code = title.get('code')
         ttbl = Table()
         ttbl.add_attr('cellspacing','3')
         ttbl.add_attr('cellpadding','3')
         ttbl.add_style('border-bottom-right-radius', '10px')
         ttbl.add_style('border-bottom-left-radius', '10px')
         ttbl.add_style('border-top-right-radius', '10px')
         ttbl.add_style('border-top-left-radius', '10px')
         ttbl.add_style('padding-left: 40px;')
         hide_unhide_bvr = my.get_hide_unhide(title_code)
         ttbl.add_behavior(hide_unhide_bvr)
         cval = i % 2
         #ttbl.add_attr('bgcolor',colors[cval])
         ttbl.add_style('background-color: %s;' % colors[cval])
         if title.get('episode') not in [None,'']:
             title_full_name = '%s: %s' % (title_full_name, title.get('episode'))
         totbl = Table()
         totbl.add_attr('cellspacing','3')
         totbl.add_attr('cellpadding','3')
         totbl.add_row()
         t1 = totbl.add_cell("<b>Title:</b> %s" % title_full_name)
         t1.add_attr('nowrap','nowrap')
         t2 = totbl.add_cell("<b>Status:</b> %s" % title.get('status'))
         t2.add_attr('nowrap','nowrap')
         t3 = totbl.add_cell("<b>Platform:</b> %s" % title.get('platform'))
         t3.add_attr('nowrap','nowrap')
         t4 = totbl.add_cell("<b>Pipeline:</b> %s" % title.get('pipeline_code'))
         t4.add_attr('nowrap','nowrap')
         totbl.add_row()
         t5 = totbl.add_cell("<b>Code:</b> %s" % title.get('code'))
         t5.add_attr('nowrap','nowrap')
         t6 = totbl.add_cell("<b>Language:</b> %s" % title.get('language'))
         t6.add_attr('nowrap','nowrap')
         t7 = totbl.add_cell("<b>Territory:</b> %s" % title.get('territory'))
         t7.add_attr('nowrap','nowrap')
         t8 = totbl.add_cell("<b>Title ID#:</b> %s" % title.get('title_id_number'))
         t8.add_attr('nowrap','nowrap')
         totbl.add_row()
         tuploader = CustomHTML5UploadButtonWdg(sk=title.get('__search_key__'))
         totbl.add_cell(tuploader)
         t9 = totbl.add_cell("<b>TRT:</b> %s" % title.get('total_program_runtime'))
         t9.add_attr('nowrap','nowrap')
         t10 = totbl.add_cell("<b>TRT w/ Textless:</b> %s" % title.get('total_runtime_w_textless'))
         t10.add_attr('nowrap','nowrap')
         t11 = totbl.add_cell("<b>Pulled Blacks:</b> %s" % title.get('pulled_blacks'))
         t11.add_attr('nowrap','nowrap')
         totbl.add_row()
         t12 = totbl.add_cell(' ')
         t13 = totbl.add_cell('<b>File Size:</b> %s' % title.get('file_size'))
         dttbl = Table()
         dttbl.add_attr('cellspacing','3')
         dttbl.add_attr('cellpadding','3')
         dttbl.add_row()
         d1 = dttbl.add_cell('<b>Start Date:</b> %s ' % my.fix_date(title.get('start_date')))
         d1.add_attr('nowrap','nowrap')
         dttbl.add_row()
         d2 = dttbl.add_cell('<b>Due Date:</b> %s ' % my.fix_date(title.get('due_date')))
         d2.add_attr('nowrap','nowrap')
         dttbl.add_row()
         d3 = dttbl.add_cell('<b>Completion Date:</b> %s ' % my.fix_date(title.get('completion_date')))
         d3.add_attr('nowrap','nowrap')
         cttbl = Table()
         cttbl.add_attr('cellspacing','3')
         cttbl.add_attr('cellpadding','3')
         cttbl.add_row()
         c1 = cttbl.add_cell('<b>Completion Ratio:</b> %s/%s ' % (title.get('wo_completed'), title.get('wo_count')))
         c1.add_attr('nowrap','nowrap')
         cttbl.add_row()
         t_expected_cost = my.make_number(title.get('expected_cost'))
         t_actual_cost = my.make_number(title.get('actual_cost'))
         t_expected_price = my.make_number(title.get('expected_price'))
         t_actual_price = my.make_number(title.get('price'))
         c2 = cttbl.add_cell('<b>Expected Cost:</b> $%.2f ' % t_expected_cost)
         c2.add_attr('nowrap','nowrap')
         cttbl.add_row()
         c3 = cttbl.add_cell('<b>Actual Cost:</b> $%.2f ' % t_actual_cost)
         c3.add_attr('nowrap','nowrap')
         cttbl.add_row()
         c4 = cttbl.add_cell('<b>Expected Price:</b> $%.2f ' % t_expected_price)
         c4.add_attr('nowrap','nowrap')
         cttbl.add_row()
         c5 = cttbl.add_cell('<b>Actual Price:</b> $%.2f ' % t_actual_price)
         c5.add_attr('nowrap','nowrap')
         ttbl.add_row()
         tt1 = ttbl.add_cell(totbl)
         tt1.add_attr('valign','top')
         tt2 = ttbl.add_cell(dttbl)
         tt2.add_attr('valign','top')
         tt3 = ttbl.add_cell(cttbl)
         tt3.add_attr('valign','top')
         discuss = DiscussionWdg(search_key=title.get('__search_key__'),append_process='Client Services,Redelivery/Rejection Request,Redelivery/Rejection Completed',chronological=True)
         tt4 = ttbl.add_cell(discuss)
         tt4.add_attr('valign','top')
         hide_row2 = ttbl.add_row()
         hide_row2.add_attr('id','billing_%s' % title_code)
         hide_row2.add_style('display: none;')
         t_hours_tbl = my.make_hours_tbl(title_hours[title_code], title_code)
         tspan = ttbl.add_cell(t_hours_tbl)
         tspan.add_attr('colspan','3')
         table.add_row()
         cellio = table.add_cell(ttbl)
         cellio.add_style('padding-left: 40px;')
         i = i + 1
         
     widget.add(table)
     return widget
    def get_example_display(my):

        div = DivWdg()

        # Smart Menu data ...
        dog_menus = [
            my.get_sm_dog_main_menu_details(),
            my.get_sm_dog_submenu_one_details(),
            my.get_sm_dog_submenu_two_details()
        ]

        cat_menus = [my.get_sm_cat_main_menu_details()]

        SmartMenu.attach_smart_context_menu(div, {
            'DOG': dog_menus,
            'CAT': cat_menus
        }, False)

        table = Table(css="maq_view_table")
        table.set_id("main_body_table")
        table.add_class("spt_table")

        table.add_behavior({
            "type":
            "smart_drag",
            "bvr_match_class":
            "SPT_DO_RESIZE",
            "cbjs_setup":
            'spt.dg_table.resize_column_setup( evt, bvr, mouse_411 );',
            "cbjs_motion":
            'spt.dg_table.resize_column_motion( evt, bvr, mouse_411 );'
        })

        table.add_behavior({
            "type":
            "smart_drag",
            "bvr_match_class":
            "SPT_DO_DRAG",
            "use_copy":
            'true',
            "use_delta":
            'true',
            'dx':
            10,
            'dy':
            10,
            "drop_code":
            'TableExampleSwitchContents',
            "cbjs_action":
            "spt.ui_play.drag_cell_drop_action( evt, bvr );",
            "copy_styles":
            'background: blue; opacity: .5; border: 1px solid black; text-align: left;'
        })

        row = table.add_row()
        for c in range(10):
            th = table.add_header()
            th.set_attr('col_idx', str(c))
            th.add_class("cell_left")
            th.add_styles("width: 150px; cursor: default;")

            # @@@
            th.add_behavior({
                "type":
                "move",
                "cbjs_action":
                '''
                    // log.debug( "(x,y) = (" + mouse_411.curr_x + "," + mouse_411.curr_y + ")" );
                    spt.ui_play.header_half_move_cbk( evt, bvr, mouse_411 );
                ''',
                "cbjs_action_on":
                '''
                    // log.debug( "START MY MOVE!" );
                ''',
                "cbjs_action_off":
                '''
                    // log.debug( "DONE MY MOVE!" );
                    spt.ui_play.header_half_move_off_cbk( evt, bvr, mouse_411 );
                '''
            })

            if (c % 2):
                th.add("H%s (Cat)" % c)
            else:
                th.add("H%s (Dog)" % c)
            th_resize = table.add_cell()
            th_resize.set_attr('col_idx', str(c + 1))
            th_resize.add_class("SPT_DO_RESIZE cell_right")
            th_resize.add_styles("width: 4px; cursor: col-resize;")

        for r in range(19):
            row = table.add_row()
            for c in range(10):
                col = table.add_cell()
                col.set_attr('col_idx', str(c))
                col.set_attr('SPT_ACCEPT_DROP', 'TableExampleSwitchContents')
                col.add_class("SPT_DO_DRAG cell_left")
                col.add_styles("cursor: pointer;")
                col.add("(%s,%s)" % (r, c))
                if (c % 2) == 0:
                    SmartMenu.assign_as_local_activator(col, "DOG")
                else:
                    SmartMenu.assign_as_local_activator(col, "CAT")
                resize = table.add_cell()
                resize.set_attr('col_idx', str(c + 1))
                resize.add_class("SPT_DO_RESIZE cell_right")
                resize.add_styles("width: 6px; cursor: col-resize;")

        div.add(table)
        return div