@itrocks/core-transformers 0.0.7 → 0.0.9
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/cjs/collection-type.js +9 -4
- package/cjs/primitive.js +3 -1
- package/esm/collection-type.js +9 -4
- package/esm/primitive.js +3 -1
- package/package.json +3 -2
package/cjs/collection-type.js
CHANGED
|
@@ -32,13 +32,18 @@ function collectionEdit(values, object, property) {
|
|
|
32
32
|
const inputs = [];
|
|
33
33
|
for (const object of values) {
|
|
34
34
|
const attrValue = `value="${depends.representativeValueOf(object)}"`;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const objectId = (0, storage_1.dataSource)().isObjectConnected(object) ? '' + object.id : '';
|
|
36
|
+
inputs.push('<li>'
|
|
37
|
+
+ `<input name="${fieldName}.${objectId}" ${attrValue}>`
|
|
38
|
+
+ `<input id="${fieldId}-id.${objectId}" name="${fieldName}_id.${objectId}" type="hidden" value="${objectId}">`
|
|
39
|
+
+ '</li>');
|
|
38
40
|
}
|
|
39
41
|
return label + `<ul data-multiple-contained-auto-width data-fetch="${fetch}" data-type="objects">`
|
|
40
42
|
+ inputs.join('')
|
|
41
|
-
+
|
|
43
|
+
+ '<li>'
|
|
44
|
+
+ `<input name="${fieldName}." placeholder="+">`
|
|
45
|
+
+ `<input id="${fieldId}-id." name="${fieldName}_id." type="hidden">`
|
|
46
|
+
+ '</li>'
|
|
42
47
|
+ '</ul>';
|
|
43
48
|
}
|
|
44
49
|
function collectionInput(values, object, property) {
|
package/cjs/primitive.js
CHANGED
|
@@ -84,7 +84,9 @@ function numberEdit(value, type, property) {
|
|
|
84
84
|
function initNumberHtmlTransformers() {
|
|
85
85
|
(0, transformer_1.setPropertyTypeTransformers)(Number, [
|
|
86
86
|
{ format: transformer_2.HTML, direction: transformer_2.EDIT, transformer: numberEdit },
|
|
87
|
-
{ format: transformer_2.HTML, direction: transformer_2.INPUT, transformer: (value) => +value }
|
|
87
|
+
{ format: transformer_2.HTML, direction: transformer_2.INPUT, transformer: (value) => (value === '') ? undefined : +value },
|
|
88
|
+
{ format: transformer_2.HTML, direction: transformer_2.OUTPUT, transformer: (value) => (value === undefined) ? '' : ('' + value) },
|
|
89
|
+
{ format: transformer_3.SQL, direction: transformer_3.READ, transformer: (value) => (value === null) ? undefined : value }
|
|
88
90
|
]);
|
|
89
91
|
}
|
|
90
92
|
// default
|
package/esm/collection-type.js
CHANGED
|
@@ -27,13 +27,18 @@ function collectionEdit(values, object, property) {
|
|
|
27
27
|
const inputs = [];
|
|
28
28
|
for (const object of values) {
|
|
29
29
|
const attrValue = `value="${depends.representativeValueOf(object)}"`;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const objectId = dataSource().isObjectConnected(object) ? '' + object.id : '';
|
|
31
|
+
inputs.push('<li>'
|
|
32
|
+
+ `<input name="${fieldName}.${objectId}" ${attrValue}>`
|
|
33
|
+
+ `<input id="${fieldId}-id.${objectId}" name="${fieldName}_id.${objectId}" type="hidden" value="${objectId}">`
|
|
34
|
+
+ '</li>');
|
|
33
35
|
}
|
|
34
36
|
return label + `<ul data-multiple-contained-auto-width data-fetch="${fetch}" data-type="objects">`
|
|
35
37
|
+ inputs.join('')
|
|
36
|
-
+
|
|
38
|
+
+ '<li>'
|
|
39
|
+
+ `<input name="${fieldName}." placeholder="+">`
|
|
40
|
+
+ `<input id="${fieldId}-id." name="${fieldName}_id." type="hidden">`
|
|
41
|
+
+ '</li>'
|
|
37
42
|
+ '</ul>';
|
|
38
43
|
}
|
|
39
44
|
function collectionInput(values, object, property) {
|
package/esm/primitive.js
CHANGED
|
@@ -73,7 +73,9 @@ function numberEdit(value, type, property) {
|
|
|
73
73
|
export function initNumberHtmlTransformers() {
|
|
74
74
|
setPropertyTypeTransformers(Number, [
|
|
75
75
|
{ format: HTML, direction: EDIT, transformer: numberEdit },
|
|
76
|
-
{ format: HTML, direction: INPUT, transformer: (value) => +value }
|
|
76
|
+
{ format: HTML, direction: INPUT, transformer: (value) => (value === '') ? undefined : +value },
|
|
77
|
+
{ format: HTML, direction: OUTPUT, transformer: (value) => (value === undefined) ? '' : ('' + value) },
|
|
78
|
+
{ format: SQL, direction: READ, transformer: (value) => (value === null) ? undefined : value }
|
|
77
79
|
]);
|
|
78
80
|
}
|
|
79
81
|
// default
|
package/package.json
CHANGED
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"README.md",
|
|
29
29
|
"*/*.d.ts",
|
|
30
30
|
"*/*.js",
|
|
31
|
-
"!*/esm.*"
|
|
31
|
+
"!*/esm.*",
|
|
32
|
+
"!*.map"
|
|
32
33
|
],
|
|
33
34
|
"homepage": "https://it.rocks",
|
|
34
35
|
"keywords": [
|
|
@@ -47,5 +48,5 @@
|
|
|
47
48
|
"build:esm": "tsc -p tsconfig.esm.json && node esm/esm"
|
|
48
49
|
},
|
|
49
50
|
"types": "./esm/core-transformers.d.ts",
|
|
50
|
-
"version": "0.0.
|
|
51
|
+
"version": "0.0.9"
|
|
51
52
|
}
|