def get_delivery_snapshot_section(self):
        label_value_pairs = (
            ('Feature', 'feature_delivery_snapshot'),
            ('Trailer', 'trailer_delivery_snapshot'),
            ('Alt Audio', 'alt_audio_delivery_snapshot'),
            ('Subtitle', 'subtitle_delivery_snapshot'),
            ('CC', 'cc_delivery_snapshot'),
            ('Vendor Notes', 'vendor_notes_delivery_snapshot'),
            ('Poster Art', 'poster_art_delivery_snapshot'),
            ('Dub Card', 'dub_card_delivery_snapshot')
        )

        table = Table()
        table.add_style('float', 'left')

        table.add_row()
        table.add_header('Delivery Snapshot')

        for label_value_pair in label_value_pairs:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell(self.get_true_false_select_wdg(value))

        section_div = DivWdg()
        section_div.add(table)

        return section_div
예제 #2
0
    def get_delivery_snapshot_section(self):
        label_value_pairs = (('Feature', 'feature_delivery_snapshot'),
                             ('Trailer', 'trailer_delivery_snapshot'),
                             ('Alt Audio', 'alt_audio_delivery_snapshot'),
                             ('Subtitle', 'subtitle_delivery_snapshot'),
                             ('CC', 'cc_delivery_snapshot'),
                             ('Vendor Notes',
                              'vendor_notes_delivery_snapshot'),
                             ('Poster Art', 'poster_art_delivery_snapshot'),
                             ('Dub Card', 'dub_card_delivery_snapshot'))

        table = Table()
        table.add_style('float', 'left')

        table.add_row()
        table.add_header('Delivery Snapshot')

        for label_value_pair in label_value_pairs:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell(self.get_true_false_select_wdg(value))

        section_div = DivWdg()
        section_div.add(table)

        return section_div
예제 #3
0
    def get_section_four_table_two(self, label_value_pairs):
        table = Table()

        table.add_row()
        table.add_header('Poster Art (One Sheet)')

        for label_value_pair in label_value_pairs:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell(self.get_true_false_select_wdg(value))

        return table
예제 #4
0
    def get_section_one_table_three(self, label_value_pairs):
        table = Table()

        table.add_row()
        table.add_header('Confirm the build of trailer/preview')

        for label_value_pair in label_value_pairs:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell(self.get_true_false_select_wdg(value))

        return table
예제 #5
0
    def get_section_two_bottom_table(self):
        table = Table()
        table.add_style('margin', '10px')
        table.add_row()

        table.add_header('')
        table.add_header('Feature')
        table.add_header('Audio Bundle')
        table.add_header('Trailer/Preview')

        label_value_pairs = ((
            'Audio configuration verified (stereo or mono/mapping is correct)?',
            'audio_configuration_verified'
        ), ('Audio is in sync with video (checked in 3 random spots and head/tail)?',
            'audio_in_sync_with_video'), (
                'Audio is tagged correctly?', 'audio_tagged_correctly'
            ), ('No audio is cut off (at beginning or end)?',
                'no_audio_cut_off'), (
                    'TRT of audio equals TRT of the video?',
                    'trt_audio_equals_trt_video'
                ), ('Correct language is present (on applicable channels)?',
                    'correct_language_present'))

        for label_value_pair in label_value_pairs:
            table.add_row()
            table.add_cell(label_value_pair[0])

            for section in ('feature', 'audio', 'preview'):
                table.add_cell(
                    self.get_true_false_select_wdg(label_value_pair[1] + '_' +
                                                   section))

        return table
예제 #6
0
    def get_element_profile_table(self):
        element_profile_table = Table()

        element_profile_table.add_row()
        element_profile_table.add_header('Element Profile')

        element_profile_table.add_row()
        element_profile_table.add_cell('Total Runtime')
        element_profile_table.add_cell(get_text_input_wdg('total_runtime',
                                                          get_attribute_or_none(self, 'total_runtime'), 300))
        element_profile_table.add_cell('Language')
        element_profile_table.add_cell(self.get_language_select())

        element_profile_table.add_row()
        element_profile_table.add_cell('TV/Feature/Trailer')
        element_profile_table.add_cell(get_text_input_wdg('tv_feature_trailer',
                                                          get_attribute_or_none(self, 'tv_feature_trailer'), 300))
        element_profile_table.add_cell('(CC)/Subtitles')
        element_profile_table.add_cell(get_text_input_wdg('cc_subtitles',
                                                          get_attribute_or_none(self, 'cc_subtitles'), 300))

        element_profile_table.add_row()
        element_profile_table.add_cell('Video Aspect Ratio')
        element_profile_table.add_cell(self.get_video_aspect_ratio_select_wdg())
        element_profile_table.add_cell('VITC')
        element_profile_table.add_cell(get_text_input_wdg('vitc', get_attribute_or_none(self, 'vitc'), 300))

        element_profile_table.add_row()
        element_profile_table.add_cell('Textless @ Tail')
        element_profile_table.add_cell(get_text_input_wdg('textless_tail',
                                                          get_attribute_or_none(self, 'textless_tail'), 300))
        element_profile_table.add_cell('Source Barcode')
        element_profile_table.add_cell(get_text_input_wdg('source_barcode',
                                                          get_attribute_or_none(self, 'source_barcode'), 300))

        element_profile_table.add_row()
        element_profile_table.add_cell('Notices')
        element_profile_table.add_cell(get_text_input_wdg('notices',
                                                          get_attribute_or_none(self, 'notices'), 300))
        element_profile_table.add_cell('Element QC Barcode')
        element_profile_table.add_cell(get_text_input_wdg('element_qc_barcode',
                                                          get_attribute_or_none(self, 'element_qc_barcode'), 300))

        element_profile_table.add_row()
        element_profile_table.add_cell('Label')
        element_profile_table.add_cell(self.get_label_select_wdg())
        element_profile_table.add_cell('Record Date')
        element_profile_table.add_cell(self.get_record_date_calendar_wdg())

        return element_profile_table
    def get_section_two_bottom_table(self):
        table = Table()
        table.add_style('margin', '10px')
        table.add_row()

        table.add_header('')
        table.add_header('Feature')
        table.add_header('Audio Bundle')
        table.add_header('Trailer/Preview')

        label_value_pairs = (
            ('Audio configuration verified (stereo or mono/mapping is correct)?', 'audio_configuration_verified'),
            ('Audio is in sync with video (checked in 3 random spots and head/tail)?', 'audio_in_sync_with_video'),
            ('Audio is tagged correctly?', 'audio_tagged_correctly'),
            ('No audio is cut off (at beginning or end)?', 'no_audio_cut_off'),
            ('TRT of audio equals TRT of the video?', 'trt_audio_equals_trt_video'),
            ('Correct language is present (on applicable channels)?', 'correct_language_present')
        )

        for label_value_pair in label_value_pairs:
            table.add_row()
            table.add_cell(label_value_pair[0])

            for section in ('feature', 'audio', 'preview'):
                table.add_cell(self.get_true_false_select_wdg(label_value_pair[1] + '_' + section))

        return table
    def get_section_one_table_three(self, label_value_pairs):
        table = Table()

        table.add_row()
        table.add_header('Confirm the build of trailer/preview')

        for label_value_pair in label_value_pairs:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell(self.get_true_false_select_wdg(value))

        return table
    def get_section_four_table_two(self, label_value_pairs):
        table = Table()

        table.add_row()
        table.add_header('Poster Art (One Sheet)')

        for label_value_pair in label_value_pairs:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell(self.get_true_false_select_wdg(value))

        return table
예제 #10
0
    def get_section_four_table_one(self, label_value_pairs):
        table = Table()
        table.add_style('float', 'left')

        table.add_row()
        table.add_header('Chapter Thumbnails')

        for label_value_pair in label_value_pairs:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell(self.get_true_false_select_wdg(value))

        return table
예제 #11
0
    def get_section_one_table_two(self, label_value_pairs):
        table = Table()
        table.add_style('float', 'left')

        table.add_row()
        table.add_header('Confirm the build of the feature')

        for label_value_pair in label_value_pairs:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell(self.get_true_false_select_wdg(value))

        return table
    def get_section_four_table_one(self, label_value_pairs):
        table = Table()
        table.add_style('float', 'left')

        table.add_row()
        table.add_header('Chapter Thumbnails')

        for label_value_pair in label_value_pairs:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell(self.get_true_false_select_wdg(value))

        return table
    def get_section_one_table_two(self, label_value_pairs):
        table = Table()
        table.add_style('float', 'left')

        table.add_row()
        table.add_header('Confirm the build of the feature')

        for label_value_pair in label_value_pairs:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell(self.get_true_false_select_wdg(value))

        return table
예제 #14
0
    def get_sobject_info_wdg(my):
        div = DivWdg()
        return div

        attr_table = Table()
        div.add(attr_table)

        attr_table.add_color("color", "color")

        sobject = my.get_sobject()

        titles, exprs = my.get_sobject_info()
        for title, expr in zip(titles, exprs):
            try:
                value = Search.eval(expr, sobject)
            except Exception, e:
                print "WARNING: ", e.message
                continue

            if value == '':
                value = '<i>none</i>'
            if len(value) > 100:
                value = "%s..." % value[:100]

            attr_table.add_row()
            th = attr_table.add_header("%s: " % title)
            th.add_style("text-align: left")
            td = attr_table.add_cell(value)
예제 #15
0
def get_files_checkbox_from_file_list(file_sobjects, selected_file_sobjects):
    """
    Given a list of file sobjects, return a table of Checkbox widgets (CheckboxWdg) using the file paths and codes.
    If a file is also in the selected_file_sobjects list, check it automatically.

    :param file_sobjects: List of file sobjects
    :param selected_file_sobjects: List of file sobjects (that are already selected)
    :return: Table
    """

    files_checkbox_table = Table()

    header_row = files_checkbox_table.add_row()
    header = files_checkbox_table.add_header(data='Files', row=header_row)
    header.add_style('text-align', 'center')
    header.add_style('text-decoration', 'underline')

    for file_sobject in file_sobjects:
        checkbox = CheckboxWdg(name=file_sobject.get_code())

        if file_sobject.get_code() in [
                selected_file.get_code()
                for selected_file in selected_file_sobjects
        ]:
            checkbox.set_checked()

        checkbox_row = files_checkbox_table.add_row()

        files_checkbox_table.add_cell(data=checkbox, row=checkbox_row)
        files_checkbox_table.add_cell(data=file_sobject.get_value('file_path'),
                                      row=checkbox_row)

    return files_checkbox_table
예제 #16
0
    def get_sobject_info_wdg(my):
        div = DivWdg()
        return div

        attr_table = Table()
        div.add(attr_table)

        attr_table.add_color("color", "color")

        sobject = my.get_sobject()

        titles, exprs = my.get_sobject_info()
        for title, expr in zip(titles, exprs):
            try:
                value = Search.eval(expr, sobject)
            except Exception, e:
                print "WARNING: ", e.message
                continue


            if value == '':
                value = '<i>none</i>'
            if len(value) > 100:
                value = "%s..." % value[:100]

            attr_table.add_row()
            th = attr_table.add_header("%s: " % title)
            th.add_style("text-align: left")
            td = attr_table.add_cell(value)
예제 #17
0
def get_files_checkbox_from_file_list(file_sobjects, selected_file_sobjects):
    """
    Given a list of file sobjects, return a table of Checkbox widgets (CheckboxWdg) using the file paths and codes.
    If a file is also in the selected_file_sobjects list, check it automatically.

    :param file_sobjects: List of file sobjects
    :param selected_file_sobjects: List of file sobjects (that are already selected)
    :return: Table
    """

    files_checkbox_table = Table()

    header_row = files_checkbox_table.add_row()
    header = files_checkbox_table.add_header(data='Files', row=header_row)
    header.add_style('text-align', 'center')
    header.add_style('text-decoration', 'underline')

    for file_sobject in file_sobjects:
        checkbox = CheckboxWdg(name=file_sobject.get_code())

        if file_sobject.get_code() in [selected_file.get_code() for selected_file in selected_file_sobjects]:
            checkbox.set_checked()

        checkbox_row = files_checkbox_table.add_row()

        files_checkbox_table.add_cell(data=checkbox, row=checkbox_row)
        files_checkbox_table.add_cell(data=file_sobject.get_value('file_path'), row=checkbox_row)

    return files_checkbox_table
예제 #18
0
파일: week_wdg.py 프로젝트: mincau/TACTIC
    def get_display(self):
        top = self.top
        top.add_style("padding: 20px")
        top.add_color("background", "background")

        start_date = 'xxx' 
        end_date = 'xxx'

        days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']

        start_time = '06:00'
        end_time = '21:00'

        table = Table()
        top.add(table)

        table.add_row()
        table.add_header()
        for day in days:
            td = table.add_header(day)

        for hour in xrange(6, 21):
            tr = table.add_row()

            td = table.add_cell()
            td.add("%0.2d:00" % hour)
            td.add_color("background", "background3")

            for day in days:
                td = table.add_cell()

                day_div = DivWdg()
                td.add(day_div)
                day_div.add_style("width: 100px")
                day_div.add_style("height: 50px")
                day_div.add_border()



            day_div = DivWdg()



        return top
예제 #19
0
    def get_video_measurements_table(self):
        video_measurements_table = Table()

        video_measurements_table.add_row()
        video_measurements_table.add_header('Video Measurements')

        text_input_name_id_pairs = [
            ('Active Video Begins', 'active_video_begins'),
            ('Active Video Ends', 'active_video_ends'),
            ('Horizontal Blanking', 'horizontal_blanking'),
            ('Luminance Peak', 'luminance_peak'),
            ('Chroma Peak', 'chroma_peak'),
            ('Head Logo', 'head_logo'),
            ('Tail Logo', 'tail_logo')
        ]

        self.setup_table_rows_with_input_boxes(video_measurements_table, text_input_name_id_pairs)

        return video_measurements_table
예제 #20
0
    def get_display(my):
        top = my.top
        top.add_style("padding: 20px")
        top.add_color("background", "background")

        start_date = 'xxx'
        end_date = 'xxx'

        days = [
            'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday',
            'Saturday'
        ]

        start_time = '06:00'
        end_time = '21:00'

        table = Table()
        top.add(table)

        table.add_row()
        table.add_header()
        for day in days:
            td = table.add_header(day)

        for hour in xrange(6, 21):
            tr = table.add_row()

            td = table.add_cell()
            td.add("%0.2d:00" % hour)
            td.add_color("background", "background3")

            for day in days:
                td = table.add_cell()

                day_div = DivWdg()
                td.add(day_div)
                day_div.add_style("width: 100px")
                day_div.add_style("height: 50px")
                day_div.add_border()

            day_div = DivWdg()

        return top
    def get_audio_configuration_section_table(self, name, id, float_left=True):
        table = Table()

        if float_left:
            table.add_style('float: left')

        table.add_style('margin', '10px')
        table.add_row()
        table.add_header(name)

        for i in range(1, 9):
            table.add_row()

            label_cell = table.add_cell('TRK. {0}'.format(i))
            label_cell.add_style('padding', '10px 10px 10px 0px')

            table.add_cell(self.get_language_select_wdg(id + '_language_' + str(i)))
            table.add_cell(self.get_type_select_wdg(id + '_type_' + str(i)))

        return table
    def get_operator_section(self):
        operator_table = Table()
        operator_table.add_attr('class', 'operator_table')
        operator_table.add_row()
        operator_table.add_header('DATE')
        operator_table.add_header('OPERATOR')
        operator_table.add_header('STYLE')
        operator_table.add_header('BAY')
        operator_table.add_header('MACHINE')
        operator_table.add_row()

        operator_table.add_cell(self.get_date_calendar_wdg())

        operator_table.add_cell(get_text_input_wdg('operator', get_attribute_or_none(self, 'operator')))

        operator_table.add_cell(self.get_style_select())
        operator_table.add_cell(self.get_bay_select())
        operator_table.add_cell(self.get_machine_select())

        return operator_table
예제 #23
0
    def get_operator_section(self):
        operator_table = Table()
        operator_table.add_attr('class', 'operator_table')
        operator_table.add_row()
        operator_table.add_header('DATE')
        operator_table.add_header('OPERATOR')
        operator_table.add_header('STYLE')
        operator_table.add_header('BAY')
        operator_table.add_header('MACHINE')
        operator_table.add_row()

        operator_table.add_cell(self.get_date_calendar_wdg())

        operator_table.add_cell(self.get_text_input_wdg('operator'))

        operator_table.add_cell(self.get_style_select())
        operator_table.add_cell(self.get_bay_select())
        operator_table.add_cell(self.get_machine_select())

        return operator_table
예제 #24
0
    def get_program_format_table(self):
        program_format_table = Table()
        program_format_table.add_style('float', 'left')

        program_format_table.add_row()
        program_format_table.add_header('Program Format')
        program_format_table.add_header()

        text_input_name_id_pairs = [
            ('Roll-up (blank)', 'roll_up_blank'),
            ('Bars/Tone', 'bars_tone'),
            ('Black/Silence', 'black_silence_1'),
            ('Slate/Silence', 'slate_silence'),
            ('Black/Silence', 'black_silence_2'),
            ('Start of Program', 'start_of_program'),
            ('End of Program', 'end_of_program')
        ]

        self.setup_table_rows_with_input_boxes(program_format_table, text_input_name_id_pairs, timecode=True)

        return program_format_table
예제 #25
0
    def get_audio_configuration_section_table(self, name, id, float_left=True):
        table = Table()

        if float_left:
            table.add_style('float: left')

        table.add_style('margin', '10px')
        table.add_row()
        table.add_header(name)

        for i in range(1, 9):
            table.add_row()

            label_cell = table.add_cell('TRK. {0}'.format(i))
            label_cell.add_style('padding', '10px 10px 10px 0px')

            table.add_cell(
                self.get_language_select_wdg(id + '_language_' + str(i)))
            table.add_cell(self.get_type_select_wdg(id + '_type_' + str(i)))

        return table
예제 #26
0
    def get_section_one_table_one(self, label_value_pairs_1,
                                  label_value_pairs_2):
        table = Table()
        table.add_row()

        table.add_header('')
        table.add_header('Feature')
        table.add_header('Trailer/Preview')

        for label_value_pair in label_value_pairs_1:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)

            for column in ('feature', 'preview'):
                select_wdg_id = value + '_' + column
                table.add_cell(self.get_true_false_select_wdg(select_wdg_id))

        for label_value_pair in label_value_pairs_2:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell()
            table.add_cell(self.get_true_false_select_wdg(value))

        return table
    def get_section_one_table_one(self, label_value_pairs_1, label_value_pairs_2):
        table = Table()
        table.add_row()

        table.add_header('')
        table.add_header('Feature')
        table.add_header('Trailer/Preview')

        for label_value_pair in label_value_pairs_1:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)

            for column in ('feature', 'preview'):
                select_wdg_id = value + '_' + column
                table.add_cell(self.get_true_false_select_wdg(select_wdg_id))

        for label_value_pair in label_value_pairs_2:
            label, value = label_value_pair

            table.add_row()
            table.add_cell(label)
            table.add_cell()
            table.add_cell(self.get_true_false_select_wdg(value))

        return table
    def setup_checkboxes_div(header_text, reasons_list):
        checkbox_table = Table()

        header_row = checkbox_table.add_row()
        header = checkbox_table.add_header(data=header_text, row=header_row)
        header.add_style('text-align', 'center')
        header.add_style('text-decoration', 'underline')

        for reason_id, reason_name in reasons_list:
            checkbox = CheckboxWdg(name=reason_id)

            checkbox_row = checkbox_table.add_row()

            checkbox_table.add_cell(data=checkbox, row=checkbox_row)
            checkbox_table.add_cell(data=reason_name, row=checkbox_row)

        return checkbox_table
    def setup_checkboxes_div(header_text, reasons_list):
        checkbox_table = Table()

        header_row = checkbox_table.add_row()
        header = checkbox_table.add_header(data=header_text, row=header_row)
        header.add_style('text-align', 'center')
        header.add_style('text-decoration', 'underline')

        for reason_id, reason_name in reasons_list:
            checkbox = CheckboxWdg(name=reason_id)

            checkbox_row = checkbox_table.add_row()

            checkbox_table.add_cell(data=checkbox, row=checkbox_row)
            checkbox_table.add_cell(data=reason_name, row=checkbox_row)

        return checkbox_table
    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
    def get_files_checkbox_for_task(self):
        files_checkbox_table = Table()

        header_row = files_checkbox_table.add_row()
        header = files_checkbox_table.add_header(data='Files', row=header_row)
        header.add_style('text-align', 'center')
        header.add_style('text-decoration', 'underline')

        for file_sobject in self.order_files:
            checkbox = CheckboxWdg(name=file_sobject.get_code())

            if file_sobject.get_code() in [selected_file.get_code() for selected_file in self.selected_files]:
                checkbox.set_checked()

            checkbox_row = files_checkbox_table.add_row()

            files_checkbox_table.add_cell(data=checkbox, row=checkbox_row)
            files_checkbox_table.add_cell(data=file_sobject.get_value('file_path'), row=checkbox_row)

        return files_checkbox_table
    def get_files_checkboxes(self):
        file_in_package_sobjects = get_file_in_package_sobjects_by_package_code(self.package_sobject.get_code())
        file_sobjects = get_file_sobjects_from_file_in_package_sobjects(file_in_package_sobjects)

        files_checkbox_table = Table()

        header_row = files_checkbox_table.add_row()
        header = files_checkbox_table.add_header(data='Files', row=header_row)
        header.add_style('text-align', 'center')
        header.add_style('text-decoration', 'underline')

        for file_sobject, file_in_package_sobject in zip(file_sobjects, file_in_package_sobjects):
            checkbox = CheckboxWdg(name=file_sobject.get_code())

            checkbox_row = files_checkbox_table.add_row()

            files_checkbox_table.add_cell(data=checkbox, row=checkbox_row)
            files_checkbox_table.add_cell(data=file_sobject.get_value('file_path'), row=checkbox_row)

        return files_checkbox_table
def get_platforms_checkboxes():
    platform_search = Search('twog/platform')
    platforms = platform_search.get_sobjects()

    platforms_checkbox_table = Table()

    header_row = platforms_checkbox_table.add_row()
    header = platforms_checkbox_table.add_header(data='Platforms', row=header_row)
    header.add_style('text-align', 'center')
    header.add_style('text-decoration', 'underline')

    for platform in platforms:
        checkbox = CheckboxWdg(name=platform.get_code())

        checkbox_row = platforms_checkbox_table.add_row()

        platforms_checkbox_table.add_cell(data=checkbox, row=checkbox_row)
        platforms_checkbox_table.add_cell(data=platform.get_value('name'), row=checkbox_row)

    return platforms_checkbox_table
def get_languages_checkboxes():
    languages_search = Search('twog/language')
    languages = languages_search.get_sobjects()

    languages_checkbox_table = Table()

    header_row = languages_checkbox_table.add_row()
    header = languages_checkbox_table.add_header(data='Languages', row=header_row)
    header.add_style('text-align', 'center')
    header.add_style('text-decoration', 'underline')

    for language in languages:
        checkbox = CheckboxWdg(name=language.get_code())

        checkbox_row = languages_checkbox_table.add_row()

        languages_checkbox_table.add_cell(data=checkbox, row=checkbox_row)
        languages_checkbox_table.add_cell(data=language.get_value('name'), row=checkbox_row)

    return languages_checkbox_table
    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
예제 #36
0
def get_languages_checkboxes():
    languages_search = Search('twog/language')
    languages = languages_search.get_sobjects()

    languages_checkbox_table = Table()

    header_row = languages_checkbox_table.add_row()
    header = languages_checkbox_table.add_header(data='Languages',
                                                 row=header_row)
    header.add_style('text-align', 'center')
    header.add_style('text-decoration', 'underline')

    for language in languages:
        checkbox = CheckboxWdg(name=language.get_code())

        checkbox_row = languages_checkbox_table.add_row()

        languages_checkbox_table.add_cell(data=checkbox, row=checkbox_row)
        languages_checkbox_table.add_cell(data=language.get_value('name'),
                                          row=checkbox_row)

    return languages_checkbox_table
예제 #37
0
    def get_first_row_wdg(self):

        # read the csv file
        self.file_path = ""

        div = DivWdg()

        div.add(self.get_upload_wdg())

        if not self.search_type:
            return div

        if not self.file_path:
            return div

        if not self.file_path.endswith(".csv"):
            div.add("Uploaded file [%s] is not a csv file" % self.file_path)
            return div

        if not os.path.exists(self.file_path):
            raise Exception("Path '%s' does not exists" % self.file_path)

        div.add(HtmlElement.br(2))

        div.add(
            HtmlElement.
            b("The following is taken from first line in the uploaded csv file.  Select the appropriate column to match."
              ))
        div.add(HtmlElement.br())
        div.add(
            HtmlElement.b(
                "Make sure you have all the required columns** in the csv."))
        option_div = DivWdg()

        option_div.add_style("float: left")
        option_div.add_style("margin-right: 30px")

        option_div.add("<p>3. Parsing Options:</p>")

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

        # first row and second row
        option_div.add(HtmlElement.br(2))
        option_div.add("Use Title Row: ")
        title_row_checkbox = FilterCheckboxWdg("has_title")
        title_row_checkbox.set_default_checked()
        option_div.add(title_row_checkbox)
        option_div.add(
            HintWdg(
                "Set this to use the first row as a title row to match up columns in the database"
            ))

        option_div.add(HtmlElement.br(2))
        option_div.add("Sample Data Row: ")
        data_row_text = TextWdg("data_row")
        data_row_text.set_attr("size", "3")
        option_div.add(data_row_text)
        option_div.add(
            HintWdg(
                "Set this as a sample data row to match the columns to the database"
            ))

        option_div.add(HtmlElement.br(2))

        div.add(option_div)
        self.has_title = title_row_checkbox.is_checked()

        # parse the first fow
        csv_parser = CsvParser(self.file_path)
        if self.has_title:
            csv_parser.set_has_title_row(True)
        else:
            csv_parser.set_has_title_row(False)
        csv_parser.parse()
        csv_titles = csv_parser.get_titles()
        csv_data = csv_parser.get_data()

        data_row = data_row_text.get_value()
        if not data_row:
            data_row = 0
        else:
            try:
                data_row = int(data_row)
            except ValueError:
                data_row = 0

            if data_row >= len(csv_data):
                data_row = len(csv_data) - 1
        data_row_text.set_value(data_row)

        table = Table()
        table.set_attr("cellpadding", "10")

        table.add_row()
        table.add_header("CSV Column Value")
        table.add_header("TACTIC Column")
        table.add_header("Create New Column")

        columns = self.search_type_obj.get_columns()
        search_type = self.search_type_obj.get_base_search_type()
        sobj = SObjectFactory.create(search_type)
        required_columns = sobj.get_required_columns()

        row = csv_data[data_row]
        labels = []
        for column in columns:
            if column in required_columns:
                label = '%s**' % column
            else:
                label = column
            labels.append(label)

        for j, cell in enumerate(row):
            table.add_row()
            table.add_cell(cell)

            column_select = SelectWdg("column_%s" % j)
            column_select.add_event(
                "onchange",
                "if (this.value!='') {set_display_off('new_column_div_%s')} else {set_display_on('new_column_div_%s')}"
                % (j, j))

            column_select.add_empty_option("-- Select --")
            column_select.set_option("values", columns)
            column_select.set_option("labels", labels)

            # only set the value if it is actually in there
            if csv_titles[j] in columns:
                column_select.set_option("default", csv_titles[j])
            column_select.set_persist_on_submit()
            column_select_value = column_select.get_value()

            display = column_select.get_buffer_display()
            td = table.add_cell(display)

            if csv_titles[j] not in columns:
                td.add(" <b style='color: red'>*</b>")

                # new property
                new_column_div = DivWdg()

                if column_select_value:
                    new_column_div.add_style("display", "none")
                else:
                    new_column_div.add_style("display", "block")

                new_column_div.set_id("new_column_div_%s" % j)

                td = table.add_cell(new_column_div)
                text = TextWdg("new_column_%s" % j)
                text.set_persist_on_submit()

                if self.has_title:
                    text.set_value(csv_titles[j])

                new_column_div.add(" ... or ...")
                new_column_div.add(text)

        self.num_columns = len(row)
        hidden = HiddenWdg("num_columns", self.num_columns)

        # need to somehow specify defaults for columns

        div.add(table)

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

        div.add(self.get_preview_wdg())

        return div
예제 #38
0
    def get_preview_wdg(self):

        widget = Widget()

        web = WebContainer.get_web()

        csv_parser = CsvParser(self.file_path)
        csv_parser.parse()
        csv_titles = csv_parser.get_titles()
        csv_data = csv_parser.get_data()

        ajax = AjaxCmd()
        ajax.set_option("search_type", self.search_type)
        ajax.set_option("file_path", self.file_path)
        ajax.add_element_name("has_title")

        event = WebContainer.get_event_container()
        caller = event.get_event_caller(SiteMenuWdg.EVENT_ID)
        div = ajax.generate_div()
        div.set_post_ajax_script(caller)
        widget.add(div)

        columns = []
        num_columns = len(csv_titles)
        ajax.set_option("num_columns", num_columns)
        for i in range(0, num_columns):
            column = web.get_form_value("column_%s" % i)
            if column:
                column = csv_titles[i]
            else:
                column = web.get_form_value("column_new_%s" % i)

            columns.append(column)

            ajax.add_element_name("column_%s" % i)
            ajax.add_element_name("new_column_%s" % i)

        ajax.register_cmd("pyasm.command.csv_import_cmd.CsvImportCmd")
        import_button = IconButtonWdg("Import", IconWdg.REFRESH, True)
        import_button.add_event("onclick",
                                ajax.get_on_script(show_progress=False))
        import_button.add_style("float: right")
        widget.add(import_button)

        preview_submit = IconSubmitWdg("Preview", IconWdg.REFRESH, True)
        preview_submit.add_style("float: right")
        widget.add(preview_submit)

        sobject_title = self.search_type_obj.get_title()
        widget.add("<p>4. Import</p>")
        widget.add(HtmlElement.br())
        widget.add(
            "<p>The following table will be imported into %s (Showing Max: 100)</p>"
            % sobject_title)

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

        table.add_row()
        for i, title in enumerate(columns):
            if not title:
                title = "<b style='color:red'>*</b>"
            table.add_header(title)

        for i, row in enumerate(csv_data):
            if i > 100:
                break
            table.add_row()
            for j, cell in enumerate(row):
                table.add_cell(cell)

        widget.add(table)

        return widget
예제 #39
0
    def get_display(self):

        # NOTE: need to add this to fit as a table layout
        self.chunk_size = 10000
        self.edit_permission = True
        self.view_editable = True

        search_key = self.kwargs.get("search_key")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            self.sobjects = [sobject]

        elif self.kwargs.get("do_search") != "false":
            self.handle_search()

        top = DivWdg()
        self.top = top
        self.set_as_panel(top)
        top.add_class("spt_sobject_top")

        inner = DivWdg()
        top.add(inner)
        inner.add_color("background", "background")
        inner.add_color("color", "color")
        # NOTE: this is not the table and is called this for backwards
        # compatibility
        inner.add_class("spt_table")
        inner.add_class("spt_layout")

        # set the sobjects to all the widgets then preprocess
        for widget in self.widgets:
            widget.set_sobjects(self.sobjects)
            widget.set_parent_wdg(self)
            # preprocess the elements
            widget.preprocess()

        #is_refresh = self.kwargs.get("is_refresh")
        #if self.kwargs.get("show_shelf") not in ['false', False]:
        #    action = self.get_action_wdg()
        #    inner.add(action)

        # get all the edit widgets
        """
        if self.view_editable and self.edit_permission:
            edit_wdgs = self.get_edit_wdgs()
            edit_div = DivWdg()
            edit_div.add_class("spt_edit_top")
            edit_div.add_style("display: none")
            inner.add(edit_div)
            for name, edit_wdg in edit_wdgs.items():
                edit_div.add(edit_wdg)
        """

        inner.set_unique_id()
        inner.add_smart_style("spt_header", "vertical-align", "top")
        inner.add_smart_style("spt_header", "text-align", "left")
        inner.add_smart_style("spt_header", "width", "150px")
        inner.add_smart_style("spt_header", "padding", "5px")
        border = inner.get_color("table_border")
        #inner.add_smart_style("spt_header", "border", "solid 1px %s" % border)

        inner.add_smart_style("spt_cell_edit", "background-repeat",
                              "no-repeat")
        inner.add_smart_style("spt_cell_edit", "background-position",
                              "bottom right")
        inner.add_smart_style("spt_cell_edit", "padding", "5px")
        inner.add_smart_style("spt_cell_edit", "min-width", "200px")

        for i, sobject in enumerate(self.sobjects):

            table = Table()
            table.add_color("color", "color")
            table.add_style("padding: 10px")
            #table.add_style("margin-bottom: 10px")
            table.add_style("width: 100%")
            inner.add(table)
            for j, widget in enumerate(self.widgets):

                name = widget.get_name()
                if name == 'preview':
                    continue

                widget.set_current_index(i)
                title = widget.get_title()

                tr = table.add_row()
                if isinstance(title, HtmlElement):
                    title.add_style("float: left")
                th = table.add_header(title)
                th.add_class("spt_header")
                td = table.add_cell(widget.get_buffer_display())
                td.add_class("spt_cell_edit")

                if j % 2 == 0:
                    tr.add_color("background-color", "background", -1)
                else:
                    tr.add_color("background-color", "background")

                # indicator that a cell is editable
                #td.add_event( "onmouseover", "$(this).setStyle('background-image', " \
                #                  "'url(/context/icons/silk/page_white_edit.png)')" )
                #td.add_event( "onmouseout",  "$(this).setStyle('background-image', '')")

        # extra stuff to make it work with ViewPanelWdg
        top.add_class("spt_table_top")
        class_name = Common.get_full_class_name(self)
        top.add_attr("spt_class_name", class_name)

        inner.add_class("spt_table_content")
        inner.add_attr("spt_search_type", self.kwargs.get('search_type'))
        inner.add_attr("spt_view", self.kwargs.get('view'))

        if self.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
예제 #40
0
    def get_display(my):


        search = Search("sthpw/login")
        logins = search.get_sobjects()

        top = my.top
        top.add_class("spt_panel_user_top")
        top.add_style("min-width: 400px")

        button = SingleButtonWdg(title="Advanced Security", icon=IconWdg.LOCK)
        top.add(button)
        button.add_style("float: right")
        button.add_style("margin-top: -8px")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.startup.SecurityWdg';
            spt.tab.set_main_body_tab()
            spt.tab.add_new("Security", "Security", class_name)
            '''
        } )



        button = SingleButtonWdg(title="Add", tip="Add New User", icon=IconWdg.ADD)
        top.add(button)
        button.add_style("float: left")
        button.add_style("margin-top: -8px")
        top.add("<br clear='all'/>")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            var class_name = 'tactic.ui.panel.EditWdg';
            var kwargs = {
                search_type: "sthpw/login",
                view: "edit",
            }
            var popup = spt.panel.load_popup("Create New User", class_name, kwargs);
            var top = bvr.src_el.getParent(".spt_panel_user_top");
            popup.on_save_cbk = function() {
                spt.panel.refresh(top);
            }

            '''
        } )




        #logins = []
        if not logins:
            arrow_div = DivWdg()
            top.add(arrow_div)
            arrow_div.add("<b><<< Click to Add</b>")
            arrow_div.add_style("position: relative")
            arrow_div.add_style("margin-top: -35px")
            arrow_div.add_style("margin-left: 35px")
            arrow_div.add_style("float: left")
            arrow_div.add_style("padding: 5px")
            arrow_div.set_box_shadow("1px 1px 2px 2px")
            arrow_div.set_round_corners(10, corners=['TL','BL'])

            div = DivWdg()
            top.add(div)
            div.add_border()
            div.add_style("min-height: 180px")
            div.add_style("margin: 15px 30px 30px 30px")
            div.add_style("padding: 20px")
            div.add_color("background", "background3")
            icon = IconWdg( "WARNING", IconWdg.WARNING )
            div.add(icon)
            div.add("<b>No users have been added</b>")
            div.add("<br/><br/>")
            div.add("For more information, read the help docs: ")
            from tactic.ui.app import HelpButtonWdg
            help = HelpButtonWdg(alias=my.get_help_alias())
            div.add(help)
            div.add("<br/>")
            div.add("Click on the 'Add' button above to start adding new users.")

            return top




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


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


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




        tr = table.add_row()
        tr.add_color("color", "color")
        tr.add_gradient("background", "background", -10)
        th = table.add_header("&nbsp;")
        th.add_style("text-align: left")
        th = table.add_header("Login")
        th.add_style("text-align: left")
        th = table.add_header("First Name")
        th.add_style("text-align: left")
        th = table.add_header("Last Name")
        th.add_style("text-align: left")
        th = table.add_header("Display Name")
        th.add_style("text-align: left")
        th = table.add_header("Activity")
        th.add_style("text-align: left")
        th = table.add_header("Groups")
        th.add_style("text-align: left")
        th = table.add_header("Security")
        th.add_style("text-align: left")
        th = table.add_header("Edit")
        th.add_style("text-align: left")





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

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

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

            td = table.add_cell(login.get_value("login"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("first_name"))
            td.add_style("padding: 3px")
            td = table.add_cell(login.get_value("last_name"))
            td.add_style("padding: 3px")

            td = table.add_cell(login.get_value("display_name"))
            td.add_style("padding: 3px")           

            search_key = login.get_search_key()
            login_code = login.get_code()
            full_name = login.get_full_name()

            td = table.add_cell()
            button = IconButtonWdg(tip="Activity", icon=IconWdg.CALENDAR)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'login_code': login_code,
                'full_name': full_name,
                'cbjs_action': '''

                var class_name = 'tactic.ui.tools.ScheduleUserToolWdg';
                var kwargs = {
                    login: bvr.login_code
                }

                var title = bvr.full_name + ' Schedule';
                var top = bvr.src_el.getParent(".spt_dashboard_top");
                spt.tab.set_tab_top(top);
                spt.tab.add_new("user_schedule", title, class_name, kwargs);
                //spt.panel.load_popup("Activty", class_name, kwargs);


                '''
            } )

 
            td = table.add_cell()
            button = IconButtonWdg(title="Groups", icon=IconWdg.GROUP_LINK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_key,
                'cbjs_action': '''

                var class_name = 'tactic.ui.startup.GroupAssignWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Group Assignment", class_name, kwargs);
                '''
            } )

  
            td = table.add_cell()
            button = IconButtonWdg(title="Security", icon=IconWdg.LOCK)
            td.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'search_key': search_key,
                'cbjs_action': '''

                var class_name = 'tactic.ui.startup.GroupSummaryWdg';
                var kwargs = {
                    search_key: bvr.search_key
                };
                var popup = spt.panel.load_popup("Security Summary", class_name, kwargs);
                '''
            } )




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

                var top = bvr.src_el.getParent(".spt_panel_user_top");
                var class_name = 'tactic.ui.panel.EditWdg';
                var kwargs = {
                    search_type: "sthpw/login",
                    view: "edit",
                    search_key: bvr.search_key
                }
                var popup = spt.panel.load_popup("Create New User", class_name, kwargs);

                popup.on_save_cbk = function() {
                    spt.panel.refresh(top);
                }

                '''
            } )

        return top
예제 #41
0
    def get_display(self):


        # NOTE: need to add this to fit as a table layout
        self.chunk_size = 10000
        self.edit_permission = True
        self.view_editable = True


        search_key = self.kwargs.get("search_key")
        if search_key:
            sobject = Search.get_by_search_key(search_key)
            self.sobjects = [sobject]

        elif self.kwargs.get("do_search") != "false":
            self.handle_search()


        top = DivWdg()
        self.top = top
        self.set_as_panel(top)
        top.add_class("spt_sobject_top")

        inner = DivWdg()
        top.add(inner)
        inner.add_color("background", "background")
        inner.add_color("color", "color")
        # NOTE: this is not the table and is called this for backwards
        # compatibility
        inner.add_class("spt_table")
        inner.add_class("spt_layout")


        # set the sobjects to all the widgets then preprocess
        for widget in self.widgets:
            widget.set_sobjects(self.sobjects)
            widget.set_parent_wdg(self)
            # preprocess the elements
            widget.preprocess()



        #is_refresh = self.kwargs.get("is_refresh")
        #if self.kwargs.get("show_shelf") not in ['false', False]:
        #    action = self.get_action_wdg()
        #    inner.add(action)


        # get all the edit widgets
        """
        if self.view_editable and self.edit_permission:
            edit_wdgs = self.get_edit_wdgs()
            edit_div = DivWdg()
            edit_div.add_class("spt_edit_top")
            edit_div.add_style("display: none")
            inner.add(edit_div)
            for name, edit_wdg in edit_wdgs.items():
                edit_div.add(edit_wdg)
        """

        inner.set_unique_id()
        inner.add_smart_style("spt_header", "vertical-align", "top")
        inner.add_smart_style("spt_header", "text-align", "left")
        inner.add_smart_style("spt_header", "width", "150px")
        inner.add_smart_style("spt_header", "padding", "5px")
        border = inner.get_color("table_border")
        #inner.add_smart_style("spt_header", "border", "solid 1px %s" % border)

        inner.add_smart_style("spt_cell_edit", "background-repeat", "no-repeat")
        inner.add_smart_style("spt_cell_edit", "background-position", "bottom right")
        inner.add_smart_style("spt_cell_edit", "padding", "5px")
        inner.add_smart_style("spt_cell_edit", "min-width", "200px")

        for i, sobject in enumerate(self.sobjects):

            table = Table()
            table.add_color("color", "color")
            table.add_style("padding: 10px")
            #table.add_style("margin-bottom: 10px")
            table.add_style("width: 100%")
            inner.add(table)
            for j, widget in enumerate(self.widgets):

                name = widget.get_name()
                if name == 'preview':
                    continue

                widget.set_current_index(i)
                title = widget.get_title()

                tr = table.add_row()
                if isinstance(title, HtmlElement):
                    title.add_style("float: left")
                th = table.add_header(title)
                th.add_class("spt_header")
                td = table.add_cell(widget.get_buffer_display())
                td.add_class("spt_cell_edit")


                if j % 2 == 0:
                    tr.add_color("background-color", "background", -1)
                else:
                    tr.add_color("background-color", "background")


                # indicator that a cell is editable
                #td.add_event( "onmouseover", "$(this).setStyle('background-image', " \
                #                  "'url(/context/icons/silk/page_white_edit.png)')" )
                #td.add_event( "onmouseout",  "$(this).setStyle('background-image', '')")



        # extra stuff to make it work with ViewPanelWdg
        top.add_class("spt_table_top");
        class_name = Common.get_full_class_name(self)
        top.add_attr("spt_class_name", class_name)

        inner.add_class("spt_table_content");
        inner.add_attr("spt_search_type", self.kwargs.get('search_type'))
        inner.add_attr("spt_view", self.kwargs.get('view'))

        if self.kwargs.get("is_refresh") == 'true':
            return inner
        else:
            return top
예제 #42
0
    def get_display(my):


        my.search_type = my.kwargs.get('search_type')
        my.texture_search_type = my.kwargs.get('texture_search_type')
        assert my.search_type

        app_name = WebContainer.get_web().get_selected_app()
        # add an outside box


        top = DivWdg(css='spt_view_panel')
        #div = DivWdg(css="maq_search_bar")
        div = DivWdg()
        div.add_color("background", "background2", -15)
        my.set_as_panel(top)

        top.add(div)
        div.add_style("margin: 5px")

        div.add_style("padding: 10px")
        
        div.add_style("font-style: bold")



        process_div = DivWdg()
        process_div.add_style("padding-left: 10px")
        div.add(process_div)
        process_div.add( my.get_process_wdg(my.search_type))
        process_div.add( my.get_context_filter_wdg() )
        process_div.add(HtmlElement.br(clear="all")) 


        div.add( HtmlElement.br() )
        checkin_options = DivWdg(css='spt_ui_options')
        checkin_options.add_style("padding: 10px")

        swap = SwapDisplayWdg()
        #swap.set_off()
        title = SpanWdg("Check in Options")
        SwapDisplayWdg.create_swap_title(title, swap, checkin_options, is_open=False)
        div.add(swap)
        div.add(title)


        checkin_options.add( my.get_file_type_wdg() )
        checkin_options.add( my.get_snapshot_type_wdg() )
        checkin_options.add(HtmlElement.br(1)) 
        checkin_options.add( my.get_export_method_wdg() )
        checkin_options.add( my.get_checkin_as_wdg() )

        #my.add( my.get_render_icon_wdg() )

        # For different export methods
        checkin_options.add( my.get_currency_wdg() )

        checkin_options.add( my.get_reference_option())
        checkin_options.add( my.get_auto_version_wdg())
        checkin_options.add( my.get_texture_option(app=app_name))
        checkin_options.add( my.get_handoff_wdg())
       
        if not my.context_select.get_value(for_display=True):
            my.add(DivWdg('A context must be selected.', css='warning'))
            return

        div.add(checkin_options)
      
        
        top.add( my.get_introspect_wdg() )
        top.add(HtmlElement.br(2))
        
        # create the interface
        table = Table()
        table.set_max_width()
        #table.set_class("table")
        table.add_color('background','background2') 
        #table.add_style('line-height','3.0em')
        #table.add_row(css='smaller')
        tr = table.add_row(css='smaller')
        tr.add_style('height', '3.5em')
        table.add_header("&nbsp;")
        table.add_header("&nbsp;")
        th = table.add_header("Instance")
        th.add_style('text-align: left')
        table.add_header(my.get_checkin())
        table.add_header("Sandbox")
        tr.add_color('background','background2', -15)
        

        # get session and handle case where there is no session
        my.session = SessionContents.get()
        if my.session == None:
            instance_names = []
            asset_codes = []
            node_names = []
        else:
            instance_names = my.session.get_instance_names()
            asset_codes = my.session.get_asset_codes()
            node_names = my.session.get_node_names()

        # get all of the possible assets based on the asset codes
        search = Search(my.search_type)
        search.add_filters("code", asset_codes)
        assets = search.get_sobjects()
        assets_dict = SObject.get_dict(assets, ["code"])

        if my.session:
            my.add("Current Project: <b>%s</b>" % my.session.get_project_dir() )
        else:
            my.add("Current Project: Please press 'Introspect'")


        count = 0
        for i in range(0, len(node_names) ):
            node_name = node_names[i]
            if not my.session.is_tactic_node(node_name) and \
                not my.session.get_node_type(node_name) in ['transform','objectSet']:
                    continue
            instance_name = instance_names[i]

            # backwards compatible:
            try:
                asset_code = asset_codes[i]
            except IndexError, e:
                asset_code = instance_name

            # skip if this is a reference
            if my.list_references == False and \
                    my.session.is_reference(node_name):
                continue

            table.add_row()


            # check that this asset exists
            asset = assets_dict.get(asset_code)
            if not asset:
                continue
           
            # list items if it is a set
            if asset.get_value('asset_type', no_exception=True) in ["set", "section"]:
                my.current_sobject = asset
                my.handle_set( table, instance_name, asset, instance_names)
                count +=1
            # if this asset is in the database, then allow it to checked in
            if asset:
                if my.session.get_snapshot_code(instance_name, snapshot_type='set'):
                    continue

                # hack remember this
                my.current_sobject = asset
                my.handle_instance(table, instance_name, asset, node_name)

            else:
                table.add_blank_cell()
                table.add_cell(instance_name)


            count += 1
예제 #43
0
        table = Table()
        table_div.add(table)
        table.add_color('background','background')
        table.add_color('color','color')
        table.add_border()
        table.set_attr("cellpadding", "3")
        #table.add_attr('border','1')

        table.add_style("width: 100%")


        table.add_row()
        for i, title in enumerate(columns):
            if not title:
                title = "<b style='color:red'>*</b>"
            th = table.add_header(title)
            th.add_style("min-width: 100px")
            th.add_gradient("background", "background", -5)
            th.add_style("padding: 3px")
            th.add_style("text-align: left")

        for i, row in enumerate(csv_data):
            if i > 100:
                break
            tr = table.add_row()
            if i % 2:
                tr.add_color("background", "background")
            else:
                tr.add_color("background", "background3")

            for j, cell in enumerate(row):
예제 #44
0
    def get_display(my):

        web = WebContainer.get_web()
        login_name = web.get_form_value('login')
        hidden = HiddenWdg('login', login_name)
        box = DivWdg(css='login')

        if web.is_IE():
            box.add_style("margin-top: 150px")
            box.add_style("margin-bottom: 150px")
        else:
            box.add_style("margin-top: auto")
            box.add_style("margin-bottom: auto")
        box.add_style("text-align: center")

        div = DivWdg()
        div.add_style("margin: 0px 0px")
        div.add_class("centered")

        div.add_style("padding-top: 95px")

        sthpw = SpanWdg("SOUTHPAW TECHNOLOGY INC", css="login_sthpw")
        sthpw.add_style("color: #CCCCCC")
        div.add(sthpw)
        div.add(HtmlElement.br())
        div.add(hidden)
        box.add(div)

        # hidden element in the form to pass message that this was not
        # actually a typical submitted form, but rather the result
        # of a login page
        div.add(HiddenWdg("is_from_login", "yes"))
        div.add_style("font-size: 10px")

        table = Table(css="login")
        table.center()
        table.set_attr("cellpadding", "3px")
        table.add_row()

        table2 = Table(css="login")
        table2.center()
        table2.add_style("width: 240px")

        table2.add_row()

        td = table2.add_header(
            'After reset, the new password will be sent to the email address for [ %s ].'
            % login_name)
        td.add_color('color', 'color', +80)
        table2.add_row_cell('&nbsp;')
        # build the button manually
        from tactic.ui.widget import ActionButtonWdg
        button = ActionButtonWdg(tip='Reset Password', title='Reset')
        button.add_style('margin: auto')
        button.add_event(
            'onclick',
            "document.form.elements['reset_password'].value='true'; document.form.submit()"
        )
        table2.add_row()
        td = table2.add_cell(button)
        hidden = HiddenWdg('reset_password')
        td.add(hidden)

        #th.add_class('center_content')

        table2.add_row()

        div.add(HtmlElement.br())
        div.add(table)

        div.add(HtmlElement.spacer_div(1, 14))
        div.add(table2)
        #div.add(HiddenWdg(my.LOGIN_MSG))

        #box.add(script)

        widget = Widget()
        #widget.add( HtmlElement.br(3) )
        table = Table()
        table.add_style("width: 100%")
        table.add_style("height: 85%")
        table.add_row()
        td = table.add_cell()
        td.add_style("vertical-align: middle")
        td.add_style("text-align: center")
        td.add_style("background: transparent")
        td.add(box)
        widget.add(table)

        return widget
예제 #45
0
    def get_display(my):

        search_key = my.kwargs.get("search_key")
        path = my.kwargs.get("path")
        parser_str = my.kwargs.get("parser")
        use_tactic_tags = my.kwargs.get("use_tactic_tags")


        from pyasm.checkin import PILMetadataParser, ImageMagickMetadataParser, ExifMetadataParser, BaseMetadataParser
        if parser_str:
            parser = BaseMetadataParser.get_parser(parser_str, path)
        else:
            parser = BaseMetadataParser.get_parser_by_path(path)

        if parser:
            if use_tactic_tags in ['true', True]:
                metadata = parser.get_tactic_metadata()
            else:
                metadata = parser.get_metadata()
        else:
            metadata = {}


        top = my.top
        top.add_color("background", "background")


        table = Table()
        table.set_max_width()
        top.add(table)
        table.set_unique_id()
        table.add_border()

        table.add_smart_styles("spt_cell", {
            'padding': '3px'
        } )



        tr = table.add_row()
        tr.add_gradient("background", "background3")
        th = table.add_header("Property")
        th.add_style("min-width: 200px")
        th.add_style("padding: 5px")
        th = table.add_header("Value")
        th.add_style("min-width: 400px")
        th.add_style("padding: 5px")

        keys = metadata.get("__keys__")
        if not keys:
            keys = metadata.keys()

        empty = False
        if not keys:
            empty = True
            keys = ['','','','','','','']
            table.add_smart_styles("spt_cell", {
                'height': '20px'
            } )


        for i, key in enumerate(keys):
            value = metadata.get(key)

            title = Common.get_display_title(key)

            tr = table.add_row()

            if i % 2:
                tr.add_color("background", "background")
                tr.add_color("color", "color")
            else:
                tr.add_color("background", "background", -8)
                tr.add_color("color", "color")

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(title)

            td = table.add_cell()
            td.add_class("spt_cell")

            if len(str(value)) > 500:
                inside = DivWdg()
                td.add(inside)
                value = value[:500]
                inside.add(value)
                inside.add_style("max-width: 600px")
            else:
                td.add(value)


        if empty:
            div = DivWdg()
            top.add(div)
            div.add_style("height: 30px")
            div.add_style("width: 150px")
            div.add_style("margin-top: -110px")
            div.center()
            div.add("<b>No Metadata</b>")
            div.add_border()
            div.add_color("background", "background3")
            div.add_color("color", "color3")
            div.add_style("padding: 20px")
            div.add_style("text-align: center")

            top.add_style("min-height: 200px")

        return top
예제 #46
0
    def get_display(my):

        my.search_type = my.kwargs.get('search_type')
        my.texture_search_type = my.kwargs.get('texture_search_type')
        assert my.search_type

        app_name = WebContainer.get_web().get_selected_app()
        # add an outside box

        top = DivWdg(css='spt_view_panel')
        #div = DivWdg(css="maq_search_bar")
        div = DivWdg()
        div.add_color("background", "background2", -15)
        my.set_as_panel(top)

        top.add(div)
        div.add_style("margin: 5px")

        div.add_style("padding: 10px")

        div.add_style("font-style: bold")

        process_div = DivWdg()
        process_div.add_style("padding-left: 10px")
        div.add(process_div)
        process_div.add(my.get_process_wdg(my.search_type))
        process_div.add(my.get_context_filter_wdg())
        process_div.add(HtmlElement.br(clear="all"))

        div.add(HtmlElement.br())
        checkin_options = DivWdg(css='spt_ui_options')
        checkin_options.add_style("padding: 10px")

        swap = SwapDisplayWdg()
        #swap.set_off()
        title = SpanWdg("Check in Options")
        SwapDisplayWdg.create_swap_title(title,
                                         swap,
                                         checkin_options,
                                         is_open=False)
        div.add(swap)
        div.add(title)

        checkin_options.add(my.get_file_type_wdg())
        checkin_options.add(my.get_snapshot_type_wdg())
        checkin_options.add(HtmlElement.br(1))
        checkin_options.add(my.get_export_method_wdg())
        checkin_options.add(my.get_checkin_as_wdg())

        #my.add( my.get_render_icon_wdg() )

        # For different export methods
        checkin_options.add(my.get_currency_wdg())

        checkin_options.add(my.get_reference_option())
        checkin_options.add(my.get_auto_version_wdg())
        checkin_options.add(my.get_texture_option(app=app_name))
        checkin_options.add(my.get_handoff_wdg())

        if not my.context_select.get_value(for_display=True):
            my.add(DivWdg('A context must be selected.', css='warning'))
            return

        div.add(checkin_options)

        top.add(my.get_introspect_wdg())
        top.add(HtmlElement.br(2))

        # create the interface
        table = Table()
        table.set_max_width()
        #table.set_class("table")
        table.add_color('background', 'background2')
        #table.add_style('line-height','3.0em')
        #table.add_row(css='smaller')
        tr = table.add_row(css='smaller')
        tr.add_style('height', '3.5em')
        table.add_header("&nbsp;")
        table.add_header("&nbsp;")
        th = table.add_header("Instance")
        th.add_style('text-align: left')
        table.add_header(my.get_checkin())
        table.add_header("Sandbox")
        tr.add_color('background', 'background2', -15)

        # get session and handle case where there is no session
        my.session = SessionContents.get()
        if my.session == None:
            instance_names = []
            asset_codes = []
            node_names = []
        else:
            instance_names = my.session.get_instance_names()
            asset_codes = my.session.get_asset_codes()
            node_names = my.session.get_node_names()

        # get all of the possible assets based on the asset codes
        search = Search(my.search_type)
        search.add_filters("code", asset_codes)
        assets = search.get_sobjects()
        assets_dict = SObject.get_dict(assets, ["code"])

        if my.session:
            my.add("Current Project: <b>%s</b>" % my.session.get_project_dir())
        else:
            my.add("Current Project: Please press 'Introspect'")

        count = 0
        for i in range(0, len(node_names)):
            node_name = node_names[i]
            if not my.session.is_tactic_node(node_name) and \
                not my.session.get_node_type(node_name) in ['transform','objectSet']:
                continue
            instance_name = instance_names[i]

            # backwards compatible:
            try:
                asset_code = asset_codes[i]
            except IndexError, e:
                asset_code = instance_name

            # skip if this is a reference
            if my.list_references == False and \
                    my.session.is_reference(node_name):
                continue

            table.add_row()

            # check that this asset exists
            asset = assets_dict.get(asset_code)
            if not asset:
                continue

            # list items if it is a set
            if asset.get_value('asset_type',
                               no_exception=True) in ["set", "section"]:
                my.current_sobject = asset
                my.handle_set(table, instance_name, asset, instance_names)
                count += 1
            # if this asset is in the database, then allow it to checked in
            if asset:
                if my.session.get_snapshot_code(instance_name,
                                                snapshot_type='set'):
                    continue

                # hack remember this
                my.current_sobject = asset
                my.handle_instance(table, instance_name, asset, node_name)

            else:
                table.add_blank_cell()
                table.add_cell(instance_name)

            count += 1
예제 #47
0
    def get_display(my):

        top = my.top
        top.add_class("spt_changelist_content")
        my.set_as_panel(top)
        top.add_color("color", "color")
        top.add_color("background", "background")
        #top.add_border()
        #top.add_style("padding", "10px")
        top.add_style("min-width: 600px")
        top.add_style("min-height: 400px")

        top.add_behavior({'type': 'load', 'cbjs_action': scm_get_onload_js()})

        sync_dir = Environment.get_sandbox_dir()
        # HARD CODED
        project = Project.get()
        depot = project.get_value("location", no_exception=True)
        if not depot:
            depot = project.get_code()
        location = '//%s' % depot

        changelist = my.kwargs.get("changelist")
        if not changelist:
            changelist = WidgetSettings.get_value_by_key("current_changelist")
        else:
            WidgetSettings.set_value_by_key("current_changelist", changelist)

        if not changelist:
            changelist = 'default'

        changelists = my.kwargs.get("changelists")
        if not changelists:
            changelists = []
        elif isinstance(changelists, basestring):
            changelists = changelists.replace("'", '"')
            changelists = jsonloads(changelists)

        top.add_behavior({
            'type':
            'load',
            'sync_dir':
            sync_dir,
            'depot':
            depot,
            'cbjs_action':
            '''
            spt.scm.sync_dir = bvr.sync_dir;
            spt.scm.depot = bvr.depot;
            '''
        })

        inner = DivWdg()
        top.add(inner)

        table = Table()
        inner.add(table)
        table.add_style("width: 100%")
        table.add_color("background", "background", -3)

        table.add_row()
        th = table.add_header("")

        th = table.add_header("Changelist")
        th.add_style("text-align: left")
        th = table.add_header("Description")
        th.add_style("text-align: left")
        th = table.add_header("# Items")
        th.add_style("text-align: left")
        th = table.add_header("Status")
        th.add_style("text-align: left")
        th = table.add_header("View")
        th.add_style("text-align: left")
        th = table.add_header("Delete")
        th.add_style("text-align: left")
        #table.set_unique_id()
        #table.add_smart_styles("spt_changelist_item", {
        #    'text-align: right'
        #    } ))

        bgcolor = table.get_color("background", -8)
        table.add_relay_behavior({
            'type':
            'mouseover',
            'bvr_match_class':
            'spt_changelist_item',
            'bgcolor':
            bgcolor,
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background-color", bvr.bgcolor);
            '''
        })
        table.add_relay_behavior({
            'type':
            'mouseout',
            'bvr_match_class':
            'spt_changelist_item',
            'cbjs_action':
            '''
            bvr.src_el.setStyle("background-color", '');
            '''
        })

        table.add_relay_behavior({
            'type':
            'mouseup',
            'bvr_match_class':
            "spt_changelist_radio",
            'cbjs_action':
            '''

            var changelist = bvr.src_el.value;
            var top = bvr.src_el.getParent(".spt_changelist_content");
            top.setAttribute("spt_changelist", changelist);
            spt.app_busy.show("Loading Changelists Information");
            spt.changelist.load(bvr.src_el, changelist);
            spt.app_busy.hide();

            '''
        })

        for c in changelists:
            num_items = len(c.get("info"))
            name = c.get("change")

            tr = table.add_row()
            tr.add_class("spt_changelist_item")

            radio = RadioWdg("changelist")
            radio.add_class("spt_changelist_radio")
            table.add_cell(radio)
            radio.set_option("value", name)
            if name == changelist:
                radio.set_checked()

            table.add_cell(name)
            table.add_cell(c.get("desc"))
            table.add_cell(num_items)
            table.add_cell(c.get("status"))

            if num_items:
                icon = IconButtonWdg(title="View", icon=IconWdg.ZOOM)

                icon.add_behavior({
                    'type':
                    'click_up',
                    'changelist':
                    c.get("change"),
                    'cbjs_action':
                    '''
                    var top = bvr.src_el.getParent(".spt_changelist_content");
                    top.setAttribute("spt_changelist", bvr.changelist);

                    spt.app_busy.show("Loading Changelist");
                    spt.changelist.load(bvr.src_el, bvr.changelist);
                    spt.app_busy.hide();

                    '''
                })
            else:
                icon = ''
            table.add_cell(icon)

            if not num_items and name != 'default':
                icon = IconButtonWdg(title="Delete Changelist",
                                     icon=IconWdg.DELETE)
            else:
                icon = ""

            table.add_cell(icon)

        inner.add("<hr/>")

        files = my.kwargs.get("files")
        if isinstance(files, basestring):
            files = files.replace("'", '"')
            files = jsonloads(files)

        if files == None:
            inner.add_behavior({
                'type':
                'load',
                'location':
                location,
                'changelist':
                changelist,
                'sync_dir':
                sync_dir,
                'cbjs_action':
                '''

spt.changelist = {}
spt.changelist.load = function(el, changelist) {
    var applet = spt.Applet.get();
    var changelists = spt.scm.run("get_changelists_by_user",[]);
    var dflt = {
        'change': 'default',
        'status': 'pending'
    }
    changelists.push(dflt);
    changelists = changelists.reverse();
    for (var i = 0; i < changelists.length; i++) {
        var info = spt.scm.run("get_changelist_files",[changelists[i].change]);
        changelists[i]['info'] = info;
    }

    // get the current chnage list
    var files = spt.scm.run("get_changelist_files",[changelist]);
    var path_info = {};
    var sizes = [];
    for ( var i = 0; i < files.length; i++) {

        // FIXME: perforce specific
        var path = files[i].depotFile;
        path = path.replace(bvr.location, bvr.sync_dir);
        files[i].path = path;

        var size;
        if (applet.exists(path)) {
            var info = applet.get_path_info(path);
            size = info.size;
        }
        else {
            size = 0;
        }
        sizes.push(size);
        path_info[path] = 'editable';
    }
    //var ret_val = spt.scm.status(bvr.sync_dir);
    //console.log(ret_val);

    var class_name = 'tactic.ui.checkin.changelist_wdg.ChangelistWdg';
    var kwargs = {
        files: files,
        sizes: sizes,
        changelist: changelist,
        changelists: changelists,
        path_info: path_info,
    }
    var top = el.getParent(".spt_changelist_content");
    spt.panel.load(top, class_name, kwargs);

}
spt.changelist.load(bvr.src_el, bvr.changelist);
            '''
            })

        content = DivWdg()
        inner.add(content)
        content.add_class("spt_changelist_content")

        if files == None:

            loading_wdg = DivWdg()
            content.add(loading_wdg)
            loading_wdg.add("<b>Loading ...</b>")
            loading_wdg.add_style("padding: 30px")

        elif files:
            title_wdg = DivWdg()
            title_wdg.add_style("height: 15px")
            title_wdg.add("Changelist: [%s]" % changelist)
            content.add(title_wdg)
            title_wdg.add_gradient("background", "background", -5)
            title_wdg.add_style("padding: 5px")
            title_wdg.add_border()

            #button = SingleButtonWdg(tip='Add New Changelist', icon=IconWdg.ADD)
            #content.add(button)

            content.add("<br/>")

            paths = [x.get("path") for x in files]
            sizes = my.kwargs.get("sizes")
            path_info = my.kwargs.get("path_info")
            from scm_dir_list_wdg import ScmDirListWdg
            # dummy search_key
            search_key = "sthpw/virtual?code=xx001"
            dir_list_wdg = ScmDirListWdg(
                base_dir=sync_dir,
                paths=paths,
                sizes=sizes,
                path_info=path_info,
                all_open=True,
                #search_key=search_key
            )
            content.add(dir_list_wdg)

        else:

            content.add("Changelist: [%s]" % changelist)
            content.add("<br/>" * 2)

            no_files_wdg = DivWdg()
            content.add(no_files_wdg)
            no_files_wdg.add_style("padding: 20px")
            no_files_wdg.add_border()
            no_files_wdg.add("No files in changelist")

            no_files_wdg.add_color("color", "color3")
            no_files_wdg.add_color("background", "background3")
            no_files_wdg.add_style("font-weight: bold")
            no_files_wdg.add_style("text-align: center")

        return top
예제 #48
0
    def get_upload_wdg(self):
        widget = Widget()

        # get the search type
        widget.add("1. Select type of asset: ")

        # handle new search_types
        new_search_type = CheckboxWdg("new_search_type_checkbox")
        new_search_type.add_event("onclick",
                                  "toggle_display('new_search_type_div')")
        #span = SpanWdg(css="med")
        #span.add(new_search_type)
        #span.add("Create new type")
        #span.add(" ... or ... ")
        #widget.add(span)

        new_search_type_div = DivWdg()
        new_search_type_div.set_id("new_search_type_div")

        name_input = TextWdg("asset_name")
        title = TextWdg("asset_title")
        description = TextAreaWdg("asset_description")

        table = Table()
        table.add_style("margin: 10px 20px")
        table.add_col().set_attr('width', '140')
        table.add_col().set_attr('width', '400')

        table.add_row()
        table.add_header("Search Type: ").set_attr('align', 'left')
        table.add_cell(name_input)
        table.add_row()
        table.add_header("Title: ").set_attr('align', 'left')
        table.add_cell(title)
        table.add_row()
        table.add_header("Description: ").set_attr('align', 'left')
        table.add_cell(description)
        new_search_type_div.add(table)
        new_search_type_div.add_style("display: none")
        #widget.add(new_search_type_div)

        # or use a pre-existing one
        search_type_select = SearchTypeSelectWdg("filter|search_type")
        search_type_select.add_empty_option("-- Select --")
        search_type_select.set_persist_on_submit()
        search_type_select.set_submit_onchange()
        widget.add(search_type_select)

        self.search_type = search_type_select.get_value()
        if self.search_type:
            sobj = SObjectFactory.create(self.search_type)
            required_columns = sobj.get_required_columns()

            widget.add(SpanWdg("Required Columns: ", css='med'))
            if not required_columns:
                required_columns = ['n/a']
            widget.add(SpanWdg(', '.join(required_columns), css='med'))

        widget.add(HtmlElement.br(2))
        widget.add("2. Upload a csv file: ")
        upload_wdg = HtmlElement.upload("uploaded_file")
        widget.add(upload_wdg)
        submit = IconSubmitWdg("Upload", IconWdg.UPLOAD, True)
        widget.add(submit)

        web = WebContainer.get_web()
        field_storage = web.get_form_value("uploaded_file")
        if field_storage != "":
            upload = FileUpload()
            upload.set_field_storage(field_storage)
            upload.set_create_icon(False)
            upload.execute()

            files = upload.get_files()
            if files:
                self.file_path = files[0]
            else:
                self.file_path = web.get_form_value("file_path")

        if self.file_path:
            hidden = HiddenWdg("file_path", self.file_path)
            widget.add(hidden)

        return widget
예제 #49
0
    def get_upload_wdg(my):
        '''get search type select and upload wdg'''
        widget = DivWdg(css='spt_import_csv')
        widget.add_color('color','color')
        widget.add_color('background','background')
        widget.add_style('width: 600px')

        # get the search type
        title = DivWdg("<b>Select sType to import data into:</b>&nbsp;&nbsp;")
        widget.add( title )
        title.add_style("float: left")

        # handle new search_types
        new_search_type = CheckboxWdg("new_search_type_checkbox")
        new_search_type.add_event("onclick", "toggle_display('new_search_type_div')")
        #span = SpanWdg(css="med")
        #span.add(new_search_type)
        #span.add("Create new type")
        #span.add(" ... or ... ")
        #widget.add(span)

        new_search_type_div = DivWdg()
        new_search_type_div.set_id("new_search_type_div")

        name_input = TextWdg("asset_name")
        title = TextWdg("asset_title")
        description = TextAreaWdg("asset_description")

        
 
        key='csv_import'
        table = Table()
        table.set_id('csv_main_body')
        table.add_style("margin: 10px 10px")
        table.add_col().set_attr('width','140')
        table.add_col().set_attr('width','400')
        
        table.add_row()
        table.add_header("Search Type: ").set_attr('align','left')
        table.add_cell(name_input)
        table.add_row()
        table.add_header("Title: ").set_attr('align','left')
        table.add_cell(title)
        table.add_row()
        table.add_header("Description: ").set_attr('align','left')
        table.add_cell(description)
        new_search_type_div.add(table)
        new_search_type_div.add_style("display: none")
        #widget.add(new_search_type_div)

        div = DivWdg()

       
        search_type_select = SearchTypeSelectWdg("search_type_filter", mode=SearchTypeSelectWdg.ALL)
        search_type_select.add_empty_option("-- Select --")
        if not search_type_select.get_value():
            search_type_select.set_value(my.search_type)
        search_type_select.set_persist_on_submit()
       

        div.add(search_type_select)

        widget.add(div)

        search_type_select.add_behavior( {'type': 'change', \
                                  'cbjs_action': "spt.panel.load('csv_import_main','%s', {}, {\
                                    'search_type_filter': bvr.src_el.value});" %(Common.get_full_class_name(my)) } )

        if my.search_type:
            sobj = None
            try:
                sobj = SObjectFactory.create(my.search_type)
            except ImportError:
                widget.add(HtmlElement.br())
                widget.add(SpanWdg('WARNING: Import Error encountered. Please choose another search type.', css='warning')) 
                return widget

            required_columns = sobj.get_required_columns()
           
            if required_columns:
                widget.add(HtmlElement.br())
                req_span = SpanWdg("Required Columns: ", css='med')
                req_span.add_color('color','color')
                widget.add(req_span)
                #required_columns = ['n/a']
                req_span.add(', '.join(required_columns))

            widget.add( HtmlElement.br() )



            if my.file_path:
                hidden = HiddenWdg("file_path", my.file_path)
                widget.add(hidden)
                
                if my.web_url:
                    file_span = FloatDivWdg('URL: <i>%s</i>&nbsp;&nbsp;&nbsp;' %my.web_url, css='med')
                else:
                    file_span = FloatDivWdg('File uploaded: <i>%s</i>&nbsp;&nbsp;&nbsp;' %os.path.basename(my.file_path), css='med')
                file_span.add_color('color','color')
                file_span.add_style('margin: 8px 0 0 10px')
                file_span.add_style('font-size: 14px')
                widget.add(file_span)

                button = ActionButtonWdg(title='Change')
                button.add_style('float','left')
                button.add_behavior( {'type': 'click_up', \
                                   'cbjs_action': "spt.panel.load('csv_import_main','%s', {}, {\
                                    'search_type_filter': '%s'});" %(Common.get_full_class_name(my), my.search_type) } )
                widget.add(button)
                widget.add("<br clear='all'/>")
                widget.add(HtmlElement.br())
                return widget

            widget.add("<br/>")
            widget.add_style("overflow-y: auto")

            msg = DivWdg()
            widget.add(msg)
            msg.add( "<div style='float: left; padding-left: 100px; padding-top: 6px'><b>Upload a csv file: </b></div>")
            msg.add_border()
            msg.add_style("width: 400px")
            msg.add_color("background", "background3")
            msg.add_style("padding: 20px")
            msg.add_style("margin: 30 auto")
            msg.add_style("text-align: center")

            ticket = Environment.get_security().get_ticket_key()

            
            on_complete = '''var server = TacticServerStub.get();
            var file = spt.html5upload.get_file();
            if (file) {
                var file_name = file.name;
                // clean up the file name the way it is done in the server
                file_name = spt.path.get_filesystem_name(file_name);    
                var server = TacticServerStub.get();

                var class_name = 'tactic.ui.widget.CsvImportWdg';
                var values = spt.api.Utility.get_input_values('csv_import_main');
                values['is_refresh'] = true;
                values['file_name'] = file_name;
                values['html5_ticket'] = '%s';
                try {
                    var info = spt.panel.load('csv_import_main', class_name, {}, values);
                    spt.app_busy.hide();
                }
                catch(e) {
                    spt.alert(spt.exception.handler(e));
                }
            }
            else  {
              alert('Error: file object cannot be found.')
            }
            spt.app_busy.hide();'''%ticket
            from tactic.ui.input import UploadButtonWdg
            browse = UploadButtonWdg(name='new_csv_upload', title="Browse", tip="Click to choose a csv file",\
                    on_complete=on_complete, ticket=ticket)
            browse.add_style('float: left')
            msg.add(browse)




            
            # this is now only used in the copy and paste Upload button for backward-compatibility
            upload_wdg = SimpleUploadWdg(key=key, show_upload=False)
            upload_wdg.add_style('display: none')
            msg.add(upload_wdg)
          
            #widget.add(span)
            msg.add("<br/><br/>-- OR --</br/><br/>")

            msg.add("<b>Published URL: </b>") 
            text = TextWdg("web_url")
            msg.add(text)
 


            msg.add("<br/><br/>-- OR --</br/><br/>")

            msg.add("<b>Copy and Paste from a Spreadsheet: </b>") 
            text = TextAreaWdg("data")
            text.add_style('width: 33em')
            text.add_class("spt_import_cut_paste")
            msg.add(text)
            button = ActionButtonWdg(title="Parse")
            button.add_style("margin: 5px auto")
            msg.add(button)
            button.add_behavior( {
                'type': 'click_up',
                'cbjs_action': '''
                var top = bvr.src_el.getParent(".spt_import_top");
                var el = top.getElement(".spt_import_cut_paste");
                var applet = spt.Applet.get();

                var value = el.value;
                var csv = [];
                // convert to a csv file!
                lines = value.split("\\n");
                for (var i = 0; i < lines.length; i++) {
                    if (lines[i] == '') {
                        continue;
                    }
                    var parts = lines[i].split("\\t");
                    var new_line = [];
                    for (var j = 0; j < parts.length; j++) {
                        if (parts[j] == '') {
                            new_line.push('');
                        }
                        else {
                            new_line.push('"'+parts[j]+'"');
                        }
                    }
                    new_line = new_line.join(",");
                    csv.push(new_line);
                }

                csv = csv.join("\\n")

                // FIXME: need to get a local temp directory
                var path = spt.browser.os_is_Windows() ? "C:/sthpw/copy_n_paste.csv" : "/tmp/sthpw/copy_n_paste.csv";
                applet.create_file(path, csv);

                // upload the file
                applet.upload_file(path)
                applet.rmtree(path);

                var top = bvr.src_el.getParent(".spt_import_csv");
                var hidden = top.getElement(".spt_upload_hidden");
                hidden.value = path;

                var file_name = spt.path.get_basename(hidden.value);
                file_name = spt.path.get_filesystem_name(file_name); 
                var class_name = 'tactic.ui.widget.CsvImportWdg';
                var values = spt.api.Utility.get_input_values('csv_import_main');
                values['is_refresh'] = true;
                values['file_name'] = file_name;
                var info = spt.panel.load('csv_import_main', class_name, {}, values);
                '''
            } )

        
        return widget
예제 #50
0
    def get_display(my):

        top = my.top
        top.add_class("spt_changelist_content")
        my.set_as_panel(top)
        top.add_color("color", "color")
        top.add_color("background", "background")
        #top.add_border()
        #top.add_style("padding", "10px")
        top.add_style("min-width: 600px")
        top.add_style("min-height: 400px")

        top.add_behavior( {
            'type': 'load',
            'cbjs_action': scm_get_onload_js()
        } )



        sync_dir = Environment.get_sandbox_dir()
        # HARD CODED
        project = Project.get()
        depot = project.get_value("location", no_exception=True)
        if not depot:
            depot = project.get_code()
        location = '//%s' % depot


        changelist = my.kwargs.get("changelist")
        if not changelist:
            changelist = WidgetSettings.get_value_by_key("current_changelist")
        else:
            WidgetSettings.set_value_by_key("current_changelist", changelist)

        if not changelist:
            changelist = 'default'


        changelists = my.kwargs.get("changelists")
        if not changelists:
            changelists = []
        elif isinstance(changelists, basestring):
            changelists = changelists.replace("'", '"')
            changelists = jsonloads(changelists)

        top.add_behavior( {
            'type': 'load',
            'sync_dir': sync_dir,
            'depot': depot,
            'cbjs_action': '''
            spt.scm.sync_dir = bvr.sync_dir;
            spt.scm.depot = bvr.depot;
            '''
        } )



        inner = DivWdg()
        top.add(inner)

        table = Table()
        inner.add(table)
        table.add_style("width: 100%")
        table.add_color("background", "background", -3)

        table.add_row()
        th = table.add_header("")

        th = table.add_header("Changelist")
        th.add_style("text-align: left")
        th = table.add_header("Description")
        th.add_style("text-align: left")
        th = table.add_header("# Items")
        th.add_style("text-align: left")
        th = table.add_header("Status")
        th.add_style("text-align: left")
        th = table.add_header("View")
        th.add_style("text-align: left")
        th = table.add_header("Delete")
        th.add_style("text-align: left")
        #table.set_unique_id()
        #table.add_smart_styles("spt_changelist_item", {
        #    'text-align: right'
        #    } ))

        bgcolor = table.get_color("background", -8)
        table.add_relay_behavior( {
            'type': 'mouseover',
            'bvr_match_class': 'spt_changelist_item',
            'bgcolor': bgcolor,
            'cbjs_action': '''
            bvr.src_el.setStyle("background-color", bvr.bgcolor);
            '''
        } )
        table.add_relay_behavior( {
            'type': 'mouseout',
            'bvr_match_class': 'spt_changelist_item',
            'cbjs_action': '''
            bvr.src_el.setStyle("background-color", '');
            '''
        } )


        table.add_relay_behavior( {
            'type': 'mouseup',
            'bvr_match_class': "spt_changelist_radio",
            'cbjs_action': '''

            var changelist = bvr.src_el.value;
            var top = bvr.src_el.getParent(".spt_changelist_content");
            top.setAttribute("spt_changelist", changelist);
            spt.app_busy.show("Loading Changelists Information");
            spt.changelist.load(bvr.src_el, changelist);
            spt.app_busy.hide();

            '''
        } )




        for c in changelists:
            num_items = len(c.get("info"))
            name = c.get("change")

            tr = table.add_row()
            tr.add_class("spt_changelist_item")

            radio = RadioWdg("changelist")
            radio.add_class("spt_changelist_radio")
            table.add_cell(radio)
            radio.set_option("value", name)
            if name == changelist:
                radio.set_checked()


            table.add_cell(name)
            table.add_cell(c.get("desc"))
            table.add_cell(num_items)
            table.add_cell(c.get("status"))

            if num_items:
                icon = IconButtonWdg(title="View", icon=IconWdg.ZOOM)

                icon.add_behavior( {
                    'type': 'click_up',
                    'changelist': c.get("change"),
                    'cbjs_action': '''
                    var top = bvr.src_el.getParent(".spt_changelist_content");
                    top.setAttribute("spt_changelist", bvr.changelist);

                    spt.app_busy.show("Loading Changelist");
                    spt.changelist.load(bvr.src_el, bvr.changelist);
                    spt.app_busy.hide();

                    '''
                } )
            else:
                icon = ''
            table.add_cell(icon)

            if not num_items and name != 'default':
                icon = IconButtonWdg(title="Delete Changelist", icon=IconWdg.DELETE)
            else:
                icon = ""

            table.add_cell(icon)




        inner.add("<hr/>")


        files = my.kwargs.get("files")
        if isinstance(files, basestring):
            files = files.replace("'", '"')
            files = jsonloads(files)



        if files == None:
            inner.add_behavior( {
                'type': 'load',
                'location': location,
                'changelist': changelist,
                'sync_dir': sync_dir,
                'cbjs_action': '''

spt.changelist = {}
spt.changelist.load = function(el, changelist) {
    var applet = spt.Applet.get();
    var changelists = spt.scm.run("get_changelists_by_user",[]);
    var dflt = {
        'change': 'default',
        'status': 'pending'
    }
    changelists.push(dflt);
    changelists = changelists.reverse();
    for (var i = 0; i < changelists.length; i++) {
        var info = spt.scm.run("get_changelist_files",[changelists[i].change]);
        changelists[i]['info'] = info;
    }

    // get the current chnage list
    var files = spt.scm.run("get_changelist_files",[changelist]);
    var path_info = {};
    var sizes = [];
    for ( var i = 0; i < files.length; i++) {

        // FIXME: perforce specific
        var path = files[i].depotFile;
        path = path.replace(bvr.location, bvr.sync_dir);
        files[i].path = path;

        var size;
        if (applet.exists(path)) {
            var info = applet.get_path_info(path);
            size = info.size;
        }
        else {
            size = 0;
        }
        sizes.push(size);
        path_info[path] = 'editable';
    }
    //var ret_val = spt.scm.status(bvr.sync_dir);
    //console.log(ret_val);

    var class_name = 'tactic.ui.checkin.changelist_wdg.ChangelistWdg';
    var kwargs = {
        files: files,
        sizes: sizes,
        changelist: changelist,
        changelists: changelists,
        path_info: path_info,
    }
    var top = el.getParent(".spt_changelist_content");
    spt.panel.load(top, class_name, kwargs);

}
spt.changelist.load(bvr.src_el, bvr.changelist);
            '''
        } )

        content = DivWdg()
        inner.add(content)
        content.add_class("spt_changelist_content")


        if files == None:

            loading_wdg = DivWdg()
            content.add(loading_wdg)
            loading_wdg.add("<b>Loading ...</b>")
            loading_wdg.add_style("padding: 30px")



        elif files:
            title_wdg = DivWdg()
            title_wdg.add_style("height: 15px")
            title_wdg.add("Changelist: [%s]" % changelist)
            content.add(title_wdg)
            title_wdg.add_gradient("background", "background", -5)
            title_wdg.add_style("padding: 5px")
            title_wdg.add_border()

            #button = SingleButtonWdg(tip='Add New Changelist', icon=IconWdg.ADD)
            #content.add(button)

            content.add("<br/>")

            paths = [x.get("path") for x in files]
            sizes = my.kwargs.get("sizes")
            path_info = my.kwargs.get("path_info")
            from scm_dir_list_wdg import ScmDirListWdg
            # dummy search_key
            search_key = "sthpw/virtual?code=xx001"
            dir_list_wdg = ScmDirListWdg(
                    base_dir=sync_dir,
                    paths=paths,
                    sizes=sizes,
                    path_info=path_info,
                    all_open=True,
                    #search_key=search_key
            )
            content.add(dir_list_wdg)

        else:

            content.add("Changelist: [%s]" % changelist)
            content.add("<br/>"*2)

            no_files_wdg = DivWdg()
            content.add(no_files_wdg)
            no_files_wdg.add_style("padding: 20px")
            no_files_wdg.add_border()
            no_files_wdg.add("No files in changelist")

            no_files_wdg.add_color("color", "color3")
            no_files_wdg.add_color("background", "background3")
            no_files_wdg.add_style("font-weight: bold")
            no_files_wdg.add_style("text-align: center")



        return top
예제 #51
0
    def get_display(self):

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

        if snapshot:
            self.snapshot = snapshot
        else:
            self.snapshot = SearchKey.get_by_search_key(search_key)

        assert self.snapshot

        metadata = self.snapshot.get_metadata()

        top = self.top
        top.add_color("background", "background")

        table = Table()
        table.set_max_width()
        top.add(table)
        table.set_unique_id()
        table.add_border()

        table.add_smart_styles("spt_cell", {'padding': '3px'})

        tr = table.add_row()
        tr.add_color("background", "background", -5)
        th = table.add_header("Property")
        th.add_style("min-width: 200px")
        th.add_style("padding: 5px")
        th = table.add_header("Value")
        th.add_style("min-width: 400px")
        th.add_style("padding: 5px")

        keys = metadata.get("__keys__")
        if not keys:
            keys = metadata.keys()

        empty = False
        if not keys:
            empty = True
            keys = ['', '', '', '', '', '', '']
            table.add_smart_styles("spt_cell", {'height': '20px'})

        for i, key in enumerate(keys):
            value = metadata.get(key)

            title = Common.get_display_title(key)

            tr = table.add_row()

            if i % 2:
                tr.add_color("background", "background")
                tr.add_color("color", "color")
            else:
                tr.add_color("background", "background", -8)
                tr.add_color("color", "color")

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(title)

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(value)

        if empty:
            div = DivWdg()
            top.add(div)
            div.add_style("height: 30px")
            div.add_style("width: 150px")
            div.add_style("margin-top: -110px")
            div.center()
            div.add("<b>No Metadata</b>")
            div.add_border()
            div.add_color("background", "background3")
            div.add_color("color", "color3")
            div.add_style("padding: 20px")
            div.add_style("text-align: center")

            top.add_style("min-height: 200px")

        return top
예제 #52
0
    def get_display(my):

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


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



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


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

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

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

            '''
        } )

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

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


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



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



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



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



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

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


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



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

            table.add_cell(title)

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



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



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

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

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

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


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

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

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

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

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


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

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

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

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

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

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

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

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


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

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

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

                '''
            } )
            """





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

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

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

                '''
            } )



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

                '''
            } )





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

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




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


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

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






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

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


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

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


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

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





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

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


                '''
            } )


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


        columns_wdg = DivWdg()
        top.add(columns_wdg)


        return top
예제 #53
0
    def get_display(my):

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


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



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


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

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

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

            '''
        } )

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

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


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



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



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



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



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

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


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



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

            table.add_cell(title)

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



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



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

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

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

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


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

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

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

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

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


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

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

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

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

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

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

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

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


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

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

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

                '''
            } )
            """





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

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

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

                '''
            } )



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

                '''
            } )





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

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




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


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

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






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

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


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

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


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

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





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

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


                '''
            } )


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


        columns_wdg = DivWdg()
        top.add(columns_wdg)


        return top
예제 #54
0
    def get_display(my):

        search_key = my.kwargs.get("search_key")
        snapshot = my.kwargs.get("snapshot")

        if snapshot:
            my.snapshot = snapshot
        else:
            my.snapshot = SearchKey.get_by_search_key(search_key)


        assert my.snapshot

        metadata = my.snapshot.get_metadata()

        top = my.top
        top.add_color("background", "background")


        table = Table()
        table.set_max_width()
        top.add(table)
        table.set_unique_id()
        table.add_border()

        table.add_smart_styles("spt_cell", {
            'padding': '3px'
        } )



        tr = table.add_row()
        tr.add_gradient("background", "background3")
        th = table.add_header("Property")
        th.add_style("min-width: 200px")
        th.add_style("padding: 5px")
        th = table.add_header("Value")
        th.add_style("min-width: 400px")
        th.add_style("padding: 5px")

        keys = metadata.get("__keys__")
        if not keys:
            keys = metadata.keys()

        empty = False
        if not keys:
            empty = True
            keys = ['','','','','','','']
            table.add_smart_styles("spt_cell", {
                'height': '20px'
            } )


        for i, key in enumerate(keys):
            value = metadata.get(key)

            title = Common.get_display_title(key)

            tr = table.add_row()

            if i % 2:
                tr.add_color("background", "background")
                tr.add_color("color", "color")
            else:
                tr.add_color("background", "background", -8)
                tr.add_color("color", "color")

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(title)

            td = table.add_cell()
            td.add_class("spt_cell")
            td.add(value)


        if empty:
            div = DivWdg()
            top.add(div)
            div.add_style("height: 30px")
            div.add_style("width: 150px")
            div.add_style("margin-top: -110px")
            div.center()
            div.add("<b>No Metadata</b>")
            div.add_border()
            div.add_color("background", "background3")
            div.add_color("color", "color3")
            div.add_style("padding: 20px")
            div.add_style("text-align: center")

            top.add_style("min-height: 200px")

        return top
예제 #55
0
    def get_example_display(my):

        div = DivWdg()

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

        cat_menus = [ my.get_sm_cat_main_menu_details() ]

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



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

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

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

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

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

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

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

        div.add( table )
        return div