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.6KB

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