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.

VDataTable.js 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  2. import '../../../src/stylus/components/_tables.styl';
  3. import '../../../src/stylus/components/_data-table.styl';
  4. import DataIterable from '../../mixins/data-iterable';
  5. import Head from './mixins/head';
  6. import Body from './mixins/body';
  7. import Foot from './mixins/foot';
  8. import Progress from './mixins/progress';
  9. import { createSimpleFunctional, getObjectValueByPath } from '../../util/helpers';
  10. // Importing does not work properly
  11. var VTableOverflow = createSimpleFunctional('v-table__overflow');
  12. /* @vue/component */
  13. export default {
  14. name: 'v-data-table',
  15. mixins: [DataIterable, Head, Body, Foot, Progress],
  16. props: {
  17. headers: {
  18. type: Array,
  19. default: function _default() {
  20. return [];
  21. }
  22. },
  23. headersLength: {
  24. type: Number
  25. },
  26. headerText: {
  27. type: String,
  28. default: 'text'
  29. },
  30. headerKey: {
  31. type: String,
  32. default: null
  33. },
  34. hideHeaders: Boolean,
  35. rowsPerPageText: {
  36. type: String,
  37. default: '$vuetify.dataTable.rowsPerPageText'
  38. },
  39. customFilter: {
  40. type: Function,
  41. default: function _default(items, search, filter, headers) {
  42. search = search.toString().toLowerCase();
  43. if (search.trim() === '') return items;
  44. var props = headers.map(function (h) {
  45. return h.value;
  46. });
  47. return items.filter(function (item) {
  48. return props.some(function (prop) {
  49. return filter(getObjectValueByPath(item, prop, item[prop]), search);
  50. });
  51. });
  52. }
  53. }
  54. },
  55. data: function data() {
  56. return {
  57. actionsClasses: 'v-datatable__actions',
  58. actionsRangeControlsClasses: 'v-datatable__actions__range-controls',
  59. actionsSelectClasses: 'v-datatable__actions__select',
  60. actionsPaginationClasses: 'v-datatable__actions__pagination'
  61. };
  62. },
  63. computed: {
  64. classes: function classes() {
  65. return _extends({
  66. 'v-datatable v-table': true,
  67. 'v-datatable--select-all': this.selectAll !== false
  68. }, this.themeClasses);
  69. },
  70. filteredItems: function filteredItems() {
  71. return this.filteredItemsImpl(this.headers);
  72. },
  73. headerColumns: function headerColumns() {
  74. return this.headersLength || this.headers.length + (this.selectAll !== false);
  75. }
  76. },
  77. created: function created() {
  78. var firstSortable = this.headers.find(function (h) {
  79. return !('sortable' in h) || h.sortable;
  80. });
  81. this.defaultPagination.sortBy = !this.disableInitialSort && firstSortable ? firstSortable.value : null;
  82. this.initPagination();
  83. },
  84. methods: {
  85. hasTag: function hasTag(elements, tag) {
  86. return Array.isArray(elements) && elements.find(function (e) {
  87. return e.tag === tag;
  88. });
  89. },
  90. genTR: function genTR(children) {
  91. var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  92. return this.$createElement('tr', data, children);
  93. }
  94. },
  95. render: function render(h) {
  96. var tableOverflow = h(VTableOverflow, {}, [h('table', {
  97. 'class': this.classes
  98. }, [this.genTHead(), this.genTBody(), this.genTFoot()])]);
  99. return h('div', [tableOverflow, this.genActionsFooter()]);
  100. }
  101. };
  102. //# sourceMappingURL=VDataTable.js.map