aloha-vue 1.2.76 → 1.2.77
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/docs/src/views/Functions/PageFilterLimitTo/i18n/de.json +1 -1
- package/docs/src/views/Functions/PageFilterLimitTo/i18n/ru.json +1 -1
- package/docs/src/views/PageNotification/PageNotification.pug +5 -1
- package/jest.config.js +9 -7
- package/package.json +2 -1
- package/src/AList/AListItem/AListItem.js +2 -2
- package/src/AList/__tests__/AList.test.js +30 -0
- package/src/compositionAPI/ANotificationAPI.js +10 -2
- package/src/filters/__tests__/filterFileSize.test.js +27 -20
- package/src/filters/filterFileSize.js +16 -7
- package/src/utils/utils.js +10 -0
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
"_PAGE_FILTER_LIMIT_TO_ARGUMENTS_TEXT_": "Der Eingangsstring, der beschnitten werden soll",
|
|
3
3
|
"_PAGE_FILTER_LIMIT_TO_ARGUMENTS_LIMIT_": "Die maximale Länge des zurückgegebenen Strings",
|
|
4
4
|
"_PAGE_FILTER_LIMIT_TO_ARGUMENTS_MAX_THREE_DOTS_": "Gibt an, ob maximal drei Punkten am Ende des Strings angezeigt werden",
|
|
5
|
-
"_PAGE_FILTER_LIMIT_TO_DESCRIPTION_": "Die Funktion <strong>filterLimitTo</strong> dient dazu, einen
|
|
5
|
+
"_PAGE_FILTER_LIMIT_TO_DESCRIPTION_": "Die Funktion <strong>filterLimitTo</strong> dient dazu, einen Eingabestring auf eine bestimmte maximale Länge zu begrenzen und optional eine spezielle Logik für Auslassungspunkte am Ende des Strings anzuwenden."
|
|
6
6
|
}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
"_PAGE_FILTER_LIMIT_TO_ARGUMENTS_TEXT_": "Входная строка, которую нужно обрезать",
|
|
3
3
|
"_PAGE_FILTER_LIMIT_TO_ARGUMENTS_LIMIT_": "Максимальная длина возвращаемой строки",
|
|
4
4
|
"_PAGE_FILTER_LIMIT_TO_ARGUMENTS_MAX_THREE_DOTS_": "Определяет, должны ли отображаться максимум три точки в конце строки",
|
|
5
|
-
"_PAGE_FILTER_LIMIT_TO_DESCRIPTION_": "Функция <strong>filterLimitTo</strong> предназначена для ограничения входной строки определенной максимальной длиной
|
|
5
|
+
"_PAGE_FILTER_LIMIT_TO_DESCRIPTION_": "Функция <strong>filterLimitTo</strong> предназначена для ограничения входной строки определенной максимальной длиной и, по желанию, применения специальной логики многоточия в конце строки."
|
|
6
6
|
}
|
|
@@ -8,5 +8,9 @@ div
|
|
|
8
8
|
:text="'_ADD_NOTIFICATION_{{type}}_'"
|
|
9
9
|
:extra="{type: type}"
|
|
10
10
|
@click="addNotificationLocal(type)"
|
|
11
|
-
text="Open Modal"
|
|
12
11
|
)
|
|
12
|
+
.a_mt_4
|
|
13
|
+
a-button.a_btn.a_btn_primary(
|
|
14
|
+
text="Object"
|
|
15
|
+
@click="addNotificationLocal({ sdf: 'x', abc: 'y', aloha: 'z' })"
|
|
16
|
+
)
|
package/jest.config.js
CHANGED
|
@@ -3,14 +3,16 @@
|
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
5
|
coverageDirectory: "coverage",
|
|
6
|
-
moduleNameMapper: {
|
|
7
|
-
"@/(.*)$": "<rootDir>/src/$1"
|
|
8
|
-
},
|
|
9
|
-
testEnvironment: "node",
|
|
10
|
-
transform: {
|
|
11
|
-
"^.+\\.jsx?$": "babel-jest"
|
|
12
|
-
},
|
|
13
6
|
transformIgnorePatterns: [
|
|
14
7
|
"<rootDir>/node_modules/(?!lodash-es)"
|
|
15
8
|
],
|
|
9
|
+
globals: {},
|
|
10
|
+
testEnvironment: "jsdom",
|
|
11
|
+
testEnvironmentOptions: {
|
|
12
|
+
customExportConditions: ["node", "node-addons"],
|
|
13
|
+
},
|
|
14
|
+
transform: {
|
|
15
|
+
"^.+\\js$": "babel-jest"
|
|
16
|
+
},
|
|
17
|
+
moduleFileExtensions: ["vue", "js", "json", "jsx", "ts", "tsx", "node"]
|
|
16
18
|
};
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"Vue.js"
|
|
15
15
|
],
|
|
16
16
|
"homepage": "https://github.com/ilia-brykin/aloha/#README.md",
|
|
17
|
-
"version": "1.2.
|
|
17
|
+
"version": "1.2.77",
|
|
18
18
|
"author": {
|
|
19
19
|
"name": "Ilia Brykin",
|
|
20
20
|
"email": "brykin.ilia@gmail.com"
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"@vue/test-utils": "^2.4.3",
|
|
56
56
|
"eslint-plugin-jest": "^27.6.1",
|
|
57
57
|
"jest": "^29.7.0",
|
|
58
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
58
59
|
"lodash": "^4.17.21",
|
|
59
60
|
"@babel/cli": "^7.23.4",
|
|
60
61
|
"@babel/core": "^7.23.7",
|
|
@@ -98,7 +98,7 @@ export default {
|
|
|
98
98
|
withDirectives(h(this.labelTag), [
|
|
99
99
|
[ASafeHtml, this.label]
|
|
100
100
|
]),
|
|
101
|
-
this.hasChildren
|
|
101
|
+
this.hasChildren ? h(AList, {
|
|
102
102
|
classItem: this.classItem,
|
|
103
103
|
classMain: this.classMain,
|
|
104
104
|
data: this.children,
|
|
@@ -110,7 +110,7 @@ export default {
|
|
|
110
110
|
labelTag: this.labelTag,
|
|
111
111
|
listItemTag: this.listItemTag,
|
|
112
112
|
tag: this.tag,
|
|
113
|
-
}, this.$slots),
|
|
113
|
+
}, this.$slots) : "",
|
|
114
114
|
]);
|
|
115
115
|
},
|
|
116
116
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mount,
|
|
3
|
+
} from "@vue/test-utils";
|
|
4
|
+
|
|
5
|
+
import AList from "../AList";
|
|
6
|
+
|
|
7
|
+
describe("AList", () => {
|
|
8
|
+
test("displays message", () => {
|
|
9
|
+
const ITEMS = [
|
|
10
|
+
{ label: "label 1" },
|
|
11
|
+
{ label: "label 2" },
|
|
12
|
+
{ label: "label 3" },
|
|
13
|
+
{ label: "label 4" },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const wrapper = mount(AList, {
|
|
17
|
+
props: {
|
|
18
|
+
data: ITEMS,
|
|
19
|
+
keyLabel: "label",
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
console.log("component.text()", wrapper.text());
|
|
23
|
+
|
|
24
|
+
// Assert the rendered text of the component
|
|
25
|
+
expect(wrapper.findAll("li")).toHaveLength(4);
|
|
26
|
+
expect(wrapper.text()).toContain("label 1label 2label 3label 4");
|
|
27
|
+
expect(wrapper.html({ raw: true })).toBe("<ul><li><span>label 1</span></li><li><span>label 2</span></li><li><span>label 3</span></li><li><span>label 4</span></li></ul>");
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
@@ -3,8 +3,12 @@ import {
|
|
|
3
3
|
ref,
|
|
4
4
|
} from "vue";
|
|
5
5
|
|
|
6
|
+
import {
|
|
7
|
+
createListFromObject,
|
|
8
|
+
} from "../utils/utils";
|
|
6
9
|
import {
|
|
7
10
|
isNil,
|
|
11
|
+
isPlainObject,
|
|
8
12
|
values,
|
|
9
13
|
} from "lodash-es";
|
|
10
14
|
|
|
@@ -28,13 +32,17 @@ export function setNotificationTimeout(timeout) {
|
|
|
28
32
|
notificationTimeout = timeout;
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
export function addNotification({ text, type = "success", timeout, extra }) {
|
|
35
|
+
export function addNotification({ text, type = "success", timeout, extra, useValuesFromObject = true }) {
|
|
32
36
|
const TIMEOUT_LOCAL = isNil(timeout) ? notificationTimeout : timeout;
|
|
33
37
|
const CURRENT_INDEX = notificationsCount;
|
|
34
38
|
const TYPE = type === "error" ? "danger" : type;
|
|
39
|
+
let textLocal = text;
|
|
40
|
+
if (isPlainObject(text) && useValuesFromObject) {
|
|
41
|
+
textLocal = createListFromObject(text); // TODO: filterList
|
|
42
|
+
}
|
|
35
43
|
|
|
36
44
|
notificationsObj.value[CURRENT_INDEX] = {
|
|
37
|
-
text,
|
|
45
|
+
text: textLocal,
|
|
38
46
|
type: TYPE,
|
|
39
47
|
index: CURRENT_INDEX,
|
|
40
48
|
extra,
|
|
@@ -2,31 +2,38 @@ import filterFileSize from "../filterFileSize.js";
|
|
|
2
2
|
|
|
3
3
|
describe("filterFileSize", () => {
|
|
4
4
|
test("default", () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
expect(filterFileSize(1024)).toBe("1,00 _A_FILE_SIZE_KB_");
|
|
6
|
+
expect(filterFileSize(0)).toBe("0,00 _A_FILE_SIZE_KB_");
|
|
7
|
+
expect(filterFileSize(500)).toBe("0,49 _A_FILE_SIZE_KB_");
|
|
8
|
+
expect(filterFileSize(504547643)).toBe("492.722,31 _A_FILE_SIZE_KB_");
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
test("units", () => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
expect(filterFileSize(1048576, { units: "mb" })).toBe("1,00 _A_FILE_SIZE_MB_");
|
|
13
|
+
expect(filterFileSize(0, { units: "mb" })).toBe("0,00 _A_FILE_SIZE_MB_");
|
|
14
|
+
expect(filterFileSize(9226889999, { units: "gb" })).toBe("8,59 _A_FILE_SIZE_GB_");
|
|
15
|
+
expect(filterFileSize(1024, { units: "" })).toBe("1,00 _A_FILE_SIZE_KB_");
|
|
16
|
+
expect(filterFileSize(0, { units: "" })).toBe("0,00 _A_FILE_SIZE_B_");
|
|
17
|
+
});
|
|
17
18
|
|
|
18
19
|
test("sourceUnits", () => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})
|
|
20
|
+
expect(filterFileSize(1, { units: "mb", sourceUnits: "mb" })).toBe("1,00 _A_FILE_SIZE_MB_");
|
|
21
|
+
expect(filterFileSize(1, { units: "kb", sourceUnits: "gb" })).toBe("1.048.576,00 _A_FILE_SIZE_KB_");
|
|
22
|
+
expect(filterFileSize(0, { sourceUnits: "mb" })).toBe("0,00 _A_FILE_SIZE_KB_");
|
|
23
|
+
expect(filterFileSize(1024, { sourceUnits: "b" })).toBe("1,00 _A_FILE_SIZE_KB_");
|
|
24
|
+
expect(filterFileSize(12, { units: "tb", sourceUnits: "pb" })).toBe("12.288,00 _A_FILE_SIZE_TB_");
|
|
25
|
+
});
|
|
26
|
+
|
|
25
27
|
test("digits", () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})
|
|
28
|
+
expect(filterFileSize(1024, { digits: 0 })).toBe("1 _A_FILE_SIZE_KB_");
|
|
29
|
+
expect(filterFileSize(500, { digits: 1 })).toBe("0,5 _A_FILE_SIZE_KB_");
|
|
30
|
+
});
|
|
31
|
+
|
|
29
32
|
test("combined", () => {
|
|
30
|
-
|
|
33
|
+
expect(filterFileSize(133889, { units: "tb", sourceUnits: "mb", digits: 3 })).toBe("0,128 _A_FILE_SIZE_TB_");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("value (String)", () => {
|
|
37
|
+
expect(filterFileSize("1024.1")).toBe("1,00 _A_FILE_SIZE_KB_");
|
|
31
38
|
});
|
|
32
|
-
});
|
|
39
|
+
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import filterFloat from "./filterFloat";
|
|
2
2
|
import {
|
|
3
3
|
getTranslatedText,
|
|
4
4
|
} from "../ATranslation/compositionAPI/UtilsAPI";
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
isNaN,
|
|
7
|
+
toNumber,
|
|
7
8
|
toUpper,
|
|
8
9
|
} from "lodash-es";
|
|
9
10
|
|
|
@@ -20,26 +21,34 @@ export default function(value, { units = "kb", sourceUnits = "b", digits = 2 } =
|
|
|
20
21
|
"zb",
|
|
21
22
|
"yb",
|
|
22
23
|
];
|
|
24
|
+
const VALUE_NUMBER = toNumber(value);
|
|
25
|
+
if (isNaN(VALUE_NUMBER)) {
|
|
26
|
+
return "";
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
const INDEX_SOURCE_UNITS = UNITS_ORDER.indexOf(sourceUnits);
|
|
24
30
|
let indexUnits = UNITS_ORDER.indexOf(units);
|
|
25
31
|
if (INDEX_SOURCE_UNITS === -1) {
|
|
26
32
|
return "";
|
|
27
33
|
}
|
|
28
|
-
const VALUE_IN_BYTES =
|
|
34
|
+
const VALUE_IN_BYTES = VALUE_NUMBER * Math.pow(KB, INDEX_SOURCE_UNITS);
|
|
29
35
|
if (indexUnits === -1) {
|
|
30
36
|
indexUnits = Math.floor(Math.log(VALUE_IN_BYTES) / Math.log(KB));
|
|
37
|
+
if (indexUnits < 0) {
|
|
38
|
+
indexUnits = 0;
|
|
39
|
+
}
|
|
31
40
|
units = UNITS_ORDER[indexUnits];
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
const UNITS_TRANSLATED = getTranslatedText({ placeholder: `_A_FILE_SIZE_${ toUpper(units) }_` });
|
|
35
44
|
|
|
36
|
-
if (
|
|
37
|
-
return
|
|
45
|
+
if (VALUE_NUMBER === 0) {
|
|
46
|
+
return filterFloat(0, { suffix: UNITS_TRANSLATED, digits });
|
|
38
47
|
}
|
|
39
48
|
if (INDEX_SOURCE_UNITS === indexUnits) {
|
|
40
|
-
return
|
|
49
|
+
return filterFloat(VALUE_NUMBER, { suffix: UNITS_TRANSLATED, digits });
|
|
41
50
|
}
|
|
42
51
|
const size = VALUE_IN_BYTES / Math.pow(KB, Math.abs(indexUnits));
|
|
43
52
|
|
|
44
|
-
return
|
|
53
|
+
return filterFloat(size, { suffix: UNITS_TRANSLATED, digits });
|
|
45
54
|
}
|
package/src/utils/utils.js
CHANGED
|
@@ -65,3 +65,13 @@ export function isArrayOfArrays(array) {
|
|
|
65
65
|
|
|
66
66
|
return every(array, isArray);
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
export function createListFromObject(obj) { // TODO: filterList, soll gelöscht werden
|
|
70
|
+
const keys = Object.keys(obj);
|
|
71
|
+
if (keys.length === 0) {
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const items = keys.map(key => `<li>${ obj[key] }</li>`).join("");
|
|
76
|
+
return `<ul class="a_list_without_styles">${ items }</ul>`;
|
|
77
|
+
}
|