<commit_before><template>
  <table>
    <colgroup>
      <col v-if="expandedRowRender" width="40"/>
      <col v-for="column in columns" :width="column.width"/>
      <col v-if="scrollY" width="15"/>
    </colgroup>
    <thead>
    <tr v-for="row in rows">
      <th v-if="expandedRowRender">&nbsp;</th>
      <th v-for="column in row" :rowspan="column.rowSpan" :colspan="column.colSpan"
          :style="{'text-align': column.align || 'left'}"
          :class="{'sortable': column.sortable}"
          @click="thClickHandler(column)">
        <template v-if="'index' === column.type">{{ column.title }}</template>
        <template v-else-if="'checkbox' === column.type">
          <fish-checkbox index="-1" @click="checkboxSelectHandler" ref="checkboxes"></fish-checkbox>
        </template>
        <template v-else>
          {{ column.title }}
        </template>
        <strong v-if="column.sortable" v-html="orderKey === column.key ? (orderBy === 'desc' ? '&#8595;' : '&#8593;') : ''"></strong>
        <template v-if="column.filters">
          <fish-table-head-filter :title="column.title" :items="column.filters" :index="column.key"
                                  ref="filters" @change="clickFilterHandler">
          </fish-table-head-filter>
        </template>
      </th>
      <th v-if="scrollY" style="width: 15px;"></th>
    </tr>
    </thead>
  </table>
</template>
<script>
  import fishTableHeadFilter from './TableHeadFilter.vue'
  import fishCheckbox from './Checkbox.vue'

  export default {
    components: {
      fishCheckbox,
      fishTableHeadFilter
    },
    name: 'fish-table-head',
    props: {
      columns: { type: Array, required: true }, // [{title: '', key: '', width: 100, type: [index, checkbox], render: () => {}, align: 'left', sortable: true}]
      rows: { type: Array, required: true },
      expandedRowRender: { type: Function, default: null }, // 没有fixed列，方可展开详情
      scrollY: { type: Boolean, default: false }
    },
    data () {
      return {
        orderKey: null,
        orderBy: ''
      }
    },
    methods: {
      checkboxSelectHandler (evt) {
        this.$emit('select', this)
      },
      clickFilterHandler (evt) {
        const { filters } = this.$refs
        const filterMap = {}
        filters.forEach((filter) => {
          if (filter.values.length > 0) filterMap[filter.index] = filter.values
        })
        this.$emit('filter-change', filterMap)
      },
      thClickHandler (column) {
        if (column.sortable) {
          if (this.orderKey !== column.key) {
            this.orderBy = ''
          }
          this.orderKey = column.key
          if (this.orderBy !== '') {
            this.orderBy = this.orderBy === 'desc' ? 'asc' : 'desc'
          } else {
            this.orderBy = 'desc'
          }
        }
        this.$emit('sort-change', this.orderKey, this.orderBy)
      }
    }
  }
</script><commit_msg>table th click bugfix<commit_after><template>
  <table>
    <colgroup>
      <col v-if="expandedRowRender" width="40"/>
      <col v-for="column in columns" :width="column.width"/>
      <col v-if="scrollY" width="15"/>
    </colgroup>
    <thead>
    <tr v-for="row in rows">
      <th v-if="expandedRowRender">&nbsp;</th>
      <th v-for="column in row" :rowspan="column.rowSpan" :colspan="column.colSpan"
          :style="{'text-align': column.align || 'left'}"
          :class="{'sortable': column.sortable}"
          @click="thClickHandler(column)">
        <template v-if="'index' === column.type">{{ column.title }}</template>
        <template v-else-if="'checkbox' === column.type">
          <fish-checkbox index="-1" @click="checkboxSelectHandler" ref="checkboxes"></fish-checkbox>
        </template>
        <template v-else>
          {{ column.title }}
        </template>
        <strong v-if="column.sortable" v-html="orderKey === column.key ? (orderBy === 'desc' ? '&#8595;' : '&#8593;') : ''"></strong>
        <template v-if="column.filters">
          <fish-table-head-filter :title="column.title" :items="column.filters" :index="column.key"
                                  ref="filters" @change="clickFilterHandler">
          </fish-table-head-filter>
        </template>
      </th>
      <th v-if="scrollY" style="width: 15px;"></th>
    </tr>
    </thead>
  </table>
</template>
<script>
  import fishTableHeadFilter from './TableHeadFilter.vue'
  import fishCheckbox from './Checkbox.vue'

  export default {
    components: {
      fishCheckbox,
      fishTableHeadFilter
    },
    name: 'fish-table-head',
    props: {
      columns: { type: Array, required: true }, // [{title: '', key: '', width: 100, type: [index, checkbox], render: () => {}, align: 'left', sortable: true}]
      rows: { type: Array, required: true },
      expandedRowRender: { type: Function, default: null }, // 没有fixed列，方可展开详情
      scrollY: { type: Boolean, default: false }
    },
    data () {
      return {
        orderKey: null,
        orderBy: ''
      }
    },
    methods: {
      checkboxSelectHandler (evt) {
        this.$emit('select', this)
      },
      clickFilterHandler (evt) {
        const { filters } = this.$refs
        const filterMap = {}
        filters.forEach((filter) => {
          if (filter.values.length > 0) filterMap[filter.index] = filter.values
        })
        this.$emit('filter-change', filterMap)
      },
      thClickHandler (column) {
        if (column.sortable) {
          if (this.orderKey !== column.key) {
            this.orderBy = ''
          }
          this.orderKey = column.key
          if (this.orderBy !== '') {
            this.orderBy = this.orderBy === 'desc' ? 'asc' : 'desc'
          } else {
            this.orderBy = 'desc'
          }
          this.$emit('sort-change', this.orderKey, this.orderBy)
        }
      }
    }
  }
</script>
{'fraction_non_alphanumeric': 0.17717614804660728, 'fraction_numerical': 0.0065113091158327625, 'mean_word_length': 2.2106710671067105, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4200508', 'n_tokens_mistral': 1842, 'n_tokens_neox': 1807, 'n_words': 358}