示例#1
0
    def get_instantiation_wdg(self):
        setting = self.get_default_setting()
        default_instantiation = setting.get('instantiation')

        div = DivWdg()
        is_unchecked = True
        default_cb = None
        for value in self.get_instantiation_options():
            name = self.get_element_name("instantiation")
            checkbox = CheckboxWdg( name )
            if value == default_instantiation:
                default_cb = checkbox
            
            checkbox.set_option("value", value)
            checkbox.set_persistence()
            if checkbox.is_checked():
                is_unchecked = False
            checkbox.add_behavior({'type': 'click_up', 
                    'propagate_evt': True,
                     "cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" %name}) 
            span = SpanWdg(checkbox, css='small')
            span.add(value)
            div.add(span)
        if is_unchecked:
            default_cb.set_checked()
        return div
示例#2
0
 def make_check_table(my, dictoid, arr, sob, my_name, color, is_external_rejection=False):
     table = Table()
     table.add_style('background-color: %s;' % color)
     max_width = 3
     table.add_row()
     top_cell = table.add_cell('<b><u>%s</u></b>' % my_name)
     top_cell.add_attr('colspan',max_width)
     top_cell.add_attr('align','center')
     count = 0
     for entry in arr:
         if count % max_width == 0:
             table.add_row()
         checker = CheckboxWdg('check_%s' % dictoid[entry])
         checker.add_attr('code', sob.get('code'))
         checker.add_attr('field', dictoid[entry])
         #checker.set_persistence()
         if sob.get(dictoid[entry]):
             checker.set_value(True)
         else:
             checker.set_value(False)
         if not is_external_rejection:
             checker.add_behavior(my.get_reason_check_behavior(dictoid[entry]))
         check_hold = table.add_cell(checker)
         check_hold.add_attr('code', sob.get('code'))
         check_hold.add_attr('field', dictoid[entry])
         label = table.add_cell(entry)
         label.add_attr('nowrap','nowrap')
         label.add_attr('width','190px')
         count = count + 1 
     return table
示例#3
0
    def get_instantiation_wdg(my):
        setting = my.get_default_setting()
        default_instantiation = setting.get('instantiation')

        div = DivWdg()
        is_unchecked = True
        default_cb = None
        for value in my.get_instantiation_options():
            name = my.get_element_name("instantiation")
            checkbox = CheckboxWdg(name)
            if value == default_instantiation:
                default_cb = checkbox

            checkbox.set_option("value", value)
            checkbox.set_persistence()
            if checkbox.is_checked():
                is_unchecked = False
            checkbox.add_behavior({
                'type':
                'click_up',
                'propagate_evt':
                True,
                "cbjs_action":
                "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name
            })
            span = SpanWdg(checkbox, css='small')
            span.add(value)
            div.add(span)
        if is_unchecked:
            default_cb.set_checked()
        return div
示例#4
0
    def get_title(my):
        mode = my.get_option("mode")
        title = SpanWdg()

        #loader = LoaderButtonWdg()
        #loader.set_load_script( my.get_load_script() )
        #return loader
        search_type = my.get_search_type()
        cb_name = '%s_%s' % (search_type, my.CB_NAME)
        master_cb = CheckboxWdg('master_control')
        master_cb.add_behavior({
            'type':
            'click_up',
            'propagate_evt':
            True,
            'cbjs_action':
            '''
                var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_table'),'%s','.spt_latest_%s');
                for (var i = 0; i < inputs.length; i++)
                    inputs[i].checked = bvr.src_el.checked;
                    ''' % (cb_name, mode)
        })
        title.add(master_cb)

        if mode == "input":
            title.add("Receive")
        else:
            title.add("Deliver")
        return title
示例#5
0
 def make_login_table(my, sob):
     table = Table()
     table.add_style('background-color: #fffff1;')
     max_width = 4
     table.add_row()
     top_cell = table.add_cell('<b><u>Responsible</u></b>')
     top_cell.add_attr('colspan',max_width)
     top_cell.add_attr('align','center')
     count = 0
     users = my.server.eval("@SOBJECT(sthpw/login['location','internal']['license_type','user']['@ORDER_BY','login'])")
     for u in users:
         if count % max_width == 0:
             table.add_row()
         checker = CheckboxWdg('responsible_%s' % u.get('login'))
         checker.add_attr('login',u.get('login'))
         checker.add_attr('code',sob.get('code'))
         checker.add_attr('current_list', sob.get('responsible_users'))
         #checker.set_persistence()
         if sob.get('responsible_users') not in [None,'']:
             if u.get('login') in sob.get('responsible_users'):
                 checker.set_value(True)
             else:
                 checker.set_value(False)
         else:
             checker.set_value(False)
         checker.add_behavior(my.get_make_responsible_behavior())
         table.add_cell(checker)
         label = table.add_cell(u.get('login'))
         label.add_attr('nowrap','nowrap')
         label.add_attr('width','137px')
         count = count + 1
     return table
示例#6
0
    def get_display(my):   
        my.sk = str(my.kwargs.get('search_key'))
        my.code = str(my.kwargs.get('code'))
        my.name = str(my.kwargs.get('name'))

        src_tbl = Table()
        togs = my.server.eval("@SOBJECT(twog/title_origin['title_code','%s'])" % my.code)
        sources = []
        for tog in togs:
            single = my.server.eval("@SOBJECT(twog/source['code','%s'])" % tog.get('source_code'))[0]
            sources.append(single)
        if len(sources) > 0:
            src_title = src_tbl.add_row()
            src_title.add_style('background-color: #cedb3a;')
            src_tbl.add_cell('Sources')
        for src in sources:
            src_tbl.add_row()
            source_look = src_tbl.add_cell('<u>Title: %s, Type: %s</u>' % (src.get('title'), src.get('source_type')))
            source_look.add_attr('nowrap', 'nowrap')
            source_look.add_style('cursor: pointer;')
            source_look.add_behavior(get_open_sob_behavior(src.get('code'), 'twog/source', 'view'))
        view_edit_wdg = EditWdg(element_name='general',mode='view',search_type='twog/title',code=my.code,title="Info for %s" % my.name,view='edit',widget_key='edit_layout',search_key=my.sk)
        delivs_tbl = Table()
        delivs = my.server.eval("@SOBJECT(twog/deliverable['title_code','%s'])" % my.code)
        if len(delivs) > 0:
            d_title = delivs_tbl.add_row()
            d_title.add_style('background-color: #3e5fc9;')
            delivs_tbl.add_cell('Deliverable(s)')
            delivs_tbl.add_cell('Satisfied?')
            
        for d in delivs:
            delivs_tbl.add_row()
            launch_look = delivs_tbl.add_cell('<u>Name: %s, Type: %s To: %s</u>' % (d.get('name'),d.get('source_type'), d.get('deliver_to'))) 
            launch_look.add_attr('nowrap', 'nowrap')
            launch_look.add_style('cursor: pointer;')
            launch_look.add_behavior(get_open_sob_behavior(d.get('code'), 'twog/deliverable', 'view'))
            checkbox = CheckboxWdg('satisfied_%s' % d.get('code'))

            if d.get('satisfied') == True:
                checkbox.set_value(True)
            else:
                checkbox.set_value(False)

            checkbox.add_behavior(get_change_deliverable_satisfied_behavior(d.get('code'), d.get('satisfied')))
            satisfied_cell = delivs_tbl.add_cell(checkbox)
            satisfied_cell.add_attr('align', 'center')
        table = Table()
        table.add_row()
        stbl = table.add_cell(src_tbl)
        stbl.add_attr('align', 'center')
        table.add_row()
        table.add_cell(' ')
        table.add_row()
        dtbl = table.add_cell(delivs_tbl)
        dtbl.add_attr('align', 'center')
        table.add_row()
        table.add_cell(view_edit_wdg)
        return table
示例#7
0
    def get_format_wdg(my, value, format, display_value):
        div = DivWdg()

        if format not in ['Checkbox'] and value == '':
            return div

        if format == 'Checkbox':

            div.add_style("width: 100%")
            div.add_class("spt_boolean_top")
            from pyasm.widget import CheckboxWdg
            checkbox = CheckboxWdg(my.get_name())
            checkbox.set_option("value", "true")
            if value:
                checkbox.set_checked()
            div.add(checkbox)
            checkbox.add_behavior({
                'type':
                'click_up',
                'propagate_evt':
                True,
                'cbjs_action':
                '''

            var cached_data = {};
            var value_wdg = bvr.src_el;
            var top_el = bvr.src_el.getParent(".spt_boolean_top");
            spt.dg_table.edit.widget = top_el;
            var key_code = spt.kbd.special_keys_map.ENTER;
            spt.dg_table.inline_edit_cell_cbk( value_wdg, cached_data );
            '''
            })

        elif format == '-$1,234.00':
            if value < 0:
                div.add_style("color: red")
                div.add("(%s)" % display_value.replace("-", ""))
            else:
                div.add_style("color: black")
                div.add(display_value)

        else:
            div.add(display_value)

        return div
示例#8
0
    def get_format_wdg(self, value, format, display_value):
        div = DivWdg()

        if format not in ['Checkbox'] and value == '':
            return div

        if format == 'Checkbox':

            div.add_style("width: 100%")
            div.add_class("spt_boolean_top")
            from pyasm.widget import CheckboxWdg
            checkbox = CheckboxWdg(self.get_name())
            checkbox.set_option("value", "true")
            if value:
                checkbox.set_checked()
            div.add(checkbox)
            checkbox.add_behavior( {
            'type': 'click_up',
            'propagate_evt': True,
            'cbjs_action': '''

            var cached_data = {};
            var value_wdg = bvr.src_el;
            var top_el = bvr.src_el.getParent(".spt_boolean_top");
            spt.dg_table.edit.widget = top_el;
            var key_code = spt.kbd.special_keys_map.ENTER;
            spt.dg_table.inline_edit_cell_cbk( value_wdg, cached_data );
            '''
            } )

        elif format == '-$1,234.00':
            if value < 0:
                div.add_style("color: red")
                div.add("(%s)" % display_value.replace("-", ""))
            else:
                div.add_style("color: black")
                div.add(display_value)

        else:
            div.add(display_value)

        return div
示例#9
0
    def get_title(my):
        mode = my.get_option("mode")
        title = SpanWdg()
       
        #loader = LoaderButtonWdg()
        #loader.set_load_script( my.get_load_script() )
        #return loader
        search_type = my.get_search_type()
        cb_name = '%s_%s' %(search_type, my.CB_NAME)
        master_cb = CheckboxWdg('master_control')
        master_cb.add_behavior({'type': 'click_up',
            'propagate_evt': True,
            'cbjs_action': '''
                var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_table'),'%s','.spt_latest_%s');
                for (var i = 0; i < inputs.length; i++)
                    inputs[i].checked = bvr.src_el.checked;
                    ''' %(cb_name, mode)})
        title.add(master_cb)

        if mode == "input":
            title.add("Receive")
        else:
            title.add("Deliver")
        return title
示例#10
0
    def get_display(my): 

        top = my.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("padding: 10px")
        top.add_style("min-width: 400px")

        from tactic.ui.app import HelpButtonWdg
        help_wdg = HelpButtonWdg(alias="exporting-csv-data")
        top.add(help_wdg)
        help_wdg.add_style("float: right")
        help_wdg.add_style("margin-top: -3px")
        
        if not my.check(): 
            top.add(DivWdg('Error: %s' %my.error_msg))
            top.add(HtmlElement.br(2))
            return super(CsvExportWdg, my).get_display()

        if my.search_type_list and my.search_type_list[0] != my.search_type:
            st = SearchType.get(my.search_type_list[0])
            title_div =DivWdg('Exporting related items [%s]' % st.get_title())
            top.add(title_div)
            top.add(HtmlElement.br())
            my.search_type = my.search_type_list[0]
            my.view = my.related_view

        if my.mode != 'export_all':
            num = len(my.selected_search_keys)
        else:
            search = Search(my.search_type)
            num = search.get_count()
        msg_div = DivWdg('Total: %s items to export'% num)
        msg_div.add_style("font-size: 12px")
        msg_div.add_style("font-weight: bold")
        msg_div.add_style('margin-left: 4px')
        top.add(msg_div)
        if num > 300:
            msg_div.add_behavior({'type':'load',
            'cbjs_action': "spt.alert('%s items are about to be exported. It may take a while.')" %num})
                
        top.add(HtmlElement.br())

        div  = DivWdg(css='spt_csv_export', id='csv_export_action')
        div.add_color("background", "background", -10)
        div.add_style("padding: 10px")
        div.add_style("margin: 5px")
        
        div.add_styles('max-height: 350px; overflow: auto')
        table = Table( css='minimal')
        table.add_color("color", "color")
        div.add(table)
        table.set_id('csv_export_table')
        table.center()
        
        
        cb_name = 'csv_column_name'
        master_cb = CheckboxWdg('master_control')
        master_cb.set_checked()
        master_cb.add_behavior({'type': 'click_up',
            'propagate_evt': True,
            'cbjs_action': '''
                var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_csv_export'),'%s');
                for (var i = 0; i < inputs.length; i++)
                    inputs[i].checked = !inputs[i].checked;
                    ''' %cb_name})


        span = SpanWdg('Select Columns To Export')
        span.add_style('font-weight','600')
        table.add_row_cell(span)
        table.add_row_cell(HtmlElement.br())

        tr = table.add_row()
        tr.add_style('border-bottom: 1px groove #777')
        td = table.add_cell(master_cb)
        label = HtmlElement.i('toggle all')
        label.add_style('color: #888')
        table.add_cell(label)


        col1 = table.add_col()
        col1.add_style('width: 35px')
        col2 = table.add_col()
        
        if not my.search_type or not my.view:
            return table

        
        # use overriding element names and derived titles if available
        config = WidgetConfigView.get_by_search_type(my.search_type, my.view)
        if my.element_names and config:
            filtered_columns = my.element_names
            titles = []
            for name in my.element_names:
                title = config.get_element_title(name)
                titles.append(title)

        else:
            
            # excluding FunctionalTableElement
            filtered_columns = []
            titles = []
            if not config:
                columns = search.get_columns()
                filtered_columns = columns
                titles = ['n/a'] * len(filtered_columns)
            else:
                columns = config.get_element_names()
                
                filtered_columns = columns
                titles = config.get_element_titles()

        
            """
            # commented out until it is decided 2.5 widgets will 
            # use this class to differentiate between reg and functional element
            from pyasm.widget import FunctionalTableElement
            for column in columns:
                widget = config.get_display_widget(column)

                if isinstance(widget, FunctionalTableElement):
                    continue
                filtered_columns.append(column)
            """

        for idx, column in enumerate(filtered_columns):
            table.add_row()
            cb = CheckboxWdg(cb_name)
            cb.set_option('value', column)
            cb.set_checked()
            table.add_cell(cb)
            
            
            title = titles[idx]
            table.add_cell('<b>%s</b> (%s) '%(title, column))

        action_div = DivWdg()
        widget = DivWdg()
        table.add_row_cell(widget)
        widget.add_style("margin: 20px 0 10px 0px")
        cb = CheckboxWdg('include_id', label=" Include ID")
        cb.set_default_checked()
        widget.add(cb)
        hint = HintWdg('To update entries with specific ID later, please check this option. For new inserts in this or other table later on, uncheck this option.') 
        widget.add(hint)

        label = string.capwords(my.mode.replace('_', ' '))
        button = ActionButtonWdg(title=label)

        is_export_all  = my.mode == 'export_all'
        button.add_behavior({
            'type': "click_up",
            'cbfn_action': 'spt.dg_table_action.csv_export',
            'element': 'csv_export',
            'column_names': 'csv_column_name',
            'search_type': my.search_type,
            'view': my.view,
            'search_keys' : my.selected_search_keys,
            'is_export_all' : is_export_all
            
        })

        my.close_action = "var popup = bvr.src_el.getParent('.spt_popup');spt.popup.close(popup)"
        if my.close_action:
            close_button = ActionButtonWdg(title='Close')
            close_button.add_behavior({
                'type': "click",
                'cbjs_action': my.close_action
            })


        table = Table()
        action_div.add(table)
        table.center()
        table.add_row()
        td = table.add_cell(button)
        td.add_style("width: 130px")
        table.add_cell(close_button)

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

        top.add(div)
        top.add(HtmlElement.br())
        top.add(action_div)
        return top
示例#11
0
    def get_first_row_wdg(my):

        # read the csv file
        #my.file_path = ""

        div = DivWdg(id='csv_import_main')
        div.add_class('spt_panel')
        
        div.add( my.get_upload_wdg() )
        if not my.search_type:
            return div

        if not my.file_path:
            return div


        if not my.file_path.endswith(".csv"):
            div.add('<br>')
            div.add( "Uploaded file [%s] is not a csv file. Refreshing in 3 seconds. . ."% os.path.basename(my.file_path))
            div.add_behavior( {'type': 'load', \
                                  'cbjs_action': "setTimeout(function() {spt.panel.load('csv_import_main','%s', {}, {\
                                    'search_type_filter': '%s'});}, 3000);" %(Common.get_full_class_name(my), my.search_type) } )
            return div

        if not os.path.exists(my.file_path):
            raise TacticException("Path '%s' does not exist" % my.file_path)

        
        div.add(HtmlElement.br(2))



        # NOT NEEDED:  clear the widget settings before drawing
        #expr = "@SOBJECT(sthpw/wdg_settings['key','EQ','pyasm.widget.input_wdg.CheckboxWdg|column_enabled_']['login','$LOGIN']['project_code','$PROJECT'])"
        #sobjs = Search.eval(expr)
        #for sobj in sobjs:
        #    sobj.delete(log=False)


        div.add( HtmlElement.b("The following is taken from the first line in the uploaded csv file.  Select the appropriate column to match.") )
        div.add(HtmlElement.br())
        """
        text =  HtmlElement.b("Make sure you have all the required columns** in the csv.")
        text.add_style('text-align: left')
        div.add(text)
        """
        div.add(HtmlElement.br(2))
        option_div_top = DivWdg()
        option_div_top.add_color('color','color')
        option_div_top.add_color('background','background', -5)
        option_div_top.add_style("padding: 10px")
        option_div_top.add_border()
        option_div_top.add_style("width: 300px")

        swap = SwapDisplayWdg(title="Parsing Options")
        option_div_top.add(swap)

        option_div_top.add_style("margin-right: 30px")

        my.search_type_obj = SearchType.get(my.search_type)

        option_div = DivWdg()
        swap.set_content_id(option_div.set_unique_id() )
        option_div.add_style("display: none")
        option_div.add_style('margin-left: 14px')
        option_div.add_style('margin-top: 10px')
        option_div.add_style("font-weight: bold")
        option_div_top.add(option_div)

        # first row and second row
        #option_div.add( HtmlElement.br() )
        option_div.add(SpanWdg("Use Title Row: ", css='small'))
        title_row_checkbox = CheckboxWdg("has_title")
        title_row_checkbox.set_default_checked()

        title_row_checkbox.add_behavior({'type' : 'click_up',
                    'propagate_evt': 'true',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(title_row_checkbox)
        option_div.add( HintWdg("Set this to use the first row as a title row to match up columns in the database") )
        

        option_div.add( HtmlElement.br(2) )
        option_div.add(SpanWdg("Use Lowercase Title: ", css='small'))
        lower_title_checkbox = CheckboxWdg("lowercase_title")

        lower_title_checkbox.add_behavior({'type' : 'click_up',
                    'propagate_evt': 'true',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(lower_title_checkbox)
        option_div.add( HtmlElement.br(2) )

        option_div.add(SpanWdg("Sample Data Row: ", css='small'))
        data_row_text = SelectWdg("data_row")
        data_row_text.set_option('values', '1|2|3|4|5')
        data_row_text.set_value('1')
        data_row_text.add_behavior({'type' : 'change',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(data_row_text)
        option_div.add( HintWdg("Set this as a sample data row for display here") )

        option_div.add( HtmlElement.br(2) )
      
        # encoder
        option_div.add(SpanWdg("Encoder: ", css='small'))
        select_wdg = SelectWdg('encoder')
        select_wdg.set_option('values', ['','utf-8', 'iso_8859-1']) 
        select_wdg.set_option('labels', ['ASCII (default)','UTF-8','Excel ISO 8859-1']) 
        select_wdg.add_behavior({'type' : 'change',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(select_wdg)
        option_div.add( HtmlElement.br(2) )


        option_div.add(SpanWdg("Identifying Column: ", css='small'))
        select_wdg = SelectWdg('id_col')
        select_wdg.set_option('empty','true')
        #columns = my.search_type_obj.get_columns()
        columns = SearchType.get_columns(my.search_type)
        
        # make sure it starts off with id, code where applicable
        if 'code' in columns:
            columns.remove('code')
            columns.insert(0, 'code')
        if 'id' in columns:
            columns.remove('id')
            columns.insert(0, 'id')

        select_wdg.set_option('values', columns) 
        option_div.add(select_wdg)
        option_div.add( HintWdg("Set which column to use for identifying an item to update during CSV Import") )
        option_div.add( HtmlElement.br(2) )

        

        div.add(option_div_top)

        my.has_title = title_row_checkbox.is_checked()
        
        
        # need to somehow specify defaults for columns
        div.add(my.get_preview_wdg())


        return div          
示例#12
0
    def get_display(my):

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


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



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


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

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

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

            '''
        } )

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

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


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



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



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



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



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

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


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



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

            table.add_cell(title)

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



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



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

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

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

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


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

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

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

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

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


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

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

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

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

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

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

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

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


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

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

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

                '''
            } )
            """





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

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

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

                '''
            } )



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

                '''
            } )





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

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




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


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

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






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

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


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

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


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

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





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

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


                '''
            } )


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


        columns_wdg = DivWdg()
        top.add(columns_wdg)


        return top
示例#13
0
    def get_display(my):
        my.init_kwargs()
        sobject = my.get_current_sobject()

        table = Table(css='minimal')
        table.add_color("color", "color")
        table.add_style("font-size: 0.9em")

       
        
        snapshots = my.get_snapshot(my.mode)
        for snapshot in snapshots:
            table.add_row()

            value = my.get_input_value(sobject, snapshot)

            current_version = snapshot.get_value("version")
            current_context = snapshot.get_value("context")
            current_revision = snapshot.get_value("revision", no_exception=True)
            current_snapshot_type = snapshot.get_value("snapshot_type")

            # hack hard coded type translation
            if current_snapshot_type == "anim_export":
                current_snapshot_type = "anim"

            # ignore icon context completely
            if current_context == "icon":
                table.add_blank_cell()
                table.add_cell("(---)")
                return table

            checkbox = CheckboxWdg('%s_%s' %(my.search_type, my.CB_NAME))
            
            # this is added back in for now to work with 3.7 Fast table
            checkbox.add_behavior({'type': 'click_up',
            'propagate_evt': True})

            checkbox.add_class('spt_latest_%s' %my.mode)
            checkbox.set_option("value", value )
            table.add_cell( checkbox )

            load_all = False
            if load_all:
                checkbox.set_checked()


            # add the file type icon
            xml = snapshot.get_snapshot_xml()
            file_name = xml.get_value("snapshot/file/@name")
            icon_link = ThumbWdg.find_icon_link(file_name)
            image = HtmlElement.img(icon_link)
            image.add_style("width: 15px")
            table.add_cell(image)

            namespace = my.get_namespace(sobject, snapshot) 
            asset_code = my.get_asset_code()
          
            # force asset mode = True   
            my.session.set_asset_mode(asset_mode=my.get_session_asset_mode())
            node_name = my.get_node_name(snapshot, asset_code, namespace)
            # get session info
            session_context = session_version = session_revision = None
            if my.session:
                
                session_context = my.session.get_context(node_name, asset_code, current_snapshot_type)
                session_version = my.session.get_version(node_name, asset_code, current_snapshot_type)
                session_revision = my.session.get_revision(node_name, asset_code,current_snapshot_type)


                # Maya Specific: try with namespace in front of it for referencing
                referenced_name = '%s:%s' %(namespace, node_name)
                if not session_context or not session_version:
                    session_context = my.session.get_context(referenced_name, asset_code, current_snapshot_type)
                    session_version = my.session.get_version(referenced_name, asset_code, current_snapshot_type)
                    session_revision = my.session.get_revision(referenced_name, asset_code, current_snapshot_type)

            from version_wdg import CurrentVersionContextWdg, SubRefWdg

            version_wdg = CurrentVersionContextWdg()
            data = {'session_version': session_version, \
                'session_context': session_context,  \
                'session_revision': session_revision,  \
                'current_context': current_context, \
                'current_version': current_version, \
                'current_revision': current_revision }
            version_wdg.set_options(data)
            
            table.add_cell(version_wdg, "no_wrap")
            td = table.add_cell(HtmlElement.b("(%s)" %current_context))
            td.add_tip("Snapshot code: %s" % snapshot.get_code())
            #table.add_cell(snapshot.get_code() )

            #if snapshot.is_current():
            #    current = IconWdg("current", IconWdg.CURRENT)
            #    table.add_cell(current)
            #else:
            #    table.add_blank_cell()


            # handle subreferences
            has_subreferences = True
            xml = snapshot.get_xml_value("snapshot")
            refs = xml.get_nodes("snapshot/file/ref")
            if my.mode == "output" and refs:
                table.add_row()
                td = table.add_cell()
                swap = SwapDisplayWdg.get_triangle_wdg()
                td.add(swap)
                td.add("[ %s reference(s)" % len(refs))
                #td.add_style("text-align: right")

                sub_ref_wdg = SubRefWdg()
                sub_ref_wdg.set_info(snapshot, my.session, namespace)
                swap.add_action_script( sub_ref_wdg.get_on_script(), "toggle_display('%s')" % sub_ref_wdg.get_top_id() )

                status = sub_ref_wdg.get_overall_status()
                td.add(SpanWdg(VersionWdg.get(status), css='small_left'))
                td.add(']')
             
                td.add( sub_ref_wdg )
                td.add_style('padding-left: 10px')



        #else:
        if not snapshots:
            table.add_row()
            table.add_blank_cell()
            table.add_cell("(---)")

        return table
示例#14
0
    def get_display(my):
        from tactic_client_lib import TacticServerStub
        widget = DivWdg()
        server = TacticServerStub.get()
        allowed_groups = ['admin','audio','billing and accounts receivable','compression','compression supervisor','edeliveries','edit','edit supervisor','executives','it','machine room','machine room supervisor','management','media vault','media vault supervisor','office employees','qc','qc supervisor','sales','sales supervisor','scheduling','scheduling supervisor','senior_staff','streamz','technical services']
        sobject = None
        code = None
        user_name = None 
        do_inserted_msg = False
        table = Table() 
        table.add_attr('class','source_security_wdg')
        if 'source_code' in my.kwargs.keys():
            code = str(my.kwargs.get('source_code'))    
        if code in [None,'']:
            if 'code' in my.kwargs.keys():
                code = my.kwargs.get('code')
        if 'user_name' in my.kwargs.keys():
            user_name = my.kwargs.get('user_name')
        else:
            login = Environment.get_login()
            user_name = login.get_login()
        if 'from' in my.kwargs.keys():
            if my.kwargs.get('from') == 'insert':
                do_inserted_msg = True
                table.add_attr('from','insert')
        if not do_inserted_msg:
            table.add_attr('from','i dunno')
        group = None
        login_in_groups = server.eval("@SOBJECT(sthpw/login_in_group['login','%s']['login_group','not in','user|client'])" % user_name)
        for lg in login_in_groups:
            if not group:
                group = lg.get('login_group')
            if 'supervisor' in lg.get('login_group'): 
                group = lg.get('login_group')
        
        
        checks = server.eval("@SOBJECT(twog/source_req['source_code','%s'])" % code)
        visi = 'display: none;'
        if len(checks) > 0:
            visi = 'display: table-row;';
        if do_inserted_msg:
            table.add_row()
            inserted_row = table.add_cell('<font color="#f0000">!!!Please Enter the High Security Requirements!!!</font>')
            colspan = 2
            if group in allowed_groups:
                colspan = 3
            inserted_row.add_attr('colspan',colspan)
        top_row = table.add_row()
        top_row.add_style(visi)
        if group in allowed_groups:
            table.add_cell(' ')
        table.add_cell(' ')
        table.add_cell('Satisfied?')
        for check in checks:
            check_row = table.add_row()
            check_row.add_attr('class','row_%s' % check.get('__search_key__'))
            if group in allowed_groups:
                killer = table.add_cell(my.x_butt)
                killer.add_style('cursor: pointer;')
                killer.add_behavior(my.get_killer_behavior(check.get('__search_key__')))
            table.add_cell(check.get('requirement'))
            checkbox = CheckboxWdg('satisfied_%s' % check.get('__search_key__'))
            #checkbox.set_persistence()
            if check.get('satisfied'): 
                checkbox.set_value(True)
            else:
                checkbox.set_value(False)
            checkbox.add_behavior(my.get_change_satisfied(check.get('__search_key__')))
            table.add_cell(checkbox)
        
        table.add_row()
        if group in allowed_groups:
            table.add_cell(' ')
        req_text = TextWdg('new_source_req')
        req_text.add_style('width: 500px')
        req_text.add_behavior(my.get_insert_new_req_from_change(code, user_name))
        table.add_cell(req_text)
        add_button = table.add_cell('<input type="button" class="add_req_button" value="+"/>')
        add_button.add_behavior(my.get_insert_new_req(code, user_name))
        if do_inserted_msg:
            table.add_row()
            inserted_row = table.add_cell('<font color="#f0000">!!!Please Enter the High Security Requirements!!!</font>')
            colspan = 2
            if group in allowed_groups:
                colspan = 3
            inserted_row.add_attr('colspan',colspan)
 
        widget.add(table)
        return widget
示例#15
0
    def get_viewer(my):
        top = DivWdg(css='spt_note_viewer_top')

        # draw checkbox options
        swap = SwapDisplayWdg()
        title = SpanWdg('main context')

        split_div = FloatDivWdg(css='spt_split_cb')
        div = DivWdg(css='spt_main_context_cb')
        content_div = DivWdg()
        content_div.add_color('color', 'color')
        content_div.add_style('padding: 10px')
        SwapDisplayWdg.create_swap_title(title,
                                         swap,
                                         content_div,
                                         is_open=False)
        div.add(swap)

        div.add(title)

        checkbox_name = 'split_screen'
        split_cb = CheckboxWdg(checkbox_name, label='Split View')
        split_cb.persistence = True
        split_cb.persistence_obj = split_cb
        key = split_cb.get_key()

        #cb.add_style('float: left')
        split_cb.add_behavior({
            'type':
            'click_up',
            'propagate_evt':
            True,
            'cbjs_action':
            '''
                    var top = bvr.src_el.getParent(".spt_note_viewer_top");
                    var table_top = top.getElement(".spt_note_viewer_table");

                    var cbs = top.getElement('.spt_main_context_cb');
                    var values = spt.api.Utility.get_input_values(cbs);

                    var processes = values.note_context_cb;
                    var kwargs = { process_names: processes};
                    if (bvr.src_el.checked) {
		        kwargs.split_view = 'true';
			kwargs.show_context = 'true';
                        kwargs.left_process_names = processes;
                        kwargs.right_process_names = processes;
                   
                    }

                    spt.input.save_selected(bvr, '%s','%s');
                    spt.app_busy.show("Note Viewer", 'Loading') ;
                    setTimeout(function(){
                        spt.panel.refresh(table_top, kwargs, false);
                        if (bvr.src_el.checked) 
                            spt.hide(cbs);
                        else 
                            spt.show(cbs);
                        spt.app_busy.hide();
                        }, 50 );
                    
                ''' % (checkbox_name, key)
        })
        split_div.add(split_cb)

        top.add(split_div)
        top.add(div)
        div.add(content_div)
        top.add(HtmlElement.br())

        checkbox_name = 'note_main_context_cb'
        cb = CheckboxWdg(checkbox_name)
        cb.persistence = True
        cb.persistence_obj = cb

        my.checked_process_names = cb.get_values()

        for value in my.process_names:
            #my.checked_process_names = web.get_form_values('process_names')
            cb = CheckboxWdg(checkbox_name, label=value)

            if value in my.checked_process_names:
                my.checked_processes.append(value)
            # FIXME: this is very tenous.  Accessing private members to
            # override behavior

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

            cb.add_behavior({
                'type':
                'click_up',
                'propagate_evt':
                True,
                'cbjs_action':
                '''
                    var top = bvr.src_el.getParent(".spt_note_viewer_top")
                    var table_top = top.getElement('.spt_note_viewer_table');
                    var cbs = top.getElement('.spt_main_context_cb');
                    var values = spt.api.Utility.get_input_values(cbs);
                   
                    var processes = values.note_main_context_cb;
                    var kwargs = { process_names: processes};
                    spt.input.save_selected(bvr, '%s','%s');
                    spt.panel.refresh(table_top, kwargs, false);
                ''' % (checkbox_name, key)
            })
            content_div.add(cb)

        table_top = DivWdg(css='spt_note_viewer_table')
        expression = "@SOBJECT(sthpw/note['context','in','%s'])" % '|'.join(
            my.checked_processes)

        if split_cb.is_checked():
            table = my.get_split_viewer()
        else:
            table_id = 'main_table1'

            table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=my.view,\
                 show_row_select=True, show_insert=False, state={'parent_key': my.parent_key}, inline_search=False, show_refresh=True, expression=expression )

        my.set_as_panel(table_top)
        table_top.add_style('float: left')

        top.add(table_top)
        table_top.add(table)

        return top
示例#16
0
    def get_viewer(my):
        top = DivWdg(css='spt_single_note_viewer_top')

        # draw checkbox options
        swap = SwapDisplayWdg()
        title = SpanWdg('context')
        title.add_color('color', 'color')
        div = DivWdg(css='spt_context_cb')
        div.add_color('color', 'color')
        SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False)

        checkbox_name = 'split_screen'
        checked_process_names = []
        if my.show_context:
            top.add(swap)
            top.add(title)
            top.add(div)

            #checkbox_name = 'note_context_cb'
            checkbox_name = my.checkbox_name
            cb = CheckboxWdg(checkbox_name)
            cb.persistence = True
            cb.persistence_obj = cb

            checked_process_names = cb.get_values()
            for value in my.process_names:
                #my.checked_process_names = web.get_form_values('process_names')
                cb = CheckboxWdg(checkbox_name, label=value)

                if value in checked_process_names:
                    my.checked_processes.append(value)
                # FIXME: this is very tenous.  Accessing private members to
                # override behavior

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

                cb.add_behavior({
                    'type':
                    'click_up',
                    'propagate_evt':
                    True,
                    'cbjs_action':
                    '''
                        var top = bvr.src_el.getParent(".spt_single_note_viewer_top")
                        var table_top = top.getElement('.spt_note_viewer_table');
                        var cbs = top.getElement('.spt_context_cb');
                        var values = spt.api.Utility.get_input_values(cbs);
                        var processes = values.%s;
                        var kwargs = { process_names: processes};
                        spt.input.save_selected(bvr, '%s','%s');
                        spt.panel.refresh(table_top, kwargs, false);
                    ''' % (checkbox_name, checkbox_name, key)
                })
                div.add(cb)
        else:
            web = WebContainer.get_web()
            checked_process_names = web.get_form_values('process_names')
        table_top = DivWdg(css='spt_note_viewer_table')
        expression = "@SOBJECT(sthpw/note['context','in','%s'])" % '|'.join(
            checked_process_names)
        table_id = 'main_table1'

        table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=my.view,\
             show_row_select=True, show_insert=False, state={'parent_key': my.parent_key}, inline_search=False, show_refresh=True, expression=expression )
        if my.resize:
            from tactic.ui.container import ResizeScrollWdg
            inner_wdg = ResizeScrollWdg(width='500px',
                                        height='500px',
                                        scroll_bar_size_str='thick',
                                        scroll_expansion='inside')
            inner_wdg.add(table)
            table_top.add(inner_wdg)
        else:
            table_top.add(table)

        my.set_as_panel(table_top)
        top.add(table_top)

        return top
示例#17
0
文件: note_wdg.py 项目: mincau/TACTIC
    def get_display(self):
        if self.is_refresh:
            top = Widget()
            self.add(top)
        else:
            container = DivWdg()
            self.add(container)
            #parent = SearchKey.get_by_search_key(self.search_key)
            top = DivWdg()
            container.add(top)
            self.set_as_panel(top)
            top.add_style("margin-top: -2px")
            
            top.add_class("spt_uber_notes_top")


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

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

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

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


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

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


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


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

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

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

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


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

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

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

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


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

            inner_div.add("<br/>")
            

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

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

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

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

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

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

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

        top.add(table)


        return super(NoteSheetWdg, self).get_display()
示例#18
0
    def get_display(self):
    
        widget = Widget()
        
        div = DivWdg(css='spt_ui_options')
        div.set_unique_id()
        table = Table()
        div.add(table)
        table.add_style("margin: 5px 15px")
        table.add_color('color','color')

        swap = SwapDisplayWdg()
        #swap.set_off()
        app = WebContainer.get_web().get_selected_app()
        outer_span = SpanWdg()
        outer_span.add_style('float: right')
        span = SpanWdg(app, css='small')
        icon = IconWdg(icon=eval("IconWdg.%s"%app.upper()), width='13px')
        outer_span.add(span)
        outer_span.add(icon)
        
        title = SpanWdg("Loading Options")
        title.add(outer_span)

        SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False)

        widget.add(swap)
        widget.add(title)
        widget.add(div)

        if not self.hide_instantiation:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Instantiation: "))
            table.add_cell(div)
            div = self.get_instantiation_wdg()
            table.add_cell(div)


        setting = self.get_default_setting()
        default_instantiation = setting.get('instantiation')
        default_connection = setting.get('connection')
        default_dependency = setting.get('texture_dependency')

        if not self.hide_connection:
            table.add_row()
            table.add_blank_cell()
            con_div = DivWdg(HtmlElement.b("Connection: "))
            table.add_cell(con_div)
            td = table.add_cell()

            is_unchecked = True
            default_cb = None
            for value in ['http', 'file system']:
                name = self.get_element_name("connection")
                checkbox = CheckboxWdg( name )
                checkbox.set_option("value", value)
                checkbox.set_persistence()
                if value == default_connection:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False
                checkbox.add_behavior({'type': 'click_up', 
                    'propagate_evt': True,
                     "cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" %name}) 
                span = SpanWdg(checkbox, css='small')
                span.add(value)

                td.add(span)
            if is_unchecked:
                default_cb.set_checked()



        if not self.hide_dependencies:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Texture Dependencies: "))
            table.add_cell(div)
            td = table.add_cell()
            
            is_unchecked = True
            default_cb = None
            for value in ['as checked in', 'latest', 'current']:
                name = self.get_element_name("dependency")
                checkbox = CheckboxWdg( name )

                
                checkbox.set_option("value", value)
                checkbox.set_persistence()
                checkbox.add_behavior({'type': 'click_up', 
                    'propagate_evt': True,
                     "cbjs_action": "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" %name}) 
                if value == default_dependency:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False

                span = SpanWdg(checkbox, css='small')
                span.add(value)
                td.add(span)
            if is_unchecked:
                default_cb.set_checked()



        from connection_select_wdg import ConnectionSelectWdg
        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Type: "))
        table.add_cell(div)
        table.add_cell( ConnectionSelectWdg() )

        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Port: "))
        table.add_cell(div)
        port_div = DivWdg()
        port_text = TextWdg("port")
        port_text.set_option('size','6')
        port_div.add(port_text)
        port_div.add_style("padding-left: 7px")
        port_div.add_style("width: 40px")
        table.add_cell( port_div )

        from pyasm.prod.web import WidgetSettings
        value = WidgetSettings.get_value_by_key("CGApp:connection_port")
        if value:
            port_text.set_value(value)
        elif WebContainer.get_web().get_selected_app() == 'Houdini':
            port_text.set_value("13000")
        else:
            port_text.set_value("4444")

        port_text.add_behavior( {
            'type': 'change',
            'cbjs_action': '''
                var value = bvr.src_el.value;
                value = parseInt(value);
                var kwargs = {
                    'data': value,
                    'key': 'CGApp:connection_port'
                }
                var cmd = "pyasm.web.WidgetSettingSaveCbk"
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, kwargs);

                // FIXME: this is dangerous use of a global var
                app.port = value;
            '''
        } )


        return widget
示例#19
0
文件: note_wdg.py 项目: mincau/TACTIC
    def get_viewer(self):
        top = DivWdg(css='spt_note_viewer_top')
            
        # draw checkbox options
        swap = SwapDisplayWdg()
        title = SpanWdg('main context')

        split_div = FloatDivWdg(css='spt_split_cb')
        div = DivWdg(css='spt_main_context_cb')
        content_div = DivWdg()
        content_div.add_color('color','color')
        content_div.add_style('padding: 10px') 
        SwapDisplayWdg.create_swap_title(title, swap, content_div, is_open=False)
        div.add(swap)

        div.add(title)

        checkbox_name = 'split_screen'
        split_cb = CheckboxWdg(checkbox_name, label='Split View')
        split_cb.persistence = True
        split_cb.persistence_obj = split_cb
        key = split_cb.get_key()
      
        #cb.add_style('float: left') 
        split_cb.add_behavior({'type': 'click_up',
        
                'propagate_evt': True,
                'cbjs_action': '''
                    var top = bvr.src_el.getParent(".spt_note_viewer_top");
                    var table_top = top.getElement(".spt_note_viewer_table");

                    var cbs = top.getElement('.spt_main_context_cb');
                    var values = spt.api.Utility.get_input_values(cbs);

                    var processes = values.note_context_cb;
                    var kwargs = { process_names: processes};
                    if (bvr.src_el.checked) {
		        kwargs.split_view = 'true';
			kwargs.show_context = 'true';
                        kwargs.left_process_names = processes;
                        kwargs.right_process_names = processes;
                   
                    }

                    spt.input.save_selected(bvr, '%s','%s');
                    spt.app_busy.show("Note Viewer", 'Loading') ;
                    setTimeout(function(){
                        spt.panel.refresh(table_top, kwargs, false);
                        if (bvr.src_el.checked) 
                            spt.hide(cbs);
                        else 
                            spt.show(cbs);
                        spt.app_busy.hide();
                        }, 50 );
                    
                ''' % ( checkbox_name, key)
                })
       	split_div.add(split_cb)
        
        top.add(split_div)
        top.add(div)
        div.add(content_div)
        top.add(HtmlElement.br())
        
        
        checkbox_name = 'note_main_context_cb'
        cb = CheckboxWdg(checkbox_name)
        cb.persistence = True
        cb.persistence_obj = cb

        self.checked_process_names = cb.get_values()
        
        for value in self.process_names:
            #self.checked_process_names = web.get_form_values('process_names')
            cb = CheckboxWdg(checkbox_name, label=value)
            
            if value in self.checked_process_names:
                self.checked_processes.append(value)
            # FIXME: this is very tenous.  Accessing private members to
            # override behavior
            
            cb.persistence = True
            cb.persistence_obj = cb
            key = cb.get_key()
            cb.set_option('value', value)

            cb.add_behavior({
                'type': 'click_up',
                'propagate_evt': True,
                'cbjs_action': '''
                    var top = bvr.src_el.getParent(".spt_note_viewer_top")
                    var table_top = top.getElement('.spt_note_viewer_table');
                    var cbs = top.getElement('.spt_main_context_cb');
                    var values = spt.api.Utility.get_input_values(cbs);
                   
                    var processes = values.note_main_context_cb;
                    var kwargs = { process_names: processes};
                    spt.input.save_selected(bvr, '%s','%s');
                    spt.panel.refresh(table_top, kwargs, false);
                ''' % (checkbox_name, key)
            }) 
            content_div.add(cb)

        table_top = DivWdg(css='spt_note_viewer_table')
        expression = "@SOBJECT(sthpw/note['context','in','%s'])" %'|'.join(self.checked_processes)

        if split_cb.is_checked():
            table = self.get_split_viewer()
        else:
            table_id = 'main_table1'
        
            table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=self.view,\
                 show_row_select=True, show_insert=False, state={'parent_key': self.parent_key}, inline_search=False, show_refresh=True, expression=expression )
        
        self.set_as_panel(table_top)
        table_top.add_style('float: left')
    
        top.add(table_top)
        table_top.add(table)

        return top
示例#20
0
    def get_file_mode_wdg(self):
        div = DivWdg()
        div.add_style("margin-top: 15px")
        div.add_style("margin-bottom: 15px")
        div.add_class("spt_file_mode")

        # drop folder
        div.add("A writable folder is required.  This is the folder that sync will drop the transacton file into.  This folder should be common to all shares that need to have recieve the transactions.")

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

        # only valid for standalone
        browser = WebContainer.get_web().get_browser()
        if browser == 'Qt':
            button = ActionButtonWdg(title="Browse")
            div.add(button)
            button.add_style("float: right")

            button.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                var applet = spt.Applet.get();
                var files = applet.open_file_browser();
                if (files.length == 0) {
                    return;
                }

                var dir = files[0];
                if (!applet.is_dir(dir)) {
                    spt.alert("Please select a folder");
                    return;
                }
                var top = bvr.src_el.getParent(".spt_file_mode");
                var folder_el = top.getElement(".spt_sync_folder");
                folder_el.value = dir;

                '''
            } )

        div.add("Sync Folder: ")
        text = TextInputWdg(name="sync_folder")
        text.add_class("spt_sync_folder")
        text.add_style("width: 300px")
        div.add(text)

        #div.add("<br/>"*2)
        #div.add("Set whether this transaction is plaintext, zipped or encrypted.")

        div.add("<br/>"*3)
        div.add("The transactions can be encrypted with an encryption ticket.  All shares must set this to be the same value in order for the transaction to be appropriately encrypted and decrypted.")


        div.add("<br/>"*2)
        div.add("Encrypt Transactions? ")
        checkbox = CheckboxWdg("is_encrypted")
        div.add(checkbox)
        checkbox.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_file_mode");
            var el = top.getElement(".spt_encrypt");
            if (el.getStyle("display") == "none") {
                el.setStyle("display", "");
            }
            else {
                el.setStyle("display", "none");
            }
            '''
        } )



        #div.add("Set whether this transaction is plaintext, zipped or encrypted.")
        encrypt_div = DivWdg()
        encrypt_div.add_class("spt_encrypt")
        div.add(encrypt_div)
        encrypt_div.add_style("display: none")
        encrypt_div.add_style("padding: 30px 20px 30px 20px")
        encrypt_div.add("Encryption Key: ")
        text = TextWdg("encrypt_key")
        text.add_style("width: 300px")
        encrypt_div.add(text)

        #div.add(self.get_ticket_wdg())


        return div
示例#21
0
文件: task_wdg.py 项目: mincau/TACTIC
    def get_display(self):
        self.check()
        if self.is_refresh:
            div = Widget()
        else:
            div = DivWdg()
            self.set_as_panel(div)
            div.add_style('padding','6px')
            min_width = '400px'
            div.add_style('min-width', min_width)
            div.add_color('background','background')
            div.add_class('spt_add_task_panel')
            div.add_style("padding: 20px")


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

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

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

        msg_div = DivWdg()
        msg_div.add_style('margin-left: 4px')
        div.add(msg_div, 'info')
        msg_div.add('Total: %s item/s to add tasks to' %len(self.search_key_list))
        div.add(HtmlElement.br())
        hint = HintWdg('Tasks are added according to the assigned pipeline.')
        msg_div.add(" &nbsp; ")
        msg_div.add(hint)
        msg_div.add(HtmlElement.br())
        
        
        option_div = DivWdg(css='spt_ui_options')
        #option_div.add_style('margin-left: 12px')
        
        sel = SelectWdg('pipeline_mode', label='Create tasks by: ')
        sel.set_option('values', ['simple process','context', 'standard'])
        sel.set_option('labels', ['process','context', 'all contexts in process'])
        sel.set_persistence()
        sel.add_behavior({'type':'change',
                 'cbjs_action': 'spt.panel.refresh(bvr.src_el)'}) 
        
        option_div.add(sel)

        value = sel.get_value()
        # default to simple process
        if not value:
            value = 'simple process'
        msg = ''
        if value not in ['simple process','context','standard']:
            value = 'simple process'
        
        if value == 'context':
            msg = 'In context mode, a single task will be created for each selected context.'
        elif value == 'simple process':
            msg = 'In process mode, a single task will be created for each selected process.'

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

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

        title = DivWdg('Assigned Pipelines')
        title.add_style('padding: 6px')
        title.add_color('background','background2')
        title.add_color('color','color', +120)
        div.add(title)
    
        content_div = DivWdg()
        content_div.add_style('min-height', '150px')
        div.add(content_div)
        content_div.add_border()
        
        filtered_search_key_list = []
        for sk in self.search_key_list:
            id = SearchKey.extract_id(sk)
            if id=='-1':
                continue
            filtered_search_key_list.append(sk)

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

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

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

        show_subpipeline = True
        min_height = '150px'



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

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

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

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

                process_label = process.get_label()
                if not process_label:
                    process_label = ''
                if mode =='context':
                    contexts =  pipeline.get_output_contexts(process.get_name())
                    
                    labels = contexts
                    if process.is_from_sub_pipeline():
                        labels = ['%s/%s'%(process.parent_pipeline_code, x) for x in contexts]
                    
                    for x in labels: 
                        process_labels.append(process_label)
                    
                    # prepend process to contexts in this mode to ensure uniqueness
                    contexts = ['%s:%s' %(process_name, x) for x in contexts]
                else:
                    contexts = [process_name]
                    labels = contexts
                
                    process_labels.append(process_label)

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

        skipped = [] 

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


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



        return div
示例#22
0
    def get_format_value(my, value, format):
        if format not in ['Checkbox'] and value == '':
            return ''

        # ------------------------------------------------
        # Integer
        if format == '-1234':
            if not value:
                # Case where value is '', 0, 0.0, -0.0 .
                value = 0
            value = "%0.0f" % my.convert_to_float(value)

        elif format == '-1,234':
            if not value:
                value = 0
            # Group the value into three numbers seperated by a comma.
            value = my.number_format(value, places=0)

        # ------------------------------------------------
        # Float
        elif format == '-1234.12':
            if not value:
                value = 0
            value = "%0.2f" % my.convert_to_float(value)

        elif format == '-1,234.12':
            # break the value up by 3s
            if not value:
                value = 0
            value = my.number_format(value, places=2)

        # ------------------------------------------------
        # Percentage
        elif format == '-13%':
            if not value:
                value = 0
            value = my.convert_to_float(value) * 100
            value = "%0.0f" % my.convert_to_float(value) + "%"

        elif format == '-12.95%':
            if not value:
                value = 0
            value = my.convert_to_float(value) * 100
            value = "%0.2f" % my.convert_to_float(value) + "%"

        # ------------------------------------------------
        # Currency
        elif format == '-$1,234':
            # break the value up by 3s
            if not value:
                value = 0
            value = my.currency_format(value, grouping=True)
            value = value[0:-3]

        elif format == '-$1,234.00':
            if not value:
                value = 0
            value = my.currency_format(value, grouping=True)

        elif format == '-$1,234.--':
            # break the value up by 3s
            if not value:
                value = 0
            value = my.currency_format(value, grouping=True)
            value = value[0:-3] + ".--"

        elif format == '-$1,234.00 CAD':
            # break the value up by 3s
            if not value:
                value = 0
            value = my.currency_format(value, grouping=True, monetary=True)

        # ------------------------------------------------
        # Date
        elif format == '31/12/99':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d/%m/%y")

        elif format == 'December 31, 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%B %d, %Y")

        elif format == '31/12/1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d/%m/%Y")

        elif format == 'Dec 31, 99':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%b %d, %y")

        elif format == 'Dec 31, 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%b %d, %Y")

        elif format == '31 Dec, 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d %b, %Y")

        elif format == '31 December 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d %B %Y")

        elif format == 'Fri, Dec 31, 99':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%a, %b %d, %y")

        elif format == 'Fri 31/Dec 99':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%a %d/%b %y")

        elif format == 'Fri, December 31, 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%a, %B %d, %Y")

        elif format == 'Friday, December 31, 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%A, %B %d, %Y")

        elif format == '12-31':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%m-%d")

        elif format == '99-12-31':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%y-%m-%d")

        elif format == '1999-12-31':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%Y-%m-%d")

        elif format == '12-31-1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%m-%d-%Y")

        elif format == '12/99':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%m-%y")

        elif format == '31/Dec':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d/%b")

        elif format == 'December':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%B")

        elif format == '52':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%U")

        # ------------------------------------------------
        # Time
        elif format == '13:37':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%H:%M")

        elif format == '13:37:46':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%H:%M:%S")

        elif format == '01:37 PM':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%I:%M %p")

        elif format == '01:37:46 PM':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                from pyasm.common import SPTDate
                timezone = my.get_option('timezone')
                if not timezone:
                    pass
                elif timezone == "local":
                    value = SPTDate.convert_to_local(value)
                else:
                    value = SPTDate.convert_to_timezone(value, "EDT")

                value = value.strftime("%I:%M:%S %p")

        elif format == '31/12/99 13:37':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d/%m/%y %H:%M")

        elif format == '31/12/99 13:37:46':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d/%m/%y %H:%M:%S")

        elif format == 'DATETIME':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                setting = ProdSetting.get_value_by_key('DATETIME')
                if not setting:
                    setting = "%Y-%m-%d %H:%M"
                value = value.strftime(setting)

        elif format == 'DATE':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                setting = ProdSetting.get_value_by_key('DATE')
                if not setting:
                    setting = "%Y-%m-%d"
                value = value.strftime(setting)
        # ------------------------------------------------
        # Scientific
        elif format == '-1.23E+03':
            if not value:
                value = ''
            else:
                try:
                    value = "%.2e" % my.convert_to_float(value)
                except:
                    value = "0.00"

        elif format == '-1.234E+03':
            if not value:
                value = ''
            else:
                try:
                    value = "%.2e" % my.convert_to_float(value)
                except:
                    value = "0.00"

        # ------------------------------------------------
        # Boolean
        # false = 0, true = 1
        elif format in ['True|False']:
            if value:
                value = 'True'
            else:
                value = 'False'

        elif format in ['true|false']:
            if value:
                value = 'true'
            else:
                value = 'false'

        elif format == 'Checkbox':

            div = DivWdg()
            div.add_class("spt_boolean_top")
            from pyasm.widget import CheckboxWdg
            checkbox = CheckboxWdg(my.get_name())
            checkbox.set_option("value", "true")
            if value:
                checkbox.set_checked()
            div.add(checkbox)

            div.add_class('spt_format_checkbox_%s' % my.get_name())

            version = my.parent_wdg.get_layout_version()
            if version == "2":
                pass
            else:
                checkbox.add_behavior({
                    'type':
                    'click_up',
                    'propagate_evt':
                    True,
                    'cbjs_action':
                    '''

                var cached_data = {};
                var value_wdg = bvr.src_el;
                var top_el = bvr.src_el.getParent(".spt_boolean_top");
                spt.dg_table.edit.widget = top_el;
                var key_code = spt.kbd.special_keys_map.ENTER;
                spt.dg_table.inline_edit_cell_cbk( value_wdg, cached_data );
                '''
                })

            value = div

        # ------------------------------------------------
        # Timecode
        elif format in [
                'MM:SS.FF', 'MM:SS:FF', 'MM:SS', 'HH:MM:SS.FF', 'HH:MM:SS:FF',
                'HH:MM:SS'
        ]:
            fps = my.get_option('fps')
            if not fps:
                fps = 24
            else:
                fps = int(fps)
            timecode = TimeCode(frames=value, fps=fps)

            value = timecode.get_timecode(format)

        # ------------------------------------------------
        # Text formats
        elif format in ['wiki']:
            pass

        return value
示例#23
0
    def get_display(self):
        self.check()
        if self.is_refresh:
            div = Widget()
        else:
            div = DivWdg()
            self.set_as_panel(div)
            div.add_style('padding', '6px')
            min_width = '400px'
            div.add_style('min-width', min_width)
            div.add_color('background', 'background')
            div.add_class('spt_add_task_panel')
            div.add_style("padding: 20px")

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

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

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

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

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

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

        option_div.add(sel)

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

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

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

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

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

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

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

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

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

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

        show_subpipeline = True
        min_height = '150px'

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

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

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

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

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

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

                    for x in labels:
                        process_labels.append(process_label)

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

                    process_labels.append(process_label)

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

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

        skipped = []

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

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

        return div
示例#24
0
    def get_display(my): 

        top = my.top
        top.add_color("background", "background")
        top.add_color("color", "color")
        top.add_style("padding: 10px")
        top.add_style("min-width: 400px")

        from tactic.ui.app import HelpButtonWdg
        help_wdg = HelpButtonWdg(alias="exporting-csv-data")
        top.add(help_wdg)
        help_wdg.add_style("float: right")
        help_wdg.add_style("margin-top: -3px")
        
        if not my.check(): 
            top.add(DivWdg('Error: %s' %my.error_msg))
            top.add(HtmlElement.br(2))
            return super(CsvExportWdg, my).get_display()

        if my.search_type_list and my.search_type_list[0] != my.search_type:
            st = SearchType.get(my.search_type_list[0])
            title_div =DivWdg('Exporting related items [%s]' % st.get_title())
            top.add(title_div)
            top.add(HtmlElement.br())
            my.search_type = my.search_type_list[0]
            my.view = my.related_view

        if my.mode != 'export_all':
            num = len(my.selected_search_keys)
        else:
            search = Search(my.search_type)
            num = search.get_count()
        msg_div = DivWdg('Total: %s items to export'% num)
        msg_div.add_style("font-size: 12px")
        msg_div.add_style("font-weight: bold")
        msg_div.add_style('margin-left: 4px')
        top.add(msg_div)
        if num > 300:
            msg_div.add_behavior({'type':'load',
            'cbjs_action': "spt.alert('%s items are about to be exported. It may take a while.')" %num})
                
        top.add(HtmlElement.br())

        div  = DivWdg(css='spt_csv_export', id='csv_export_action')
        div.add_color("background", "background", -10)
        div.add_style("padding: 10px")
        div.add_style("margin: 5px")
        
        div.add_styles('max-height: 350px; overflow: auto')
        table = Table( css='minimal')
        table.add_color("color", "color")
        div.add(table)
        table.set_id('csv_export_table')
        table.center()
        
        
        cb_name = 'csv_column_name'
        master_cb = CheckboxWdg('master_control')
        master_cb.set_checked()
        master_cb.add_behavior({'type': 'click_up',
            'propagate_evt': True,
            'cbjs_action': '''
                var inputs = spt.api.Utility.get_inputs(bvr.src_el.getParent('.spt_csv_export'),'%s');
                for (var i = 0; i < inputs.length; i++)
                    inputs[i].checked = !inputs[i].checked;
                    ''' %cb_name})


        span = SpanWdg('Select Columns To Export')
        span.add_style('font-weight','600')
        table.add_row_cell(span)
        table.add_row_cell(HtmlElement.br())

        tr = table.add_row()
        tr.add_style('border-bottom: 1px groove #777')
        td = table.add_cell(master_cb)
        label = HtmlElement.i('toggle all')
        label.add_style('color: #888')
        table.add_cell(label)


        col1 = table.add_col()
        col1.add_style('width: 35px')
        col2 = table.add_col()
        
        if not my.search_type or not my.view:
            return table

        # use overriding element names and derived titles if available
        config = WidgetConfigView.get_by_search_type(my.search_type, my.view)
        if my.element_names and config:
            filtered_columns = my.element_names
            titles = []
            for name in my.element_names:
                title = config.get_element_title(name)
                titles.append(title)

        else:
            
            # excluding FunctionalTableElement
            filtered_columns = []
            titles = []
            if not config:
                columns = search.get_columns()
                filtered_columns = columns
                titles = ['n/a'] * len(filtered_columns)
            else:
                columns = config.get_element_names()
                
                filtered_columns = columns
                titles = config.get_element_titles()

        
            """
            # commented out until it is decided 2.5 widgets will 
            # use this class to differentiate between reg and functional element
            from pyasm.widget import FunctionalTableElement
            for column in columns:
                widget = config.get_display_widget(column)

                if isinstance(widget, FunctionalTableElement):
                    continue
                filtered_columns.append(column)
            """

        for idx, column in enumerate(filtered_columns):
            table.add_row()
            cb = CheckboxWdg(cb_name)
            cb.set_option('value', column)
            cb.set_checked()
            table.add_cell(cb)
            
            
            title = titles[idx]
            table.add_cell('<b>%s</b> (%s) '%(title, column))

        action_div = DivWdg()
        widget = DivWdg()
        table.add_row_cell(widget)
        widget.add_style("margin: 20px 0 10px 0px")
        cb = CheckboxWdg('include_id', label=" Include ID")
        cb.set_default_checked()
        widget.add(cb)
        hint = HintWdg('To update entries with specific ID later, please check this option. For new inserts in this or other table later on, uncheck this option.') 
        widget.add(hint)

        label = string.capwords(my.mode.replace('_', ' '))
        button = ActionButtonWdg(title=label, size='l')
        is_export_all  = my.mode == 'export_all'
        button.add_behavior({
            'type': "click_up",
            'cbfn_action': 'spt.dg_table_action.csv_export',
            'element': 'csv_export',
            'column_names': 'csv_column_name',
            'search_type': my.search_type,
            'view': my.view,
            'search_keys' : my.selected_search_keys,
            'is_export_all' : is_export_all
            
        })

        my.close_action = "var popup = bvr.src_el.getParent('.spt_popup');spt.popup.close(popup)"
        if my.close_action:
            close_button = ActionButtonWdg(title='Close')
            close_button.add_behavior({
                'type': "click",
                'cbjs_action': my.close_action
            })


        table = Table()
        action_div.add(table)
        table.center()
        table.add_row()
        td = table.add_cell(button)
        td.add_style("width: 130px")
        table.add_cell(close_button)

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

        top.add(div)
        top.add(HtmlElement.br())
        top.add(action_div)

        if my.is_test:
            rtn_data = {'columns': my.element_names, 'count': len(my.selected_search_keys)}
            if my.mode == 'export_matched':
                rtn_data['sql'] =  my.table.search_wdg.search.get_statement()
            from pyasm.common import jsondumps
            rtn_data = jsondumps(rtn_data)
            return rtn_data

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

            top.add_class("spt_uber_notes_top")

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

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

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

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

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

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

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

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

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

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

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

        selected_process_names = []
        step = 0

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

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

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

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

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

            inner_div.add(cb)

            inner_div.add("<br/>")

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

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

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

        main_config_view = my._get_main_config(view, selected_process_names)

        sobject_dict = {}

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

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

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

        top.add(table)

        return super(NoteSheetWdg, my).get_display()
示例#26
0
文件: note_wdg.py 项目: mincau/TACTIC
    def get_viewer(self):
        top = DivWdg(css='spt_single_note_viewer_top')
            
        # draw checkbox options
        swap = SwapDisplayWdg()
        title = SpanWdg('context')
        title.add_color('color','color')
        div = DivWdg(css='spt_context_cb')
        div.add_color('color','color')
        SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False)
        
        checkbox_name = 'split_screen'
        checked_process_names = []
        if self.show_context:
            top.add(swap)
            top.add(title)
            top.add(div)
            
            #checkbox_name = 'note_context_cb'
            checkbox_name = self.checkbox_name
            cb = CheckboxWdg(checkbox_name)
            cb.persistence = True
            cb.persistence_obj = cb

            checked_process_names = cb.get_values()
            for value in self.process_names:
                #self.checked_process_names = web.get_form_values('process_names')
                cb = CheckboxWdg(checkbox_name, label=value)
                
                if value in checked_process_names:
                    self.checked_processes.append(value)
                # FIXME: this is very tenous.  Accessing private members to
                # override behavior
                
                cb.persistence = True
                cb.persistence_obj = cb
                key = cb.get_key()
                cb.set_option('value', value)

                cb.add_behavior({
                    'type': 'click_up',
                    'propagate_evt': True,
                    'cbjs_action': '''
                        var top = bvr.src_el.getParent(".spt_single_note_viewer_top")
                        var table_top = top.getElement('.spt_note_viewer_table');
                        var cbs = top.getElement('.spt_context_cb');
                        var values = spt.api.Utility.get_input_values(cbs);
                        var processes = values.%s;
                        var kwargs = { process_names: processes};
                        spt.input.save_selected(bvr, '%s','%s');
                        spt.panel.refresh(table_top, kwargs, false);
                    ''' % (checkbox_name, checkbox_name, key)
                }) 
                div.add(cb)
        else:
            web = WebContainer.get_web()
            checked_process_names = web.get_form_values('process_names')
        table_top = DivWdg(css='spt_note_viewer_table')
        expression = "@SOBJECT(sthpw/note['context','in','%s'])" %'|'.join(checked_process_names)
        table_id = 'main_table1'
    
        table = TableLayoutWdg(table_id=table_id, search_type='sthpw/note', view=self.view,\
             show_row_select=True, show_insert=False, state={'parent_key': self.parent_key}, inline_search=False, show_refresh=True, expression=expression )
	if self.resize:
	    from tactic.ui.container import ResizeScrollWdg
	    inner_wdg = ResizeScrollWdg( width='500px', height='500px', scroll_bar_size_str='thick', scroll_expansion='inside' )
	    inner_wdg.add(table)
            table_top.add(inner_wdg)
	else:
            table_top.add(table)

        self.set_as_panel(table_top)
        top.add(table_top)

        return top
示例#27
0
    def get_format_value(my, value, format):
        if format not in ['Checkbox'] and value == '':
            return ''

        # ------------------------------------------------
        # Integer
        if format == '-1234':
            if not value:
                # Case where value is '', 0, 0.0, -0.0 . 
                value = 0
            value = "%0.0f" % my.convert_to_float(value)

        elif format == '-1,234':
            if not value:
                value = 0
            # Group the value into three numbers seperated by a comma.
            value = my.number_format(value, places=0)

        # ------------------------------------------------
        # Float
        elif format == '-1234.12':
            if not value:
                value = 0
            value = "%0.2f" % my.convert_to_float(value)

        elif format == '-1,234.12':
            # break the value up by 3s
            if not value:
                value = 0
            value = my.number_format(value, places=2)

        # ------------------------------------------------
        # Percentage
        elif format == '-13%':
            if not value:
                value = 0
            value = my.convert_to_float(value) * 100
            value = "%0.0f" % my.convert_to_float(value) + "%"

        elif format == '-12.95%':
            if not value:
                value = 0
            value = my.convert_to_float(value) * 100
            value = "%0.2f" % my.convert_to_float(value) + "%"

        # ------------------------------------------------
        # Currency
        elif format == '-$1,234':
            # break the value up by 3s
            if not value:
                value = 0
            value = my.currency_format(value, grouping=True)
            value = value[0:-3]

        elif format == '-$1,234.00':
            if not value:
                value = 0
            value = my.currency_format(value, grouping=True)

        elif format == '-$1,234.--':
            # break the value up by 3s
            if not value:
                value = 0
            value = my.currency_format(value, grouping=True)
            value = value[0:-3] + ".--"

        elif format == '-$1,234.00 CAD':
            # break the value up by 3s
            if not value:
                value = 0
            value = my.currency_format(value, grouping=True, monetary=True)

        elif format == '($1,234.00)':
            # break the value up by 3s
            if not value or value == "0":
                value = " "
            else:
                value = my.currency_format(value, grouping=True)
                if value.startswith("-"):
                    value = "<span style='color: #F00'>(%s)</span>" % value.replace("-", "")


        # ------------------------------------------------
        # Date
        elif format == '31/12/99':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d/%m/%y")

        elif format == 'December 31, 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%B %d, %Y")

        elif format == '31/12/1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d/%m/%Y")

        elif format == 'Dec 31, 99':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%b %d, %y")

        elif format == 'Dec 31, 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%b %d, %Y")

        elif format == '31 Dec, 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d %b, %Y")

        elif format == '31 December 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d %B %Y")

        elif format == 'Fri, Dec 31, 99':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%a, %b %d, %y")

        elif format == 'Fri 31/Dec 99':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%a %d/%b %y")

        elif format == 'Fri, December 31, 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%a, %B %d, %Y")

        elif format == 'Friday, December 31, 1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%A, %B %d, %Y")

        elif format == '12-31':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%m-%d")

        elif format == '99-12-31':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%y-%m-%d")

        elif format == '1999-12-31':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%Y-%m-%d")

        elif format == '12-31-1999':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%m-%d-%Y")

        elif format == '12/99':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%m-%y")

        elif format == '31/Dec':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d/%b")

        elif format == 'December':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%B")

        elif format == '52':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%U")

        # ------------------------------------------------
        # Time
        elif format == '13:37':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%H:%M")

        elif format == '13:37:46':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%H:%M:%S")

        elif format == '01:37 PM':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%I:%M %p")

        elif format == '01:37:46 PM':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                from pyasm.common import SPTDate
                timezone = my.get_option('timezone')
                if not timezone:
                    pass
                elif timezone == "local":
                    value = SPTDate.convert_to_local(value)
                else:
                    value = SPTDate.convert_to_timezone(value, "EDT")

                value = value.strftime("%I:%M:%S %p")

        elif format == '31/12/99 13:37':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d/%m/%y %H:%M")

        elif format == '31/12/99 13:37:46':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                value = value.strftime("%d/%m/%y %H:%M:%S")

        elif format == 'DATETIME':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                setting = ProdSetting.get_value_by_key('DATETIME')
                if not setting:
                    setting = "%Y-%m-%d %H:%M"
                value = value.strftime(setting)

        elif format == 'DATE':
            if not value:
                value = ''
            else:
                value = parser.parse(value)
                setting = ProdSetting.get_value_by_key('DATE')
                if not setting:
                    setting = "%Y-%m-%d"
                value = value.strftime(setting)
        # ------------------------------------------------
        # Scientific
        elif format == '-1.23E+03':
            if not value:
                value = ''
            else:
                try:
                    value = "%.2e" % my.convert_to_float(value)
                except:
                    value = "0.00"

        elif format == '-1.234E+03':
            if not value:
                value = ''
            else:
                try:
                    value = "%.2e" % my.convert_to_float(value)
                except:
                    value = "0.00"

        # ------------------------------------------------
        # Boolean
        # false = 0, true = 1
        elif format in ['True|False']:
            if value:
                value = 'True'
            else: 
                value = 'False'

        elif format in ['true|false']:
            if value:
                value = 'true'
            else: 
                value = 'false'

        elif format == 'Checkbox':

            div = DivWdg()
            div.add_class("spt_boolean_top")
            from pyasm.widget import CheckboxWdg
            checkbox = CheckboxWdg(my.get_name())
            checkbox.set_option("value", "true")
            if value:
                checkbox.set_checked()
            div.add(checkbox)

            div.add_class('spt_format_checkbox_%s' % my.get_name())

            version = my.parent_wdg.get_layout_version()
            if version == "2":
                pass
            else:
                checkbox.add_behavior( {
                'type': 'click_up',
                'propagate_evt': True,
                'cbjs_action': '''

                var cached_data = {};
                var value_wdg = bvr.src_el;
                var top_el = bvr.src_el.getParent(".spt_boolean_top");
                spt.dg_table.edit.widget = top_el;
                var key_code = spt.kbd.special_keys_map.ENTER;
                spt.dg_table.inline_edit_cell_cbk( value_wdg, cached_data );
                '''
                } )

            value = div


        # ------------------------------------------------
        # Timecode
        elif format in ['MM:SS.FF','MM:SS:FF', 'MM:SS', 'HH:MM:SS.FF', 'HH:MM:SS:FF', 'HH:MM:SS']:
            fps = my.get_option('fps')
            if not fps:
                fps = 24
            else:
                fps = int(fps)
            timecode = TimeCode(frames=value, fps=fps)

            value = timecode.get_timecode(format)


        # ------------------------------------------------
        # Text formats
        elif format in ['wiki']:
            pass

       
        return value
示例#28
0
    def get_display(my):

        widget = Widget()

        div = DivWdg(css='spt_ui_options')
        div.set_unique_id()
        table = Table()
        div.add(table)
        table.add_style("margin: 5px 15px")
        table.add_color('color', 'color')

        swap = SwapDisplayWdg()
        #swap.set_off()
        app = WebContainer.get_web().get_selected_app()
        outer_span = SpanWdg()
        outer_span.add_style('float: right')
        span = SpanWdg(app, css='small')
        icon = IconWdg(icon=eval("IconWdg.%s" % app.upper()), width='13px')
        outer_span.add(span)
        outer_span.add(icon)

        title = SpanWdg("Loading Options")
        title.add(outer_span)

        SwapDisplayWdg.create_swap_title(title, swap, div, is_open=False)

        widget.add(swap)
        widget.add(title)
        widget.add(div)

        if not my.hide_instantiation:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Instantiation: "))
            table.add_cell(div)
            div = my.get_instantiation_wdg()
            table.add_cell(div)

        setting = my.get_default_setting()
        default_instantiation = setting.get('instantiation')
        default_connection = setting.get('connection')
        default_dependency = setting.get('texture_dependency')

        if not my.hide_connection:
            table.add_row()
            table.add_blank_cell()
            con_div = DivWdg(HtmlElement.b("Connection: "))
            table.add_cell(con_div)
            td = table.add_cell()

            is_unchecked = True
            default_cb = None
            for value in ['http', 'file system']:
                name = my.get_element_name("connection")
                checkbox = CheckboxWdg(name)
                checkbox.set_option("value", value)
                checkbox.set_persistence()
                if value == default_connection:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False
                checkbox.add_behavior({
                    'type':
                    'click_up',
                    'propagate_evt':
                    True,
                    "cbjs_action":
                    "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name
                })
                span = SpanWdg(checkbox, css='small')
                span.add(value)

                td.add(span)
            if is_unchecked:
                default_cb.set_checked()

        if not my.hide_dependencies:
            table.add_row()
            table.add_blank_cell()
            div = DivWdg(HtmlElement.b("Texture Dependencies: "))
            table.add_cell(div)
            td = table.add_cell()

            is_unchecked = True
            default_cb = None
            for value in ['as checked in', 'latest', 'current']:
                name = my.get_element_name("dependency")
                checkbox = CheckboxWdg(name)

                checkbox.set_option("value", value)
                checkbox.set_persistence()
                checkbox.add_behavior({
                    'type':
                    'click_up',
                    'propagate_evt':
                    True,
                    "cbjs_action":
                    "spt.toggle_checkbox(bvr, '.spt_ui_options', '%s')" % name
                })
                if value == default_dependency:
                    default_cb = checkbox
                if checkbox.is_checked():
                    is_unchecked = False

                span = SpanWdg(checkbox, css='small')
                span.add(value)
                td.add(span)
            if is_unchecked:
                default_cb.set_checked()

        from connection_select_wdg import ConnectionSelectWdg
        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Type: "))
        table.add_cell(div)
        table.add_cell(ConnectionSelectWdg())

        table.add_row()
        table.add_blank_cell()
        div = DivWdg(HtmlElement.b("Connection Port: "))
        table.add_cell(div)
        port_div = DivWdg()
        port_text = TextWdg("port")
        port_text.set_option('size', '6')
        port_div.add(port_text)
        port_div.add_style("padding-left: 7px")
        port_div.add_style("width: 40px")
        table.add_cell(port_div)

        from pyasm.prod.web import WidgetSettings
        value = WidgetSettings.get_value_by_key("CGApp:connection_port")
        if value:
            port_text.set_value(value)
        elif WebContainer.get_web().get_selected_app() == 'Houdini':
            port_text.set_value("13000")
        else:
            port_text.set_value("4444")

        port_text.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
                var value = bvr.src_el.value;
                value = parseInt(value);
                var kwargs = {
                    'data': value,
                    'key': 'CGApp:connection_port'
                }
                var cmd = "pyasm.web.WidgetSettingSaveCbk"
                var server = TacticServerStub.get();
                server.execute_cmd(cmd, kwargs);

                // FIXME: this is dangerous use of a global var
                app.port = value;
            '''
        })

        return widget
示例#29
0
    def get_file_mode_wdg(my):
        div = DivWdg()
        div.add_style("margin-top: 15px")
        div.add_style("margin-bottom: 15px")
        div.add_class("spt_file_mode")

        # drop folder
        div.add(
            "A writable folder is required.  This is the folder that sync will drop the transacton file into.  This folder should be common to all shares that need to have recieve the transactions."
        )

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

        # only valid for standalone
        browser = WebContainer.get_web().get_browser()
        if browser == 'Qt':
            button = ActionButtonWdg(title="Browse")
            div.add(button)
            button.add_style("float: right")

            button.add_behavior({
                'type':
                'click_up',
                'cbjs_action':
                '''
                var applet = spt.Applet.get();
                var files = applet.open_file_browser();
                if (files.length == 0) {
                    return;
                }

                var dir = files[0];
                if (!applet.is_dir(dir)) {
                    spt.alert("Please select a folder");
                    return;
                }
                var top = bvr.src_el.getParent(".spt_file_mode");
                var folder_el = top.getElement(".spt_sync_folder");
                folder_el.value = dir;

                '''
            })

        div.add("Sync Folder: ")
        text = TextInputWdg(name="sync_folder")
        text.add_class("spt_sync_folder")
        text.add_style("width: 300px")
        div.add(text)

        #div.add("<br/>"*2)
        #div.add("Set whether this transaction is plaintext, zipped or encrypted.")

        div.add("<br/>" * 3)
        div.add(
            "The transactions can be encrypted with an encryption ticket.  All shares must set this to be the same value in order for the transaction to be appropriately encrypted and decrypted."
        )

        div.add("<br/>" * 2)
        div.add("Encrypt Transactions? ")
        checkbox = CheckboxWdg("is_encrypted")
        div.add(checkbox)
        checkbox.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_file_mode");
            var el = top.getElement(".spt_encrypt");
            if (el.getStyle("display") == "none") {
                el.setStyle("display", "");
            }
            else {
                el.setStyle("display", "none");
            }
            '''
        })

        #div.add("Set whether this transaction is plaintext, zipped or encrypted.")
        encrypt_div = DivWdg()
        encrypt_div.add_class("spt_encrypt")
        div.add(encrypt_div)
        encrypt_div.add_style("display: none")
        encrypt_div.add_style("padding: 30px 20px 30px 20px")
        encrypt_div.add("Encryption Key: ")
        text = TextWdg("encrypt_key")
        text.add_style("width: 300px")
        encrypt_div.add(text)

        #div.add(my.get_ticket_wdg())

        return div
示例#30
0
    def get_display(my):
        my.init_kwargs()
        sobject = my.get_current_sobject()

        table = Table(css='minimal')
        table.add_color("color", "color")
        table.add_style("font-size: 0.9em")

        snapshots = my.get_snapshot(my.mode)
        for snapshot in snapshots:
            table.add_row()

            value = my.get_input_value(sobject, snapshot)

            current_version = snapshot.get_value("version")
            current_context = snapshot.get_value("context")
            current_revision = snapshot.get_value("revision",
                                                  no_exception=True)
            current_snapshot_type = snapshot.get_value("snapshot_type")

            # hack hard coded type translation
            if current_snapshot_type == "anim_export":
                current_snapshot_type = "anim"

            # ignore icon context completely
            if current_context == "icon":
                table.add_blank_cell()
                table.add_cell("(---)")
                return table

            checkbox = CheckboxWdg('%s_%s' % (my.search_type, my.CB_NAME))

            # this is added back in for now to work with 3.7 Fast table
            checkbox.add_behavior({'type': 'click_up', 'propagate_evt': True})

            checkbox.add_class('spt_latest_%s' % my.mode)
            checkbox.set_option("value", value)
            table.add_cell(checkbox)

            load_all = False
            if load_all:
                checkbox.set_checked()

            # add the file type icon
            xml = snapshot.get_snapshot_xml()
            file_name = xml.get_value("snapshot/file/@name")
            icon_link = ThumbWdg.find_icon_link(file_name)
            image = HtmlElement.img(icon_link)
            image.add_style("width: 15px")
            table.add_cell(image)

            namespace = my.get_namespace(sobject, snapshot)
            asset_code = my.get_asset_code()

            # force asset mode = True
            my.session.set_asset_mode(asset_mode=my.get_session_asset_mode())
            node_name = my.get_node_name(snapshot, asset_code, namespace)
            # get session info
            session_context = session_version = session_revision = None
            if my.session:

                session_context = my.session.get_context(
                    node_name, asset_code, current_snapshot_type)
                session_version = my.session.get_version(
                    node_name, asset_code, current_snapshot_type)
                session_revision = my.session.get_revision(
                    node_name, asset_code, current_snapshot_type)

                # Maya Specific: try with namespace in front of it for referencing
                referenced_name = '%s:%s' % (namespace, node_name)
                if not session_context or not session_version:
                    session_context = my.session.get_context(
                        referenced_name, asset_code, current_snapshot_type)
                    session_version = my.session.get_version(
                        referenced_name, asset_code, current_snapshot_type)
                    session_revision = my.session.get_revision(
                        referenced_name, asset_code, current_snapshot_type)

            from version_wdg import CurrentVersionContextWdg, SubRefWdg

            version_wdg = CurrentVersionContextWdg()
            data = {'session_version': session_version, \
                'session_context': session_context,  \
                'session_revision': session_revision,  \
                'current_context': current_context, \
                'current_version': current_version, \
                'current_revision': current_revision }
            version_wdg.set_options(data)

            table.add_cell(version_wdg, "no_wrap")
            td = table.add_cell(HtmlElement.b("(%s)" % current_context))
            td.add_tip("Snapshot code: %s" % snapshot.get_code())
            #table.add_cell(snapshot.get_code() )

            #if snapshot.is_current():
            #    current = IconWdg("current", IconWdg.CURRENT)
            #    table.add_cell(current)
            #else:
            #    table.add_blank_cell()

            # handle subreferences
            has_subreferences = True
            xml = snapshot.get_xml_value("snapshot")
            refs = xml.get_nodes("snapshot/file/ref")
            if my.mode == "output" and refs:
                table.add_row()
                td = table.add_cell()
                swap = SwapDisplayWdg.get_triangle_wdg()
                td.add(swap)
                td.add("[ %s reference(s)" % len(refs))
                #td.add_style("text-align: right")

                sub_ref_wdg = SubRefWdg()
                sub_ref_wdg.set_info(snapshot, my.session, namespace)
                swap.add_action_script(
                    sub_ref_wdg.get_on_script(),
                    "toggle_display('%s')" % sub_ref_wdg.get_top_id())

                status = sub_ref_wdg.get_overall_status()
                td.add(SpanWdg(VersionWdg.get(status), css='small_left'))
                td.add(']')

                td.add(sub_ref_wdg)
                td.add_style('padding-left: 10px')

        #else:
        if not snapshots:
            table.add_row()
            table.add_blank_cell()
            table.add_cell("(---)")

        return table
示例#31
0
    def get_display(my):

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


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



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


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

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

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

            '''
        } )

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

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


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



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



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



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



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

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


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



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

            table.add_cell(title)

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



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



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

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

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

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


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

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

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

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

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


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

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

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

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

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

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

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

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


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

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

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

                '''
            } )
            """





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

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

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

                '''
            } )



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

                '''
            } )





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

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




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


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

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






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

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


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

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


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

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





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

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


                '''
            } )


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


        columns_wdg = DivWdg()
        top.add(columns_wdg)


        return top
示例#32
0
    def get_first_row_wdg(my):

        # read the csv file
        #my.file_path = ""

        div = DivWdg(id='csv_import_main')
        div.add_class('spt_panel')
        
        div.add( my.get_upload_wdg() )
        if not my.search_type:
            return div

        if not my.file_path:
            return div


        if not my.file_path.endswith(".csv"):
            div.add('<br/>')
            div.add( "Uploaded file [%s] is not a csv file. Refreshing in 3 seconds. . ."% os.path.basename(my.file_path))
            div.add_behavior( {'type': 'load', \
                                  'cbjs_action': "setTimeout(function() {spt.panel.load('csv_import_main','%s', {}, {\
                                    'search_type_filter': '%s'});}, 3000);" %(Common.get_full_class_name(my), my.search_type) } )
            return div

        if not os.path.exists(my.file_path):
            raise TacticException("Path '%s' does not exist" % my.file_path)

        
        div.add(HtmlElement.br(2))



        # NOT NEEDED:  clear the widget settings before drawing
        #expr = "@SOBJECT(sthpw/wdg_settings['key','EQ','pyasm.widget.input_wdg.CheckboxWdg|column_enabled_']['login','$LOGIN']['project_code','$PROJECT'])"
        #sobjs = Search.eval(expr)
        #for sobj in sobjs:
        #    sobj.delete(log=False)


        div.add( HtmlElement.b("The following is taken from the first line in the uploaded csv file.  Select the appropriate column to match.") )
        div.add(HtmlElement.br())
        """
        text =  HtmlElement.b("Make sure you have all the required columns** in the csv.")
        text.add_style('text-align: left')
        div.add(text)
        """
        div.add(HtmlElement.br(2))
        option_div_top = DivWdg()
        option_div_top.add_color('color','color')
        option_div_top.add_color('background','background', -5)
        option_div_top.add_style("padding: 10px")
        option_div_top.add_border()
        option_div_top.add_style("width: 300px")

        swap = SwapDisplayWdg(title="Parsing Options")
        option_div_top.add(swap)

        option_div_top.add_style("margin-right: 30px")

        my.search_type_obj = SearchType.get(my.search_type)

        option_div = DivWdg()
        swap.set_content_id(option_div.set_unique_id() )
        option_div.add_style("display: none")
        option_div.add_style('margin-left: 14px')
        option_div.add_style('margin-top: 10px')
        option_div.add_style("font-weight: bold")
        option_div_top.add(option_div)

        # first row and second row
        #option_div.add( HtmlElement.br() )
        option_div.add(SpanWdg("Use Title Row: ", css='small'))
        title_row_checkbox = CheckboxWdg("has_title")
        title_row_checkbox.set_default_checked()

        title_row_checkbox.add_behavior({'type' : 'click_up',
                    'propagate_evt': 'true',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(title_row_checkbox)
        option_div.add( HintWdg("Set this to use the first row as a title row to match up columns in the database") )
        

        option_div.add( HtmlElement.br(2) )
        option_div.add(SpanWdg("Use Lowercase Title: ", css='small'))
        lower_title_checkbox = CheckboxWdg("lowercase_title")

        lower_title_checkbox.add_behavior({'type' : 'click_up',
                    'propagate_evt': 'true',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(lower_title_checkbox)
        option_div.add( HtmlElement.br(2) )

        option_div.add(SpanWdg("Sample Data Row: ", css='small'))
        data_row_text = SelectWdg("data_row")
        data_row_text.set_option('values', '1|2|3|4|5')
        data_row_text.set_value('1')
        data_row_text.add_behavior({'type' : 'change',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(data_row_text)
        option_div.add( HintWdg("Set this as a sample data row for display here") )

        option_div.add( HtmlElement.br(2) )
      
        # encoder
        option_div.add(SpanWdg("Encoder: ", css='small'))
        select_wdg = SelectWdg('encoder')
        select_wdg.set_option('values', ['','utf-8', 'iso_8859-1']) 
        select_wdg.set_option('labels', ['ASCII (default)','UTF-8','Excel ISO 8859-1']) 
        select_wdg.add_behavior({'type' : 'change',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(select_wdg)
        option_div.add( HtmlElement.br(2) )


        option_div.add(SpanWdg("Identifying Column: ", css='small'))
        select_wdg = SelectWdg('id_col')
        select_wdg.set_option('empty','true')
        #columns = my.search_type_obj.get_columns()
        columns = SearchType.get_columns(my.search_type)
        
        # make sure it starts off with id, code where applicable
        if 'code' in columns:
            columns.remove('code')
            columns.insert(0, 'code')
        if 'id' in columns:
            columns.remove('id')
            columns.insert(0, 'id')

        select_wdg.set_option('values', columns) 
        option_div.add(select_wdg)
        option_div.add( HintWdg("Set which column to use for identifying an item to update during CSV Import") )
        option_div.add( HtmlElement.br(2) )

        
        # triggers mode
        option_div.add(SpanWdg("Triggers: ", css='small'))
        select_wdg = SelectWdg('triggers_mode')
        select_wdg.set_option('values', ['','False', 'True', 'none']) 
        select_wdg.set_option('labels', ['- Select -','Internal Triggers Only','All Triggers','No Triggers']) 
        select_wdg.add_behavior({'type' : 'change',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(select_wdg)
        option_div.add( HtmlElement.br(2) )

        div.add(option_div_top)

        my.has_title = title_row_checkbox.is_checked()
        
        
        # need to somehow specify defaults for columns
        div.add(my.get_preview_wdg())


        return div