@proteinjs/db-ui 1.0.16 → 1.0.18
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/.eslintrc.js +20 -0
- package/.prettierignore +4 -0
- package/.prettierrc +8 -0
- package/CHANGELOG.md +18 -30
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/form/RecordForm.d.ts.map +1 -1
- package/dist/src/form/RecordForm.js +29 -13
- package/dist/src/form/RecordForm.js.map +1 -1
- package/dist/src/form/RecordFormCustomization.d.ts.map +1 -1
- package/dist/src/form/RecordFormCustomization.js +5 -2
- package/dist/src/form/RecordFormCustomization.js.map +1 -1
- package/dist/src/form/customizations/MigrationRecordFormCustomization.d.ts.map +1 -1
- package/dist/src/form/customizations/MigrationRecordFormCustomization.js +3 -1
- package/dist/src/form/customizations/MigrationRecordFormCustomization.js.map +1 -1
- package/dist/src/pages/RecordFormPage.d.ts.map +1 -1
- package/dist/src/pages/RecordFormPage.js +8 -5
- package/dist/src/pages/RecordFormPage.js.map +1 -1
- package/dist/src/pages/RecordTablePage.d.ts.map +1 -1
- package/dist/src/pages/RecordTablePage.js +7 -7
- package/dist/src/pages/RecordTablePage.js.map +1 -1
- package/dist/src/pages/TablesPage.d.ts.map +1 -1
- package/dist/src/pages/TablesPage.js +1 -1
- package/dist/src/pages/TablesPage.js.map +1 -1
- package/dist/src/pages/UuidGeneratorPage.d.ts.map +1 -1
- package/dist/src/pages/UuidGeneratorPage.js +2 -2
- package/dist/src/pages/UuidGeneratorPage.js.map +1 -1
- package/dist/src/table/QueryTableLoader.d.ts.map +1 -1
- package/dist/src/table/QueryTableLoader.js +2 -1
- package/dist/src/table/QueryTableLoader.js.map +1 -1
- package/dist/src/table/RecordTable.d.ts.map +1 -1
- package/dist/src/table/RecordTable.js +12 -6
- package/dist/src/table/RecordTable.js.map +1 -1
- package/generated/index.ts +10 -13
- package/index.ts +4 -4
- package/jest.config.js +8 -17
- package/package.json +54 -49
- package/src/form/RecordForm.tsx +57 -40
- package/src/form/RecordFormCustomization.tsx +11 -9
- package/src/form/customizations/MigrationRecordFormCustomization.tsx +8 -6
- package/src/pages/RecordFormPage.tsx +18 -22
- package/src/pages/RecordTablePage.tsx +16 -22
- package/src/pages/TablesPage.tsx +11 -11
- package/src/pages/UuidGeneratorPage.tsx +17 -17
- package/src/table/QueryTableLoader.ts +6 -6
- package/src/table/RecordTable.tsx +32 -27
- package/tsconfig.json +17 -17
|
@@ -62,7 +62,8 @@ function deleteButton(table) {
|
|
|
62
62
|
return __generator(this, function (_a) {
|
|
63
63
|
switch (_a.label) {
|
|
64
64
|
case 0:
|
|
65
|
-
qb = new db_1.QueryBuilderFactory()
|
|
65
|
+
qb = new db_1.QueryBuilderFactory()
|
|
66
|
+
.getQueryBuilder(table)
|
|
66
67
|
.condition({ field: 'id', operator: 'IN', value: selectedRows.map(function (row) { return row.id; }) });
|
|
67
68
|
return [4 /*yield*/, (0, db_1.getDb)().delete(table, qb)];
|
|
68
69
|
case 1:
|
|
@@ -95,17 +96,21 @@ function RecordTable(props) {
|
|
|
95
96
|
function defaultColumns() {
|
|
96
97
|
var _a, _b;
|
|
97
98
|
var columnProperties = [];
|
|
98
|
-
if (props.table.columns['name'])
|
|
99
|
+
if (props.table.columns['name']) {
|
|
99
100
|
columnProperties.push('name');
|
|
101
|
+
}
|
|
100
102
|
for (var _i = 0, _c = Object.keys(props.table.columns); _i < _c.length; _i++) {
|
|
101
103
|
var columnProperty = _c[_i];
|
|
102
|
-
if (columnProperties.length >= 5)
|
|
104
|
+
if (columnProperties.length >= 5) {
|
|
103
105
|
break;
|
|
104
|
-
|
|
106
|
+
}
|
|
107
|
+
if (columnProperty == 'name' || columnProperty == 'created' || columnProperty == 'updated') {
|
|
105
108
|
continue;
|
|
109
|
+
}
|
|
106
110
|
var column = props.table.columns[columnProperty];
|
|
107
|
-
if ((_b = (_a = column.options) === null || _a === void 0 ? void 0 : _a.ui) === null || _b === void 0 ? void 0 : _b.hidden)
|
|
111
|
+
if ((_b = (_a = column.options) === null || _a === void 0 ? void 0 : _a.ui) === null || _b === void 0 ? void 0 : _b.hidden) {
|
|
108
112
|
continue;
|
|
113
|
+
}
|
|
109
114
|
columnProperties.push(columnProperty);
|
|
110
115
|
}
|
|
111
116
|
columnProperties.push('created');
|
|
@@ -124,8 +129,9 @@ function RecordTable(props) {
|
|
|
124
129
|
}
|
|
125
130
|
function buttons() {
|
|
126
131
|
var buttons = [];
|
|
127
|
-
if (props.buttons)
|
|
132
|
+
if (props.buttons) {
|
|
128
133
|
buttons.push.apply(buttons, props.buttons);
|
|
134
|
+
}
|
|
129
135
|
buttons.push(deleteButton(props.table));
|
|
130
136
|
buttons.push(createButton(props.table));
|
|
131
137
|
return buttons;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordTable.js","sourceRoot":"","sources":["../../../src/table/RecordTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"RecordTable.js","sourceRoot":"","sources":["../../../src/table/RecordTable.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0B;AAC1B,sDAAkD;AAClD,kDAAuB;AACvB,oCAA8F;AAC9F,oCAAkF;AAClF,uDAAsD;AACtD,0DAA4E;AAC5E,4DAA2D;AAa3D,SAAS,YAAY,CAAmB,KAAe;IAAvD,iBAgBC;IAfC,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,IAAI,EAAE,uBAAM;QACZ,UAAU,EAAE;YACV,oBAAoB,EAAE,IAAI;YAC1B,sBAAsB,EAAE,KAAK;SAC9B;QACD,OAAO,EAAE,UAAO,YAAY,EAAE,QAAQ;;;;;wBAC9B,EAAE,GAAG,IAAI,wBAAmB,EAAE;6BACjC,eAAe,CAAC,KAAK,CAAC;6BACtB,SAAS,CAAC,EAAE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AK,CAAC,CAAC,CAAC,UAAG,IAAA,gBAAC,EAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,WAAQ,EACvF,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,EAAE,EACzD,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,kBAAkB,EAAE,EACzE,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC,4BAA4B,EAC/G,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,EAC5C,OAAO,EAAE,OAAO,EAAE,GAClB,CACH,CAAC;AACJ,CAAC;AA7DD,kCA6DC"}
|
package/generated/index.ts
CHANGED
|
@@ -13,11 +13,10 @@ import 'react';
|
|
|
13
13
|
import 'string';
|
|
14
14
|
import 'uuid';
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
/** Generate Source Graph */
|
|
18
17
|
|
|
19
|
-
const sourceGraph =
|
|
20
|
-
|
|
18
|
+
const sourceGraph =
|
|
19
|
+
'{"options":{"directed":true,"multigraph":false,"compound":false},"nodes":[{"v":"@proteinjs/db-ui/QueryTableLoader","value":{"packageName":"@proteinjs/db-ui","name":"QueryTableLoader","filePath":"/home/runner/work/db/db/packages/ui/src/table/QueryTableLoader.ts","qualifiedName":"@proteinjs/db-ui/QueryTableLoader","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"table","type":{"packageName":"","name":"Table<T>","filePath":null,"qualifiedName":"/Table<T>","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"query","type":{"packageName":"","name":"Query<T>","filePath":null,"qualifiedName":"/Query<T>","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"},{"name":"sort","type":{"packageName":"","name":"SortCriteria<T>[]","filePath":null,"qualifiedName":"/SortCriteria<T>[]","typeParameters":null,"directParents":null},"isOptional":true,"isAbstract":false,"isStatic":false,"visibility":"private"}],"methods":[{"name":"load","returnType":{"packageName":"","name":"Promise<RowWindow<T>>","filePath":null,"qualifiedName":"/Promise<RowWindow<T>>","typeParameters":null,"directParents":null},"isAsync":true,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"startIndex","type":{"packageName":"","name":"number","filePath":null,"qualifiedName":"/number","typeParameters":null,"directParents":null}},{"name":"endIndex","type":{"packageName":"","name":"number","filePath":null,"qualifiedName":"/number","typeParameters":null,"directParents":null}}]}],"typeParameters":["/T extends Record"],"directParentInterfaces":[{"packageName":"@proteinjs/ui","name":"TableLoader","filePath":null,"qualifiedName":"@proteinjs/ui/TableLoader","properties":[],"methods":[],"typeParameters":["/T"],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/ui/TableLoader"},{"v":"@proteinjs/db-ui/RecordFormCustomization","value":{"packageName":"@proteinjs/db-ui","name":"RecordFormCustomization","filePath":"/home/runner/work/db/db/packages/ui/src/form/RecordFormCustomization.tsx","qualifiedName":"@proteinjs/db-ui/RecordFormCustomization","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"table","type":{"packageName":"","name":"Table<any>","filePath":null,"qualifiedName":"/Table<any>","typeParameters":null,"directParents":null},"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"getFormButtons","returnType":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"record","type":{"packageName":"","name":"any","filePath":null,"qualifiedName":"/any","typeParameters":null,"directParents":null}},{"name":"defaultFormButtons","type":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[{"packageName":"@proteinjs/reflection","name":"Loadable","filePath":null,"qualifiedName":"@proteinjs/reflection/Loadable","properties":[],"methods":[],"typeParameters":[],"directParents":[]}],"directParentClasses":[],"sourceType":2}},{"v":"@proteinjs/reflection/Loadable"},{"v":"@proteinjs/db-ui/recordFormPage","value":{"packageName":"@proteinjs/db-ui","name":"recordFormPage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/RecordFormPage.tsx","qualifiedName":"@proteinjs/db-ui/recordFormPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/ui/Page"},{"v":"@proteinjs/db-ui/recordTablePage","value":{"packageName":"@proteinjs/db-ui","name":"recordTablePage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/RecordTablePage.tsx","qualifiedName":"@proteinjs/db-ui/recordTablePage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/db-ui/tablesPage","value":{"packageName":"@proteinjs/db-ui","name":"tablesPage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/TablesPage.tsx","qualifiedName":"@proteinjs/db-ui/tablesPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/db-ui/uuidGeneratorPage","value":{"packageName":"@proteinjs/db-ui","name":"uuidGeneratorPage","filePath":"/home/runner/work/db/db/packages/ui/src/pages/UuidGeneratorPage.tsx","qualifiedName":"@proteinjs/db-ui/uuidGeneratorPage","type":{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":[{"packageName":"@proteinjs/ui","name":"Page","filePath":null,"qualifiedName":"@proteinjs/ui/Page","typeParameters":[],"directParents":null}]},"isExported":true,"isConst":true,"sourceType":0}},{"v":"@proteinjs/db-ui/MigrationRecordFormCustomization","value":{"packageName":"@proteinjs/db-ui","name":"MigrationRecordFormCustomization","filePath":"/home/runner/work/db/db/packages/ui/src/form/customizations/MigrationRecordFormCustomization.tsx","qualifiedName":"@proteinjs/db-ui/MigrationRecordFormCustomization","isAbstract":false,"isStatic":false,"visibility":"public","properties":[{"name":"table","type":null,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public"}],"methods":[{"name":"getFormButtons","returnType":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null},"isAsync":false,"isOptional":false,"isAbstract":false,"isStatic":false,"visibility":"public","parameters":[{"name":"migration","type":{"packageName":"@proteinjs/db","name":"Migration","filePath":null,"qualifiedName":"@proteinjs/db/Migration","typeParameters":null,"directParents":null}},{"name":"defaultFormButtons","type":{"packageName":"","name":"FormButtons<any>","filePath":null,"qualifiedName":"/FormButtons<any>","typeParameters":null,"directParents":null}}]}],"typeParameters":[],"directParentInterfaces":[],"directParentClasses":[{"packageName":"@proteinjs/db-ui","name":"RecordFormCustomization","filePath":null,"qualifiedName":"@proteinjs/db-ui/RecordFormCustomization","isAbstract":false,"isStatic":false,"visibility":"public","properties":[],"methods":[],"typeParameters":[],"directParentInterfaces":[],"directParentClasses":[]}],"sourceType":2}}],"edges":[{"v":"@proteinjs/db-ui/QueryTableLoader","w":"@proteinjs/ui/TableLoader","value":"implements interface"},{"v":"@proteinjs/db-ui/RecordFormCustomization","w":"@proteinjs/reflection/Loadable","value":"implements interface"},{"v":"@proteinjs/db-ui/recordFormPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/recordTablePage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/tablesPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/uuidGeneratorPage","w":"@proteinjs/ui/Page","value":"has type"},{"v":"@proteinjs/db-ui/MigrationRecordFormCustomization","w":"@proteinjs/db-ui/RecordFormCustomization","value":"extends class"}]}';
|
|
21
20
|
|
|
22
21
|
/** Generate Source Links */
|
|
23
22
|
|
|
@@ -30,20 +29,18 @@ import { uuidGeneratorPage } from '../src/pages/UuidGeneratorPage';
|
|
|
30
29
|
import { MigrationRecordFormCustomization } from '../src/form/customizations/MigrationRecordFormCustomization';
|
|
31
30
|
|
|
32
31
|
const sourceLinks = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
'@proteinjs/db-ui/QueryTableLoader': QueryTableLoader,
|
|
33
|
+
'@proteinjs/db-ui/RecordFormCustomization': RecordFormCustomization,
|
|
34
|
+
'@proteinjs/db-ui/recordFormPage': recordFormPage,
|
|
35
|
+
'@proteinjs/db-ui/recordTablePage': recordTablePage,
|
|
36
|
+
'@proteinjs/db-ui/tablesPage': tablesPage,
|
|
37
|
+
'@proteinjs/db-ui/uuidGeneratorPage': uuidGeneratorPage,
|
|
38
|
+
'@proteinjs/db-ui/MigrationRecordFormCustomization': MigrationRecordFormCustomization,
|
|
40
39
|
};
|
|
41
40
|
|
|
42
|
-
|
|
43
41
|
/** Load Source Graph and Links */
|
|
44
42
|
|
|
45
43
|
import { SourceRepository } from '@proteinjs/reflection';
|
|
46
44
|
SourceRepository.merge(sourceGraph, sourceLinks);
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
export * from '../index';
|
|
46
|
+
export * from '../index';
|
package/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './src/table/RecordTable'
|
|
2
|
-
export * from './src/table/QueryTableLoader'
|
|
3
|
-
export * from './src/form/RecordForm'
|
|
4
|
-
export * from './src/form/RecordFormCustomization'
|
|
1
|
+
export * from './src/table/RecordTable';
|
|
2
|
+
export * from './src/table/QueryTableLoader';
|
|
3
|
+
export * from './src/form/RecordForm';
|
|
4
|
+
export * from './src/form/RecordFormCustomization';
|
package/jest.config.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"ts",
|
|
11
|
-
"tsx",
|
|
12
|
-
"js",
|
|
13
|
-
"jsx",
|
|
14
|
-
"json",
|
|
15
|
-
"node"
|
|
16
|
-
],
|
|
17
|
-
"testEnvironment": "node"
|
|
18
|
-
}
|
|
2
|
+
roots: ['<rootDir>/test'],
|
|
3
|
+
transform: {
|
|
4
|
+
'^.+\\.tsx?$': 'ts-jest',
|
|
5
|
+
},
|
|
6
|
+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
|
|
7
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
8
|
+
testEnvironment: 'node',
|
|
9
|
+
};
|
package/package.json
CHANGED
|
@@ -1,51 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
2
|
+
"name": "@proteinjs/db-ui",
|
|
3
|
+
"version": "1.0.18",
|
|
4
|
+
"description": "Db ui components",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/proteinjs/db.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/proteinjs/db/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/proteinjs/db#readme",
|
|
16
|
+
"author": "Brent Bahry",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"clean": "rm -rf dist/ node_modules/ generated/",
|
|
20
|
+
"build": "reflection-build && tsc",
|
|
21
|
+
"watch": "reflection-watch"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@emotion/react": "11.11.1",
|
|
25
|
+
"@emotion/styled": "11.11.0",
|
|
26
|
+
"@mui/icons-material": "5.14.11",
|
|
27
|
+
"@mui/material": "5.14.11",
|
|
28
|
+
"@proteinjs/db": "^1.0.17",
|
|
29
|
+
"@proteinjs/reflection": "1.1.1",
|
|
30
|
+
"@proteinjs/ui": "2.0.2",
|
|
31
|
+
"@proteinjs/util": "1.1.0",
|
|
32
|
+
"moment": "2.29.4",
|
|
33
|
+
"react": "18.2.0",
|
|
34
|
+
"string": "3.3.3",
|
|
35
|
+
"uuid": "8.3.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@proteinjs/reflection-build": "1.0.16",
|
|
39
|
+
"@types/jest": "29.5.5",
|
|
40
|
+
"@types/node": "14.0.27",
|
|
41
|
+
"@types/react": "18.2.23",
|
|
42
|
+
"@types/string": "0.0.33",
|
|
43
|
+
"@types/uuid": "8.3.0",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "7.8.0",
|
|
45
|
+
"@typescript-eslint/parser": "7.8.0",
|
|
46
|
+
"eslint": "8.57.0",
|
|
47
|
+
"eslint-config-prettier": "9.1.0",
|
|
48
|
+
"eslint-plugin-prettier": "5.1.3",
|
|
49
|
+
"jest": "29.7.0",
|
|
50
|
+
"ts-jest": "29.1.1",
|
|
51
|
+
"typescript": "5.2.2"
|
|
52
|
+
},
|
|
53
|
+
"main": "./dist/generated/index.js",
|
|
54
|
+
"types": "./dist/generated/index.d.ts",
|
|
55
|
+
"gitHead": "e168c40fd3f7c538d5d5ddcedb0bb4f5550ca81f"
|
|
51
56
|
}
|
package/src/form/RecordForm.tsx
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import S from 'string'
|
|
3
|
-
import moment from 'moment'
|
|
4
|
-
import { StringUtil, isInstanceOf } from '@proteinjs/util'
|
|
5
|
-
import { Form, Fields, textField, FormButtons } from '@proteinjs/ui'
|
|
6
|
-
import { Table, Record, Column, getDbService, DateTimeColumn, BooleanColumn } from '@proteinjs/db'
|
|
7
|
-
import { recordTableLink } from '../pages/RecordTablePage'
|
|
8
|
-
import { recordFormLink } from '../pages/RecordFormPage'
|
|
9
|
-
import { getRecordFormCustomization } from './RecordFormCustomization'
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import S from 'string';
|
|
3
|
+
import moment from 'moment';
|
|
4
|
+
import { StringUtil, isInstanceOf } from '@proteinjs/util';
|
|
5
|
+
import { Form, Fields, textField, FormButtons } from '@proteinjs/ui';
|
|
6
|
+
import { Table, Record, Column, getDbService, DateTimeColumn, BooleanColumn } from '@proteinjs/db';
|
|
7
|
+
import { recordTableLink } from '../pages/RecordTablePage';
|
|
8
|
+
import { recordFormLink } from '../pages/RecordFormPage';
|
|
9
|
+
import { getRecordFormCustomization } from './RecordFormCustomization';
|
|
10
10
|
|
|
11
11
|
export type RecordFormProps<T extends Record> = {
|
|
12
|
-
table: Table<T
|
|
13
|
-
record?: T
|
|
14
|
-
}
|
|
12
|
+
table: Table<T>;
|
|
13
|
+
record?: T;
|
|
14
|
+
};
|
|
15
15
|
|
|
16
16
|
export function RecordForm<T extends Record>({ table, record }: RecordFormProps<T>) {
|
|
17
17
|
const isNewRecord = typeof record === 'undefined';
|
|
@@ -21,25 +21,30 @@ export function RecordForm<T extends Record>({ table, record }: RecordFormProps<
|
|
|
21
21
|
name={S(table.name).humanize().s}
|
|
22
22
|
createFields={createFields()}
|
|
23
23
|
fieldLayout={fieldLayout()}
|
|
24
|
-
buttons={
|
|
24
|
+
buttons={
|
|
25
|
+
recordFormCustomization?.getFormButtons ? recordFormCustomization.getFormButtons(record, buttons()) : buttons()
|
|
26
|
+
}
|
|
25
27
|
onLoad={onLoad}
|
|
26
28
|
onLoadProgressMessage={`Loading ${S(table.name).humanize().s}`}
|
|
27
29
|
/>
|
|
28
30
|
);
|
|
29
31
|
|
|
30
32
|
function getColumns() {
|
|
31
|
-
const columns: {[columnPropertyName: string]: Column<T, any>} = {};
|
|
33
|
+
const columns: { [columnPropertyName: string]: Column<T, any> } = {};
|
|
32
34
|
const nameColumn = (table.columns as any)['name'] as Column<T, any>;
|
|
33
|
-
if (nameColumn)
|
|
35
|
+
if (nameColumn) {
|
|
34
36
|
columns['name'] = nameColumn;
|
|
37
|
+
}
|
|
35
38
|
|
|
36
|
-
for (
|
|
39
|
+
for (const columnPropertyName in table.columns) {
|
|
37
40
|
const column = (table.columns as any)[columnPropertyName] as Column<T, any>;
|
|
38
|
-
if (columnPropertyName == 'name' || columnPropertyName == 'created' || columnPropertyName == 'updated')
|
|
41
|
+
if (columnPropertyName == 'name' || columnPropertyName == 'created' || columnPropertyName == 'updated') {
|
|
39
42
|
continue;
|
|
43
|
+
}
|
|
40
44
|
|
|
41
|
-
if (column.options?.ui?.hidden)
|
|
45
|
+
if (column.options?.ui?.hidden) {
|
|
42
46
|
continue;
|
|
47
|
+
}
|
|
43
48
|
|
|
44
49
|
columns[columnPropertyName] = column;
|
|
45
50
|
}
|
|
@@ -51,14 +56,14 @@ export function RecordForm<T extends Record>({ table, record }: RecordFormProps<
|
|
|
51
56
|
|
|
52
57
|
return columns;
|
|
53
58
|
}
|
|
54
|
-
|
|
59
|
+
|
|
55
60
|
function createFields(): () => Fields {
|
|
56
61
|
return () => {
|
|
57
62
|
const fields: Fields = {};
|
|
58
|
-
for (
|
|
63
|
+
for (const columnPropertyName in getColumns()) {
|
|
59
64
|
fields[columnPropertyName] = textField({
|
|
60
65
|
name: columnPropertyName,
|
|
61
|
-
label: StringUtil.humanizeCamel(columnPropertyName),
|
|
66
|
+
label: StringUtil.humanizeCamel(columnPropertyName),
|
|
62
67
|
});
|
|
63
68
|
}
|
|
64
69
|
|
|
@@ -71,9 +76,10 @@ export function RecordForm<T extends Record>({ table, record }: RecordFormProps<
|
|
|
71
76
|
const layoutColumns = Object.entries(columns).length > 6 ? 2 : 1;
|
|
72
77
|
if (layoutColumns > 1) {
|
|
73
78
|
const layout: (keyof T)[][] = [];
|
|
74
|
-
for (
|
|
75
|
-
if (layout.length == 0 || layout[layout.length - 1].length >= layoutColumns)
|
|
79
|
+
for (const columnPropertyName in columns) {
|
|
80
|
+
if (layout.length == 0 || layout[layout.length - 1].length >= layoutColumns) {
|
|
76
81
|
layout.push([]);
|
|
82
|
+
}
|
|
77
83
|
|
|
78
84
|
layout[layout.length - 1].push(columnPropertyName as keyof T);
|
|
79
85
|
}
|
|
@@ -100,13 +106,16 @@ export function RecordForm<T extends Record>({ table, record }: RecordFormProps<
|
|
|
100
106
|
return { path: recordTableLink(table) };
|
|
101
107
|
},
|
|
102
108
|
onClick: async (fields: Fields, buttons: FormButtons<Fields>) => {
|
|
103
|
-
if (!record || !record.id)
|
|
109
|
+
if (!record || !record.id) {
|
|
104
110
|
throw new Error(`Unable to delete record, record or id undefined`);
|
|
111
|
+
}
|
|
105
112
|
|
|
106
113
|
await getDbService().delete(table, { id: record.id } as any);
|
|
107
114
|
return `Deleted ${S(table.name).humanize().s}`;
|
|
108
115
|
},
|
|
109
|
-
progressMessage: (fields: Fields) => {
|
|
116
|
+
progressMessage: (fields: Fields) => {
|
|
117
|
+
return `Deleting ${S(table.name).humanize().s}`;
|
|
118
|
+
},
|
|
110
119
|
},
|
|
111
120
|
save: {
|
|
112
121
|
name: 'Save',
|
|
@@ -118,10 +127,11 @@ export function RecordForm<T extends Record>({ table, record }: RecordFormProps<
|
|
|
118
127
|
variant: 'contained',
|
|
119
128
|
},
|
|
120
129
|
onClick: async (fields: Fields, buttons: FormButtons<Fields>) => {
|
|
121
|
-
if (!record || !record.id)
|
|
130
|
+
if (!record || !record.id) {
|
|
122
131
|
throw new Error(`Unable to save record, record or id undefined`);
|
|
132
|
+
}
|
|
123
133
|
|
|
124
|
-
for (
|
|
134
|
+
for (const columnPropertyName in fields) {
|
|
125
135
|
const field = fields[columnPropertyName];
|
|
126
136
|
(record as any)[columnPropertyName] = field.field.value;
|
|
127
137
|
}
|
|
@@ -129,7 +139,9 @@ export function RecordForm<T extends Record>({ table, record }: RecordFormProps<
|
|
|
129
139
|
await getDbService().update(table, record);
|
|
130
140
|
return `Saved ${S(table.name).humanize().s}`;
|
|
131
141
|
},
|
|
132
|
-
progressMessage: (fields: Fields) => {
|
|
142
|
+
progressMessage: (fields: Fields) => {
|
|
143
|
+
return `Saving ${S(table.name).humanize().s}`;
|
|
144
|
+
},
|
|
133
145
|
},
|
|
134
146
|
create: {
|
|
135
147
|
name: 'Create',
|
|
@@ -145,7 +157,7 @@ export function RecordForm<T extends Record>({ table, record }: RecordFormProps<
|
|
|
145
157
|
},
|
|
146
158
|
onClick: async (fields: Fields, buttons: FormButtons<Fields>) => {
|
|
147
159
|
const record: any = {};
|
|
148
|
-
for (
|
|
160
|
+
for (const columnPropertyName in fields) {
|
|
149
161
|
const field = fields[columnPropertyName];
|
|
150
162
|
(record as any)[columnPropertyName] = field.field.value;
|
|
151
163
|
}
|
|
@@ -153,36 +165,41 @@ export function RecordForm<T extends Record>({ table, record }: RecordFormProps<
|
|
|
153
165
|
newRecord = await getDbService().insert(table, record);
|
|
154
166
|
return `Created ${S(table.name).humanize().s}`;
|
|
155
167
|
},
|
|
156
|
-
progressMessage: (fields: Fields) => {
|
|
168
|
+
progressMessage: (fields: Fields) => {
|
|
169
|
+
return `Creating ${S(table.name).humanize().s}`;
|
|
170
|
+
},
|
|
157
171
|
},
|
|
158
|
-
}
|
|
172
|
+
};
|
|
159
173
|
}
|
|
160
174
|
|
|
161
175
|
async function onLoad(fields: Fields, buttons: FormButtons<Fields>) {
|
|
162
|
-
if (isNewRecord)
|
|
176
|
+
if (isNewRecord) {
|
|
163
177
|
return;
|
|
178
|
+
}
|
|
164
179
|
|
|
165
|
-
for (
|
|
180
|
+
for (const columnPropertyName in fields) {
|
|
166
181
|
const column = (table.columns as any)[columnPropertyName] as Column<any, any>;
|
|
167
182
|
const field = fields[columnPropertyName].field;
|
|
168
183
|
let fieldValue = (record as any)[columnPropertyName];
|
|
169
|
-
if (moment.isMoment(fieldValue))
|
|
184
|
+
if (moment.isMoment(fieldValue)) {
|
|
170
185
|
fieldValue = fieldValue.format('ddd, MMM Do YY, h:mm:ss a');
|
|
171
|
-
else if (isInstanceOf(column, BooleanColumn))
|
|
186
|
+
} else if (isInstanceOf(column, BooleanColumn)) {
|
|
172
187
|
fieldValue = fieldValue == true ? 'True' : 'False';
|
|
173
|
-
|
|
188
|
+
}
|
|
189
|
+
|
|
174
190
|
field.value = fieldValue;
|
|
175
191
|
if (
|
|
176
|
-
columnPropertyName == 'created' ||
|
|
177
|
-
columnPropertyName == 'updated' ||
|
|
192
|
+
columnPropertyName == 'created' ||
|
|
193
|
+
columnPropertyName == 'updated' ||
|
|
178
194
|
columnPropertyName == 'id' ||
|
|
179
195
|
isInstanceOf(column, DateTimeColumn)
|
|
180
196
|
) {
|
|
181
|
-
if (!field.accessibility)
|
|
197
|
+
if (!field.accessibility) {
|
|
182
198
|
field.accessibility = {};
|
|
199
|
+
}
|
|
183
200
|
|
|
184
201
|
field.accessibility.readonly = true;
|
|
185
202
|
}
|
|
186
203
|
}
|
|
187
204
|
}
|
|
188
|
-
}
|
|
205
|
+
}
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { Loadable, SourceRepository } from '@proteinjs/reflection'
|
|
2
|
-
import { FormButtons } from '@proteinjs/ui'
|
|
3
|
-
import { Table } from '@proteinjs/db'
|
|
1
|
+
import { Loadable, SourceRepository } from '@proteinjs/reflection';
|
|
2
|
+
import { FormButtons } from '@proteinjs/ui';
|
|
3
|
+
import { Table } from '@proteinjs/db';
|
|
4
4
|
|
|
5
|
-
export const getRecordFormCustomizations = () =>
|
|
5
|
+
export const getRecordFormCustomizations = () =>
|
|
6
|
+
SourceRepository.get().objects<RecordFormCustomization>('@proteinjs/db-ui/RecordFormCustomization');
|
|
6
7
|
|
|
7
8
|
export const getRecordFormCustomization = (tableName: string) => {
|
|
8
9
|
const recordFormCustomizations = getRecordFormCustomizations();
|
|
9
|
-
for (
|
|
10
|
-
if (recordFormCustomization.table.name == tableName)
|
|
10
|
+
for (const recordFormCustomization of recordFormCustomizations) {
|
|
11
|
+
if (recordFormCustomization.table.name == tableName) {
|
|
11
12
|
return recordFormCustomization;
|
|
13
|
+
}
|
|
12
14
|
}
|
|
13
|
-
}
|
|
15
|
+
};
|
|
14
16
|
|
|
15
17
|
export abstract class RecordFormCustomization implements Loadable {
|
|
16
18
|
abstract table: Table<any>;
|
|
17
|
-
|
|
19
|
+
getFormButtons(record: any, defaultFormButtons: FormButtons<any>): FormButtons<any> {
|
|
18
20
|
return defaultFormButtons;
|
|
19
21
|
}
|
|
20
|
-
}
|
|
22
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Fields, FormButtons } from '@proteinjs/ui'
|
|
2
|
-
import { Migration, getMigrationRunnerService, tables } from '@proteinjs/db'
|
|
3
|
-
import { RecordFormCustomization } from '../RecordFormCustomization'
|
|
1
|
+
import { Fields, FormButtons } from '@proteinjs/ui';
|
|
2
|
+
import { Migration, getMigrationRunnerService, tables } from '@proteinjs/db';
|
|
3
|
+
import { RecordFormCustomization } from '../RecordFormCustomization';
|
|
4
4
|
|
|
5
5
|
export class MigrationRecordFormCustomization extends RecordFormCustomization {
|
|
6
6
|
public table = tables.Migration;
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
getFormButtons(migration: Migration, defaultFormButtons: FormButtons<any>): FormButtons<any> {
|
|
9
9
|
const formButtons = { ...defaultFormButtons };
|
|
10
10
|
delete formButtons['create'];
|
|
@@ -22,8 +22,10 @@ export class MigrationRecordFormCustomization extends RecordFormCustomization {
|
|
|
22
22
|
await getMigrationRunnerService().runMigration(migration.id);
|
|
23
23
|
return `Started migration`;
|
|
24
24
|
},
|
|
25
|
-
progressMessage: (fields: Fields) => {
|
|
25
|
+
progressMessage: (fields: Fields) => {
|
|
26
|
+
return `Starting migration`;
|
|
27
|
+
},
|
|
26
28
|
};
|
|
27
29
|
return formButtons;
|
|
28
30
|
}
|
|
29
|
-
}
|
|
31
|
+
}
|