Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

head.js 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  2. import { consoleWarn } from '../../../util/console';
  3. import VCheckbox from '../../VCheckbox';
  4. import VIcon from '../../VIcon';
  5. /* @vue/component */
  6. export default {
  7. props: {
  8. sortIcon: {
  9. type: String,
  10. default: '$vuetify.icons.sort'
  11. }
  12. },
  13. methods: {
  14. genTHead: function genTHead() {
  15. var _this = this;
  16. if (this.hideHeaders) return; // Exit Early since no headers are needed.
  17. var children = [];
  18. if (this.$scopedSlots.headers) {
  19. var row = this.$scopedSlots.headers({
  20. headers: this.headers,
  21. indeterminate: this.indeterminate,
  22. all: this.everyItem
  23. });
  24. children = [this.hasTag(row, 'th') ? this.genTR(row) : row, this.genTProgress()];
  25. } else {
  26. var _row = this.headers.map(function (o, i) {
  27. return _this.genHeader(o, _this.headerKey ? o[_this.headerKey] : i);
  28. });
  29. var checkbox = this.$createElement(VCheckbox, {
  30. props: {
  31. dark: this.dark,
  32. light: this.light,
  33. color: this.selectAll === true ? '' : this.selectAll,
  34. hideDetails: true,
  35. inputValue: this.everyItem,
  36. indeterminate: this.indeterminate
  37. },
  38. on: { change: this.toggle }
  39. });
  40. this.hasSelectAll && _row.unshift(this.$createElement('th', [checkbox]));
  41. children = [this.genTR(_row), this.genTProgress()];
  42. }
  43. return this.$createElement('thead', [children]);
  44. },
  45. genHeader: function genHeader(header, key) {
  46. var array = [this.$scopedSlots.headerCell ? this.$scopedSlots.headerCell({ header: header }) : header[this.headerText]];
  47. return this.$createElement.apply(this, ['th'].concat(_toConsumableArray(this.genHeaderData(header, array, key))));
  48. },
  49. genHeaderData: function genHeaderData(header, children, key) {
  50. var classes = ['column'];
  51. var data = {
  52. key: key,
  53. attrs: {
  54. role: 'columnheader',
  55. scope: 'col',
  56. width: header.width || null,
  57. 'aria-label': header[this.headerText] || '',
  58. 'aria-sort': 'none'
  59. }
  60. };
  61. if (header.sortable == null || header.sortable) {
  62. this.genHeaderSortingData(header, children, data, classes);
  63. } else {
  64. data.attrs['aria-label'] += ': Not sorted.'; // TODO: Localization
  65. }
  66. classes.push('text-xs-' + (header.align || 'left'));
  67. if (Array.isArray(header.class)) {
  68. classes.push.apply(classes, _toConsumableArray(header.class));
  69. } else if (header.class) {
  70. classes.push(header.class);
  71. }
  72. data.class = classes;
  73. return [data, children];
  74. },
  75. genHeaderSortingData: function genHeaderSortingData(header, children, data, classes) {
  76. var _this2 = this;
  77. if (!('value' in header)) {
  78. consoleWarn('Headers must have a value property that corresponds to a value in the v-model array', this);
  79. }
  80. data.attrs.tabIndex = 0;
  81. data.on = {
  82. click: function click() {
  83. _this2.expanded = {};
  84. _this2.sort(header.value);
  85. },
  86. keydown: function keydown(e) {
  87. // check for space
  88. if (e.keyCode === 32) {
  89. e.preventDefault();
  90. _this2.sort(header.value);
  91. }
  92. }
  93. };
  94. classes.push('sortable');
  95. var icon = this.$createElement(VIcon, {
  96. props: {
  97. small: true
  98. }
  99. }, this.sortIcon);
  100. if (!header.align || header.align === 'left') {
  101. children.push(icon);
  102. } else {
  103. children.unshift(icon);
  104. }
  105. var pagination = this.computedPagination;
  106. var beingSorted = pagination.sortBy === header.value;
  107. if (beingSorted) {
  108. classes.push('active');
  109. if (pagination.descending) {
  110. classes.push('desc');
  111. data.attrs['aria-sort'] = 'descending';
  112. data.attrs['aria-label'] += ': Sorted descending. Activate to remove sorting.'; // TODO: Localization
  113. } else {
  114. classes.push('asc');
  115. data.attrs['aria-sort'] = 'ascending';
  116. data.attrs['aria-label'] += ': Sorted ascending. Activate to sort descending.'; // TODO: Localization
  117. }
  118. } else {
  119. data.attrs['aria-label'] += ': Not sorted. Activate to sort ascending.'; // TODO: Localization
  120. }
  121. }
  122. }
  123. };
  124. //# sourceMappingURL=head.js.map