Ejemplo n.º 1
0
    def get_display(my):
        widget = DivWdg(id='link_view_select')
        widget.add_class("link_view_select")
        if my.refresh:
            widget = Widget()
        else:
            my.set_as_panel(widget)
        
        views = []
        if my.search_type:
            from pyasm.search import WidgetDbConfig
            search = Search( WidgetDbConfig.SEARCH_TYPE )
            search.add_filter("search_type", my.search_type)
            search.add_regex_filter("view", "link_search:|saved_search:", op="NEQI")
            search.add_order_by('view')
            widget_dbs = search.get_sobjects()
            views = SObject.get_values(widget_dbs, 'view')
        
        labels = [view for view in views]

        views.insert(0, 'table')
        labels.insert(0, 'table (Default)')
        st_select = SelectWdg('new_link_view', label='View: ')
        st_select.set_option('values', views)
        st_select.set_option('labels', labels)
        widget.add(st_select)
        return widget
Ejemplo n.º 2
0
    def get_sync_mode_wdg(self):

        div = DivWdg()
        div.add_class("spt_sync_mode")

        div.add("Share Mode: ")
        select = SelectWdg("sync_mode")
        div.add(select)
        select.set_option("values", "file|xmlrpc")

        select.add_behavior( {
            'type': 'change',
            'cbjs_action': '''
            var top = bvr.src_el.getParent(".spt_sync_mode");
            var value = bvr.src_el.value;
            var xmlrpc_el = top.getElement(".spt_xmlrpc_mode");
            var file_el = top.getElement(".spt_file_mode");

            if (value == 'xmlrpc') {
                spt.show(xmlrpc_el);
                spt.hide(file_el);
            }
            else {
                spt.hide(xmlrpc_el);
                spt.show(file_el);
            }
            '''
        } )

        div.add( self.get_xmlrpc_mode_wdg() )
        div.add( self.get_file_mode_wdg() )

        return div
    def get_display(self):
        outer_div = DivWdg()
        outer_div.set_id('new-department-request-entry-form')

        page_label = "<div>Fill out the following form to submit a new request. The request will be added to the " \
                     "department's list, and will be addressed as soon as possible. You will receive a " \
                     "notification when the request is complete.</div><br/>"
        outer_div.add(page_label)

        outer_div.add(get_label_widget('Name'))
        outer_div.add(get_text_input_wdg('name', 800))

        outer_div.add(get_label_widget('Description'))
        outer_div.add(
            obu.get_text_area_input_wdg('description', 800,
                                        [('display', 'block')]))

        outer_div.add(get_label_widget('Due Date'))
        outer_div.add(get_datetime_calendar_wdg())

        department_select_wdg = SelectWdg('department_select')
        department_select_wdg.append_option('Onboarding', 'onboarding')
        department_select_wdg.append_option('Edel', 'edel')
        department_select_wdg.append_option('Compression', 'compression')
        department_select_wdg.append_option('QC', 'qc')

        outer_div.add(get_label_widget('Department'))
        outer_div.add(department_select_wdg)

        self.get_submit_widget(outer_div)

        return outer_div
    def get_display(self):
        div_wdg = DivWdg()

        current_code_div = DivWdg()
        component_code = self.file_flow_sobject.get('component_code')

        component_sobject = get_sobject_by_code('twog/component',
                                                component_code)
        current_code_div.add('Current Component set to {0} ({1})'.format(
            component_sobject.get('name'), component_code))

        order_sobject = get_order_sobject_from_component_sobject(
            component_sobject)
        component_sobjects_for_order = get_component_sobjects_from_order_code(
            order_sobject.get_code())

        component_select_wdg = SelectWdg()
        component_select_wdg.set_id('component_select')
        component_select_wdg.add_style('width: 165px;')
        component_select_wdg.add_empty_option()

        for component in component_sobjects_for_order:
            component_select_wdg.append_option(component.get('name'),
                                               component.get_code())

        div_wdg.add(current_code_div)
        div_wdg.add(component_select_wdg)

        return div_wdg
    def get_display(self):
        div_wdg = DivWdg()

        current_code_div = DivWdg()
        component_code = self.file_flow_sobject.get('component_code')

        component_sobject = get_sobject_by_code('twog/component', component_code)
        current_code_div.add('Current Component set to {0} ({1})'.format(component_sobject.get('name'),
                                                                         component_code))

        order_sobject = get_order_sobject_from_component_sobject(component_sobject)
        component_sobjects_for_order = get_component_sobjects_from_order_code(order_sobject.get_code())

        component_select_wdg = SelectWdg()
        component_select_wdg.set_id('component_select')
        component_select_wdg.add_style('width: 165px;')
        component_select_wdg.add_empty_option()

        for component in component_sobjects_for_order:
            component_select_wdg.append_option(component.get('name'), component.get_code())

        div_wdg.add(current_code_div)
        div_wdg.add(component_select_wdg)

        return div_wdg
    def get_display(self):
        outer_div = DivWdg()
        outer_div.set_id('new-department-request-entry-form')

        page_label = "<div>Fill out the following form to submit a new request. The request will be added to the " \
                     "department's list, and will be addressed as soon as possible. You will receive a " \
                     "notification when the request is complete.</div><br/>"
        outer_div.add(page_label)

        outer_div.add(get_label_widget('Name'))
        outer_div.add(get_text_input_wdg('name', 800))

        outer_div.add(get_label_widget('Description'))
        outer_div.add(obu.get_text_area_input_wdg('description', 800, [('display', 'block')]))

        outer_div.add(get_label_widget('Due Date'))
        outer_div.add(get_datetime_calendar_wdg())

        department_select_wdg = SelectWdg('department_select')
        department_select_wdg.append_option('Onboarding', 'onboarding')
        department_select_wdg.append_option('Edel', 'edel')
        department_select_wdg.append_option('Compression', 'compression')
        department_select_wdg.append_option('QC', 'qc')

        outer_div.add(get_label_widget('Department'))
        outer_div.add(department_select_wdg)

        self.get_submit_widget(outer_div)

        return outer_div
def get_file_in_package_status_select():
    task_status_select = SelectWdg('file_status_select')
    task_status_select.set_id('file_status_select')
    task_status_select.add_style('width: 165px;')
    task_status_select.add_empty_option()

    pipeline = Pipeline.get_by_code('twog_Delivery')

    for status in pipeline.get_process_names():
        task_status_select.append_option(status, status)

    return task_status_select
Ejemplo n.º 8
0
def get_title_select_wdg(width=300):
    title_select_wdg = SelectWdg('title_code')
    title_select_wdg.set_id('title_code')
    title_select_wdg.add_style('width', '{0}px'.format(width))
    title_select_wdg.add_empty_option()

    title_search = Search('twog/title')
    titles = title_search.get_sobjects()

    for title in titles:
        title_select_wdg.append_option(title.get_value('name'),
                                       title.get_code())

    return title_select_wdg
Ejemplo n.º 9
0
    def get_security_wdg(my):

        div = DivWdg()
        div.add_class("spt_security")

        div.add(
            "A server can sync either be scoped for a single project or all projects.  Transactions that occur in the admin project never get synced."
        )

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

        div.add("Project: ")

        search = Search("sthpw/project")
        search.add_filters("code", ['admin', 'unittest'], op='not in')
        search.add_order_by("title")
        projects = search.get_sobjects()

        select = SelectWdg("projects")
        div.add(select)
        labels = [x.get_value("title") for x in projects]
        values = [x.get_value("code") for x in projects]

        project_code = Project.get_project_code()
        if project_code != 'admin':
            select.set_value(project_code)
        select.set_option("labels", labels)
        select.set_option("values", values)
        select.add_empty_option("-- All --")

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

        return div
Ejemplo n.º 10
0
    def get_display(my):

        widget = Widget()

        div = DivWdg(css="filter_box")

        show_span = SpanWdg(css="med")
        show_span.add("Show All Types: ")
        checkbox = FilterCheckboxWdg("show_all_types")
        checkbox.set_persistence()
        show_span.add(checkbox)
        show_all_types = checkbox.get_value()
        div.add(show_span)

        span = SpanWdg(css="med")
        span.add("Search Type: ")

        select = SelectWdg("filter|search_type")
        select.add_empty_option("-- Select --")
        project = Project.get()
        project_type = project.get_base_type()
        search = Search("sthpw/search_object")
        if show_all_types:
            search.add_where(
                """
            namespace = '%s' or namespace = '%s' or search_type in ('sthpw/task')
            """
                % (project_type, project.get_code())
            )
        else:
            # show only the custom ones
            search.add_filter("namespace", project.get_code())

        search.add_order_by("title")
        sobjects = search.get_sobjects()

        select.set_sobjects_for_options(sobjects, "search_type", "title")
        # select.set_option("query", "sthpw/search_object|search_type|title")
        select.set_persistence()
        select.add_event("onchange", "document.form.submit()")
        search_type = select.get_value()
        span.add(select)
        div.add(span)

        # make sure the current selection exists
        try:
            SearchType.get(search_type)
        except SearchException, e:
            return div
Ejemplo n.º 11
0
def get_language_select_wdg():
    language_select_wdg = SelectWdg('language_code')
    language_select_wdg.set_id('language_code')
    language_select_wdg.add_style('display', 'inline-block')
    language_select_wdg.add_empty_option()

    language_search = Search('twog/language')
    languages = language_search.get_sobjects()

    languages = sorted(languages, key=lambda x: x.get_value('name'))

    for language in languages:
        language_select_wdg.append_option(language.get_value('name'),
                                          language.get_code())

    return language_select_wdg
Ejemplo n.º 12
0
    def get_display(my):
        sobject = my.get_current_sobject()
        key = sobject.get_value("key")
        options = sobject.get_value("options")
        type = sobject.get_value("type")

        # get the value of the users preferences
        search = Search("sthpw/pref_setting")
        search.add_user_filter()
        search.add_filter("key", key)
        pref_setting = search.get_sobject()
        if pref_setting:
            value = pref_setting.get_value("value")
        else:
            value = ""

        div = DivWdg()

        element_name = "%s_%s" % (my.get_name(), sobject.get_id())

        script = '''var server = TacticServerStub.get();
                var value = bvr.src_el.value;
                if (!value) return;

                spt.app_busy.show("Saving", "Saving Preference for [%s]");

                setTimeout( function() {
                    try{
                        server.execute_cmd('tactic.ui.table.SetPreferenceCmd', {key: '%s', value: value});
                    }catch(e){
                        spt.alert(spt.exception.handler(e));
                    }
                        
                    spt.app_busy.hide() 
                        
                    }, 200);''' % (key, key)

        if key in ['skin', 'palette', 'js_logging_level']:
            script = '''%s; spt.app_busy.show('Reloading Page ...'); setTimeout('spt.refresh_page()', 200);''' % script

        if type == "sequence":
            from pyasm.prod.web import SelectWdg
            select = SelectWdg(element_name)
            select.add_behavior({'type': "change", 'cbjs_action': script})

            select.set_option("values", options)
            if value:
                select.set_value(value)
            div.add(select)
        else:
            text = TextWdg(element_name)
            text.add_behavior({'type': "blur", 'cbjs_action': script})
            if value:
                text.set_value(value)
            div.add(text)

        return div
Ejemplo n.º 13
0
    def get_display(my):

        state = my.get_state()
        search_type = state.get("search_type")
        sobj = my.get_current_sobject()

        if search_type:
            st = search_type
        else:

            st = sobj.get_base_search_type()
        # for inline insert, this should proceed
        #if not sobj:
        #    return ''

        st_suffix = st.split('/', 1)

        if len(st_suffix) == 2:
            st_suffix = st_suffix[1]

        search = Search('sthpw/pipeline')
        search.add_op_filters([('search_type', 'EQ', '/%s' % st_suffix)])

        # takes into account site-wide pipeline
        search.add_project_filter(show_unset=True)
        sobjects = search.get_sobjects()

        codes = [x.get_code() for x in sobjects]
        select = SelectWdg(my.get_input_name())
        select.add_empty_option("-- Default --")
        select.set_option("values", codes)
        if sobj:
            value = sobj.get_value(my.get_name())
            if value:
                select.set_value(value)

        else:
            # only for inline
            behavior = {
                'type':
                'click',
                'cbjs_action':
                'spt.dg_table.select_wdg_clicked( evt, bvr.src_el );'
            }
            select.add_behavior(behavior)

        return select
def get_title_select_wdg(width=300):
    title_select_wdg = SelectWdg('title_code')
    title_select_wdg.set_id('title_code')
    title_select_wdg.add_style('width', '{0}px'.format(width))
    title_select_wdg.add_empty_option()

    title_search = Search('twog/title')
    titles = title_search.get_sobjects()

    for title in titles:
        title_select_wdg.append_option(title.get_value('name'), title.get_code())

    return title_select_wdg
Ejemplo n.º 15
0
    def get_display(my):
        return ''

        search_types = 'MMS/discipline.MMS/product_type'.split(".")

        top = DivWdg()
        parents = None
        for search_type in search_types:

            if not parents:
                search = Search(search_type)
                sobjects = search.get_sobjects()

                columns = search.get_columns()
                column = columns[1]

                select = SelectWdg(search_type)
                select.set_option("values", [x.get_id() for x in sobjects] )
                select.set_option("labels", [x.get_value(column) for x in sobjects] )
                top.add(select)
            else:
                for parent in parents:

                    search = Search(search_type)
                    search.add_relationship_filter(parent)
                    sobjects = search.get_sobjects()

                    if not sobjects:
                        continue

                    columns = search.get_columns()
                    column = columns[1]


                    values = [x.get_id() for x in sobjects]
                    labels = [x.get_value(column) for x in sobjects]


                    select = SelectWdg(search_type)
                    select.add_attr("spt_input_key", parent.get_id() )
                    select.set_option("values", values )
                    select.set_option("labels", labels )
                    top.add(select)

            parents = sobjects
        return top
Ejemplo n.º 16
0
    def get_security_wdg(self):

        div = DivWdg()
        div.add_class("spt_security")

        div.add("A server can sync either be scoped for a single project or all projects.  Transactions that occur in the admin project never get synced.")

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

        div.add("Project: ")

        search = Search("sthpw/project")
        search.add_filters("code", ['admin','unittest'], op='not in')
        search.add_order_by("title")
        projects = search.get_sobjects()

        select = SelectWdg("projects")
        div.add(select)
        labels = [x.get_value("title") for x in projects]
        values = [x.get_value("code") for x in projects]

        project_code = Project.get_project_code()
        if project_code != 'admin':
            select.set_value(project_code)
        select.set_option("labels", labels)
        select.set_option("values", values)
        select.add_empty_option("-- All --")


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

        return div
Ejemplo n.º 17
0
 def get_assigned_group_select(my, assigned, name):
     # Make the select element for groups
     groups_expr = "@GET(sthpw/login_group['login_group','not in','user|client|compression supervisor|edit supervisor|machine room supervisor|media vault supervisor|qc supervisor|sales supervisor|scheduling supervisor|streamz|executives|admin|management|office employees|it'].login_group)"
     groups = my.server.eval(groups_expr)
     group_sel = SelectWdg(name)
     if len(groups) > 0:
         group_sel.append_option('--Select--', '')
         if assigned:
             group_sel.set_value(assigned)
         else:
             group_sel.set_value('')
         for group in groups:
             group_sel.append_option(group, group)
     return group_sel
Ejemplo n.º 18
0
 def get_assigned_select(my, assigned):
     # Make the select element for workers
     workers_expr = "@GET(sthpw/login['location','internal']['license_type','user'].login)"
     workers = my.server.eval(workers_expr)
     work_sel = SelectWdg('task_assigned_select')
     if len(workers) > 0:
         work_sel.append_option('--Select--', '')
         if assigned:
             work_sel.set_value(assigned)
         else:
             work_sel.set_value('')
         for worker in workers:
             work_sel.append_option(worker, worker)
     return work_sel
Ejemplo n.º 19
0
def get_file_select_wdg_from_file_list(files, width=400):
    """
    Given a list of file sobjects, return a SelectWdg using the file paths and codes

    :param files: List of file sobjects
    :param width: Width of the SelectWdg
    :return: SelectWdg
    """
    file_select_wdg = SelectWdg('file_select')
    file_select_wdg.set_id('file_select')
    file_select_wdg.add_style('width', '{0}px'.format(width))
    file_select_wdg.add_empty_option()

    for file_sobject in files:
        file_select_wdg.append_option(file_sobject.get('file_path'),
                                      file_sobject.get_code())

    return file_select_wdg
Ejemplo n.º 20
0
    def get_display(my):
        sobject = my.get_current_sobject()
        key = sobject.get_value("key")
        options = sobject.get_value("options")
        type = sobject.get_value("type")

        # get the value of the users preferences
        search = Search("sthpw/pref_setting")
        search.add_user_filter()
        search.add_filter("key", key)
        pref_setting = search.get_sobject()
        if pref_setting:
            value = pref_setting.get_value("value")
        else:
            value = ""

        div = DivWdg()

        element_name = "%s_%s" % (my.get_name(), sobject.get_id() )
      
        script = '''var server = TacticServerStub.get();
                var value = bvr.src_el.value;
                if (!value) return;

                spt.app_busy.show("Saving", "Saving Preference for [%s]");

                setTimeout( function() {
                    try{
                        server.execute_cmd('tactic.ui.table.SetPreferenceCmd', {key: '%s', value: value});
                    }catch(e){
                        spt.alert(spt.exception.handler(e));
                    }
                        
                    spt.app_busy.hide() 
                        
                    }, 200);'''%(key, key)

        if key in ['skin', 'palette', 'js_logging_level']:
            script = '''%s; spt.app_busy.show('Reloading Page ...'); setTimeout('spt.refresh_page()', 200);'''%script

        if type == "sequence":
            from pyasm.prod.web import SelectWdg
            select = SelectWdg(element_name)
            select.add_behavior({'type': "change", 
                'cbjs_action': script})

            select.set_option("values",options)
            if value:
                select.set_value(value)
            div.add(select)
        else:
            text = TextWdg(element_name)
            text.add_behavior({'type': "blur", 
                'cbjs_action': script})
            if value:
                text.set_value(value)
            div.add(text)
     
        return div
    def get_description_select_wdg(name, value=None):
        select_wdg = SelectWdg(name)
        select_wdg.set_id(name)
        select_wdg.add_empty_option()

        description_search = Search('twog/prequal_line_description')
        descriptions = description_search.get_sobjects()

        for description in descriptions:
            select_wdg.append_option(description.get_value('name'), description.get_code())

        if value:
            select_wdg.set_value(value)

        return select_wdg
Ejemplo n.º 22
0
 def get_assigned_select(self, assigned):
     workers_search = Search("sthpw/login")
     workers_search.add_filter('location', 'internal')
     workers_search.add_filter('license_type', 'user')
     workers = workers_search.get_sobjects()
     work_sel = SelectWdg('task_assigned_select')
     if len(workers) > 0:
         work_sel.append_option('--Select--', '')
         if assigned:
             work_sel.set_value(assigned)
         else:
             work_sel.set_value('')
         for worker in workers:
             work_sel.append_option(worker.get_value('login'), worker.get_value('login'))
     return work_sel
Ejemplo n.º 23
0
 def get_sel(my, id_name, arr, default, alpha_sort):
     this_sel = SelectWdg(id_name)
     this_sel.add_attr('id',id_name)
     if default not in arr and default not in [None,'']:
         arr.append(default)
     if alpha_sort:
         arr.sort()
     arr2 = []
     for a in arr:
         arr2.append(a)
     this_sel.append_option('--Select--','')
     for a in arr2:
         this_sel.append_option(a,a)
     this_sel.set_value(default)
     return this_sel
def get_language_select_wdg():
    language_select_wdg = SelectWdg('language_code')
    language_select_wdg.set_id('language_code')
    language_select_wdg.add_style('display', 'inline-block')
    language_select_wdg.add_empty_option()

    language_search = Search('twog/language')
    languages = language_search.get_sobjects()

    languages = sorted(languages, key=lambda x: x.get_value('name'))

    for language in languages:
        language_select_wdg.append_option(language.get_value('name'), language.get_code())

    return language_select_wdg
    def get_select_wdg(name, options, saved_value=None):
        select_wdg = SelectWdg(name)
        select_wdg.set_id(name)
        select_wdg.add_empty_option()

        for option_set in options:
            label = option_set[0]
            value = option_set[1]

            select_wdg.append_option(label, value)

        if saved_value:
            select_wdg.set_value(saved_value)

        return select_wdg
Ejemplo n.º 26
0
    def get_assigned_group_select(self, assigned):
        where_str = "('user','client','compression supervisor','edit supervisor','machine room supervisor','media vault supervisor','qc supervisor','sales supervisor','scheduling supervisor','streamz','executives','admin','management','office employees','it')"
        group_search = Search("sthpw/login_group")
        group_search.add_where("\"login_group\" not in %s" % where_str)
        groups = group_search.get_sobjects()

        group_sel = SelectWdg('task_assigned_group_select')
        if len(groups) > 0:
            group_sel.append_option('--Select--', '')
            if assigned:
                group_sel.set_value(assigned)
            else:
                group_sel.set_value('')
            for group in groups:
                group_sel.append_option(group.get_value('login_group'), group.get_value('login_group'))
        return group_sel
Ejemplo n.º 27
0
def get_season_select_wdg(width=300):
    season_select_wdg = SelectWdg('season_code')
    season_select_wdg.set_id('season_code')
    season_select_wdg.add_style('width', '{0}px'.format(width))

    season_search = Search('twog/season')
    seasons = season_search.get_sobjects()

    for season in seasons:
        season_select_wdg.append_option(season.get_value('name'),
                                        season.get_code())

    return season_select_wdg
Ejemplo n.º 28
0
def get_file_select_wdg_from_file_list(files, width=400):
    """
    Given a list of file sobjects, return a SelectWdg using the file paths and codes

    :param files: List of file sobjects
    :param width: Width of the SelectWdg
    :return: SelectWdg
    """
    file_select_wdg = SelectWdg('file_select')
    file_select_wdg.set_id('file_select')
    file_select_wdg.add_style('width', '{0}px'.format(width))
    file_select_wdg.add_empty_option()

    for file_sobject in files:
        file_select_wdg.append_option(file_sobject.get('file_path'), file_sobject.get_code())

    return file_select_wdg
Ejemplo n.º 29
0
    def get_display(self):

        widget = DivWdg()

        pipeline_code = self.get_option('pipeline')
        pipeline = Pipeline.get_by_code(pipeline_code)
        if not pipeline:
            widget.add("No pipeline defined")
            return widget
            

        processes = pipeline.get_process_names()

        widget.add_style("border: solid 1px blue")
        widget.add_style("position: absolute")
        widget.add_style("top: 300")
        widget.add_style("left: -500")

        for process in processes:

            #inputs = pipeline.get_input_processes(process)
            outputs = pipeline.get_output_processes(process)

            div = DivWdg()
            widget.add(div)
            div.add_class("spt_input_option")
            div.add_attr("spt_input_key", process)

            #if not outputs:
            #    # then we can't go anywhere, so just add a message
            #    text = ""
            #    div.add(text)
            #    continue

            values = []
            #values.extend( [str(x) for x in inputs] )
            values.append(process)
            values.extend( [str(x) for x in outputs] )


            select = SelectWdg(self.get_input_name())
            select.set_value(process)
            select.add_empty_option('-- Select --')
            select.set_option("values", values)
            div.add(select)

            from tactic.ui.panel import CellEditWdg
            CellEditWdg.add_edit_behavior(select)


        return widget
Ejemplo n.º 30
0
def get_select_widget_from_search_type(search_type, label, label_column, value_column, search_filters=None,
                                       search_order_bys=None):
    """
    Given a search_type, create a SelectWdg. Provide label, label_column, and value_column to set the SearchWdg
    attributes. If filters are given, apply those to the search as well.

    :param search_type: s_type ('twog/title' for example)
    :param label: String, set as 'label' on the select html element
    :param label_column: String, the database column to use for the option labels
    :param value_column: String, the database column to use for the option values
    :param search_filters: A list of tuples containing search filters (optional)
    :param search_order_bys: A list of strings corresponding to database columns to sort by (optional)
    :return: SelectWdg
    """
    search = Search(search_type)

    if search_filters:
        for search_filter in search_filters:
            filter_name = search_filter[0]
            filter_value = search_filter[1]

            try:
                filter_operator = search_filter[2]
            except IndexError:
                filter_operator = None

            if filter_operator:
                search.add_filter(filter_name, filter_value, filter_operator)
            else:
                search.add_filter(filter_name, filter_value)

    if search_order_bys:
        for search_order_by in search_order_bys:
            search.add_order_by(search_order_by)

    search_wdg = SelectWdg(label)
    search_wdg.add_empty_option('----')
    search_wdg.set_search_for_options(search, label_column=label_column, value_column=value_column)

    return search_wdg
Ejemplo n.º 31
0
    def get_display(my):
        widget = DivWdg(id='link_view_select')
        widget.add_class("link_view_select")
        if my.refresh:
            widget = Widget()
        else:
            my.set_as_panel(widget)

        views = []
        if my.search_type:
            from pyasm.search import WidgetDbConfig
            search = Search(WidgetDbConfig.SEARCH_TYPE)
            search.add_filter("search_type", my.search_type)
            search.add_regex_filter("view",
                                    "link_search:|saved_search:",
                                    op="NEQI")
            search.add_order_by('view')
            widget_dbs = search.get_sobjects()
            views = SObject.get_values(widget_dbs, 'view')

        labels = [view for view in views]

        views.insert(0, 'table')
        labels.insert(0, 'table (Default)')
        st_select = SelectWdg('new_link_view', label='View: ')
        st_select.set_option('values', views)
        st_select.set_option('labels', labels)
        widget.add(st_select)
        return widget
Ejemplo n.º 32
0
    def get_sync_mode_wdg(my):

        div = DivWdg()
        div.add_class("spt_sync_mode")

        div.add("Share Mode: ")
        select = SelectWdg("sync_mode")
        div.add(select)
        select.set_option("values", "file|xmlrpc")

        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_sync_mode");
            var value = bvr.src_el.value;
            var xmlrpc_el = top.getElement(".spt_xmlrpc_mode");
            var file_el = top.getElement(".spt_file_mode");

            if (value == 'xmlrpc') {
                spt.show(xmlrpc_el);
                spt.hide(file_el);
            }
            else {
                spt.hide(xmlrpc_el);
                spt.show(file_el);
            }
            '''
        })

        div.add(my.get_xmlrpc_mode_wdg())
        div.add(my.get_file_mode_wdg())

        return div
Ejemplo n.º 33
0
 def get_display(my):   
     from pyasm.prod.biz import ProdSetting
     my.code = str(my.kwargs.get('code'))
     my.sk = str(my.kwargs.get('sk'))
     my.movement_code = str(my.kwargs.get('movement_code'))
     my.source_contexts = ProdSetting.get_value_by_key('source_contexts').split('|')
     ms = MovementScripts(movement_code=my.movement_code)
     table = Table()
     table.add_attr('class','movement_twog_easy_checkin')
     table.add_attr('width','100%s' % '%')
     table.add_row()
     title_bar = table.add_cell('<b><u>Checkin New File</u></b>')
     title_bar.add_attr('align','center')
     title_bar.add_attr('colspan','4')
     title_bar.add_style('font-size: 110%ss' % '%')
     processes_sel = SelectWdg('source_process_select')
     for ctx in my.source_contexts:
         processes_sel.append_option(ctx,ctx)
     table.add_row()
     mini0 = Table()
     mini0.add_row()
     mini0.add_cell('Checkin Context: ')
     mini0.add_cell(processes_sel)
     table.add_cell(mini0)
     mini1 = Table()
     mini1.add_row()
     file_holder = mini1.add_cell(' ')
     file_holder.add_attr('width','100%s' % '%')
     file_holder.add_attr('align','center')
     file_holder.add_attr('class','file_holder')
     button = mini1.add_cell('<input type="button" value="Browse"/>')
     button.add_attr('align','right')
     button.add_style('cursor: pointer;')
     button.add_behavior(ms.get_easy_checkin_browse_behavior())
     big_button = mini1.add_cell('<input type="button" value="Check In" class="easy_checkin_commit" disabled/>')
     big_button.add_style('cursor: pointer;')
     big_button.add_behavior(ms.get_easy_checkin_commit_behavior(my.sk))
     table.add_cell(mini1)
     return table
Ejemplo n.º 34
0
    def get_display(self):
        from calendar_wdg import CalendarInputWdg
        top = DivWdg()
        top.add_class("spt_input_top")

        if not self.calendar_key:
            self.calendar_key = 'read'

        top.add_attr("spt_cbjs_get_input_key", \
            "var value=spt.dg_table.get_element_value(cell_to_edit, '%s'); return value" %self.get_name())

        #top.add_style("background: black")

        # put in a default
        default_sel = SelectWdg(self.get_name())
        for key, value in self.kwargs.items():
            default_sel.set_option(key, value)

      
        sel_div = DivWdg(css='spt_input_option')
        sel_div.add_attr("spt_input_key", "default")
        #default_div.add("No options for selected [%s]" % depend_element)
        sel_div.add(default_sel)
        top.add(sel_div)
      

        cal = CalendarInputWdg(self.get_name())


        cal_div = DivWdg(css='spt_input_option')
        cal_div.add_attr("spt_input_key", self.calendar_key)
        cal_div.add(cal)

        from tactic.ui.panel import CellEditWdg
        CellEditWdg.add_edit_behavior(default_sel)

        top.add(cal_div)

        return top
Ejemplo n.º 35
0
def get_pipeline_select_wdg(search_type, width=300):
    """
    Given a search type, return a select widget with the pipelines available for that search type

    :param search_type: Search type as a string
    :param width: Width of the widget in pixels
    :return: SelectWdg
    """
    pipeline_select_wdg = SelectWdg('pipeline_code')
    pipeline_select_wdg.set_id('pipeline_code')
    pipeline_select_wdg.add_style('width', '{0}px'.format(width))
    pipeline_select_wdg.add_empty_option()

    pipeline_search = Search('sthpw/pipeline')
    pipeline_search.add_filter('search_type', search_type)
    pipelines = pipeline_search.get_sobjects()

    for pipeline in pipelines:
        pipeline_select_wdg.append_option(pipeline.get_value('name'),
                                          pipeline.get_code())

    return pipeline_select_wdg
Ejemplo n.º 36
0
    def get_display(my):
        from calendar_wdg import CalendarInputWdg
        top = DivWdg()
        top.add_class("spt_input_top")

        if not my.calendar_key:
            my.calendar_key = 'read'

        top.add_attr("spt_cbjs_get_input_key", \
            "var value=spt.dg_table.get_element_value(cell_to_edit, '%s'); return value" %my.get_name())

        #top.add_style("background: black")

        # put in a default
        default_sel = SelectWdg(my.get_name())
        for key, value in my.kwargs.items():
            default_sel.set_option(key, value)

      
        sel_div = DivWdg(css='spt_input_option')
        sel_div.add_attr("spt_input_key", "default")
        #default_div.add("No options for selected [%s]" % depend_element)
        sel_div.add(default_sel)
        top.add(sel_div)
      

        cal = CalendarInputWdg(my.get_name())


        cal_div = DivWdg(css='spt_input_option')
        cal_div.add_attr("spt_input_key", my.calendar_key)
        cal_div.add(cal)

        from tactic.ui.panel import CellEditWdg
        CellEditWdg.add_edit_behavior(default_sel)

        top.add(cal_div)

        return top
Ejemplo n.º 37
0
def get_instructions_select_wdg():
    """
    Get a Select Widget with all the instructions options

    :return: SelectWdg
    """

    instructions_search = Search('twog/instructions')

    instructions_select_wdg = SelectWdg('instructions_select')
    instructions_select_wdg.set_id('instructions_select')
    instructions_select_wdg.add_empty_option()
    instructions_select_wdg.set_search_for_options(instructions_search, 'code', 'name')

    return instructions_select_wdg
def get_season_select_wdg(width=300):
    season_select_wdg = SelectWdg('season_code')
    season_select_wdg.set_id('season_code')
    season_select_wdg.add_style('width', '{0}px'.format(width))

    season_search = Search('twog/season')
    seasons = season_search.get_sobjects()

    for season in seasons:
        season_select_wdg.append_option(season.get_value('name'), season.get_code())

    return season_select_wdg
Ejemplo n.º 39
0
    def get_package_select_wdg(self):
        """
        Get a SelectWdg that contains all the possible packages that the component can switch to.

        :return: SelectWdg
        """

        # Set up a basic select widget with an empty object
        package_select_wdg = SelectWdg('reassign_package_select')
        package_select_wdg.set_id('reassign_package_select')
        package_select_wdg.add_style('width', '300px')
        package_select_wdg.add_empty_option()

        # Get the packages
        packages = self.get_packages()

        # Add the package names as the labels and the codes as the values
        for package in packages:
            package_select_wdg.append_option(package.get_value('name'),
                                             package.get_code())

        # Return the SelectWdg
        return package_select_wdg
    def get_display(my):

        div = DivWdg()
        table = Table()
        table.set_class("minimal")
        table.add_style("font-size: 0.8em")
        table.add_row()
        table.add_cell("File")
        table.add_cell('<input type="file" name="%s"/>' % (my.get_input_name())
        )
        table.add_row()
        table.add_cell("Context")

        select = SelectWdg("%s|context" % my.get_input_name() )
        select.set_option("values", "publish|roughDesign|colorFinal|colorKey")
        table.add_cell(select)

        table.add_row()
        table.add_cell("Description")
        table.add_cell('<textarea name="%s|description"></textarea>' % my.get_input_name())
        div.add(table)

        return div
def get_title_select_wdg():
    """
    Get a SelectWdg that contains all the possible titles that the component can switch to.

    :return: SelectWdg
    """

    # Set up a basic select widget with an empty object
    title_select_wdg = SelectWdg('title_select')
    title_select_wdg.set_id('title_select')
    title_select_wdg.add_style('width', '300px')
    title_select_wdg.add_empty_option()

    # Get the titles
    titles_search = Search('twog/title')
    titles = titles_search.get_sobjects()

    # Add the title names as the labels and the codes as the values
    for title in titles:
        title_select_wdg.append_option(title.get_value('name'),
                                       title.get_code())

    # Return the SelectWdg
    return title_select_wdg
Ejemplo n.º 42
0
    def get_display(my):

        widget = DivWdg()

        pipeline_code = my.get_option('pipeline')
        pipeline = Pipeline.get_by_code(pipeline_code)
        if not pipeline:
            widget.add("No pipeline defined")
            return widget
            

        processes = pipeline.get_process_names()

        widget.add_style("border: solid 1px blue")
        widget.add_style("position: absolute")
        widget.add_style("top: 300")
        widget.add_style("left: -500")

        for process in processes:

            #inputs = pipeline.get_input_processes(process)
            outputs = pipeline.get_output_processes(process)

            div = DivWdg()
            widget.add(div)
            div.add_class("spt_input_option")
            div.add_attr("spt_input_key", process)

            #if not outputs:
            #    # then we can't go anywhere, so just add a message
            #    text = ""
            #    div.add(text)
            #    continue

            values = []
            #values.extend( [str(x) for x in inputs] )
            values.append(process)
            values.extend( [str(x) for x in outputs] )


            select = SelectWdg(my.get_input_name())
            select.set_value(process)
            select.add_empty_option('-- Select --')
            select.set_option("values", values)
            div.add(select)

            from tactic.ui.panel import CellEditWdg
            CellEditWdg.add_edit_behavior(select)


        return widget
Ejemplo n.º 43
0
    def get_display(self):
        top = DivWdg()
        top.add_style("width: 200px")
        top.add_style("height: 200px")
        top.add_color("background", "background")
        top.add_color("padding", "10px")
        top.add_border()

        template = self.get_option("template")
        template = "prod/sequence"

        select = SelectWdg("foo")
        top.add(select)
        select.set_option("values", "XG|FF|WOW")

        text = TextWdg("foo")
        top.add(text)



        top.add("!!!!!")


        return top
Ejemplo n.º 44
0
def get_pipeline_select_wdg(search_type, width=300):
    """
    Given a search type, return a select widget with the pipelines available for that search type

    :param search_type: Search type as a string
    :param width: Width of the widget in pixels
    :return: SelectWdg
    """
    pipeline_select_wdg = SelectWdg('pipeline_code')
    pipeline_select_wdg.set_id('pipeline_code')
    pipeline_select_wdg.add_style('width', '{0}px'.format(width))
    pipeline_select_wdg.add_empty_option()

    pipeline_search = Search('sthpw/pipeline')
    pipeline_search.add_filter('search_type', search_type)
    pipelines = pipeline_search.get_sobjects()

    for pipeline in pipelines:
        pipeline_select_wdg.append_option(pipeline.get_value('name'), pipeline.get_code())

    return pipeline_select_wdg
Ejemplo n.º 45
0
def get_instructions_select_wdg(division_code, platform_code):
    """
    Get a Select Widget with all the package instructions options

    :return: SelectWdg
    """

    package_instructions_search = Search('twog/package_instructions')
    package_instructions_search.add_filter('division_code', division_code)
    package_instructions_search.add_filter('platform_code', platform_code)

    instructions_select_wdg = SelectWdg('package_instructions_select')
    instructions_select_wdg.set_id('package_instructions_select')
    instructions_select_wdg.add_empty_option()
    instructions_select_wdg.set_search_for_options(package_instructions_search,
                                                   'code', 'name')

    return instructions_select_wdg
    def get_package_select_wdg(self):
        """
        Get a SelectWdg that contains all the possible packages that the component can switch to.

        :return: SelectWdg
        """

        # Set up a basic select widget with an empty object
        package_select_wdg = SelectWdg('reassign_package_select')
        package_select_wdg.set_id('reassign_package_select')
        package_select_wdg.add_style('width', '300px')
        package_select_wdg.add_empty_option()

        # Get the packages
        packages = self.get_packages()

        # Add the package names as the labels and the codes as the values
        for package in packages:
            package_select_wdg.append_option(package.get_value('name'), package.get_code())

        # Return the SelectWdg
        return package_select_wdg
def get_title_select_wdg():
    """
    Get a SelectWdg that contains all the possible titles that the component can switch to.

    :return: SelectWdg
    """

    # Set up a basic select widget with an empty object
    title_select_wdg = SelectWdg('title_select')
    title_select_wdg.set_id('title_select')
    title_select_wdg.add_style('width', '300px')
    title_select_wdg.add_empty_option()

    # Get the titles
    titles_search = Search('twog/title')
    titles = titles_search.get_sobjects()

    # Add the title names as the labels and the codes as the values
    for title in titles:
        title_select_wdg.append_option(title.get_value('name'), title.get_code())

    # Return the SelectWdg
    return title_select_wdg
Ejemplo n.º 48
0
def get_instructions_template_select_wdg():
    """
    Get a Select Widget with all the instructions template options

    :return: SelectWdg
    """

    instructions_search = Search('twog/instructions_template')

    instructions_template_select_wdg = SelectWdg('instructions_template_select')
    instructions_template_select_wdg.set_id('instructions_template_select')
    instructions_template_select_wdg.add_empty_option()

    instructions_sobjects = instructions_search.get_sobjects()
    instructions_sobjects = sorted(instructions_sobjects, key=lambda sobject: sobject.get('name'))

    for instructions_sobject in instructions_sobjects:
        instructions_template_select_wdg.append_option(instructions_sobject.get('name'),
                                                       instructions_sobject.get_code())

    return instructions_template_select_wdg
Ejemplo n.º 49
0
    def get_display(my):

        search_type = "prod/asset"

        web = WebContainer.get_web()
        related_asset = web.get_form_value("edit|related")
        search = Search(search_type)
        search.add_filter("code", related_asset)
        sobjects = search.get_sobjects()

        labels = "|".join([
            "%s - %s" % (x.get_code(), x.get_value("name")) for x in sobjects
        ])
        values = "|".join([x.get_code() for x in sobjects])

        select = SelectWdg(my.get_input_name())
        select.set_persist_on_submit()
        select.set_option("values", values)
        select.set_option("labels", labels)
        select.set_option("web_state", "true")

        return select
def get_select_widget_from_search_type(search_type, label, label_column, value_column, search_filters=None,
                                       search_order_bys=None):
    """
    Given a search_type, create a SelectWdg. Provide label, label_column, and value_column to set the SearchWdg
    attributes. If filters are given, apply those to the search as well.

    :param search_type: s_type ('twog/title' for example)
    :param label: String, set as 'label' on the select html element
    :param label_column: String, the database column to use for the option labels
    :param value_column: String, the database column to use for the option values
    :param search_filters: A list of tuples containing search filters (optional)
    :param search_order_bys: A list of strings corresponding to database columns to sort by (optional)
    :return: SelectWdg
    """
    search = Search(search_type)

    if search_filters:
        for search_filter in search_filters:
            filter_name = search_filter[0]
            filter_value = search_filter[1]

            try:
                filter_operator = search_filter[2]
            except IndexError:
                filter_operator = None

            if filter_operator:
                search.add_filter(filter_name, filter_value, filter_operator)
            else:
                search.add_filter(filter_name, filter_value)

    if search_order_bys:
        for search_order_by in search_order_bys:
            search.add_order_by(search_order_by)

    search_wdg = SelectWdg(label)
    search_wdg.add_empty_option('----')
    search_wdg.set_search_for_options(search, label_column=label_column, value_column=value_column)

    return search_wdg
Ejemplo n.º 51
0
    def get_display(self):

        state = self.get_state()
        search_type = state.get("search_type")
        sobj = self.get_current_sobject()

        if search_type:
            st = search_type
        elif not search_type:
            return "N/A - Not enough info to display"
        else:
            st = sobj.get_base_search_type()

        # for inline insert, this should proceed
        #if not sobj:
        #    return ''

        st_suffix = st.split('/', 1)

        if len(st_suffix) == 2:
            st_suffix = st_suffix[1]

        search = Search('sthpw/pipeline')
        search.add_op_filters([('search_type', 'EQ', '/%s' % st_suffix)])

        # takes into account site-wide pipeline
        search.add_project_filter(show_unset=True)
        sobjects = search.get_sobjects()

        codes = [x.get_code() for x in sobjects]

        if self.get_option("use_code") in [True, 'true']:
            names = codes
        else:

            names = []
            for x in sobjects:
                name = x.get_value("name")
                if not name:
                    name = x.get_value("code")
                names.append(name)

        select = SelectWdg(self.get_input_name())

        # Only on insert, a default pipeline will
        # be assigned.
        if sobj and sobj.is_insert():
            select.add_empty_option("-- Default --")
        else:
            select.add_empty_option()
        select.set_option("values", codes)
        select.set_option("labels", names)

        if sobj:
            value = sobj.get_value(self.get_name(), no_exception=True)
            if value:
                select.set_value(value)

        else:
            # only for inline
            #behavior =  { 'type': 'click',
            #       'cbjs_action': 'spt.dg_table.select_wdg_clicked( evt, bvr.src_el );'}
            #select.add_behavior(behavior)
            pass

        return select
Ejemplo n.º 52
0
    def get_display(self):

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

        self.search_key = self.kwargs.get("search_key")
        sobject = Search.get_by_search_key(self.search_key)

        if sobject.get_base_search_type() == "sthpw/snapshot":
            snapshot = sobject
        elif sobject.get_base_search_type() == "sthpw/file":
            # if it is a file object
            snapshot = sobject.get_parent()
        else:
            snapshots = Snapshot.get_by_sobject(sobject, is_latest=True)
            snapshot = snapshots[0]

        # Extension determine UI class for preview
        thumb_path = snapshot.get_web_path_by_type("icon")
        web_src = snapshot.get_web_path_by_type("web")

        from pyasm.biz import File
        file_type = "main"
        lib_path = snapshot.get_lib_path_by_type(file_type)
        src = snapshot.get_web_path_by_type(file_type)
        if not web_src:
            web_src = src

        parts = os.path.splitext(src)
        ext = parts[1]
        ext = ext.lstrip(".")
        ext = ext.lower()

        #parent = snapshot.get_parent()

        top = self.top
        self.set_as_panel(top)

        if ext == "pdf":
            iframe = HtmlElement.iframe()
            iframe.set_attr('src', src)
            iframe.add_style("width: 100%")
            iframe.add_style("height: 800px")
            top.add(iframe)
            return top

        from tactic.ui.container import ResizableTableWdg
        table = ResizableTableWdg()
        top.add(table)
        tr = table.add_row()

        # These bvrs allow for smooth switching if switching between files
        # like in the RepoBrowserWdg
        tr.add_style("height: 200px")
        load_height_bvr = {
            'type':
            'load',
            'cbjs_action':
            '''
            var last_height = spt.container.get_value("last_img_height");
            if (last_height) {
                bvr.src_el.setStyle("height", last_height);
            } 
            '''
        }
        tr.add_behavior(load_height_bvr)

        unload_height_bvr = {
            'type':
            'unload',
            'cbjs_action':
            '''
            var last_height = bvr.src_el.getStyle("height");
            spt.container.set_value("last_img_height", last_height);
            '''
        }
        tr.add_behavior(unload_height_bvr)

        table.add_style("width: 100%")
        table.add_style("text-align", "center")

        from tactic.ui.widget import EmbedWdg
        td = table.add_cell()
        td.add_color(
            "background",
            "background",
        )
        td.add_style("vertical-align: middle")
        td.add_style("height: inherit")
        td.add_style("overflow-x: auto")

        if ext in ['txt', 'html', 'ini']:
            content_div = DivWdg()
            f = open(lib_path, 'r')
            content = f.read(10000)
            f.close()
            if not content:
                text = "No Content"
            else:

                size = os.path.getsize(lib_path)

                from pyasm.common import FormatValue
                value = FormatValue().get_format_value(size, "KB")

                content_div.add("Showing first 10K of %s<hr/>" % value)

                text = TextAreaWdg()
                text.add(content)
                text.add_style("width: 100%")
                text.add_style("height: 100%")
                text.add_style("padding: 10px")
                text.add_style("border: none")
                text.add_attr("readonly", "true")

            content_div.add(text)
            td.add(content_div)
            content_div.add_style("color", "#000")
            content_div.add_style("width", "auto")
            content_div.add_style("margin", "20px")
            content_div.add_style("height", "100%")

        elif ext in File.IMAGE_EXT or ext == "gif":
            if lib_path.find("#") != -1:
                img = DivWdg()

                file_range = snapshot.get_file_range()
                file_range_div = DivWdg()
                file_range_div.add("File Range: %s" % file_range.get_display())
                img.add(file_range_div)
                file_range_div.add_style("font-size: 1.4em")
                file_range_div.add_style("margin: 15px 0px")
                """
                left_chevron = IconWdg("Previous", "BS_CHEVRON_LEFT")
                file_range_div.add(left_chevron)
                right_chevron = IconWdg("Next", "BS_CHEVRON_RIGHT")
                file_range_div.add(right_chevron)
                """

                expanded_paths = snapshot.get_expanded_web_paths()
                lib_paths = snapshot.get_expanded_lib_paths()
                lib_path = lib_paths[0]

                items_div = DivWdg()
                img.add(items_div)
                items_div.add_style("width: auto")

                for path in expanded_paths:
                    item = HtmlElement.img(src=path)
                    items_div.add(item)
                    item.add_style("max-height: 300px")
                    item.add_style("height: auto")
                    item.add_style("width: 32%")
                    item.add_style("margin: 2px")
                    item.add_style("display: inline-block")
                    #item.add_class("spt_resizable")

                img.add_style("margin: 20px")
                img.add_style("max-height: 400px")
                img.add_style("overflow-y: auto")
                img.add_style("overflow-hidden: auto")
                img.add_style("text-align: left")

            else:
                if ext == "gif":
                    img = HtmlElement.img(src=src)
                else:
                    img = HtmlElement.img(src=web_src)
                img.add_style("height: inherit")
                img.add_style("width: auto")
            td.add(img)
        elif ext in File.VIDEO_EXT:
            embed_wdg = EmbedWdg(src=src,
                                 thumb_path=thumb_path,
                                 preload="auto",
                                 controls=True)
            td.add(embed_wdg)

            embed_wdg.add_style("margin: auto auto")
            embed_wdg.add_class("spt_resizable")

            embed_wdg.add_behavior(load_height_bvr)
            embed_wdg.add_behavior(unload_height_bvr)

        else:
            thumb_table = DivWdg()
            td.add(thumb_table)

            thumb_table.add_behavior({
                'type':
                'click_up',
                'src':
                src,
                'cbjs_action':
                '''
                window.open(bvr.src);
                '''
            })
            thumb_table.add_class("hand")
            thumb_table.add_style("width: 200px")
            thumb_table.add_style("height: 125px")
            thumb_table.add_style("padding: 5px")
            thumb_table.add_style("margin-left: 20px")
            thumb_table.add_style("display: inline-block")
            thumb_table.add_style("vertical-align: top")
            thumb_table.add_style("overflow-y: hidden")
            from tactic.ui.panel import ThumbWdg2
            thumb = ThumbWdg2()
            thumb_table.add(thumb)
            thumb.set_sobject(snapshot)

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

        from tactic.ui.checkin import PathMetadataWdg
        from tactic.ui.checkin import SnapshotMetadataWdg

        from pyasm.widget import SelectWdg
        select = SelectWdg(name="parser")
        select.add_style("width: 125px")
        select.add_style("margin-top: 0px")
        select.add_style("margin-right: 10px")
        select.add_empty_option("-- Metadata --")
        td.add(select)
        select.add_style("float: right")
        select.set_option("values",
                          ["IPTC", "EXIF", "XMP", "ImageMagick", "PIL"])
        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
            var parser = bvr.src_el.value;
            spt.panel.refresh_element(bvr.src_el, {parser: parser})
            '''
        })
        if parser:
            select.set_value(parser)

        title_div = DivWdg()
        td.add(title_div)
        title_div.add("<div style='font-size: 16px'>File Metadata</div>")
        title_div.add("<div>Metadata extracted directly from the file</div>")
        title_div.add("<hr/>")
        title_div.add_style("text-align: left")
        title_div.add_style("margin: 0px 10px")

        metadata_div = DivWdg()
        td.add(metadata_div)
        metadata_div.add_style("max-height: 400px")
        metadata_div.add_style("overflow-y: auto")
        metadata_div.add_style("overflow-x: hidden")
        metadata_div.add_style("margin: 20px 0px 20px 10px")
        metadata_div.add_style("text-align: left")

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

        server_src = lib_path

        # get it dynamically by path
        metadata_wdg = PathMetadataWdg(path=server_src,
                                       parser=parser,
                                       use_tactic_tags=use_tactic_tags,
                                       search_key=self.search_key)
        metadata_div.add(metadata_wdg)

        top.add("<br/>")

        return top
Ejemplo n.º 53
0
    def get_display(self):

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

        behavior = {
            'type': 'keyboard',
            'kbd_handler_name': 'DgTableMultiLineTextEdit'
        }
        div.add_behavior(behavior)

        project_code = None
        sobject = self.get_current_sobject()
        if sobject:
            project_code = sobject.get_project_code()
        project_filter = Project.get_project_filter(project_code)

        query_filter = self.get_option("query_filter")
        if not query_filter:
            # try getting it from the search_type
            web = WebContainer.get_web()
            search_type = web.get_form_value("search_type")
            if search_type:
                search_type_obj = SearchType.get(search_type)
                base_search_type = search_type_obj.get_base_search_type()
                query_filter = "search_type = '%s'" % base_search_type

        # add the project filter
        if query_filter:
            query_filter = "%s and %s" % (query_filter, project_filter)
        else:
            query_filter = project_filter

        self.set_option("query_filter", query_filter)

        select = SelectWdg()
        select.add_empty_option("-- Select --")
        select.copy(self)

        select.add_event("onchange", "alert('cow')")
        div.add(select)

        span = SpanWdg(css="med")
        span.add("Add Initial Tasks: ")
        checkbox = CheckboxWdg("add_initial_tasks")
        checkbox.set_persistence()
        if checkbox.is_checked(False):
            checkbox.set_checked()
        span.add(checkbox)
        div.add(span)

        # list all of the processes with checkboxes
        pipeline_code = select.get_value()
        if pipeline_code:
            pipeline = Pipeline.get_by_code(pipeline_code)
            if not pipeline:
                print "WARNING: pipeline '%s' does not exist" % pipeline_code
                return
            process_names = pipeline.get_process_names(recurse=True)

            process_div = DivWdg()
            for process in process_names:
                checkbox = CheckboxWdg("add_initial_tasks")
                process_div.add(checkbox)
                process_div.add("&nbsp;")
                process_div.add(process)
                process_div.add(HtmlElement.br())
            div.add(process_div)

        return div
Ejemplo n.º 54
0
    def get_display(my):
        my.labels_attr =  my.get_option('label_attr')
        if my.labels_attr:
            my.labels_attr = my.labels_attr.split('|')

        from tactic.ui.panel import EditWdg
        if hasattr(my, 'parent_wdg') and isinstance(my.get_parent_wdg(), EditWdg):
            sobject = my.get_current_sobject()
            parent = sobject.get_parent()
            group = None
            pipeline_code = None

            if parent:
                pipeline_code = parent.get_value('pipeline_code')
            pipeline = Pipeline.get_by_code(pipeline_code)
            
            labels_expr = None

            if pipeline:
                attrs = pipeline.get_process_attrs(sobject.get_value('process'))
                group = attrs.get('%s_login_group'%my.get_name())
            if group:
            
                values_expr = "@GET(sthpw/login_group['login_group', '%s'].sthpw/login_in_group.sthpw/login.login)"%group
                if my.labels_attr:
                    labels_expr = ["@GET(sthpw/login_group['login_group', '%s'].sthpw/login_in_group.sthpw/login.%s)"%(group, x.strip()) for x in my.labels_attr]
                    labels_expr =  ' + &nbsp + '.join(labels_expr)
            else:
                values_expr = "@GET(sthpw/login.login)"
                if my.labels_attr:
                    labels_expr = ["@GET(sthpw/login.%s)"%(x.strip()) for x in my.labels_attr]
                    labels_expr =  ' + &nbsp + '.join(labels_expr)
            select = SelectWdg(my.get_input_name())
            select.add_empty_option("-- Select a User --")
            """
            values = []
            labels = []
            for user in group_users:
                values.append(user)
                labels.append('  %s'%user)
            """
            select.set_option('values_expr', values_expr)
            if labels_expr:
                select.set_option('labels_expr', labels_expr)
            current_value = sobject.get_value(my.get_name())
            if current_value:
                select.set_value(current_value)
            return select


        #all_users = Search.eval("@GET(sthpw/login.login)")
        all_users = Search.eval("@SOBJECT(sthpw/login)")
        all_users_label =  []
        
        # don't use expression here since it's not as db-efficient as retrieving the sobjects
        """
        if my.labels_attr:
            labels_expr = ["@GET(sthpw/login.login.%s)"%x.strip() for x in my.labels_attr]
        """
        '''
        groups = Search.eval("@SOBJECT(sthpw/login_group)")
        group_dict = {}
        for group in groups:
            group_users =
Search.eval("@GET(sthpw/login_group['login_group',
'%s'].sthpw/login_in_group.sthpw/login.login)"%group.get_value('login_group'))
            group_dict[group.get_value('login_group')] = group_users
        '''

        logins_dict = {}
        for user in all_users:
            user_name = user.get_value('login')
            logins_dict[user_name] = {}
        group_dict = {}
        items = Search.eval("@SOBJECT(sthpw/login_in_group)")
        for item in items:
             item_login = item.get_value("login")
             if logins_dict.get(item_login) == None:
                 continue
             item_group = item.get_value("login_group")

             group_list = group_dict.get(item_group)
             if group_list == None:
                 group_list = []
                 group_dict[item_group] = group_list
             group_list.append(item_login)


            
        
        top = DivWdg()
        
        top.add_class("spt_input_top")

        # HACK! This isn't very well constructed
        ### Tore: Not my code! Copied from ProcessContextInputWdg. Seems to work though.
        top.add_attr("spt_cbjs_get_input_key", "return cell_to_edit.getAttribute('spt_pipeline_code');")
        
        # Adding an "all users" select option in case it can't find a useful select widget.
        div = DivWdg()
        div.add_class("spt_input_option")
        #div.add_attr("spt_input_key", '__all__') #Not needed, since it defaults to the first one anyway.
        select = SelectWdg(my.get_name())
        select.add_empty_option("-- Select a User --")
        values = []
        labels = []
        labels_dict = {}
        for user in all_users:
            user_name = user.get_value('login')
            values.append(user_name)
            label = user_name
            if my.labels_attr:
                user_labels = [user.get_value(x) for x in my.labels_attr]
                label = ' '.join(user_labels)

            labels_dict[user_name] = label
            
            labels.append('%s'%label)
            #print "select ", user_name

        # -- NOTE: leaving this commented out code here for reference. Not sure why this is the case but when
        # --       this click behavior is used instead of a 'change' behavior that forces a blur on select,
        # --       click selection only works for this widget in Firefox and does NOT work in IE
        #
        # select.add_behavior( { 'type': 'click',
        #    'cbjs_action': 'spt.dg_table.select_wdg_clicked( evt, bvr.src_el );' } )


        # -- Replace previous 'click' behavior with a 'change' behavior to force blur() of select element ...
        # -- this works for both Firefox and IE
        #
        select.add_behavior( { 'type': 'change',
           'cbjs_action': 'bvr.src_el.blur();' } )


        #behavior = {
        #    'type': 'keyboard',
        #    'kbd_handler_name': 'DgTableSelectWidgetKeyInput',
        #}
        #select.add_behavior( behavior )


        select.set_option("values", values)
        select.set_option("labels", labels)
           
        div.add(select)
        top.add(div)
        
        #Building each of the select widgets per group here.
        for group in group_dict.keys():
            div = DivWdg()
            div.add_class("spt_input_option")
            div.add_attr("spt_input_key", group)
            
            select = SelectWdg(my.get_name())
            select.add_empty_option("-- Select a User --")
            values = ['']
            labels = ['<< %s >>'%group]
            for user in group_dict[group]:
                values.append(user)
                label = labels_dict.get(user)
                labels.append('  %s'%label)
            select.add_behavior( { 'type': 'click',
               'cbjs_action': 'spt.dg_table.select_wdg_clicked( evt, bvr.src_el );' } )
            #behavior = {
            #    'type': 'keyboard',
            #    'kbd_handler_name': 'DgTableSelectWidgetKeyInput',
            #}
            #select.add_behavior( behavior )
            select.set_option("values", values)
            select.set_option("labels", labels)
            
            div.add(select)
            top.add(div)
        
        return top
Ejemplo n.º 55
0
    def get_display(my):
        top = DivWdg()
        top.add_class("spt_top")

        dialog = DialogWdg()
        dialog_id = dialog.get_id()

        # create the button
        button = DivWdg()
        button.add_style("padding: 5px")
        button.add_style("width: 30px")
        button.add_style("text-align: center")
        button.add_style("float: left")
        button.add_gradient("background", "background")
        button.add_border()
        top.add(button)
        icon = IconWdg("Press Me", IconWdg.ZOOM)
        icon.add_style("float: left")
        button.add(icon)
        icon = IconWdg("Press Me", IconWdg.INFO_OPEN_SMALL)
        icon.add_style("margin-left: -9px")
        button.add(icon)
        button.add_behavior({
            'type':
            'click_up',
            'dialog_id':
            dialog_id,
            'cbjs_action':
            '''
        var pos = bvr.src_el.getPosition();
        var el = $(bvr.dialog_id);
        el.setStyle("left", pos.x+1);
        el.setStyle("top", pos.y+32);
        el.setStyle("display", "");
        '''
        })

        # defined the dialog
        top.add(dialog)
        dialog.add_title("Search Limit")

        table = Table()
        table.add_color("color", "color2")
        dialog.add(table)
        table.add_row()
        td = table.add_cell()
        td.add("Search Limit: ")

        td = table.add_cell()
        select = SelectWdg("search_limit")
        select.set_option("values", "5|10|20|50|100|200|Custom")
        td.add(select)

        save_button = ProdIconButtonWdg("Save")
        td.add(save_button)
        cancel_script = dialog.get_cancel_script()
        save_button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''
        var dialog_top = bvr.src_el.getParent(".spt_dialog_top");
        var values = spt.api.get_input_values(dialog_top);

        var top = spt.get_parent(bvr.src_el, ".spt_top");
        var input = top.getElement(".spt_search_limit");
        input.value = values.search_limit;
        %s
        ''' % cancel_script
        })

        text = TextWdg("search_limit")
        text.add_class("spt_search_limit")
        top.add(text)

        return top
Ejemplo n.º 56
0
    def get_display(self):
        type = self.kwargs.get("type")

        if type not in ['string', 'varchar', 'float', 'integer', 'timestamp', 'login']:
            print("WARNING: FilterWdg: type [%s] not supported, using 'string'" % type)
            type = 'string'

        filter_span = SpanWdg()

        web = WebContainer.get_web()

        if type in ["string", "varchar"]:

            relations = ["is", "is not", "contains", "does not contain", "is empty", "starts with", "ends with"]
            relation_select = SelectWdg("%s_relation" % self.prefix)
            relation_select.set_option("values", relations)
            relation_select.set_persist_on_submit()
            self.set_filter_value(relation_select)

            filter_span.add(relation_select)
            value_text = TextWdg("%s_value" % self.prefix)
            value_text.set_persist_on_submit()
            self.set_filter_value(value_text)
            filter_span.add(value_text)

        elif type in ['integer', 'float', 'currency']:
            relations = ["is equal to", "is greater than", "is less than"]
            relation_select = SelectWdg("%s_relation" % self.prefix)
            relation_select.set_option("values", relations)
            relation_select.set_persist_on_submit()
            self.set_filter_value(relation_select)
            filter_span.add(relation_select)

            value_text = TextWdg("%s_value" % self.prefix)
            value_text.set_persist_on_submit()
            self.set_filter_value(value_text)
            filter_span.add(value_text)

        elif type == 'timestamp':
            relations = ["is newer than", "is older than"]
            relation_select = SelectWdg("%s_relation" % self.prefix)
            relation_select.set_option("values", relations)
            relation_select.set_persist_on_submit()
            self.set_filter_value(relation_select)
            filter_span.add(relation_select)

            options = ["1 day", '2 days', '1 week', '1 month']
            another_select = SelectWdg("%s_select" % self.prefix)
            another_select.add_empty_option("-- Select --")
            another_select.set_option("values", options)
            another_select.set_persist_on_submit()
            self.set_filter_value(another_select)
            filter_span.add(another_select)

            filter_span.add(" or ")

            value_text = TextWdg("%s_value" % self.prefix)
            value_text.set_persist_on_submit()
            self.set_filter_value(value_text)
            filter_span.add(value_text)

        elif type in ['login']:

            relations = ["is", "is not", "contains", "does not contain", "is empty", "starts with", "ends with"]
            relation_select = SelectWdg("%s_relation" % self.prefix)
            relation_select.set_option("values", relations)
            relation_select.set_persist_on_submit()
            self.set_filter_value(relation_select)
            filter_span.add(relation_select)

            value_text = CheckboxWdg("%s_user" % self.prefix)
            value_text.set_persist_on_submit()
            self.set_filter_value(value_text)
            filter_span.add(value_text)
            filter_span.add("{user}")

            filter_span.add(" or ")

            value_text = TextWdg("%s_value" % self.prefix)
            value_text.set_persist_on_submit()
            self.set_filter_value(value_text)
            filter_span.add(value_text)


        return filter_span