コード例 #1
0
    def get_display(self):
        web = WebContainer.get_web()

        widget = Widget()

        search_type = web.get_form_value("parent_search_type")
        search_id = web.get_form_value("parent_search_id")

        if not search_type:
            widget.add("RenderSubmitInfo: parent type not found")
            return widget

        hidden = HiddenWdg("parent_search_type", search_type)
        widget.add(hidden)
        hidden = HiddenWdg("parent_search_id", search_id)
        widget.add(hidden)

        sobject = Search.get_by_id(search_type, search_id)
        table = TableWdg(search_type, css="embed")
        table.set_show_property(False)
        table.set_sobject(sobject)
        table.remove_widget("render")
        table.remove_widget("description")
        widget.add(table)

        return widget
コード例 #2
0
    def add_inputs(my):
        ''' register the inputs '''
        if not my.task:
            return
        hidden = HiddenWdg('skey_TimecardWdg_%s' % my.task.get_id())
        my.add_ajax_input(hidden)

        week_text = TextWdg('week_%s' % my.task.get_search_key())
        my.add_ajax_input(week_text)

        year_text = HiddenWdg('year_%s' % my.task.get_search_key())
        my.add_ajax_input(year_text)
コード例 #3
0
    def init_setup(my):
        '''set the ajax top and register some inputs'''
        div_id = 'timecard_%s' % my.task.get_id()
        my.main_div = DivWdg(id=div_id)
        my.set_ajax_top(my.main_div)

        # register the inputs first
        hidden = HiddenWdg('skey_TimecardWdg_%s' % my.task.get_id())
        my.add_ajax_input(hidden)

        week_text = TextWdg('week_%s' % my.task.get_search_key())
        my.add_ajax_input(week_text)

        year_text = HiddenWdg('year_%s' % my.task.get_search_key())
        my.add_ajax_input(year_text)
コード例 #4
0
    def get_info_wdg(my):
        widget = Widget()
        context_input = HiddenWdg("%s|context" % my.get_input_name(),
                                  my.context)
        context_input.add_class('spt_upload_context')

        widget.add(context_input)

        # override the column
        column = my.get_option("column")
        if column != "":
            column_input = HiddenWdg("%s|column" % my.get_input_name(), column)
            widget.add(column_input)

        return widget
コード例 #5
0
    def get_display(my):

        main_div = my.main_div

        if not my.week:
            today = Date()
            my.week = today.get_week()
            my.year = today.get_year()

        task_row = TimecardTaskRowWdg()
        task_row.set_task(my.task)

        if my.task:
            hidden = HiddenWdg('skey_TimecardWdg_%s' % my.task.get_id(),
                               my.task.get_search_key())
            main_div.add(hidden)
        else:
            return "There was a problem reading task data. Refresh"

        my._add_week(main_div, my.week, task_row)
        my._add_year(main_div, my.year, task_row)

        main_div.add(task_row)

        main_div.add(HtmlElement.br(2))

        # draw the processing icon
        process_div = _get_div(1)
        process_div.add(" ")
        main_div.add(process_div)

        main_div.add(HtmlElement.br())

        return main_div
コード例 #6
0
    def get_display(my):

        main_div = my.main_div

        if not my.week:
            today = Date()
            my.week = today.get_week()
            my.year = today.get_year()

        task_row = TimecardTaskRowWdg()
        task_row.set_task(my.task)
        hidden = HiddenWdg('skey_SpecialDayWdg_%s' % my.task.get_id(),
                           my.task.get_search_key())
        main_div.add(hidden)

        my._add_week(main_div, my.week, task_row)
        my._add_year(main_div, my.year, task_row)

        main_div.add(task_row)
        main_div.add(HtmlElement.br(2))

        # draw the processing icon
        process_div = _get_div(1)
        process_div.add(" ")
        main_div.add(process_div)

        main_div.add(HtmlElement.br())

        return main_div
コード例 #7
0
ファイル: sobject_group_wdg.py プロジェクト: zieglerm/TACTIC
    def _get_target_span(self):
        # get the target span
        search = Search(self.container_cls.SEARCH_TYPE)
        self._order_search(search)
        groups = search.get_sobjects()
        if groups:
            self.container_sobj = groups[0]

        target_span = SpanWdg(css='med')
        group_table = Table(self.GROUP_TABLE_NAME, css='table')
        group_table.add_style('width', '30em')
        group_table.add_col(css='small')
        group_table.add_col(css='small')
        group_table.add_col()

        target_span.add(group_table)
        group_table.add_row_cell(search.get_search_type_obj()\
            .get_description(), "heading")
        checkbox = CheckboxWdg()
        checkbox.set_option("onclick", \
            "a=new Elements('container_ids');a.toggle_all(this);")
        group_table.add_row()
        group_table.add_cell(checkbox)
        col_name = group_table.get_next_col_name()

        toggle_control = HiddenRowToggleWdg(col_name,
                                            is_control=True,
                                            auto_index=True)

        group_table.add_cell(toggle_control)
        group_table.add_cell('MASTER CONTROL')

        remove_cmd = HiddenWdg(SObjectGroupCmd.REMOVE_CMD)
        self.add(remove_cmd)
        for group in groups:
            group_table.add_row()
            checkbox = CheckboxWdg("container_ids")
            checkbox.set_option("value", group.get_primary_key_value())

            toggle = HiddenRowToggleWdg(col_name, auto_index=True)
            toggle.store_event()

            group_details = ItemInContainerWdg(group, self.item_sobj,
                                               self.item_cls,
                                               self.grouping_cls)

            # set the target content of the toggle
            toggle.set_static_content(group_details)

            group_table.add_cell(checkbox)
            group_table.add_cell(toggle, add_hidden_wdg=True)
            group_table.add_cell(group.get_description())
            num_items = group_details.get_num_items()
            if num_items:
                td = group_table.add_cell("( %s )" % num_items, 'no_wrap')
                td.add_style('color: #777')
            else:
                group_table.add_blank_cell()

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

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

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

        return widget
コード例 #9
0
ファイル: drop_element_wdg.py プロジェクト: hellios78/TACTIC
    def get_display(my):
        my.display_expr = my.kwargs.get('display_expr')
        my.values = []

        instance_type = my.get_option("instance_type")
        accepted_type = my.get_option("accepted_drop_type")

        div = DivWdg()
        div.add_class("spt_drop_element_top")
        div.add_style("width: 100%")
        div.add_style("height: 100%")
        div.add_style("min-width: 100px")
        div.add_style("max-height: 300px")
        div.add_style("overflow-y: auto")

        my.value_wdg = HiddenWdg(my.get_name())
        my.value_wdg.add_class("spt_drop_element_value")
        div.add(my.value_wdg)

        version = my.parent_wdg.get_layout_version()
        if version != "2":
            my.add_drop_behavior(div, accepted_type)

        # add the hidden div which holds containers info for the sobject
        template_div = DivWdg()
        template_div.add_style("display: none")
        template_item = my.get_item_div(None)

        # float left for the new icon beside it
        item_div = template_item.get_widget('item_div')
        item_div.add_style('float: left')

        template_item.add_class("spt_drop_template")
        #template_item.add_style('float: left')
        new_icon = IconWdg("New", IconWdg.NEW)
        new_icon.add_style('padding-left', '3px')
        #TODO: insert the new_icon at add(new_icon, index=0) and make sure
        # the js-side sobject_drop_action cloning align the template div properly
        #template_item.add(" - ")
        template_item.add(new_icon)
        template_div.add(template_item)
        div.add(template_div)

        # list out the relationships
        #sobject = my.get_current_sobject()
        #search_type = sobject.get_base_search_type()

        content_div = DivWdg()
        div.add(content_div)
        # shrink wrapping for FF
        content_div.add_style('float: left')
        content_div.add_class("spt_drop_content")

        if instance_type:
            instance_wdg = my.get_instance_wdg(instance_type)
            content_div.add(instance_wdg)

        return div
コード例 #10
0
ファイル: dynamic_list_wdg.py プロジェクト: zieglerm/TACTIC
    def get_item_wdg(self, item, is_template=False):
        item_div = DivWdg()
        item_div.add_style("margin-top: 3px")

        if is_template == True:
            item_div.add_style("display: none")
            #item_div.add_style("border: solid 1px blue")
            item_div.add_class("spt_list_template_item")
        else:
            item_div.add_class("spt_list_item")

        outer = DivWdg()
        outer.add_style("float: left")
        outer.add_style("text-align: left")
        outer.add(item)

        if self.show_enabled:
            checkbox = CheckboxWdg("enabled")
            checkbox.add_style("float: left")
            checkbox.set_checked()
        else:
            checkbox = HiddenWdg("enabled")
        item_div.add(checkbox)

        #item_div.add(item)
        item_div.add(outer)

        from tactic.ui.widget import IconButtonWdg

        add_wdg = DivWdg()
        add_wdg.add_class("hand")
        add_wdg.add_class("SPT_DTS")
        #add_wdg.add("(+)")
        add_wdg.add_class("spt_add")
        button = IconButtonWdg(title="Add Entry", icon="BS_PLUS")
        add_wdg.add(button)
        add_wdg.add_style("float: left")
        add_wdg.add_style("opacity: 0.5")
        #add_wdg.add_style("margin: 3px")
        item_div.add(add_wdg)

        remove_wdg = DivWdg()
        remove_wdg.add_class("hand")
        remove_wdg.add_class("SPT_DTS")
        #remove_wdg.add("(-)")
        remove_wdg.add_class("spt_remove")
        button = IconButtonWdg(title="Remove Entry", icon="BS_REMOVE")
        remove_wdg.add(button)
        remove_wdg.add_style("float: left")
        remove_wdg.add_style("opacity: 0.5")
        #remove_wdg.add_style("margin: 3px")
        item_div.add(remove_wdg)
        item_div.add("<br clear='all'/>")

        return item_div
コード例 #11
0
ファイル: introspect.py プロジェクト: zieglerm/TACTIC
    def get_display(self):

        search_wdg = DivWdg()
        search_wdg.add_class("spt_table_search")
        prefix = HiddenWdg("prefix", "introspect")
        search_wdg.add(prefix)

        hidden = HiddenWdg("introspect", "true")
        search_wdg.add(hidden)

        class_name = HiddenWdg("class_name", "tactic.ui.cgapp.IntrospectWdg")
        search_wdg.add(class_name)

        checkbox = CheckboxWdg("search")
        search_wdg.add("Session Filter: ")
        search_wdg.add(checkbox)

        self.top.add(search_wdg)

        return self.top
コード例 #12
0
ファイル: simple_search_wdg.py プロジェクト: mwx1993/TACTIC
    def get_top(my):
        top = my.top
        top.add_color("background", "background", -5)
        top.add_style("margin-bottom: -2px")
        top.add_class("spt_filter_top")

        table = Table()
        top.add(table)

        table.add_style("margin-left: auto")
        table.add_style("margin-right: auto")
        table.add_style("width: 100%")


        tr = table.add_row()

        if not my.content:
            my.content = DivWdg()
            my.content.add("No Content")

        td = table.add_cell()
        td.add(my.content)
        my.content.add_style("margin: -2 -1 -2 -2")


        show_search = my.kwargs.get("show_search")
        if show_search in [False, 'false']:
            show_search = False
        else:
            show_search = True
        if show_search:
            search_wdg = my.get_search_wdg()
            table.add_row()
            search_wdg.add_style("float: right")

            search_wdg.add_style("padding-top: 6px")
            search_wdg.add_style("padding-left: 10px")
            search_wdg.add_style("height: 33px")

            td = table.add_cell()
            td.add(search_wdg)
            td.add_style("padding: 10px 20px")
            #td.add_border()
            #td.add_color("background", "background", -10)



        hidden = HiddenWdg("prefix", my.prefix)
        top.add(hidden)
        # this cannot be spt_search as it will confuse spt.dg_table.search_cbk() 
        top.add_class("spt_simple_search")

        return top
コード例 #13
0
    def get_display(my):
        top = DivWdg()
        top.add_color("color", "color")
        #top.add_color("background", "background")
        top.add_class("spt_simple_upload_top")

        top.add(my.browse)

        hidden = HiddenWdg("%s|path" % my.get_input_name())
        hidden.add_class("spt_upload_hidden")
        top.add(hidden)

        # this can be used for some other transaction that picks up this file to checkin
        hidden = HiddenWdg("%s|ticket" % my.get_input_name())
        hidden.add_class("spt_upload_ticket")
        top.add(hidden)

        # if not specified, get the sobject's icon context
        my.context = my.kwargs.get("context")
        if not my.context:
            current = my.get_current_sobject()
            if current:
                my.context = current.get_icon_context()
            else:
                from pyasm.biz import Snapshot
                my.context = Snapshot.get_default_context()

        top.add_attr("spt_context", my.context)

        top.add(my.get_info_wdg())

        files_div = DivWdg()
        top.add(files_div)
        files_div.add_class("spt_upload_files")
        files_div.add_style("font-size: 11px")
        files_div.add_style("margin-top: 10px")

        my.add_action()

        return top
コード例 #14
0
    def get_display(self):
        self.display_expr = self.kwargs.get('display_expr')
        self.values = []

        instance_type = self.get_option("instance_type")
        accepted_type = self.get_option("accepted_drop_type")

        div = DivWdg()
        div.add_class("spt_drop_element_top")
        div.add_style("width: 100%")
        div.add_style("min-height: 70px")
        div.add_style("height: auto")
        div.add_style("min-width: 100px")
        div.add_style("max-height: 300px")
        div.add_style("overflow-y: auto")
        div.add_style("overflow-x: hidden")

        self.value_wdg = HiddenWdg(self.get_name())
        self.value_wdg.add_class("spt_drop_element_value")
        div.add(self.value_wdg)

        version = self.parent_wdg.get_layout_version()
        #if version != "2":
        self.add_drop_behavior(div, accepted_type)

        # add the hidden div which holds containers info for the sobject
        template_div = DivWdg()
        template_div.add_style("display: none")
        template_item = self.get_item_div(None)

        # float left for the new icon beside it
        item_div = template_item.get_widget('item_div')
        #item_div.add_style('float: left')

        template_item.add_class("spt_drop_template")
        new_icon = IconWdg("New", IconWdg.NEW)
        new_icon.add_style('padding-left', '3px')
        #TODO: insert the new_icon at add(new_icon, index=0) and make sure
        # the js-side sobject_drop_action cloning align the template div properly
        #template_item.add(new_icon)
        template_div.add(template_item)
        div.add(template_div)

        content_div = DivWdg()
        div.add(content_div)
        content_div.add_class("spt_drop_content")

        if instance_type:
            instance_wdg = self.get_instance_wdg(instance_type)
            content_div.add(instance_wdg)

        return div
コード例 #15
0
    def get_display(my):

        web = WebContainer.get_web()
        args = web.get_form_args()

        # get the args in the URL
        search_type = args['search_type']
        search_id = args['search_id']

        sobject = Search.get_by_search_key("%s|%s" % (search_type,search_id) )

        planner_search_type = my.get_search_type()


        # get parent instances first
        '''
        all_instances = []
        parent_code = ""
        if sobject.has_value("parent_code"):
            parent_code = sobject.get_value("parent_code")
        if parent_code != "":
            parent = sobject.get_by_code(parent_code)

            search = Search(planner_search_type)
            search.add_filter(sobject.get_foreign_key(), parent.get_code())
            instances = search.get_sobjects()

            all_instances.extend(instances)
        '''


        search = Search(planner_search_type)
        search.add_filter(sobject.get_foreign_key(), sobject.get_code())
        instances = search.get_sobjects()
        #all_instances.extend(instances)

        widget = DivWdg()
        widget.add( HiddenWdg("planner_search_type", planner_search_type) )
        widget.add_style("width: 95%")
        widget.add_style("float: right")
        table = TableWdg(search_type, "layout", css='minimal')
        table.table.set_max_width(use_css=True)
        #table.set_sobjects(all_instances)
        table.set_search(search)
        table.do_search()
        table.set_show_property(False)

        #aux_data = ShotInstance.get_aux_data(all_instances)
        #table.set_aux_data(aux_data)
        widget.add(table)
        return widget
コード例 #16
0
    def get_display(self):
        audio_configuration_table = Table()
        audio_configuration_table.set_id('audio_configuration_table')
        audio_configuration_table.add_style('margin', '10px')

        if self.lines:
            audio_configuration_table.add_row()
            audio_configuration_table.add_header('Audio Configuration')

            audio_configuration_table.add_row()
            audio_configuration_table.add_header('Channel')
            audio_configuration_table.add_header('Content')
            audio_configuration_table.add_header('Tone')
            audio_configuration_table.add_header('Peak')

            for iterator, line in enumerate(self.lines):
                current_row = audio_configuration_table.add_row()

                audio_configuration_table.add_cell(
                    self.get_text_input_wdg_for_audio_config(
                        'channel-{0}'.format(iterator), 150,
                        line.get_value('channel')))
                audio_configuration_table.add_cell(
                    self.get_text_input_wdg_for_audio_config(
                        'content-{0}'.format(iterator), 150,
                        line.get_value('content')))
                audio_configuration_table.add_cell(
                    self.get_text_input_wdg_for_audio_config(
                        'tone-{0}'.format(iterator), 150,
                        line.get_value('tone')))
                audio_configuration_table.add_cell(
                    self.get_text_input_wdg_for_audio_config(
                        'peak-{0}'.format(iterator), 150,
                        line.get_value('peak')))
                audio_configuration_table.add_cell(
                    HiddenWdg('audio-line-code-{0}'.format(iterator),
                              line.get_code()))
                audio_configuration_table.add_cell(
                    self.get_remove_row_button(line.get_code()))
        else:
            audio_configuration_table.add(
                "No Audio Configuration lines exist yet. Add one?")

        audio_configuration_table.add(self.get_add_row_button())

        main_div = DivWdg()
        main_div.set_id('audio_config_lines_div')
        main_div.add_style('margin', '10px')
        main_div.add(audio_configuration_table)

        return main_div
コード例 #17
0
    def get_display(my):
        web = WebContainer.get_web()

        if web.get_form_value("Insert/Exit"):
            widget = Widget()
            iframe = WebContainer.get_iframe()
            widget.add( HtmlElement.script(iframe.get_off_script()) )
            widget.add( HtmlElement.script("window.parent.document.form.submit()") )
            return widget


        database = Project.get_project_code()
        search_type = web.get_form_value("search_type")
        assert search_type

        view = web.get_form_value("view")
        if not view:
            view = get_template_view()
        
        widget = DivWdg()

        WebContainer.register_cmd("pyasm.widget.CustomAddElementCbk")

        # remember some parameters
        widget.add( HiddenWdg("search_type", search_type) )
        widget.add( HiddenWdg("view", view) )

        # Get the definition widget and list all of the custom elements
        config = WidgetConfigView.get_by_search_type(search_type,DEFAULT_VIEW)
        element_names = config.get_element_names()

        # show current custom
        widget.add("<h3>Add Element for [%s]</h3>" % search_type)

        widget.add( my.get_new_custom_widget(view) )

        return widget
コード例 #18
0
    def add_header(my, table, title):
        table.add_style('width', '50em')
        
        parent_st = my.kwargs.get('search_type')
        parent_sid =  my.kwargs.get('search_id')

        sobj = Search.get_by_id(parent_st, parent_sid)
        sobj_code = 'New'
        sobj_title = ''
        if sobj:
            sobj_code = sobj.get_code()
            sobj_title = sobj.get_search_type_obj().get_title()
        th = table.add_header( "Append File for %s [%s]" % (sobj_title, sobj_code))
        th.set_attr("colspan", "2")
     
        
        if sobj:
            hidden = HiddenWdg('parent_search_key', SearchKey.get_by_sobject(sobj) )
            th.add(hidden)
コード例 #19
0
    def get_display_old(my):
        '''This is NOT used, just used as a reference for the old method'''
        icon_id = 'upload_div'
        div = DivWdg()

        if my.get_option('upload_type') == 'arbitrary':
            counter = HiddenWdg('upload_counter', '0')
            div.add(counter)
            icon = IconButtonWdg('add upload', icon=IconWdg.ADD)
            icon.set_id(icon_id)
            icon.add_event('onclick', "Common.add_upload_input('%s','%s','upload_counter')" \
                %(icon_id, my.get_input_name()))
            div.add(icon)

        table = Table()
        table.set_class("minimal")
        table.add_style("font-size: 0.8em")

        names = my.get_option('names')
        required = my.get_option('required')
        if not names:
            my.add_upload(table, my.name)
        else:
            names = names.split('|')
            if required:
                required = required.split('|')
                if len(required) != len(names):
                    raise TacticException(
                        'required needs to match the number of names if defined in the config file.'
                    )
            # check for uniqueness in upload_names
            if len(set(names)) != len(names):
                raise TacticException(
                    '[names] in the config file must be unique')

            for idx, name in enumerate(names):
                if required:
                    is_required = required[idx] == 'true'
                else:
                    is_required = False
                my.add_upload(table, name, is_required)

        table.add_row()
コード例 #20
0
    def init(my):

        #info_div = DivWdg()
        #info_div.add_attr("spt_class_name", "pyasm.prod.web.SObjectPlannerWdg")
        #my.add(info_div)

        help = HelpItemWdg(
            'Shot Planner tab',
            'The Shot Planner tab lets you search through your asset library and assign them to one or more shots. On assignment, asset instances are created which can be accessed in the 3D App area. The blue arrows lets you drill down to the assigned instances and shot details information respectively.'
        )
        my.add(help)
        my.add(my.get_action_wdg())

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

        hidden = HiddenWdg("search_type", my.get_search_type())
        my.add(hidden)
        WebState.get().add_state("planner_search_type", my.get_search_type())

        # add the left widget
        left_view = my.get_left_view()
        left_wdg = my.get_left_wdg(left_view)
        td = table.add_cell(left_wdg)
        td.add_style("vertical-align: top")
        td.add_style("width: 50%")

        # add the right widget
        right_view = my.get_right_view()
        right_wdg = my.get_right_wdg(right_view)
        td = table.add_cell(right_wdg)
        td.add_style("width: 50%")
        td.add_style("vertical-align: top")

        my.add(table)
コード例 #21
0
    def handle_item_div(my, item_div, dirname, basename):

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

        icon_string = my.get_file_icon(dirname, basename)

        icon_div = DivWdg()
        td = table.add_cell(icon_div)
        td.add_style("width: 15px")

        icon = IconWdg("%s/%s" % (dirname, basename), icon_string)
        icon_div.add(icon)
        icon_div.add_style("float: left")
        icon_div.add_style("margin-top: -1px")

        path = "%s/%s" % (dirname, basename)
        status = my.path_info.get(path)
        margin_left = -16
        if status == 'same':
            check = IconWdg("No Changes", IconWdg.CHECK, width=12)
        elif status == 'added':
            check = IconWdg("Added", IconWdg.NEW, width=16)
            margin_left = -18
        elif status == 'unversioned':
            check = IconWdg("Unversioned", IconWdg.HELP, width=12)
        elif status == 'missing':
            check = IconWdg("Missing", IconWdg.WARNING, width=12)
        elif status == 'editable':
            check = IconWdg("Editable", IconWdg.EDIT, width=12)
        elif status == 'modified':
            check = IconWdg("Modified", IconWdg.WARNING, width=12)
        else:
            check = IconWdg("Error (unknown status)", IconWdg.ERROR, width=12)

        if check:
            td = table.add_cell(check)
            td.add_style("width: 3px")
            check.add_style("float: left")
            check.add_style("margin-left: %spx" % margin_left)
            check.add_style("margin-top: 4px")
            item_div.add_color("color", "color", [0, 0, 50])

            if status == 'missing':
                item_div.add_style("opacity: 0.3")

        else:
            item_div.add_style("opacity: 0.8")

        name_div = DivWdg()
        td = table.add_cell(name_div)
        name_div.add(basename)
        name_div.add_style("float: left")

        if status != "same":
            name_div.add(" <i style='opacity: 0.5; font-size: 10px'>(%s)</i>" %
                         status)

        spath = path.replace(" ", "_")

        # add the size of the file
        size_div = DivWdg()
        td = table.add_cell(size_div)
        td.add_style("width: 60px")

        size = my.sizes.get(spath)
        if size is None or size == -1:
            size_div.add("-")
        else:
            size_div.add(FormatValue().get_format_value(size, 'KB'))

        size_div.add_style("margin-right: 5px")
        size_div.add_style('text-align: right')

        # FIXME: this still is needed right now, although really used.
        my.subcontext_options = []
        if not my.subcontext_options:
            subcontext = TextWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.add_class("spt_subcontext")
            subcontext.add_style("float: right")

        else:
            subcontext = SelectWdg("subcontext")
            subcontext = HiddenWdg("subcontext")
            subcontext.set_option("show_missing", False)
            subcontext.set_option("values", my.subcontext_options)
            subcontext.add_empty_option("----")

        subcontext.add_behavior({
            'type':
            'click_up',
            'propagate_evt':
            False,
            'cbjs_action':
            '''
            bvr.src_el.focus();
            '''
        })

        subcontext.add_style("display: none")
        item_div.add(subcontext)
コード例 #22
0
ファイル: sobject_load_wdg.py プロジェクト: zieglerm/TACTIC
    def get_display(self):

        widget = Widget()
        self.search_type = self.options.get("search_type")
        if not self.search_type:
            self.search_type = self.kwargs.get("search_type")

        assert self.search_type

        self.load_options_class = self.kwargs.get('load_options_class')

        state = Container.get("global_state")
        if state:
            self.process = state.get("process")
        else:
            self.process = None

        # the filter for searching assets
        div = DivWdg(css='filter_box')
        div.add_color("background", "background2", -35)

        from app_init_wdg import PyMayaInit, PyXSIInit, PyHoudiniInit
        if WebContainer.get_web().get_selected_app() == 'Maya':
            app = PyMayaInit()
        elif WebContainer.get_web().get_selected_app() == 'XSI':
            app = PyXSIInit()
        elif WebContainer.get_web().get_selected_app() == 'Houdini':
            app = PyHoudiniInit()
        div.add(app)

        # add the possibility of a custom callback
        callback = self.options.get('callback')
        if callback:
            hidden = HiddenWdg("callback", callback)
            div.add(hidden)

        # or add the possiblity of a switch mode
        pipeline_type = "load"
        hidden = HiddenWdg("pipeline_type", pipeline_type)

        if self.process:
            process_div = DivWdg()
            process_div.add_style("margin: 10px")
            process_div.add("PROCESS: %s" % self.process)
            process_div.add_style("font-size: 20px")
            widget.add(process_div)

            hidden_wdg = HiddenWdg("process_select_%s" % self.search_type)
            hidden_wdg.set_value(self.process)
            widget.add(hidden_wdg)
        else:
            search_type = self.search_type
            if search_type == 'prod/shot_instance':
                search_type = 'prod/shot'

            process_filter = ProcessFilterWdg(
                self.get_context_data(search_type), search_type)
            span = SpanWdg(process_filter, css='med')
            div.add(span)
            widget.add(div)

        # load options for diff search type
        if self.load_options_class:
            load_options = Common.create_from_class_path(
                self.load_options_class)
        elif self.search_type == 'prod/asset':
            load_options = LoadOptionsWdg()
        elif self.search_type == 'prod/shot':
            load_options = ShotLoadOptionsWdg()
        elif self.search_type == 'prod/shot_instance':
            load_options = AnimLoadOptionsWdg()
        else:
            load_options = LoadOptionsWdg()
        load_options.set_prefix(self.search_type)

        widget.add(load_options)

        return widget
コード例 #23
0
    def get_display(my):

        if not my.preprocessed:
            my.preprocess()

        if my.is_refresh:
            top = Widget()
        else:
            top = DivWdg()
            top.add_class("spt_work_hours_top")

            hidden = HiddenWdg('workhour_data')
            hidden.add_class('spt_workhour_data')

            header_data = {'start_date': str(my.start_date)}
            header_data = jsondumps(header_data).replace('"', "&quot;")
            hidden.set_value(header_data, set_form_value=False)
            top.add(hidden)

        days = []
        for date in my.dates:
            days.append(date.strftime("%Y_%m_%d"))
        today = my.today.strftime("%Y_%m_%d")
        task = my.get_current_sobject()

        if not my.is_refresh:
            my.set_as_panel(top)

        entries = my.entries.get(task.get_code())
        if isinstance(task, Task):
            parent = task.get_parent()
            if not parent:
                disabled = True
            else:
                disabled = False
        else:
            disabled = False

        if not entries:
            entries = {}

        table = Table()
        top.add(table)

        if my.use_straight_time:
            row_list = [my.ST_ROW]
            if my.show_overtime:
                row_list.append(my.OT_ROW)
            prefix_list = ['', 'ot']
        else:
            row_list = [my.STT_ROW, my.ENT_ROW]
            prefix_list = ['stt', 'ent']
        text = HiddenWdg(my.get_name())
        text.add_class("spt_data")

        table.add_color("color", "color")
        table.add_styles("width: %spx; float: left" % my.table_width)
        for row_to_draw in row_list:
            tr = table.add_row()
            tr.add_style('line-height', '8px')

            td = table.add_blank_cell()
            offset_width = my.MONTH_WIDTH + my.LEFT_WIDTH + 8
            td.add_style("min-width: %spx" % offset_width)
            td.add(text)

            # go through each day and draw an input for overtime
            total_hours_st = 0
            total_hours_ot = 0
            search_key = task.get_search_key()

            # Add a label to indicate if the row is straight time or overtime

            time_prefix = ''
            if row_to_draw == my.OT_ROW:
                time_prefix = 'ot'
                div = DivWdg()
                div.add("OT")
                div.add_styles('text-align: right; margin-right: 4px')
                td.add(div)
            elif row_to_draw == my.STT_ROW:
                time_prefix = 'stt'
                div = DivWdg()
                div.add("ST")

                div.add_styles('text-align: right; margin: 0 4px 4px 0')
                td.add(div)
            elif row_to_draw == my.ENT_ROW:
                time_prefix = 'ent'
                div = DivWdg()
                div.add("ET")

                div.add_styles('text-align: right; margin: 0 4px 4px 0')
                td.add(div)

            for idx, day in enumerate(days):
                day_wdg = DivWdg()
                day_wdg.add(day)

                td = table.add_cell()
                td.add_style("width: %spx" % my.day_width)

                text = TextWdg('%sday_%s' % (time_prefix, day))

                if disabled:
                    text.set_option('read_only', 'true')
                    text.set_attr('disabled', 'disabled')

                td.add(text)
                text.add_class('spt_day%s' % (time_prefix))
                text.add_styles(
                    "width: %spx;text-align: right;padding-left: 2px" %
                    (my.day_width - 2))
                #text.add_styles("width: 100%;text-align: right;padding-left: 2px")
                if day == today:
                    text.add_style("border: solid 1px black")

                week_day = my.weekday_dict[idx]
                if week_day in ['Sat', 'Sun']:
                    # MAIN: Overtime, weekend
                    if row_to_draw == my.OT_ROW:
                        text.add_color("background",
                                       "background2",
                                       modifier=[-15, 0, 5])
                    else:
                        text.add_color("background",
                                       "background2",
                                       modifier=[0, 15, 20])

                if row_to_draw == my.OT_ROW:
                    text.add_attr('input_field_type', 'ot')
                else:
                    text.add_attr('input_field_type', 'st')

                if my.kwargs.get('show_all_users') == 'false':
                    pass
                else:
                    text.set_option('read_only', 'true')
                #TODO: while we may have multiple entries per task, we will only use the latest one here
                # for now, making the UI cleaner

                # if a corresponding entry exists, display its value
                entry_list_dict = entries.get(day)
                daily_sum = 0
                value = 0
                entry_list = []
                if entry_list_dict:
                    row_key = my.ROW_DICT.get(row_to_draw)
                    entry_list = entry_list_dict.get(row_key)
                if entry_list:

                    for entry in entry_list:
                        # Check if there is something in the category column.
                        category = entry.get_value("category")
                        if row_to_draw == my.OT_ROW:
                            # Skip if the category field does not have a 'ot' indicated.
                            if not category:
                                print "Warning this work_hour entry has no category [%s]" % entry.get_code(
                                )
                                continue

                        # Check if there exist a value in the straight_time column
                        value, delta = my.get_time_value(entry, row_to_draw)
                        if value:

                            text.set_value(value)
                            text.add_attr('orig_input_value', value)

                            if row_to_draw == my.OT_ROW:
                                total_hours_ot += float(delta)
                            else:
                                total_hours_st += float(delta)

                            daily_sum += delta

                # we only use value instead of the sum "daily_sum" for now
                if row_to_draw == my.OT_ROW:
                    my.summary_ot[idx].update({search_key: daily_sum})
                else:
                    my.summary_st[idx].update({search_key: daily_sum})

                script = '''
                        var orig_value = bvr.src_el.getAttribute("orig_input_value");
                        var input_field_type = bvr.src_el.getAttribute("input_field_type");
                    
                        bvr.src_el.value = bvr.src_el.value.strip();
                        if (bvr.src_el.value == '') {
                            if (orig_value) {
                                bvr.src_el.value = 0;
                            }
                            else {
                                return;
                            }
                        }
                        else if (bvr.src_el.value == orig_value) {
                            return;
                        }

                       
                        bvr.prefix_list.splice( bvr.prefix_list.indexOf(bvr.time_prefix),1)
                        var other_time_prefix = bvr.prefix_list[0];
                        spt.work_hour.update_total(bvr, '.spt_day' + bvr.time_prefix);

                        // register this as changed item
                        var all_top_el = bvr.src_el.getParent(".spt_work_hours_top");

                        var values1 = spt.api.Utility.get_input_values(all_top_el, '.spt_day'+ bvr.time_prefix, false);
                        var values2 = spt.api.Utility.get_input_values(all_top_el, '.spt_day'+ other_time_prefix, false);

                        // Merge values from straight time and overtime fields in values variable.
                        for (var attr in values2) {
                            values1[attr] = values2[attr];
                        }

                        for (val in values1) {
                            if (values1[val] && isNaN(values1[val])) {
                                spt.error('You have non-numeric values in your work hours. Please correct it: ' + values[val]);
                                return;
                            }
                        }
                        delete values1.data; 
                        var value_wdg = all_top_el.getElement(".spt_data");

                        var value = JSON.stringify(values1);
                        value_wdg.value = value;
                        
                        var layout = bvr.src_el.getParent(".spt_layout");
                        var version = layout.getAttribute("spt_version");
                        if (version == "2") {
                            spt.table.set_layout(layout);
                            spt.table.accept_edit(all_top_el, value, false);
                        }
                        else {
                            var cached_data = {};
                            spt.dg_table.edit.widget = all_top_el;
                            spt.dg_table.inline_edit_cell_cbk( value_wdg, cached_data );
                        }
                        '''
                # accept on pressing Enter
                behavior = {
                    'type':
                    'keydown',
                    'time_prefix':
                    time_prefix,
                    'prefix_list':
                    prefix_list,
                    'cbjs_action':
                    '''
                   if (evt.key=='enter') {
                       %s
                    }

                ''' % script
                }

                text.add_behavior(behavior)

                behavior = {
                    'type':
                    'blur',
                    'time_prefix':
                    time_prefix,
                    'prefix_list':
                    prefix_list,
                    'cbjs_action':
                    '''
                        %s

                ''' % script
                }
                text.add_behavior(behavior)

            text = TextWdg("total")
            td = table.add_cell(text)
            td.add_style("width: 35px")

            text.add_attr('spt_total', '.spt_total%s' % (time_prefix))
            text.add_class('spt_total%s' % (time_prefix))
            text.add_styles(
                "width: %spx; text-align: right; padding-right: 3px" %
                my.day_width)
            text.set_attr("readonly", "readonly")

            # MAIN: Overtime, total.
            if row_to_draw == my.OT_ROW:
                text.add_color("background",
                               "background2",
                               modifier=[5, -15, 0])
                if total_hours_ot:
                    text.set_value("%0.1f" % total_hours_ot)
                my.summary_ot[7].update({search_key: total_hours_ot})
            else:
                text.add_color("background",
                               "background2",
                               modifier=[20, 0, 15])
                if total_hours_st:
                    text.set_value("%0.1f" % total_hours_st)
                my.summary_st[7].update({search_key: total_hours_st})
            td = table.add_blank_cell()
            td.add_style('width: 100%')

        return top
コード例 #24
0
    def get_title(my):

        div = DivWdg()
        div.add_behavior({'type': 'load', 'cbjs_action': my.get_onload_js()})
        # for csv export
        hid = HiddenWdg('start_date', my.start_date)
        div.add(hid)

        mday = my.today.strftime("%d")
        mmonth = my.today.strftime("%m")

        my.weekday_dict = {}
        days = []
        for idx, date in enumerate(my.dates):
            day_div = DivWdg()
            days.append(day_div)
            week_day = date.strftime("%a")
            day_div.add("%s<br/>%s" % (week_day, date.strftime("%d")))
            my.weekday_dict[idx] = week_day

        table = Table()
        div.add(table)
        table.add_row()
        table.add_color("color", "color")
        table.add_style("width: %spx" % my.table_width)
        table.add_style("float: left")

        month_div = FloatDivWdg(my.start_date.strftime("%b"))
        month_div.add_style('font-weight: 600')
        td = table.add_cell(month_div)
        td.add_style('width', '%spx' % my.MONTH_WIDTH)

        icon = IconButtonWdg(tip="Previous Week", icon=IconWdg.LEFT)
        td = table.add_cell(icon)
        offset = 0
        if not my.use_straight_time:
            offset = 12
        td.add_style("width: %spx" % (my.LEFT_WIDTH + offset))

        display_days = my.days_per_page
        next_start_date = my.start_date + datetime.timedelta(days=display_days)
        prev_start_date = my.start_date + datetime.timedelta(
            days=-display_days)

        icon.add_behavior({
            'type':
            'click_up',
            'start_date':
            prev_start_date.__str__(),
            'cbjs_action':
            '''
           spt.app_busy.show('Loading previous week...');
           var header = bvr.src_el.getParent('.spt_table_header');
           if (!header) {
                spt.alert('Work hour widget requires the new Fast Table Layout to scroll to previous week. You can do so in [Manage Side Bar].');
                spt.app_busy.hide();
                return;
           } 
           var cur_name = spt.table.get_element_name_by_header(header);
           var values = {'start_date': bvr.start_date};
           spt.table.refresh_column(cur_name, values);

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

        for day in days:
            day_wdg = DivWdg()
            day_wdg.add(day)

            td = table.add_cell()
            td.add(day_wdg)
            td.add_styles(
                "text-align: center; padding-left: 2px;min-width: %spx" %
                my.day_width)

        icon = IconButtonWdg(tip="Next Week", icon=IconWdg.RIGHT)
        icon.add_behavior({
            'type':
            'click_up',
            'start_date':
            next_start_date.__str__(),
            'cbjs_action':
            '''
           spt.app_busy.show('Loading next week...');
           var header = bvr.src_el.getParent('.spt_table_header');
           if (!header) {
                spt.alert('Work hour widget requires the new Fast Table Layout to scroll to next week. You can do so in [Manage Side Bar].');
                spt.app_busy.hide();
                return;
           } 
           var cur_name = spt.table.get_element_name_by_header(header);
           var values = {'start_date': bvr.start_date};
           spt.table.refresh_column(cur_name, values);
           spt.app_busy.hide();

        
        '''
        })
        td = table.add_cell(icon)
        td.add_style('width: %spx' % my.day_width)
        # empty total cell
        td = table.add_blank_cell()
        td.add_style('width: 100%')

        return div
コード例 #25
0
    def get_display(self):

        top = self.top
        top.add_class("spt_upload_top")
        top.add_style("display: inline-block")

        title = self.kwargs.get("title")
        name = self.kwargs.get("name")

        if not name:
            name = "upload"

        if not title:
            title = Common.get_display_title(name)

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

        hidden = HiddenWdg(name)
        top.add(hidden)

        multiple = self.kwargs.get("multiple")
        if multiple in [True, 'true']:
            multiple = True
        else:
            multiple = False

        if self.upload_id:
            upload_id = self.upload_id
        else:
            upload = Html5UploadWdg(name=name, multiple=multiple)
            top.add(upload)
            upload_id = upload.get_upload_id()

        button = self.get_activator_wdg(title)

        button_id = self.kwargs.get("id")
        if button_id:
            button.set_id(button_id)
        top.add(button)

        upload_init = self.kwargs.get("upload_init")
        if not upload_init:
            upload_init = ""

        upload_start = self.kwargs.get("upload_start")
        if not upload_start:
            upload_start = '''
            var top = bvr.src_el.getParent(".spt_upload_top");
            var hidden = top.getElement(".spt_input");
            var file = spt.html5upload.get_file();
            if (!file) {
               return;
            }
            hidden.value = file.name;
            '''

        on_complete = self.get_on_complete()
        if not on_complete:
            on_complete = '''
            var files = spt.html5upload.get_files();
            if (files.length == 0) {
               alert('Error: files cannot be found.')
               spt.app_busy.hide();
               return;
            }

            spt.notify.show_message("Uploaded "+files.length+" files");
            spt.app_busy.hide();
            '''

        upload_progress = self.kwargs.get("upload_progress")
        if not upload_progress:
            upload_progress = '''
            var percent = Math.round(evt.loaded * 100 / evt.total);
            spt.app_busy.show("Uploading ["+percent+"% complete]");
            '''

        reader_load = self.kwargs.get("reader_load")
        if not reader_load:
            reader_load = ""

        button.add_behavior({
            'type':
            'click_up',
            'upload_id':
            upload_id,
            'search_key':
            search_key,
            'ticket':
            self.ticket,
            'multiple':
            multiple,
            'kwargs':
            self.on_complete_kwargs,
            'cbjs_action':
            '''
            var search_key = bvr.search_key;

            // set the form
            if (!spt.html5upload.form) {
                spt.html5upload.set_form( $(bvr.upload_id) );
            }
            spt.html5upload.clear();
            spt.html5upload.kwargs = bvr.kwargs;

            var file_obj = spt.html5upload.form.getElement(".spt_file");
           
            var is_multiple = bvr.multiple == true;
        


            var upload_start = function(evt) {
            %s;
            }

            var upload_progress = function(evt) {
            %s;
            }

            // set an action for completion
            var upload_complete = function(evt) {
            %s;
            spt.app_busy.hide();
            }

            var reader_load = function(file) {
            %s;
            }

            var upload_file_kwargs =  {
                  reader_load: reader_load,
                  upload_start: upload_start,
                  upload_complete: upload_complete,
                  upload_progress: upload_progress
                };
            if (bvr.ticket)
               upload_file_kwargs['ticket'] = bvr.ticket; 
            else if (spt.html5upload.ticket) {
                
               upload_file_kwargs['ticket'] = spt.html5upload.ticket; 
            }


            var onchange = function () {
                %s;
                spt.html5upload.upload_file(upload_file_kwargs);
	    }

	    if (is_multiple) {
                file_obj.setAttribute('multiple','multiple');
                spt.html5upload.select_files(onchange);
            }
            else
                spt.html5upload.select_file(onchange);

            ''' % (upload_start, upload_progress, on_complete, reader_load,
                   upload_init)
        })

        return top
コード例 #26
0
    def get_display(my):

        top_wdg = DivWdg()
        top_wdg.add_style("color: black")
        top_wdg.add_style("width: 350px")
        top_wdg.add_style("margin-top: 10px")
        top_wdg.add_style("padding: 10px")
        top_wdg.add_border()
        title = DivWdg()
        title.add_style("color: black")
        title.add_style("margin-top: -22px")

        top_wdg.add(title)
        #if not my.name_string:
        #    title.add('No database column')
        #    return top_wdg

        title.add("Widget Definition")

        widget_types = {
            'foreign_key': 'tactic.ui.table.ForeignKeyElementWdg',
            'button': 'tactic.ui.table.ButtonElementWdg',
            'expression': 'tactic.ui.table.ExpressionElementWdg'
        }

        web = WebContainer.get_web()
        config_string = web.get_form_value("config_xml")
        if not config_string:
            config_string = '<config/>'
        xml = Xml()
        xml.read_string(config_string)

        #print "config_string: ", config_string

        # get values from the config file
        element_name = xml.get_value('element/@name')

        config = WidgetConfig.get(
            view='element',
            xml='<config><element>%s</element></config>' % config_string)
        display_options = config.get_display_options(element_name)

        title = xml.get_value('element/@title')
        display_handler = xml.get_value('element/display/@class')
        if not display_handler:
            display_handler = 'tactic.ui.panel.TypeTableElementWdg'

        widget_name = xml.get_value('element/display/@widget')
        if not widget_name:
            widget_name = 'custom'

        custom_table = Table()
        custom_table.add_style("color: black")
        top_wdg.add(custom_table)

        name_text = DivWdg()
        name_text.add_style("color: black")
        name_text.add(element_name)
        custom_table.add_row()
        custom_table.add_cell("Name: ")
        custom_table.add_cell(name_text)

        # add title
        custom_table.add_row()
        title_wdg = TextWdg("custom_title")
        title_wdg.set_value(title)
        title_wdg.add_attr("size", "50")
        custom_table.add_cell("Title: ")
        custom_table.add_cell(title_wdg)

        # add description
        #custom_table.add_row()
        #description_wdg = TextAreaWdg("custom_description")
        #td = custom_table.add_cell( "Description: " )
        #td.add_style("vertical-align: top")
        #custom_table.add_cell( description_wdg )

        type_select = SelectWdg("custom_type")
        #type_select.add_empty_option("-- Select --")

        type_select.set_option(
            "values",
            "string|integer|float|boolean|currency|date|foreign_key|link|list|button|custom"
        )
        type_select.set_option(
            "labels",
            "String(db)|Integer(db)|Float(db)|Boolean(db)|Currency(db)|Date(db)|Foreign Key|Link|List|Button|Custom"
        )
        type_select.set_value(widget_name)

        #type_select.set_option("values", "string|integer|float|boolean|currency|date|link|list|foreign_key|button|empty")
        #type_select.set_option("labels", "String|Integer|Float|Boolean|Currency|Date|Link|List|Foreign Key|Button|Empty")
        custom_table.add_row()
        td = custom_table.add_cell("Widget Type: ")
        td.add_style("vertical-align: top")
        td = custom_table.add_cell(type_select)
        type_select.add_event(
            "onchange", "spt.CustomProject.property_type_select_cbk(this)")

        td.add(HtmlElement.br())
        display_handler_text = TextWdg("display_handler")
        display_handler_text.add_attr("size", "50")
        display_handler_text.set_value(display_handler)
        td.add(display_handler_text)

        # extra info for foreign key
        custom_table.add_row()
        div = DivWdg()
        div.add_class("foreign_key_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())

        # extra info for foreign key
        custom_table.add_row()
        div = DivWdg()
        div.add_class("foreign_key_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Relate to: ")
        search_type_select = SearchTypeSelectWdg(
            "foreign_key_search_select",
            mode=SearchTypeSelectWdg.CURRENT_PROJECT)
        div.add(search_type_select)
        td.add(div)

        # extra info for list
        custom_table.add_row()
        div = DivWdg()
        div.add_class("list_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Values: ")
        search_type_text = TextWdg("list_values")
        div.add(search_type_text)
        td.add(div)

        # extra info for button
        custom_table.add_row()
        div = DivWdg()
        div.add_style("color: black")
        div.add_class("button_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")

        #class_path = "tactic.ui.table.ButtonElementWdg"
        class_path = display_handler
        button = Common.create_from_class_path(class_path)
        args_keys = button.get_args_keys()

        div.add("Options")
        div.add(HtmlElement.br())

        for key in args_keys.keys():
            option_name_text = HiddenWdg("option_name")
            option_name_text.set_value(key)
            div.add(option_name_text)

            div.add("%s: " % key)
            div.add(" &nbsp; &nbsp;")

            input = button.get_input_by_arg_key(key)

            value = display_options.get(key)
            if value:
                input.set_value(value)

            div.add(input)
            div.add(HtmlElement.br())
        td.add(div)

        # is searchable checkbox
        #custom_table.add_row()
        #current_searchable_wdg = CheckboxWdg("is_searchable")
        #current_view_wdg.set_checked()
        #custom_table.add_cell("Searchable? ")
        #td = custom_table.add_cell(current_searchable_wdg)

        custom_table.close_tbody()

        return top_wdg
コード例 #27
0
    def get_simple_definition_wdg(my):

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

        title.add("Column Definition")

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

        detail_wdg.add(HtmlElement.br(2))

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

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

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

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

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

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

        detail_wdg.add(nullable)

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

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

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

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

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


            '''
        })

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

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

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

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

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

        return detail_wdg
コード例 #28
0
    def get_new_definition_wdg(my):
        detail_wdg = DivWdg()
        detail_wdg.add_style("color: black")
        detail_wdg.add_style("width: 350px")
        detail_wdg.add_style("margin-top: 10px")
        detail_wdg.add_style("padding: 10px")
        detail_wdg.add_border()
        title = DivWdg()
        title.add_style("color: black")
        title.add("Column Definition")
        title.add_style("margin-top: -22px")
        detail_wdg.add(title)

        # add a name entry
        title = SpanWdg()
        detail_wdg.add("Name: ")
        detail_wdg.add(title)
        input = SpanWdg()
        input.add_style('padding-top: 6px')
        input.set_id("config_element_name")
        text = TextWdg('column_name')
        text.set_value(my.name_string)
        input.add(text)
        detail_wdg.add(input)
        hidden = HiddenWdg('target_search_type', my.search_type)
        detail_wdg.add(hidden)

        detail_wdg.add(HtmlElement.br(2))

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

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

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

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

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

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

        detail_wdg.add(nullable)

        return detail_wdg
コード例 #29
0
    def get_display(my):

        # add the detail widget
        detail_wdg = DivWdg(css='spt_detail_panel')
        if not my.name_string and not my.config_string:
            detail_wdg.add("<br/>" * 3)
            detail_wdg.add('<- Click on an item on the left for modification.')
            detail_wdg.add_style("padding: 10px")
            detail_wdg.add_color("background", "background", -5)
            detail_wdg.add_style("width: 350px")
            detail_wdg.add_style("height: 400px")
            detail_wdg.add_border()

            return detail_wdg

        if my.kwargs.get("mode") == "empty":
            overlay = DivWdg()
            detail_wdg.add(overlay)

        detail_wdg.add_border()
        detail_wdg.add_color("color", "black")
        detail_wdg.add_style("padding: 10px")
        detail_wdg.add_color("background", "background", -5)

        detail_wdg.set_id('search_type_detail')

        # put in the selection for simple or advanced
        select = SelectWdg("config_mode", label='Mode: ')
        select.set_persistence()
        values = ['simple', 'advanced']
        select.set_option("values", values)
        config_mode = select.get_value()
        #select.add_behavior({"type": "change", "cbjs_action": "spt.simple_display_toggle( spt.get_cousin(bvr.src_el, '.spt_detail_panel','.config_simple') )"})
        select.add_behavior({"type": "change", "cbjs_action": \
            "spt.simple_display_toggle( spt.get_cousin(bvr.src_el, '.spt_detail_panel','.config_advanced')); %s" %select.get_save_script()})

        select.add_class('spt_config_mode')

        title_div = DivWdg("Column Detail")
        title_div.add_class("maq_search_bar")
        detail_wdg.add(title_div)
        detail_wdg.add("<br/>")
        detail_wdg.add(select)
        detail_wdg.add(HtmlElement.br(2))

        #simple_mode_wdg = WidgetDetailSimpleModeWdg()
        #detail_wdg.add(simple_mode_wdg)
        #detail_wdg.add(HtmlElement.br(2))

        if my.is_new_column:
            detail_wdg.add(my.get_new_definition_wdg())
        else:

            simple_wdg = my.get_simple_definition_wdg()

            simple_wdg.add_class("config_simple")
            detail_wdg.add(simple_wdg)
            adv_wdg = my.get_advanced_definition_wdg()
            adv_wdg.add_class("config_advanced")
            if config_mode == 'simple':
                adv_wdg.add_style('display: none')
            detail_wdg.add(HtmlElement.br(2))
            detail_wdg.add(adv_wdg)

        detail_wdg.add(HtmlElement.br(2))

        security_wdg = my.get_security_wdg()
        detail_wdg.add(security_wdg)

        # add hidden input for view for panel refreshing
        # we are only interested in whether it is project_view or definition
        # sub-views of project_view is not of our interest

        #if my.view != 'project_view':
        #    my.view = 'custom_definition'
        detail_wdg.add(HiddenWdg('view', my.view))

        return detail_wdg
コード例 #30
0
    def get_display(my):

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

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

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

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

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

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

        top.add("<br/>")

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            try {

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

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

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

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

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

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

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

            }
            else {

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

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

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

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


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

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

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

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

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

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

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

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

        return top