|
4 | 4 | :class="tableClass"
|
5 | 5 | >
|
6 | 6 | <thead :class="headClass">
|
7 |
| - <tr> |
8 |
| - <th v-for="(field,key) in fields" |
9 |
| - @click.stop.prevent="headClicked($event,field,key)" |
10 |
| - @keydown.enter.stop.prevent="headClicked($event,field,key)" |
11 |
| - @keydown.space.stop.prevent="headClicked($event,field,key)" |
12 |
| - :key="key" |
13 |
| - :class="fieldClass(field,key)" |
14 |
| - :style="field.thStyle || {}" |
15 |
| - :aria-label="field.sortable ? ((localSortDesc && localSortBy === key) ? labelSortAsc : labelSortDesc) : null" |
16 |
| - :aria-sort="(field.sortable && localSortBy === key) ? (localSortDesc ? 'descending' : 'ascending') : null" |
17 |
| - :tabindex="field.sortable?'0':null" |
18 |
| - > |
19 |
| - <slot :name="'HEAD_'+key" :label="field.label" :column="key" :field="field"> |
| 7 | + <tr> |
| 8 | + <th v-for="(field,key) in fields" |
| 9 | + @click.stop.prevent="headClicked($event,field,key)" |
| 10 | + @keydown.enter.stop.prevent="headClicked($event,field,key)" |
| 11 | + @keydown.space.stop.prevent="headClicked($event,field,key)" |
| 12 | + :key="key" |
| 13 | + :class="fieldClass(field,key)" |
| 14 | + :style="field.thStyle || {}" |
| 15 | + :aria-label="field.sortable ? ((localSortDesc && localSortBy === key) ? labelSortAsc : labelSortDesc) : null" |
| 16 | + :aria-sort="(field.sortable && localSortBy === key) ? (localSortDesc ? 'descending' : 'ascending') : null" |
| 17 | + :tabindex="field.sortable?'0':null" |
| 18 | + > |
| 19 | + <slot :name="'HEAD_'+key" :label="field.label" :column="key" :field="field"> |
20 | 20 | <div v-html="field.label"></div>
|
21 |
| - </slot> |
22 |
| - </th> |
23 |
| - </tr> |
| 21 | + </slot> |
| 22 | + </th> |
| 23 | + </tr> |
24 | 24 | </thead>
|
25 | 25 | <tfoot v-if="footClone" :class="footClass">
|
26 |
| - <tr> |
27 |
| - <th v-for="(field,key) in fields" |
28 |
| - @click.stop.prevent="headClicked($event,field,key)" |
29 |
| - @keydown.enter.stop.prevent="headClicked($event,field,key)" |
30 |
| - @keydown.space.stop.prevent="headClicked($event,field,key)" |
31 |
| - :key="key" |
32 |
| - :class="fieldClass(field,key)" |
33 |
| - :style="field.thStyle || {}" |
34 |
| - :aria-label="field.sortable ? ((localSortDesc && localSortBy === key) ? labelSortAsc : labelSortDesc) : null" |
35 |
| - :aria-sort="(field.sortable && localSortBy === key) ? (localSortDesc ? 'descending' : 'ascending') : null" |
36 |
| - :tabindex="field.sortable?'0':null" |
37 |
| - > |
38 |
| - <slot v-if="$scopedSlots['FOOT_'+key]" :name="'FOOT_'+key" :label="field.label" :column="key" :field="field"> |
| 26 | + <tr> |
| 27 | + <th v-for="(field,key) in fields" |
| 28 | + @click.stop.prevent="headClicked($event,field,key)" |
| 29 | + @keydown.enter.stop.prevent="headClicked($event,field,key)" |
| 30 | + @keydown.space.stop.prevent="headClicked($event,field,key)" |
| 31 | + :key="key" |
| 32 | + :class="fieldClass(field,key)" |
| 33 | + :style="field.thStyle || {}" |
| 34 | + :aria-label="field.sortable ? ((localSortDesc && localSortBy === key) ? labelSortAsc : labelSortDesc) : null" |
| 35 | + :aria-sort="(field.sortable && localSortBy === key) ? (localSortDesc ? 'descending' : 'ascending') : null" |
| 36 | + :tabindex="field.sortable?'0':null" |
| 37 | + > |
| 38 | + <slot v-if="$scopedSlots['FOOT_'+key]" :name="'FOOT_'+key" :label="field.label" :column="key" |
| 39 | + :field="field"> |
39 | 40 | <div v-html="field.label"></div>
|
40 |
| - </slot> |
41 |
| - <slot v-else :name="'HEAD_'+key" :label="field.label" :column="key" :field="field"> |
| 41 | + </slot> |
| 42 | + <slot v-else :name="'HEAD_'+key" :label="field.label" :column="key" :field="field"> |
42 | 43 | <div v-html="field.label"></div>
|
43 |
| - </slot> |
44 |
| - </th> |
45 |
| - </tr> |
| 44 | + </slot> |
| 45 | + </th> |
| 46 | + </tr> |
46 | 47 | </tfoot>
|
47 | 48 | <tbody>
|
48 | 49 | <tr v-for="(item,index) in _items"
|
|
53 | 54 | >
|
54 | 55 | <template v-for="(field,key) in fields">
|
55 | 56 | <td v-if="hasFormatter(field)" :key="key" :class="tdClass(field, item, key)"
|
56 |
| - v-html="callFormatter(field, item, key)"> |
| 57 | + v-html="callFormatter(item, key, field)"> |
57 | 58 | </td>
|
58 | 59 | <td v-else :class="tdClass(field, item, key)" :key="key">
|
59 | 60 | <slot :name="key" :value="item[key]" :item="item" :index="index">{{item[key]}}</slot>
|
|
81 | 82 | <script>
|
82 | 83 | import { warn } from '../utils';
|
83 | 84 | import { keys } from '../utils/object.js';
|
84 |
| - import {listenOnRootMixin} from '../mixins'; |
| 85 | + import { listenOnRootMixin } from '../mixins'; |
85 | 86 |
|
86 | 87 | const toString = v => {
|
87 | 88 | if (!v) {
|
|
135 | 136 | default() {
|
136 | 137 | if (this && this.itemsProvider) {
|
137 | 138 | // Deprecate itemsProvider
|
138 |
| - warn("b-table: prop 'items-provider' has been deprecated. Pass a function to 'items' instead"); |
| 139 | + warn('b-table: prop \'items-provider\' has been deprecated. Pass a function to \'items\' instead'); |
139 | 140 | return this.itemsProvider;
|
140 | 141 | }
|
141 | 142 | return [];
|
|
482 | 483 | return;
|
483 | 484 | }
|
484 | 485 | let sortChanged = false;
|
485 |
| - if (!field.sortable) { |
486 |
| - if (this.localSortBy) { |
487 |
| - this.localSortBy = null; |
488 |
| - this.localSortDesc = false; |
489 |
| - sortChanged = true; |
490 |
| - } |
491 |
| - } else { |
| 486 | + if (field.sortable) { |
492 | 487 | if (key === this.localSortBy) {
|
493 | 488 | // Change sorting direction on current column
|
494 | 489 | this.localSortDesc = !this.localSortDesc;
|
|
498 | 493 | this.localSortDesc = false;
|
499 | 494 | }
|
500 | 495 | sortChanged = true;
|
| 496 | + } else if (this.localSortBy) { |
| 497 | + this.localSortBy = null; |
| 498 | + this.localSortDesc = false; |
| 499 | + sortChanged = true; |
501 | 500 | }
|
| 501 | +
|
502 | 502 | this.$emit('head-clicked', key, field);
|
503 | 503 | if (sortChanged) {
|
504 | 504 | // Sorting parameters changed
|
|
544 | 544 | hasFormatter(field) {
|
545 | 545 | return field.formatter && ((typeof (field.formatter) === 'function') || (typeof (field.formatter) === 'string'));
|
546 | 546 | },
|
547 |
| - callFormatter(field, item, key) { |
| 547 | + callFormatter(item, key, field) { |
548 | 548 | if (field.formatter && (typeof (field.formatter) === 'function'))
|
549 | 549 | return field.formatter(item[key]);
|
550 | 550 |
|
|
0 commit comments