aloha-vue 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,6 +47,8 @@ export default {
47
47
  id: "obj",
48
48
  path: "obj.aloha",
49
49
  sortId: "obj.aloha",
50
+ slot: "get",
51
+ filter: "boolean",
50
52
  },
51
53
  {
52
54
  label: "Obj2",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "aloha-vue",
3
3
  "description": "Project aloha",
4
- "version": "1.0.11",
4
+ "version": "1.0.12",
5
5
  "author": "Ilia Brykin",
6
6
  "dependencies": {
7
7
  "@popperjs/core": "2.11.5",
@@ -0,0 +1,139 @@
1
+ import {
2
+ capitalize,
3
+ h,
4
+ } from "vue";
5
+
6
+ import FiltersAPI from "../compositionAPI/FiltersAPI";
7
+
8
+ import {
9
+ forEach,
10
+ get,
11
+ isArray, isFunction,
12
+ isUndefined,
13
+ } from "lodash-es";
14
+
15
+ // @vue/component
16
+ export default {
17
+ name: "AGet",
18
+ props: {
19
+ path: {
20
+ type: [String, Array],
21
+ required: true,
22
+ info: "Weg zu Informationen. Z.B.('a[0].b.c', 'vertrag.antrag_obj.pk', ['vertrag', aloha, 'pk'])",
23
+ },
24
+ data: {
25
+ type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
26
+ required: false,
27
+ default: undefined,
28
+ info: "Haupt-Objekt oder -Array, wo man sucht",
29
+ },
30
+ tag: {
31
+ type: String,
32
+ required: false,
33
+ default: "span",
34
+ info: "Semantisch-relevanter HTML-Tag.(span, div, ...)",
35
+ },
36
+ defaultValue: {
37
+ type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
38
+ required: false,
39
+ default: undefined,
40
+ info: "Standardwert, wenn Lodash-Funktion 'get' undefined zurückschickt",
41
+ },
42
+ filter: {
43
+ type: String,
44
+ required: false,
45
+ default: undefined,
46
+ },
47
+ filterParameters: {
48
+ type: Array,
49
+ required: false,
50
+ default: () => [],
51
+ },
52
+ replacedWithDefault: {
53
+ type: [String, Number, Boolean, Array, Object, Date, Function, Symbol],
54
+ required: false,
55
+ default: undefined,
56
+ info: "Wenn das Wert, das Lodash-Funktion 'get' zurückschickt, === this.replacedWithDefault, dann this.defaultValue",
57
+ },
58
+ },
59
+ setup() {
60
+ const {
61
+ filterBoolean,
62
+ filterCurrency,
63
+ filterDate,
64
+ filterDefaultForEmpty,
65
+ filterEmail,
66
+ filterFileSize,
67
+ filterIban,
68
+ filterJson,
69
+ filterKeyValue,
70
+ filterLimitTo,
71
+ filterLink,
72
+ filterList,
73
+ filterSearchHighlight,
74
+ } = FiltersAPI();
75
+
76
+ return {
77
+ filterBoolean,
78
+ filterCurrency,
79
+ filterDate,
80
+ filterDefaultForEmpty,
81
+ filterEmail,
82
+ filterFileSize,
83
+ filterIban,
84
+ filterJson,
85
+ filterKeyValue,
86
+ filterLimitTo,
87
+ filterLink,
88
+ filterList,
89
+ filterSearchHighlight,
90
+ };
91
+ },
92
+ computed: {
93
+ valueLocal() {
94
+ const VALUE = get(this.data, this.pathLocal, this.defaultValue);
95
+ if (this.isValueEqualsWithValueThenDefaultValue(VALUE)) {
96
+ return this.defaultValue;
97
+ }
98
+ if (this.filter) {
99
+ const FILTER_FUNCTION_NAME = `filter${ capitalize(this.filter) }`;
100
+ if (isFunction(this[FILTER_FUNCTION_NAME])) {
101
+ return this[FILTER_FUNCTION_NAME](VALUE, ...this.filterParameters);
102
+ }
103
+ console.warn(`filter "${ FILTER_FUNCTION_NAME }" ist not defined`);
104
+ }
105
+ return VALUE;
106
+ },
107
+
108
+ pathLocal() {
109
+ if (isArray(this.path)) {
110
+ return this.path.join(".");
111
+ }
112
+ return this.path;
113
+ },
114
+ },
115
+ methods: {
116
+ isValueEqualsWithValueThenDefaultValue(value) {
117
+ if (isUndefined(this.replacedWithDefault)) {
118
+ return false;
119
+ }
120
+ let isEquals = false;
121
+ if (isArray(this.replacedWithDefault)) {
122
+ forEach(this.replacedWithDefault, item => {
123
+ if (item === value) {
124
+ isEquals = true;
125
+ return false;
126
+ }
127
+ });
128
+ } else if (this.replacedWithDefault === value) {
129
+ isEquals = true;
130
+ }
131
+ return isEquals;
132
+ },
133
+ },
134
+ render() {
135
+ return h(this.tag, {
136
+ innerHTML: this.valueLocal,
137
+ });
138
+ },
139
+ };
@@ -6,6 +6,7 @@ import {
6
6
  toRef,
7
7
  } from "vue";
8
8
 
9
+ import AGet from "../AGet/AGet";
9
10
  import ATableCountProPage from "./ATableCountProPage/ATableCountProPage";
10
11
  import ATableHeader from "./ATableHeader/ATableHeader";
11
12
  import ATablePagination from "./ATablePagination/ATablePagination";
@@ -21,7 +22,13 @@ import {
21
22
  getModelColumnsVisibleDefault,
22
23
  } from "./utils/utils";
23
24
  import {
24
- cloneDeep, forEach, get, isArray, isNil, isPlainObject, keyBy,
25
+ cloneDeep,
26
+ forEach,
27
+ get,
28
+ isArray,
29
+ isNil,
30
+ isPlainObject,
31
+ keyBy,
25
32
  orderBy,
26
33
  startsWith,
27
34
  uniqueId,
@@ -474,7 +481,18 @@ export default {
474
481
  return h(ATableTr, {
475
482
  row,
476
483
  rowIndex,
477
- }, this.$slots);
484
+ }, {
485
+ get: vm => [
486
+ h(AGet, {
487
+ data: vm.row,
488
+ path: vm.column.path,
489
+ filter: vm.column.filter,
490
+ filterParameters: vm.column.filterParameters,
491
+ defaultValue: vm.column.defaultValue,
492
+ }),
493
+ ],
494
+ ...this.$slots,
495
+ });
478
496
  })),
479
497
  ]),
480
498
  !this.hasRows && h("div", {