aloha-vue 2.80.0 → 2.80.1
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 +4 -0
- package/dist/aloha-vue.es.js +2070 -2072
- package/dist/aloha-vue.umd.js +96 -96
- package/package.json +1 -1
- package/src/ui/AValidatedJson/__tests__/AValidatedJson.ValueKey.test.js +23 -0
- package/src/ui/utils/__tests__/utils.requiredElements.test.js +53 -0
- package/src/ui/utils/utils.js +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aloha-vue",
|
|
3
|
-
"version": "2.80.
|
|
3
|
+
"version": "2.80.1",
|
|
4
4
|
"description": "Aloha-vue is a JavaScript library that provides a wide range of accessible components and directives for Vue.js. Accessibility is of paramount importance to us, and we have designed all our components to meet accessibility compliance criteria. This library is a valuable tool for frontend developers and has already been used in three projects, including two large-scale ones",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility compliance criteria",
|
|
@@ -118,4 +118,27 @@ describe("AValidatedJson valueKey rendering", () => {
|
|
|
118
118
|
list.vm.closeModalCreateListMode({ model: { value: "Vue" } });
|
|
119
119
|
expect(wrapper.emitted("update:modelValue").at(-1)).toEqual([{ tags: ["Aloha", "Vue"] }]);
|
|
120
120
|
});
|
|
121
|
+
|
|
122
|
+
it("saves a parent item containing a required primitive list", async() => {
|
|
123
|
+
const wrapper = mountList({
|
|
124
|
+
valueKey: undefined,
|
|
125
|
+
modelValue: [{ tags: ["Aloha"] }],
|
|
126
|
+
children: [{
|
|
127
|
+
id: "tags",
|
|
128
|
+
type: "validatedJson",
|
|
129
|
+
mode: "list",
|
|
130
|
+
valueKey: "value",
|
|
131
|
+
required: true,
|
|
132
|
+
children: [{ id: "value", type: "text", required: true }],
|
|
133
|
+
}],
|
|
134
|
+
});
|
|
135
|
+
wrapper.findComponent(AValidatedJsonItem).vm.openModalUpdate();
|
|
136
|
+
await nextTick();
|
|
137
|
+
const modal = wrapper.findComponent(AValidatedJsonModalCreateOrUpdate);
|
|
138
|
+
expect(modal.vm.isAnyRequiredElementEmpty).toBe(false);
|
|
139
|
+
modal.vm.changeDataForm({ fullModel: { tags: ["Aloha", "Vue"] } });
|
|
140
|
+
await nextTick();
|
|
141
|
+
modal.vm.save();
|
|
142
|
+
expect(wrapper.emitted("update:modelValue").at(-1)).toEqual([[{ tags: ["Aloha", "Vue"] }]]);
|
|
143
|
+
});
|
|
121
144
|
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
describe,
|
|
3
|
+
expect,
|
|
4
|
+
it,
|
|
5
|
+
} from "vitest";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
filterVisibleRequiredUiElements,
|
|
9
|
+
isAnyRequiredUiElementEmpty,
|
|
10
|
+
} from "../utils";
|
|
11
|
+
|
|
12
|
+
function requiredList(children = [{ id: "value", type: "text", required: true }]) {
|
|
13
|
+
return { id: "tags", type: "validatedJson", mode: "list", valueKey: "value", required: true, children };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe("required validatedJson list fields", () => {
|
|
17
|
+
it.each([
|
|
18
|
+
{ values: ["Aloha"] },
|
|
19
|
+
{ values: [0] },
|
|
20
|
+
{ values: [false] },
|
|
21
|
+
{ values: [null] },
|
|
22
|
+
{ values: [{ text: "Aloha" }] },
|
|
23
|
+
])("accepts a populated list $values without treating it as one child form", ({ values }) => {
|
|
24
|
+
const fields = filterVisibleRequiredUiElements({ elements: [requiredList()] });
|
|
25
|
+
expect(isAnyRequiredUiElementEmpty({ elements: fields, model: { tags: values } })).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it.each([{ values: [] }, { values: undefined }, { values: null }])("rejects an empty or absent required list $values", ({ values }) => {
|
|
29
|
+
expect(isAnyRequiredUiElementEmpty({ elements: [requiredList()], model: { tags: values } })).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("retains a required list with optional item fields", () => {
|
|
33
|
+
const field = requiredList([{ id: "value", type: "text" }]);
|
|
34
|
+
const fields = filterVisibleRequiredUiElements({ elements: [field] });
|
|
35
|
+
expect(fields).toHaveLength(1);
|
|
36
|
+
expect(fields[0].children).toEqual(field.children);
|
|
37
|
+
expect(isAnyRequiredUiElementEmpty({ elements: fields, model: { tags: [] } })).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("ignores optional and hidden lists", () => {
|
|
41
|
+
const fields = filterVisibleRequiredUiElements({ elements: [
|
|
42
|
+
{ ...requiredList(), required: false },
|
|
43
|
+
{ ...requiredList(), isHide: true },
|
|
44
|
+
] });
|
|
45
|
+
expect(fields).toEqual([]);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("continues checking required children in single mode", () => {
|
|
49
|
+
const fields = filterVisibleRequiredUiElements({ elements: [{ ...requiredList(), mode: "single" }] });
|
|
50
|
+
expect(isAnyRequiredUiElementEmpty({ elements: fields, model: { tags: { value: "" } } })).toBe(true);
|
|
51
|
+
expect(isAnyRequiredUiElementEmpty({ elements: fields, model: { tags: { value: "Aloha" } } })).toBe(false);
|
|
52
|
+
});
|
|
53
|
+
});
|
package/src/ui/utils/utils.js
CHANGED
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
isNil,
|
|
13
13
|
} from "lodash-es";
|
|
14
14
|
|
|
15
|
+
const isValidatedJsonList = element => element.type === "validatedJson" && element.mode === "list";
|
|
16
|
+
|
|
15
17
|
export function getLabelClickEventName(id) {
|
|
16
18
|
return `clickALabel_${ id }`;
|
|
17
19
|
}
|
|
@@ -33,7 +35,7 @@ export function filterVisibleRequiredUiElements({ elements }) {
|
|
|
33
35
|
return false;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
if (element?.children?.length) {
|
|
38
|
+
if (element?.children?.length && !isValidatedJsonList(element)) {
|
|
37
39
|
element.children = filterVisibleRequiredUiElements({ elements: element.children });
|
|
38
40
|
|
|
39
41
|
if (!element.children.length) {
|
|
@@ -50,7 +52,7 @@ export function isAnyRequiredUiElementEmpty({ elements, model }) {
|
|
|
50
52
|
|
|
51
53
|
forEach(elements, element => {
|
|
52
54
|
const CURREN_MODEL = get(model, element.id);
|
|
53
|
-
if (typesModelArray.value[element.type]) {
|
|
55
|
+
if (typesModelArray.value[element.type] || isValidatedJsonList(element)) {
|
|
54
56
|
if (!isArray(CURREN_MODEL) || !CURREN_MODEL.length) {
|
|
55
57
|
isAnyEmpty = true;
|
|
56
58
|
return false;
|