aloha-vue 2.60.0 → 2.61.0
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.
- package/CHANGELOG.md +8 -0
- package/dist/aloha-vue.css +9 -0
- package/dist/aloha-vue.css.map +1 -1
- package/dist/aloha-vue.es.js +9553 -9379
- package/dist/aloha-vue.umd.js +49 -49
- package/package.json +1 -1
- package/scss/components/ATableForm.scss +13 -0
- package/src/ATableForm/ATableForm.js +18 -6
- package/src/ATableForm/ATableFormCellList/ATableFormCellList.js +122 -0
- package/src/ATableForm/ATableFormCellList/compositionAPI/DataAPI.js +60 -0
- package/src/ATableForm/ATableFormRow/ATableFormRow.js +463 -443
- package/src/ATableForm/ATableFormRow/compositionAPI/EditAPI.js +102 -98
- package/src/ATableForm/__tests__/ATableForm.DragAndDropAPI.test.js +3 -1
- package/src/ATableForm/__tests__/ATableForm.ListView.test.js +255 -0
- package/src/ATableForm/compositionAPI/ColumnsAPI.js +40 -39
- package/src/ATableForm/compositionAPI/DragAndDropAPI.js +6 -3
- package/src/ATableForm/compositionAPI/EditAPI.js +127 -119
- package/src/ui/AForm/AForm.js +14 -9
|
@@ -1,119 +1,127 @@
|
|
|
1
|
-
import {
|
|
2
|
-
computed,
|
|
3
|
-
ref,
|
|
4
|
-
toRef,
|
|
5
|
-
} from "vue";
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
setFocusToElement,
|
|
9
|
-
} from "../../utils/utilsDOM";
|
|
10
|
-
import {
|
|
11
|
-
cloneDeep,
|
|
12
|
-
isFunction,
|
|
13
|
-
} from "lodash-es";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
activeEditRowKey.value = undefined;
|
|
79
|
-
activeEditModel.value =
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
1
|
+
import {
|
|
2
|
+
computed,
|
|
3
|
+
ref,
|
|
4
|
+
toRef,
|
|
5
|
+
} from "vue";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
setFocusToElement,
|
|
9
|
+
} from "../../utils/utilsDOM";
|
|
10
|
+
import {
|
|
11
|
+
cloneDeep,
|
|
12
|
+
isFunction,
|
|
13
|
+
} from "lodash-es";
|
|
14
|
+
|
|
15
|
+
const hasRequiredElement = element => {
|
|
16
|
+
if (element?.required) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return element?.children?.some(hasRequiredElement) || false;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default function EditAPI(props, {
|
|
24
|
+
columnsVisible = computed(() => []),
|
|
25
|
+
getRowKey = () => {},
|
|
26
|
+
}) {
|
|
27
|
+
const addRow = toRef(props, "addRow");
|
|
28
|
+
const isAddable = toRef(props, "isAddable");
|
|
29
|
+
const isEditable = toRef(props, "isEditable");
|
|
30
|
+
const prepareEditModel = toRef(props, "prepareEditModel");
|
|
31
|
+
const rows = toRef(props, "rows");
|
|
32
|
+
|
|
33
|
+
const activeEditRowKey = ref(undefined);
|
|
34
|
+
const activeEditModel = ref(undefined);
|
|
35
|
+
const isAddRowActive = ref(false);
|
|
36
|
+
|
|
37
|
+
const hasActiveEditRow = computed(() => {
|
|
38
|
+
return !!activeEditRowKey.value || isAddRowActive.value;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const canAddRow = computed(() => {
|
|
42
|
+
if (!isAddable.value) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return isFunction(addRow.value);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const hasRequiredEditableColumns = computed(() => {
|
|
50
|
+
if (!isEditable.value) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return columnsVisible.value.some(column => {
|
|
55
|
+
return hasRequiredElement(column.formElement);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const getPreparedEditModel = params => {
|
|
60
|
+
if (!isFunction(prepareEditModel.value)) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const result = prepareEditModel.value(params);
|
|
65
|
+
|
|
66
|
+
if (result?.model === undefined) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return cloneDeep(result.model);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const onAddRow = () => {
|
|
74
|
+
if (hasActiveEditRow.value || !canAddRow.value) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
activeEditRowKey.value = undefined;
|
|
79
|
+
activeEditModel.value = getPreparedEditModel({
|
|
80
|
+
rows: rows.value,
|
|
81
|
+
});
|
|
82
|
+
isAddRowActive.value = true;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const onCancelEditRow = ({ trigger, id } = {}) => {
|
|
86
|
+
activeEditRowKey.value = undefined;
|
|
87
|
+
activeEditModel.value = undefined;
|
|
88
|
+
isAddRowActive.value = false;
|
|
89
|
+
if (trigger === "cancel") {
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
setFocusToElement({ selector: `#${ id }_edit` });
|
|
92
|
+
});
|
|
93
|
+
} else if (trigger === "save") {
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
setFocusToElement({ selector: `#${ id }` });
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const onEditRow = ({ row, rowIndex }) => {
|
|
101
|
+
if (isAddRowActive.value) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
activeEditModel.value = getPreparedEditModel({
|
|
106
|
+
row,
|
|
107
|
+
rowIndex,
|
|
108
|
+
rows: rows.value,
|
|
109
|
+
});
|
|
110
|
+
activeEditRowKey.value = getRowKey({
|
|
111
|
+
row,
|
|
112
|
+
rowIndex,
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
activeEditRowKey,
|
|
118
|
+
activeEditModel,
|
|
119
|
+
canAddRow,
|
|
120
|
+
hasActiveEditRow,
|
|
121
|
+
hasRequiredEditableColumns,
|
|
122
|
+
isAddRowActive,
|
|
123
|
+
onAddRow,
|
|
124
|
+
onCancelEditRow,
|
|
125
|
+
onEditRow,
|
|
126
|
+
};
|
|
127
|
+
}
|
package/src/ui/AForm/AForm.js
CHANGED
|
@@ -90,11 +90,16 @@ export default {
|
|
|
90
90
|
required: false,
|
|
91
91
|
default: "",
|
|
92
92
|
},
|
|
93
|
-
showErrors: {
|
|
94
|
-
type: Boolean,
|
|
95
|
-
required: false,
|
|
96
|
-
default: true,
|
|
97
|
-
},
|
|
93
|
+
showErrors: {
|
|
94
|
+
type: Boolean,
|
|
95
|
+
required: false,
|
|
96
|
+
default: true,
|
|
97
|
+
},
|
|
98
|
+
showRequiredText: {
|
|
99
|
+
type: Boolean,
|
|
100
|
+
required: false,
|
|
101
|
+
default: true,
|
|
102
|
+
},
|
|
98
103
|
tag: {
|
|
99
104
|
type: String,
|
|
100
105
|
required: false,
|
|
@@ -177,10 +182,10 @@ export default {
|
|
|
177
182
|
this.$slots.formPrepend() :
|
|
178
183
|
"",
|
|
179
184
|
|
|
180
|
-
this.isRequiredLocal ?
|
|
181
|
-
h(ARequired, {
|
|
182
|
-
text: this.textRequired,
|
|
183
|
-
}) :
|
|
185
|
+
this.showRequiredText && this.isRequiredLocal ?
|
|
186
|
+
h(ARequired, {
|
|
187
|
+
text: this.textRequired,
|
|
188
|
+
}) :
|
|
184
189
|
"",
|
|
185
190
|
this.$slots.formPrependAfterRequired ?
|
|
186
191
|
this.$slots.formPrependAfterRequired() :
|