@itrocks/core-transformers 0.0.14 → 0.0.16
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 +3 -3
- package/cjs/store.d.ts +1 -1
- package/cjs/store.js +5 -5
- package/esm/collection-type.js +3 -3
- package/esm/store.d.ts +1 -1
- package/esm/store.js +5 -5
- package/package.json +1 -1
package/cjs/collection-type.js
CHANGED
|
@@ -24,7 +24,7 @@ const depends = {
|
|
|
24
24
|
tr: text => text
|
|
25
25
|
};
|
|
26
26
|
const areMayEntity = (entries) => (typeof entries[0])[0] === 'o';
|
|
27
|
-
function collectionEdit(values, object, property) {
|
|
27
|
+
async function collectionEdit(values, object, property) {
|
|
28
28
|
const fieldId = depends.fieldIdOf(property);
|
|
29
29
|
const fieldName = depends.fieldNameOf(property);
|
|
30
30
|
const propertyType = new reflect_2.ReflectProperty(object, property).collectionType;
|
|
@@ -32,7 +32,7 @@ function collectionEdit(values, object, property) {
|
|
|
32
32
|
const label = `<label for="${fieldId}">${depends.tr(depends.displayOf(object, property))}</label>`;
|
|
33
33
|
const inputs = [];
|
|
34
34
|
for (const object of values) {
|
|
35
|
-
const attrValue = `value="${depends.representativeValueOf(object)}"`;
|
|
35
|
+
const attrValue = `value="${await depends.representativeValueOf(object)}"`;
|
|
36
36
|
const objectId = (0, storage_1.dataSource)().isObjectConnected(object) ? '' + object.id : '';
|
|
37
37
|
inputs.push('<li>'
|
|
38
38
|
+ `<input name="${fieldName}.${objectId}" ${attrValue}>`
|
|
@@ -91,7 +91,7 @@ async function collectionOutput(values, object, property, askFor) {
|
|
|
91
91
|
+ '</li>'))).join('')
|
|
92
92
|
+ '</ul>';
|
|
93
93
|
}
|
|
94
|
-
return values.map(object => depends.representativeValueOf(object)).join(', ');
|
|
94
|
+
return (await Promise.all(values.map(object => depends.representativeValueOf(object)))).join(', ');
|
|
95
95
|
}
|
|
96
96
|
function initCollectionHtmlTransformers(dependencies = {}) {
|
|
97
97
|
Object.assign(depends, dependencies);
|
package/cjs/store.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type Dependencies = SqlDependencies & {
|
|
|
7
7
|
displayOf: (object: AnyObject, property: string) => string;
|
|
8
8
|
fieldIdOf: (property: string) => string;
|
|
9
9
|
fieldNameOf: (property: string) => string;
|
|
10
|
-
representativeValueOf: (object: object) => string
|
|
10
|
+
representativeValueOf: (object: object) => Promise<string>;
|
|
11
11
|
routeOf: (type: Type) => string;
|
|
12
12
|
tr: (text: string) => string;
|
|
13
13
|
};
|
package/cjs/store.js
CHANGED
|
@@ -17,7 +17,7 @@ const depends = {
|
|
|
17
17
|
fieldIdOf: property => property,
|
|
18
18
|
fieldNameOf: property => property,
|
|
19
19
|
ignoreTransformedValue: Symbol('ignoreTransformedValue'),
|
|
20
|
-
representativeValueOf: object => (0, class_type_1.baseType)((0, class_type_1.typeOf)(object)).name,
|
|
20
|
+
representativeValueOf: async (object) => (0, class_type_1.baseType)((0, class_type_1.typeOf)(object)).name,
|
|
21
21
|
routeOf: type => '/' + (0, class_type_1.baseType)(type).name,
|
|
22
22
|
tr: text => text
|
|
23
23
|
};
|
|
@@ -38,11 +38,11 @@ function setStoreDependencies(dependencies) {
|
|
|
38
38
|
}
|
|
39
39
|
exports.setStoreHtmlDependencies = setStoreDependencies;
|
|
40
40
|
exports.setStoreSqlDependencies = setStoreDependencies;
|
|
41
|
-
function storeEdit(value, object, property) {
|
|
41
|
+
async function storeEdit(value, object, property) {
|
|
42
42
|
const fieldName = depends.fieldNameOf(property);
|
|
43
43
|
const fieldId = depends.fieldIdOf(property);
|
|
44
44
|
const type = new reflect_1.ReflectProperty(object, property).type.type;
|
|
45
|
-
const textValue = value ? depends.representativeValueOf(value) : '';
|
|
45
|
+
const textValue = value ? await depends.representativeValueOf(value) : '';
|
|
46
46
|
const fetch = depends.routeOf(type) + '/summary';
|
|
47
47
|
const label = `<label for="${fieldId}">${depends.tr(depends.displayOf(object, property))}</label>`;
|
|
48
48
|
const name = `id="${fieldId}" name="${fieldName}"`;
|
|
@@ -71,8 +71,8 @@ function storeInput(value, object, property, data) {
|
|
|
71
71
|
}
|
|
72
72
|
return depends.ignoreTransformedValue;
|
|
73
73
|
}
|
|
74
|
-
function storeOutput(value) {
|
|
75
|
-
return value ? depends.representativeValueOf(value) : '';
|
|
74
|
+
async function storeOutput(value) {
|
|
75
|
+
return value ? await depends.representativeValueOf(value) : '';
|
|
76
76
|
}
|
|
77
77
|
async function storeSave(value, _object, property, record) {
|
|
78
78
|
const dao = (0, storage_1.dataSource)();
|
package/esm/collection-type.js
CHANGED
|
@@ -20,7 +20,7 @@ const depends = {
|
|
|
20
20
|
tr: text => text
|
|
21
21
|
};
|
|
22
22
|
const areMayEntity = (entries) => (typeof entries[0])[0] === 'o';
|
|
23
|
-
function collectionEdit(values, object, property) {
|
|
23
|
+
async function collectionEdit(values, object, property) {
|
|
24
24
|
const fieldId = depends.fieldIdOf(property);
|
|
25
25
|
const fieldName = depends.fieldNameOf(property);
|
|
26
26
|
const propertyType = new ReflectProperty(object, property).collectionType;
|
|
@@ -28,7 +28,7 @@ function collectionEdit(values, object, property) {
|
|
|
28
28
|
const label = `<label for="${fieldId}">${depends.tr(depends.displayOf(object, property))}</label>`;
|
|
29
29
|
const inputs = [];
|
|
30
30
|
for (const object of values) {
|
|
31
|
-
const attrValue = `value="${depends.representativeValueOf(object)}"`;
|
|
31
|
+
const attrValue = `value="${await depends.representativeValueOf(object)}"`;
|
|
32
32
|
const objectId = dataSource().isObjectConnected(object) ? '' + object.id : '';
|
|
33
33
|
inputs.push('<li>'
|
|
34
34
|
+ `<input name="${fieldName}.${objectId}" ${attrValue}>`
|
|
@@ -87,7 +87,7 @@ async function collectionOutput(values, object, property, askFor) {
|
|
|
87
87
|
+ '</li>'))).join('')
|
|
88
88
|
+ '</ul>';
|
|
89
89
|
}
|
|
90
|
-
return values.map(object => depends.representativeValueOf(object)).join(', ');
|
|
90
|
+
return (await Promise.all(values.map(object => depends.representativeValueOf(object)))).join(', ');
|
|
91
91
|
}
|
|
92
92
|
export function initCollectionHtmlTransformers(dependencies = {}) {
|
|
93
93
|
Object.assign(depends, dependencies);
|
package/esm/store.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type Dependencies = SqlDependencies & {
|
|
|
7
7
|
displayOf: (object: AnyObject, property: string) => string;
|
|
8
8
|
fieldIdOf: (property: string) => string;
|
|
9
9
|
fieldNameOf: (property: string) => string;
|
|
10
|
-
representativeValueOf: (object: object) => string
|
|
10
|
+
representativeValueOf: (object: object) => Promise<string>;
|
|
11
11
|
routeOf: (type: Type) => string;
|
|
12
12
|
tr: (text: string) => string;
|
|
13
13
|
};
|
package/esm/store.js
CHANGED
|
@@ -10,7 +10,7 @@ const depends = {
|
|
|
10
10
|
fieldIdOf: property => property,
|
|
11
11
|
fieldNameOf: property => property,
|
|
12
12
|
ignoreTransformedValue: Symbol('ignoreTransformedValue'),
|
|
13
|
-
representativeValueOf: object => baseType(typeOf(object)).name,
|
|
13
|
+
representativeValueOf: async (object) => baseType(typeOf(object)).name,
|
|
14
14
|
routeOf: type => '/' + baseType(type).name,
|
|
15
15
|
tr: text => text
|
|
16
16
|
};
|
|
@@ -31,11 +31,11 @@ export function setStoreDependencies(dependencies) {
|
|
|
31
31
|
}
|
|
32
32
|
export const setStoreHtmlDependencies = setStoreDependencies;
|
|
33
33
|
export const setStoreSqlDependencies = setStoreDependencies;
|
|
34
|
-
function storeEdit(value, object, property) {
|
|
34
|
+
async function storeEdit(value, object, property) {
|
|
35
35
|
const fieldName = depends.fieldNameOf(property);
|
|
36
36
|
const fieldId = depends.fieldIdOf(property);
|
|
37
37
|
const type = new ReflectProperty(object, property).type.type;
|
|
38
|
-
const textValue = value ? depends.representativeValueOf(value) : '';
|
|
38
|
+
const textValue = value ? await depends.representativeValueOf(value) : '';
|
|
39
39
|
const fetch = depends.routeOf(type) + '/summary';
|
|
40
40
|
const label = `<label for="${fieldId}">${depends.tr(depends.displayOf(object, property))}</label>`;
|
|
41
41
|
const name = `id="${fieldId}" name="${fieldName}"`;
|
|
@@ -64,8 +64,8 @@ function storeInput(value, object, property, data) {
|
|
|
64
64
|
}
|
|
65
65
|
return depends.ignoreTransformedValue;
|
|
66
66
|
}
|
|
67
|
-
function storeOutput(value) {
|
|
68
|
-
return value ? depends.representativeValueOf(value) : '';
|
|
67
|
+
async function storeOutput(value) {
|
|
68
|
+
return value ? await depends.representativeValueOf(value) : '';
|
|
69
69
|
}
|
|
70
70
|
async function storeSave(value, _object, property, record) {
|
|
71
71
|
const dao = dataSource();
|
package/package.json
CHANGED