adminforth 1.3.11 → 1.3.12
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.
|
@@ -57,25 +57,28 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
|
|
|
57
57
|
throw new Error('Method not implemented.');
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
createRecord({ resource, record, adminUser }: {
|
|
60
|
+
async createRecord({ resource, record, adminUser }: {
|
|
61
61
|
resource: AdminForthResource; record: any; adminUser: any;
|
|
62
|
-
}): Promise<
|
|
62
|
+
}): Promise<any> {
|
|
63
63
|
// transform value using setFieldValue and call createRecordOriginalValues
|
|
64
|
-
const
|
|
65
|
-
|
|
64
|
+
const filledRecord = {...record};
|
|
65
|
+
const recordWithOriginalValues = {...record};
|
|
66
|
+
|
|
66
67
|
for (const col of resource.dataSourceColumns) {
|
|
67
68
|
if (col.fillOnCreate) {
|
|
68
|
-
if (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
if (filledRecord[col.name] === undefined) {
|
|
70
|
+
filledRecord[col.name] = col.fillOnCreate({
|
|
71
|
+
initialRecord: record,
|
|
72
|
+
adminUser
|
|
73
|
+
});
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
|
-
|
|
75
|
-
newRecord[col.name] = this.setFieldValue(col, record[col.name]);
|
|
76
|
+
recordWithOriginalValues[col.name] = this.setFieldValue(col, filledRecord[col.name]);
|
|
76
77
|
}
|
|
77
|
-
process.env.HEAVY_DEBUG && console.log('🪲🪲🪲🪲 creating record',
|
|
78
|
-
|
|
78
|
+
process.env.HEAVY_DEBUG && console.log('🪲🪲🪲🪲 creating record', recordWithOriginalValues);
|
|
79
|
+
await this.createRecordOriginalValues({ resource, record: recordWithOriginalValues });
|
|
80
|
+
|
|
81
|
+
return recordWithOriginalValues;
|
|
79
82
|
}
|
|
80
83
|
|
|
81
84
|
updateRecord({ resource, recordId, newValues }: { resource: AdminForthResource; recordId: string; newValues: any; }): Promise<void> {
|
|
@@ -50,21 +50,26 @@ export default class AdminForthBaseConnector {
|
|
|
50
50
|
createRecordOriginalValues({ resource, record }) {
|
|
51
51
|
throw new Error('Method not implemented.');
|
|
52
52
|
}
|
|
53
|
-
createRecord(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
createRecord(_a) {
|
|
54
|
+
return __awaiter(this, arguments, void 0, function* ({ resource, record, adminUser }) {
|
|
55
|
+
// transform value using setFieldValue and call createRecordOriginalValues
|
|
56
|
+
const filledRecord = Object.assign({}, record);
|
|
57
|
+
const recordWithOriginalValues = Object.assign({}, record);
|
|
58
|
+
for (const col of resource.dataSourceColumns) {
|
|
59
|
+
if (col.fillOnCreate) {
|
|
60
|
+
if (filledRecord[col.name] === undefined) {
|
|
61
|
+
filledRecord[col.name] = col.fillOnCreate({
|
|
62
|
+
initialRecord: record,
|
|
63
|
+
adminUser
|
|
64
|
+
});
|
|
65
|
+
}
|
|
62
66
|
}
|
|
67
|
+
recordWithOriginalValues[col.name] = this.setFieldValue(col, filledRecord[col.name]);
|
|
63
68
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
process.env.HEAVY_DEBUG && console.log('🪲🪲🪲🪲 creating record', recordWithOriginalValues);
|
|
70
|
+
yield this.createRecordOriginalValues({ resource, record: recordWithOriginalValues });
|
|
71
|
+
return recordWithOriginalValues;
|
|
72
|
+
});
|
|
68
73
|
}
|
|
69
74
|
updateRecord({ resource, recordId, newValues }) {
|
|
70
75
|
throw new Error('Method not implemented.');
|