remult 0.22.2 → 0.22.3
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/esm/graphql.js +27 -27
- package/esm/postgres/schema-builder.js +4 -4
- package/esm/remult-knex/index.js +2 -2
- package/esm/src/backend-tests/backend-database-test-setup.backend-spec.js +10 -0
- package/esm/src/id-entity.d.ts +4 -0
- package/esm/src/id-entity.js +8 -0
- package/esm/src/remult3/RepositoryImplementation.js +7 -5
- package/esm/src/shared-tests/db-tests.db-tests.js +35 -0
- package/package.json +1 -1
- package/postgres/postgresColumnSyntax.d.ts +2 -0
- package/postgres/postgresColumnSyntax.js +34 -0
- package/remult-knex/index.js +2 -2
- package/remult-middleware.d.ts +2 -0
- package/remult-middleware.js +70 -0
- package/server/register-actions-on-server.d.ts +3 -0
- package/server/register-actions-on-server.js +50 -0
- package/server/register-entities-on-server.d.ts +3 -0
- package/server/register-entities-on-server.js +19 -0
- package/src/backend-tests/backend-database-test-setup.backend-spec.js +10 -0
- package/{esm/core/src → src}/backend-tests/my-test.backend-spec.d.ts +1 -1
- package/src/backend-tests/my-test.backend-spec.js +217 -0
- package/src/backend-tests/test-http-server.backend-spec.d.ts +6 -0
- package/src/backend-tests/test-http-server.backend-spec.js +342 -0
- package/src/id-entity.d.ts +4 -0
- package/src/id-entity.js +17 -0
- package/src/remult3/RepositoryImplementation.js +15 -13
- package/src/shared-tests/db-tests.db-tests.js +64 -0
- package/{esm/core/src/valueConverters.d.ts → valueConverters.d.ts} +12 -13
- package/valueConverters.js +168 -0
- package/esm/angular/interfaces/index.d.ts +0 -1
- package/esm/angular/interfaces/index.js +0 -1
- package/esm/angular/interfaces/src/column-collection.d.ts +0 -70
- package/esm/angular/interfaces/src/column-collection.js +0 -341
- package/esm/angular/interfaces/src/data-area-settings.d.ts +0 -15
- package/esm/angular/interfaces/src/data-area-settings.js +0 -35
- package/esm/angular/interfaces/src/data-control-interfaces.d.ts +0 -36
- package/esm/angular/interfaces/src/data-control-interfaces.js +0 -57
- package/esm/angular/interfaces/src/dataList.d.ts +0 -13
- package/esm/angular/interfaces/src/dataList.js +0 -42
- package/esm/angular/interfaces/src/filter-helper.d.ts +0 -13
- package/esm/angular/interfaces/src/filter-helper.js +0 -59
- package/esm/angular/interfaces/src/grid-settings.d.ts +0 -145
- package/esm/angular/interfaces/src/grid-settings.js +0 -387
- package/esm/angular/interfaces/src/public_api.d.ts +0 -4
- package/esm/angular/interfaces/src/public_api.js +0 -4
- package/esm/angular/src/angular/RemultAngularPluginsService.d.ts +0 -4
- package/esm/angular/src/angular/RemultAngularPluginsService.js +0 -3
- package/esm/angular/src/angular/data-control/data-control2.component.d.ts +0 -49
- package/esm/angular/src/angular/data-control/data-control2.component.js +0 -138
- package/esm/core/SseSubscriptionServer.d.ts +0 -33
- package/esm/core/SseSubscriptionServer.js +0 -107
- package/esm/core/assign.d.ts +0 -1
- package/esm/core/assign.js +0 -5
- package/esm/core/classType.d.ts +0 -3
- package/esm/core/classType.js +0 -1
- package/esm/core/index.d.ts +0 -27
- package/esm/core/index.js +0 -25
- package/esm/core/inputTypes.d.ts +0 -9
- package/esm/core/inputTypes.js +0 -9
- package/esm/core/live-query/data-provider-live-query-storage.d.ts +0 -22
- package/esm/core/live-query/data-provider-live-query-storage.js +0 -71
- package/esm/core/postgres/index.d.ts +0 -2
- package/esm/core/postgres/index.js +0 -2
- package/esm/core/postgres/postgres-data-provider.d.ts +0 -36
- package/esm/core/postgres/postgres-data-provider.js +0 -120
- package/esm/core/postgres/schema-builder.d.ts +0 -17
- package/esm/core/postgres/schema-builder.js +0 -153
- package/esm/core/remult-fresh.d.ts +0 -17
- package/esm/core/remult-fresh.js +0 -29
- package/esm/core/remult-knex/index.d.ts +0 -30
- package/esm/core/remult-knex/index.js +0 -446
- package/esm/core/remult-mongo.d.ts +0 -24
- package/esm/core/remult-mongo.js +0 -254
- package/esm/core/server/JsonEntityFileStorage.d.ts +0 -10
- package/esm/core/server/JsonEntityFileStorage.js +0 -25
- package/esm/core/server/core.d.ts +0 -4
- package/esm/core/server/core.js +0 -4
- package/esm/core/server/expressBridge.d.ts +0 -182
- package/esm/core/server/expressBridge.js +0 -938
- package/esm/core/server/index.d.ts +0 -6
- package/esm/core/server/index.js +0 -9
- package/esm/core/server/initAsyncHooks.d.ts +0 -1
- package/esm/core/server/initAsyncHooks.js +0 -9
- package/esm/core/server/initDataProvider.d.ts +0 -2
- package/esm/core/server/initDataProvider.js +0 -14
- package/esm/core/src/__EntityValueProvider.d.ts +0 -11
- package/esm/core/src/__EntityValueProvider.js +0 -1
- package/esm/core/src/__RowsOfDataForTesting.d.ts +0 -3
- package/esm/core/src/__RowsOfDataForTesting.js +0 -1
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +0 -6
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.js +0 -147
- package/esm/core/src/backend-tests/my-test.backend-spec.js +0 -197
- package/esm/core/src/backend-tests/test-http-server.backend-spec.d.ts +0 -1
- package/esm/core/src/backend-tests/test-http-server.backend-spec.js +0 -167
- package/esm/core/src/buildRestDataProvider.d.ts +0 -31
- package/esm/core/src/buildRestDataProvider.js +0 -113
- package/esm/core/src/column-interfaces.d.ts +0 -154
- package/esm/core/src/column-interfaces.js +0 -7
- package/esm/core/src/column.d.ts +0 -58
- package/esm/core/src/column.js +0 -174
- package/esm/core/src/context.d.ts +0 -134
- package/esm/core/src/context.js +0 -286
- package/esm/core/src/data-api.d.ts +0 -39
- package/esm/core/src/data-api.js +0 -279
- package/esm/core/src/data-interfaces.d.ts +0 -41
- package/esm/core/src/data-interfaces.js +0 -12
- package/esm/core/src/data-providers/array-entity-data-provider.d.ts +0 -22
- package/esm/core/src/data-providers/array-entity-data-provider.js +0 -252
- package/esm/core/src/data-providers/in-memory-database.d.ts +0 -9
- package/esm/core/src/data-providers/in-memory-database.js +0 -14
- package/esm/core/src/data-providers/json-data-provider.d.ts +0 -12
- package/esm/core/src/data-providers/json-data-provider.js +0 -55
- package/esm/core/src/data-providers/rest-data-provider.d.ts +0 -49
- package/esm/core/src/data-providers/rest-data-provider.js +0 -256
- package/esm/core/src/data-providers/sql-database.d.ts +0 -33
- package/esm/core/src/data-providers/sql-database.js +0 -384
- package/esm/core/src/data-providers/web-sql-data-provider.d.ts +0 -24
- package/esm/core/src/data-providers/web-sql-data-provider.js +0 -143
- package/esm/core/src/entity.d.ts +0 -91
- package/esm/core/src/entity.js +0 -1
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.d.ts +0 -50
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.js +0 -150
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.d.ts +0 -1
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.js +0 -1
- package/esm/core/src/filter/filter-interfaces.d.ts +0 -85
- package/esm/core/src/filter/filter-interfaces.js +0 -477
- package/esm/core/src/live-query/LiveQueryClient.d.ts +0 -20
- package/esm/core/src/live-query/LiveQueryClient.js +0 -188
- package/esm/core/src/live-query/SseSubscriptionClient.d.ts +0 -5
- package/esm/core/src/live-query/SseSubscriptionClient.js +0 -86
- package/esm/core/src/live-query/SubscriptionChannel.d.ts +0 -72
- package/esm/core/src/live-query/SubscriptionChannel.js +0 -123
- package/esm/core/src/live-query/SubscriptionServer.d.ts +0 -53
- package/esm/core/src/live-query/SubscriptionServer.js +0 -111
- package/esm/core/src/live-query/live-query-tests.spec.d.ts +0 -6
- package/esm/core/src/live-query/live-query-tests.spec.js +0 -952
- package/esm/core/src/remult-proxy.d.ts +0 -35
- package/esm/core/src/remult-proxy.js +0 -113
- package/esm/core/src/remult3/DecoratorReplacer.d.ts +0 -10
- package/esm/core/src/remult3/DecoratorReplacer.js +0 -20
- package/esm/core/src/remult3/RepositoryImplementation.d.ts +0 -355
- package/esm/core/src/remult3/RepositoryImplementation.js +0 -2109
- package/esm/core/src/remult3/index.d.ts +0 -2
- package/esm/core/src/remult3/index.js +0 -2
- package/esm/core/src/remult3/remult3.d.ts +0 -395
- package/esm/core/src/remult3/remult3.js +0 -2
- package/esm/core/src/server-action.d.ts +0 -81
- package/esm/core/src/server-action.js +0 -394
- package/esm/core/src/shared-tests/db-tests-setup.d.ts +0 -32
- package/esm/core/src/shared-tests/db-tests-setup.js +0 -78
- package/esm/core/src/shared-tests/db-tests.db-tests.d.ts +0 -25
- package/esm/core/src/shared-tests/db-tests.db-tests.js +0 -810
- package/esm/core/src/shared-tests/deleteAll.d.ts +0 -2
- package/esm/core/src/shared-tests/deleteAll.js +0 -4
- package/esm/core/src/shared-tests/entityWithValidations.d.ts +0 -14
- package/esm/core/src/shared-tests/entityWithValidations.js +0 -43
- package/esm/core/src/shared-tests/index.d.ts +0 -4
- package/esm/core/src/shared-tests/index.js +0 -4
- package/esm/core/src/shared-tests/test-custom-id-column.spec.d.ts +0 -1
- package/esm/core/src/shared-tests/test-custom-id-column.spec.js +0 -67
- package/esm/core/src/shared-tests/test-special-value.spec.d.ts +0 -10
- package/esm/core/src/shared-tests/test-special-value.spec.js +0 -73
- package/esm/core/src/shared-tests/test-update-with-null.spec.d.ts +0 -1
- package/esm/core/src/shared-tests/test-update-with-null.spec.js +0 -31
- package/esm/core/src/sort.d.ts +0 -16
- package/esm/core/src/sort.js +0 -103
- package/esm/core/src/sql-command.d.ts +0 -19
- package/esm/core/src/sql-command.js +0 -1
- package/esm/core/src/test.d.ts +0 -3
- package/esm/core/src/test.js +0 -12
- package/esm/core/src/tests/Done.d.ts +0 -5
- package/esm/core/src/tests/Done.js +0 -9
- package/esm/core/src/tests/RowProvider.spec.d.ts +0 -16
- package/esm/core/src/tests/RowProvider.spec.js +0 -631
- package/esm/core/src/tests/TestDataApiResponse.d.ts +0 -10
- package/esm/core/src/tests/TestDataApiResponse.js +0 -22
- package/esm/core/src/tests/basicRowFunctionality.spec.d.ts +0 -8
- package/esm/core/src/tests/basicRowFunctionality.spec.js +0 -2103
- package/esm/core/src/tests/c.d.ts +0 -8
- package/esm/core/src/tests/c.js +0 -13
- package/esm/core/src/tests/createData.d.ts +0 -7
- package/esm/core/src/tests/createData.js +0 -22
- package/esm/core/src/tests/d.d.ts +0 -6
- package/esm/core/src/tests/d.js +0 -11
- package/esm/core/src/tests/dWithPrefilter.d.ts +0 -7
- package/esm/core/src/tests/dWithPrefilter.js +0 -18
- package/esm/core/src/tests/entityForCustomFilter.d.ts +0 -16
- package/esm/core/src/tests/entityForCustomFilter.js +0 -33
- package/esm/core/src/tests/entityWithValidationsOnColumn.d.ts +0 -5
- package/esm/core/src/tests/entityWithValidationsOnColumn.js +0 -13
- package/esm/core/src/tests/frontend-database-tests-setup.spec.d.ts +0 -4
- package/esm/core/src/tests/frontend-database-tests-setup.spec.js +0 -37
- package/esm/core/src/tests/h.d.ts +0 -6
- package/esm/core/src/tests/h.js +0 -24
- package/esm/core/src/tests/remult-3-basic-tests.spec.d.ts +0 -1
- package/esm/core/src/tests/remult-3-basic-tests.spec.js +0 -236
- package/esm/core/src/tests/remult-3-entities.d.ts +0 -23
- package/esm/core/src/tests/remult-3-entities.js +0 -39
- package/esm/core/src/tests/tasks.d.ts +0 -6
- package/esm/core/src/tests/tasks.js +0 -10
- package/esm/core/src/tests/test-context-as-storage.spec.d.ts +0 -0
- package/esm/core/src/tests/test-context-as-storage.spec.js +0 -1
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.d.ts +0 -1
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.js +0 -389
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.d.ts +0 -5
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.js +0 -152
- package/esm/core/src/tests/test-decorator-precedence.spec.d.ts +0 -1
- package/esm/core/src/tests/test-decorator-precedence.spec.js +0 -38
- package/esm/core/src/tests/test-default-value.spec.d.ts +0 -1
- package/esm/core/src/tests/test-default-value.spec.js +0 -33
- package/esm/core/src/tests/test-entity-inheritance.spec.d.ts +0 -14
- package/esm/core/src/tests/test-entity-inheritance.spec.js +0 -82
- package/esm/core/src/tests/test-exceptions.spec.d.ts +0 -1
- package/esm/core/src/tests/test-exceptions.spec.js +0 -375
- package/esm/core/src/tests/test-json.spec.d.ts +0 -1
- package/esm/core/src/tests/test-json.spec.js +0 -115
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.d.ts +0 -9
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.js +0 -809
- package/esm/core/src/tests/test-non-active-record.spec.d.ts +0 -1
- package/esm/core/src/tests/test-non-active-record.spec.js +0 -66
- package/esm/core/src/tests/test-object-column.spec.d.ts +0 -1
- package/esm/core/src/tests/test-object-column.spec.js +0 -189
- package/esm/core/src/tests/test-paged-foreach.spec.d.ts +0 -1
- package/esm/core/src/tests/test-paged-foreach.spec.js +0 -328
- package/esm/core/src/tests/test-remult-angular.spec.d.ts +0 -1
- package/esm/core/src/tests/test-remult-angular.spec.js +0 -23
- package/esm/core/src/tests/test-server-controller.spec.d.ts +0 -7
- package/esm/core/src/tests/test-server-controller.spec.js +0 -489
- package/esm/core/src/tests/test-server-expressions.spec.d.ts +0 -1
- package/esm/core/src/tests/test-server-expressions.spec.js +0 -178
- package/esm/core/src/tests/test-server-method-on-entity.spec.d.ts +0 -1
- package/esm/core/src/tests/test-server-method-on-entity.spec.js +0 -306
- package/esm/core/src/tests/test-sql-expression.spec.d.ts +0 -5
- package/esm/core/src/tests/test-sql-expression.spec.js +0 -205
- package/esm/core/src/tests/test-sql.spec.d.ts +0 -1
- package/esm/core/src/tests/test-sql.spec.js +0 -170
- package/esm/core/src/tests/test-subscribe.spec.d.ts +0 -1
- package/esm/core/src/tests/test-subscribe.spec.js +0 -135
- package/esm/core/src/tests/test-type-recovery.spec.d.ts +0 -1
- package/esm/core/src/tests/test-type-recovery.spec.js +0 -49
- package/esm/core/src/tests/test-where-api.spec.d.ts +0 -1
- package/esm/core/src/tests/test-where-api.spec.js +0 -434
- package/esm/core/src/tests/testHelper.spec.d.ts +0 -36
- package/esm/core/src/tests/testHelper.spec.js +0 -226
- package/esm/core/src/tests/testModel/models.d.ts +0 -16
- package/esm/core/src/tests/testModel/models.js +0 -25
- package/esm/core/src/validators.d.ts +0 -14
- package/esm/core/src/validators.js +0 -33
- package/esm/core/src/valueConverters.js +0 -197
- package/esm/core/urlBuilder.d.ts +0 -6
- package/esm/core/urlBuilder.js +0 -20
- package/esm/test-servers/shared/Task.d.ts +0 -9
- package/esm/test-servers/shared/Task.js +0 -32
- package/esm/test.d.ts +0 -5
- package/esm/test.js +0 -6
|
@@ -2377,3 +2377,67 @@ db_tests_setup_1.testAll('test relation to number id', function (_a) {
|
|
|
2377
2377
|
});
|
|
2378
2378
|
});
|
|
2379
2379
|
}, false, { exclude: [db_tests_setup_1.TestDbs.mongo, db_tests_setup_1.TestDbs.mongoNoTrans] });
|
|
2380
|
+
db_tests_setup_1.testAll('test relation to string id', function (_a) {
|
|
2381
|
+
var createEntity = _a.createEntity;
|
|
2382
|
+
return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
2383
|
+
var category, task, catRepo, taskRepo, cat, _b, _c, _d;
|
|
2384
|
+
return tslib_1.__generator(this, function (_e) {
|
|
2385
|
+
switch (_e.label) {
|
|
2386
|
+
case 0:
|
|
2387
|
+
category = /** @class */ (function () {
|
|
2388
|
+
function class_12() {
|
|
2389
|
+
this.id = '';
|
|
2390
|
+
this.name = '';
|
|
2391
|
+
}
|
|
2392
|
+
return class_12;
|
|
2393
|
+
}());
|
|
2394
|
+
DecoratorReplacer_1.describeClass(category, remult3_1.Entity('rel_ID_string_categories', { allowApiCrud: true }), {
|
|
2395
|
+
id: remult3_1.Fields.cuid(),
|
|
2396
|
+
name: remult3_1.Fields.string(),
|
|
2397
|
+
});
|
|
2398
|
+
task = /** @class */ (function () {
|
|
2399
|
+
function class_13() {
|
|
2400
|
+
this.id = 0;
|
|
2401
|
+
this.title = '';
|
|
2402
|
+
}
|
|
2403
|
+
return class_13;
|
|
2404
|
+
}());
|
|
2405
|
+
DecoratorReplacer_1.describeClass(task, remult3_1.Entity('rel_ID_string_task', { allowApiCrud: true }), {
|
|
2406
|
+
id: remult3_1.Fields.autoIncrement(),
|
|
2407
|
+
title: remult3_1.Fields.string(),
|
|
2408
|
+
category: remult3_1.Field(function () { return category; }),
|
|
2409
|
+
});
|
|
2410
|
+
return [4 /*yield*/, createEntity(category)];
|
|
2411
|
+
case 1:
|
|
2412
|
+
catRepo = _e.sent();
|
|
2413
|
+
return [4 /*yield*/, createEntity(task)];
|
|
2414
|
+
case 2:
|
|
2415
|
+
taskRepo = _e.sent();
|
|
2416
|
+
return [4 /*yield*/, catRepo.insert([{ name: 'cat0' }, { name: 'cat1' }])];
|
|
2417
|
+
case 3:
|
|
2418
|
+
cat = _e.sent();
|
|
2419
|
+
return [4 /*yield*/, taskRepo.insert([
|
|
2420
|
+
{ title: 't1', category: cat[0] },
|
|
2421
|
+
{ title: 't2', category: cat[0] },
|
|
2422
|
+
{ title: 't3', category: cat[1] },
|
|
2423
|
+
])];
|
|
2424
|
+
case 4:
|
|
2425
|
+
_e.sent();
|
|
2426
|
+
expect(taskRepo.fields.category.valueConverter.fieldTypeInDb).toBeUndefined();
|
|
2427
|
+
_b = expect;
|
|
2428
|
+
return [4 /*yield*/, taskRepo.count({ category: cat[0] })];
|
|
2429
|
+
case 5:
|
|
2430
|
+
_b.apply(void 0, [_e.sent()]).toBe(2);
|
|
2431
|
+
_c = expect;
|
|
2432
|
+
return [4 /*yield*/, taskRepo.count({ category: cat[1] })];
|
|
2433
|
+
case 6:
|
|
2434
|
+
_c.apply(void 0, [_e.sent()]).toBe(1);
|
|
2435
|
+
_d = expect;
|
|
2436
|
+
return [4 /*yield*/, taskRepo.count({ category: { $id: cat[0].id } })];
|
|
2437
|
+
case 7:
|
|
2438
|
+
_d.apply(void 0, [_e.sent()]).toBe(2);
|
|
2439
|
+
return [2 /*return*/];
|
|
2440
|
+
}
|
|
2441
|
+
});
|
|
2442
|
+
});
|
|
2443
|
+
}, false, { exclude: [db_tests_setup_1.TestDbs.mongo, db_tests_setup_1.TestDbs.mongoNoTrans] });
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { ValueConverter } from "./column-interfaces";
|
|
2
|
-
export declare class ValueConverters {
|
|
3
|
-
static readonly Date: ValueConverter<Date>;
|
|
4
|
-
static readonly DateOnly: ValueConverter<Date>;
|
|
5
|
-
static readonly DateOnlyString: ValueConverter<Date>;
|
|
6
|
-
static readonly Boolean: ValueConverter<Boolean>;
|
|
7
|
-
static readonly Number: ValueConverter<number>;
|
|
8
|
-
static readonly
|
|
9
|
-
static readonly
|
|
10
|
-
static readonly
|
|
11
|
-
static readonly
|
|
12
|
-
|
|
13
|
-
}
|
|
1
|
+
import { ValueConverter } from "./src/column-interfaces";
|
|
2
|
+
export declare class ValueConverters {
|
|
3
|
+
static readonly Date: ValueConverter<Date>;
|
|
4
|
+
static readonly DateOnly: ValueConverter<Date>;
|
|
5
|
+
static readonly DateOnlyString: ValueConverter<Date>;
|
|
6
|
+
static readonly Boolean: ValueConverter<Boolean>;
|
|
7
|
+
static readonly Number: ValueConverter<number>;
|
|
8
|
+
static readonly Integer: ValueConverter<number>;
|
|
9
|
+
static readonly Default: ValueConverter<any>;
|
|
10
|
+
static readonly JsonString: ValueConverter<any>;
|
|
11
|
+
static readonly JsonValue: ValueConverter<any>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ValueConverters = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var inputTypes_1 = require("./inputTypes");
|
|
6
|
+
var ValueConverters = /** @class */ (function () {
|
|
7
|
+
function ValueConverters() {
|
|
8
|
+
}
|
|
9
|
+
ValueConverters.Date = {
|
|
10
|
+
toJson: function (val) {
|
|
11
|
+
if (!val)
|
|
12
|
+
return '';
|
|
13
|
+
if (typeof (val) === "string")
|
|
14
|
+
val = new Date(val);
|
|
15
|
+
if (val instanceof Date) {
|
|
16
|
+
return val.toISOString();
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
console.log("ToJsonError", val);
|
|
20
|
+
throw new Error("Expected date but got val");
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
fromJson: function (val) {
|
|
24
|
+
if (val == undefined)
|
|
25
|
+
return undefined;
|
|
26
|
+
if (val == '')
|
|
27
|
+
return undefined;
|
|
28
|
+
if (val.startsWith('0000-00-00'))
|
|
29
|
+
return undefined;
|
|
30
|
+
return new Date(Date.parse(val));
|
|
31
|
+
},
|
|
32
|
+
toDb: function (x) { return x; },
|
|
33
|
+
fromDb: function (x) { return x; },
|
|
34
|
+
fromInput: function (x) { return ValueConverters.Date.fromJson(x); },
|
|
35
|
+
toInput: function (x) { return ValueConverters.Date.toJson(x); },
|
|
36
|
+
displayValue: function (val) {
|
|
37
|
+
if (!val)
|
|
38
|
+
return '';
|
|
39
|
+
return val.toLocaleString();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
ValueConverters.DateOnly = {
|
|
43
|
+
fromInput: function (x) { return ValueConverters.DateOnly.fromJson(x); },
|
|
44
|
+
toInput: function (x) { return ValueConverters.DateOnly.toJson(x); },
|
|
45
|
+
toJson: function (val) {
|
|
46
|
+
var d = val;
|
|
47
|
+
if (typeof d === "string" || typeof (d) === "number")
|
|
48
|
+
d = new Date(d);
|
|
49
|
+
if (!d || d == null)
|
|
50
|
+
return null;
|
|
51
|
+
if (d.getHours() == 0)
|
|
52
|
+
return new Date(d.valueOf() - d.getTimezoneOffset() * 60000).toISOString().substring(0, 10);
|
|
53
|
+
else
|
|
54
|
+
return d.toISOString().substring(0, 10);
|
|
55
|
+
},
|
|
56
|
+
fromJson: function (value) {
|
|
57
|
+
if (!value || value == '' || value == '0000-00-00')
|
|
58
|
+
return null;
|
|
59
|
+
var d = new Date(Date.parse(value));
|
|
60
|
+
d.setMinutes(d.getMinutes() + d.getTimezoneOffset());
|
|
61
|
+
return d;
|
|
62
|
+
},
|
|
63
|
+
inputType: inputTypes_1.InputTypes.date,
|
|
64
|
+
toDb: function (val) {
|
|
65
|
+
if (!val)
|
|
66
|
+
return null;
|
|
67
|
+
return ValueConverters.DateOnly.fromJson(ValueConverters.DateOnly.toJson(val));
|
|
68
|
+
} //when using date storage, the database expects and returns a date local and every where else we reflect on date iso
|
|
69
|
+
,
|
|
70
|
+
fromDb: function (val) {
|
|
71
|
+
var d = val;
|
|
72
|
+
if (!d)
|
|
73
|
+
return null;
|
|
74
|
+
return val;
|
|
75
|
+
},
|
|
76
|
+
fieldTypeInDb: 'date',
|
|
77
|
+
displayValue: function (value) {
|
|
78
|
+
if (!value)
|
|
79
|
+
return '';
|
|
80
|
+
return value.toLocaleDateString(undefined);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
ValueConverters.DateOnlyString = tslib_1.__assign(tslib_1.__assign({}, ValueConverters.DateOnly), { toDb: function (d) {
|
|
84
|
+
var val = ValueConverters.DateOnly.toJson(d);
|
|
85
|
+
if (!val)
|
|
86
|
+
return undefined;
|
|
87
|
+
return val.replace(/-/g, '');
|
|
88
|
+
}, fromDb: function (val) {
|
|
89
|
+
if (val === null)
|
|
90
|
+
return null;
|
|
91
|
+
if (!val)
|
|
92
|
+
return undefined;
|
|
93
|
+
return new Date(val.substring(0, 4) + '-' + val.substring(4, 6) + '-' + val.substring(6, 8));
|
|
94
|
+
} });
|
|
95
|
+
ValueConverters.Boolean = {
|
|
96
|
+
toDb: function (val) { return val; },
|
|
97
|
+
inputType: inputTypes_1.InputTypes.checkbox,
|
|
98
|
+
fromDb: function (value) {
|
|
99
|
+
return ValueConverters.Boolean.fromJson(value);
|
|
100
|
+
},
|
|
101
|
+
fromJson: function (value) {
|
|
102
|
+
if (typeof value === "boolean")
|
|
103
|
+
return value;
|
|
104
|
+
if (value !== undefined && value !== null) {
|
|
105
|
+
return value.toString().trim().toLowerCase() == 'true';
|
|
106
|
+
}
|
|
107
|
+
return value;
|
|
108
|
+
},
|
|
109
|
+
toJson: function (x) { return x; },
|
|
110
|
+
fromInput: function (x) { return ValueConverters.Boolean.fromJson(x); },
|
|
111
|
+
toInput: function (x) { return ValueConverters.Boolean.toJson(x); }
|
|
112
|
+
};
|
|
113
|
+
ValueConverters.Number = {
|
|
114
|
+
fromDb: function (value) {
|
|
115
|
+
if (value === null)
|
|
116
|
+
return null;
|
|
117
|
+
if (value !== undefined)
|
|
118
|
+
return +value;
|
|
119
|
+
return undefined;
|
|
120
|
+
},
|
|
121
|
+
toDb: function (value) { return value; },
|
|
122
|
+
fromJson: function (value) { return ValueConverters.Number.fromDb(value); },
|
|
123
|
+
toJson: function (value) { return ValueConverters.Number.toDb(value); },
|
|
124
|
+
fromInput: function (x, type) {
|
|
125
|
+
var r = +x;
|
|
126
|
+
if (!x)
|
|
127
|
+
return undefined;
|
|
128
|
+
return r;
|
|
129
|
+
},
|
|
130
|
+
toInput: function (x, type) {
|
|
131
|
+
return x === null || x === void 0 ? void 0 : x.toString();
|
|
132
|
+
},
|
|
133
|
+
inputType: inputTypes_1.InputTypes.number
|
|
134
|
+
};
|
|
135
|
+
ValueConverters.Integer = tslib_1.__assign(tslib_1.__assign({}, ValueConverters.Number), { toJson: function (value) {
|
|
136
|
+
var val = ValueConverters.Number.toDb(value);
|
|
137
|
+
if (!val)
|
|
138
|
+
return val;
|
|
139
|
+
return +(+val).toFixed(0);
|
|
140
|
+
}, toDb: function (value) { return ValueConverters.Integer.toJson(value); }, fieldTypeInDb: 'integer' });
|
|
141
|
+
ValueConverters.Default = {
|
|
142
|
+
fromJson: function (x) { return x; },
|
|
143
|
+
toJson: function (x) { return x; },
|
|
144
|
+
fromDb: function (x) { return ValueConverters.JsonString.fromDb(x); },
|
|
145
|
+
toDb: function (x) { return ValueConverters.JsonString.toDb(x); },
|
|
146
|
+
fromInput: function (x) { return ValueConverters.Default.fromJson(x); },
|
|
147
|
+
toInput: function (x) { return ValueConverters.Default.toJson(x); }
|
|
148
|
+
};
|
|
149
|
+
ValueConverters.JsonString = {
|
|
150
|
+
fromJson: function (x) { return x; },
|
|
151
|
+
toJson: function (x) { return x; },
|
|
152
|
+
fromDb: function (x) { return x == null ? null : x ? JSON.parse(ValueConverters.JsonString.fromJson(x)) : undefined; },
|
|
153
|
+
toDb: function (x) { return x !== undefined ? x === null ? null : JSON.stringify(ValueConverters.JsonString.toJson(x)) : undefined; },
|
|
154
|
+
fromInput: function (x) { return ValueConverters.JsonString.fromJson(x); },
|
|
155
|
+
toInput: function (x) { return ValueConverters.JsonString.toJson(x); }
|
|
156
|
+
};
|
|
157
|
+
ValueConverters.JsonValue = {
|
|
158
|
+
fromJson: function (x) { return x; },
|
|
159
|
+
toJson: function (x) { return x; },
|
|
160
|
+
fromDb: function (x) { return x; },
|
|
161
|
+
toDb: function (x) { return x; },
|
|
162
|
+
fromInput: function (x) { return ValueConverters.JsonString.fromJson(x); },
|
|
163
|
+
toInput: function (x) { return ValueConverters.JsonString.toJson(x); },
|
|
164
|
+
fieldTypeInDb: 'json'
|
|
165
|
+
};
|
|
166
|
+
return ValueConverters;
|
|
167
|
+
}());
|
|
168
|
+
exports.ValueConverters = ValueConverters;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './src/public_api';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './src/public_api';
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { FieldMetadata, FieldRef, EntityMetadata, ValueListItem, Remult, Repository, EntityOrderBy, EntityFilter } from "remult";
|
|
2
|
-
import { DataControlInfo, DataControlSettings, ValueOrEntityExpression } from "./data-control-interfaces";
|
|
3
|
-
import { FilterHelper } from "./filter-helper";
|
|
4
|
-
export declare class FieldCollection<rowType = any> {
|
|
5
|
-
currentRow: () => any;
|
|
6
|
-
private allowUpdate;
|
|
7
|
-
filterHelper: FilterHelper<rowType>;
|
|
8
|
-
private showArea;
|
|
9
|
-
private _getRowColumn;
|
|
10
|
-
constructor(currentRow: () => any, allowUpdate: () => boolean, filterHelper: FilterHelper<rowType>, showArea: () => boolean, _getRowColumn: (row: rowType, col: FieldMetadata) => FieldRef<any, any>);
|
|
11
|
-
__showArea(): boolean;
|
|
12
|
-
__getColumn(map: DataControlSettings, record: any): any;
|
|
13
|
-
__visible(col: DataControlSettings, row: any): boolean;
|
|
14
|
-
allowClick(col: DataControlSettings<any, any>, row: any): boolean;
|
|
15
|
-
getRowColumn<T>(args: {
|
|
16
|
-
col: DataControlSettings<any>;
|
|
17
|
-
row: any;
|
|
18
|
-
}, what: (c: FieldRef<any, any>, row: any) => T): T;
|
|
19
|
-
__dataControlStyle(map: DataControlSettings): string;
|
|
20
|
-
private settingsByKey;
|
|
21
|
-
allowDesignMode: boolean;
|
|
22
|
-
add(...columns: DataControlInfo<rowType>[]): Promise<void>;
|
|
23
|
-
add(...columns: string[]): Promise<void>;
|
|
24
|
-
private doWhenWeHaveContext;
|
|
25
|
-
private remult;
|
|
26
|
-
setContext(remult: Remult): void;
|
|
27
|
-
buildDropDown(s: DataControlSettings): Promise<void>;
|
|
28
|
-
designMode: boolean;
|
|
29
|
-
colListChanged(): void;
|
|
30
|
-
_colListChangeListeners: (() => void)[];
|
|
31
|
-
onColListChange(action: (() => void)): void;
|
|
32
|
-
moveCol(col: DataControlSettings, move: number): void;
|
|
33
|
-
filterRows(col: DataControlSettings): void;
|
|
34
|
-
clearFilter(col: DataControlSettings): void;
|
|
35
|
-
_shouldShowFilterDialog(col: DataControlSettings): boolean;
|
|
36
|
-
deleteCol(col: DataControlSettings): void;
|
|
37
|
-
addCol(col: DataControlSettings, newCol: DataControlSettings): void;
|
|
38
|
-
_getEditable(col: DataControlSettings, row: rowType): boolean;
|
|
39
|
-
_click(col: DataControlSettings, row: any): void;
|
|
40
|
-
_getColDisplayValue(col: DataControlSettings, row: rowType): any;
|
|
41
|
-
_getColDataType(col: DataControlSettings): string;
|
|
42
|
-
_getColumnClass(col: DataControlSettings, row: any): any;
|
|
43
|
-
_getError(col: DataControlSettings, r: any): any;
|
|
44
|
-
autoGenerateColumnsBasedOnData(defs: EntityMetadata<any>): void;
|
|
45
|
-
__changeWidth(col: DataControlSettings, what: number): void;
|
|
46
|
-
_colValueChanged(col: DataControlSettings, row: any): false | undefined;
|
|
47
|
-
items: DataControlSettings[];
|
|
48
|
-
private gridColumns;
|
|
49
|
-
private nonGridColumns;
|
|
50
|
-
numOfColumnsInGrid: number;
|
|
51
|
-
private _lastColumnCount;
|
|
52
|
-
private _lastNumOfColumnsInGrid;
|
|
53
|
-
private augmented;
|
|
54
|
-
augment(augmenter: dataControlAugmenter, s: DataControlSettings): void;
|
|
55
|
-
private _initColumnsArrays;
|
|
56
|
-
getGridColumns(augmenter: dataControlAugmenter): DataControlSettings<any, any>[];
|
|
57
|
-
getNonGridColumns(augmenter: dataControlAugmenter): DataControlSettings<any, any>[];
|
|
58
|
-
}
|
|
59
|
-
export declare function valueOrEntityExpressionToValue<T, entityType>(f: ValueOrEntityExpression<T, entityType>, e: entityType): T;
|
|
60
|
-
/** returns an array of values that can be used in the value list property of a data control object */
|
|
61
|
-
export declare function getEntityValueList<T>(repository: Repository<T>, args?: {
|
|
62
|
-
idField?: (e: EntityMetadata<T>) => FieldMetadata;
|
|
63
|
-
captionField?: (e: EntityMetadata<T>) => FieldMetadata;
|
|
64
|
-
orderBy?: EntityOrderBy<T>;
|
|
65
|
-
where?: EntityFilter<T>;
|
|
66
|
-
}): Promise<ExtendedValueListItem[]>;
|
|
67
|
-
export interface ExtendedValueListItem extends ValueListItem {
|
|
68
|
-
entity?: any;
|
|
69
|
-
}
|
|
70
|
-
export declare type dataControlAugmenter = (f: FieldMetadata, op: DataControlSettings) => void;
|
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
import { getEntityRef } from "remult";
|
|
2
|
-
import { decorateDataSettings, getFieldDefinition } from "./data-control-interfaces";
|
|
3
|
-
import { getEntitySettings } from 'remult/src/remult3';
|
|
4
|
-
export class FieldCollection {
|
|
5
|
-
currentRow;
|
|
6
|
-
allowUpdate;
|
|
7
|
-
filterHelper;
|
|
8
|
-
showArea;
|
|
9
|
-
_getRowColumn;
|
|
10
|
-
constructor(currentRow, allowUpdate, filterHelper, showArea, _getRowColumn) {
|
|
11
|
-
this.currentRow = currentRow;
|
|
12
|
-
this.allowUpdate = allowUpdate;
|
|
13
|
-
this.filterHelper = filterHelper;
|
|
14
|
-
this.showArea = showArea;
|
|
15
|
-
this._getRowColumn = _getRowColumn;
|
|
16
|
-
}
|
|
17
|
-
__showArea() {
|
|
18
|
-
return this.showArea();
|
|
19
|
-
}
|
|
20
|
-
__getColumn(map, record) {
|
|
21
|
-
if (!map.field)
|
|
22
|
-
return undefined;
|
|
23
|
-
let result;
|
|
24
|
-
if (record)
|
|
25
|
-
result = getEntityRef(record).fields.find(getFieldDefinition(map.field));
|
|
26
|
-
if (!result)
|
|
27
|
-
result = map.field;
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
__visible(col, row) {
|
|
31
|
-
if (col.visible === undefined)
|
|
32
|
-
return true;
|
|
33
|
-
return this.getRowColumn({ col, row }, (c, row) => col.visible(row, c));
|
|
34
|
-
}
|
|
35
|
-
allowClick(col, row) {
|
|
36
|
-
if (!col.click)
|
|
37
|
-
return false;
|
|
38
|
-
if (!this._getEditable(col, row))
|
|
39
|
-
return false;
|
|
40
|
-
if (col.allowClick === undefined) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
return this.getRowColumn({ col, row }, (c, row) => col.allowClick(row, c));
|
|
44
|
-
}
|
|
45
|
-
getRowColumn(args, what) {
|
|
46
|
-
let field;
|
|
47
|
-
let row = args.row;
|
|
48
|
-
if (this._getRowColumn && args.col.field && row) {
|
|
49
|
-
field = this._getRowColumn(row, getFieldDefinition(args.col.field));
|
|
50
|
-
}
|
|
51
|
-
if (!field)
|
|
52
|
-
field = args.col.field;
|
|
53
|
-
if (!row && field)
|
|
54
|
-
row = field.container;
|
|
55
|
-
return what(field, row);
|
|
56
|
-
}
|
|
57
|
-
__dataControlStyle(map) {
|
|
58
|
-
if (map.width && map.width.trim().length > 0) {
|
|
59
|
-
if ((+map.width).toString() == map.width)
|
|
60
|
-
return map.width + "px";
|
|
61
|
-
return map.width;
|
|
62
|
-
}
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
settingsByKey = {};
|
|
66
|
-
allowDesignMode;
|
|
67
|
-
async add(...columns) {
|
|
68
|
-
var promises = [];
|
|
69
|
-
for (let c of columns) {
|
|
70
|
-
if (!c)
|
|
71
|
-
continue;
|
|
72
|
-
let s;
|
|
73
|
-
let x = c;
|
|
74
|
-
let col = c;
|
|
75
|
-
let ecol = c;
|
|
76
|
-
if (!x.field && col.valueConverter || ecol.metadata) {
|
|
77
|
-
x = {
|
|
78
|
-
field: c,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
if (x.field) {
|
|
82
|
-
decorateDataSettings(x.field, x);
|
|
83
|
-
}
|
|
84
|
-
if (x.getValue) {
|
|
85
|
-
s = x;
|
|
86
|
-
}
|
|
87
|
-
{
|
|
88
|
-
promises.push(this.buildDropDown(x));
|
|
89
|
-
}
|
|
90
|
-
this.items.push(x);
|
|
91
|
-
}
|
|
92
|
-
await Promise.all(promises);
|
|
93
|
-
return Promise.resolve();
|
|
94
|
-
}
|
|
95
|
-
doWhenWeHaveContext = [];
|
|
96
|
-
remult;
|
|
97
|
-
setContext(remult) {
|
|
98
|
-
this.remult = remult;
|
|
99
|
-
for (const what of this.doWhenWeHaveContext) {
|
|
100
|
-
what(remult);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async buildDropDown(s) {
|
|
104
|
-
if (s.valueList) {
|
|
105
|
-
let orig = s.valueList;
|
|
106
|
-
let result = [];
|
|
107
|
-
s.valueList = result;
|
|
108
|
-
if (orig instanceof Array) {
|
|
109
|
-
for (let item of orig) {
|
|
110
|
-
let type = typeof (item);
|
|
111
|
-
if (type == "string" || type == "number")
|
|
112
|
-
result.push({ id: item, caption: item });
|
|
113
|
-
else {
|
|
114
|
-
let x = item;
|
|
115
|
-
if (x && x.id != undefined) {
|
|
116
|
-
result.push(x);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
else if (typeof orig === "function") {
|
|
122
|
-
let theFunc = orig;
|
|
123
|
-
let todo = async (remult) => {
|
|
124
|
-
let x = await theFunc(remult);
|
|
125
|
-
if (x === undefined)
|
|
126
|
-
s.valueList = undefined;
|
|
127
|
-
else
|
|
128
|
-
result.push(...x);
|
|
129
|
-
fixResult(result, s.field);
|
|
130
|
-
};
|
|
131
|
-
if (this.remult) {
|
|
132
|
-
todo(this.remult);
|
|
133
|
-
}
|
|
134
|
-
else
|
|
135
|
-
this.doWhenWeHaveContext.push(async (remult) => todo(remult));
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
result.push(...(await orig));
|
|
139
|
-
}
|
|
140
|
-
fixResult(result, s.field);
|
|
141
|
-
}
|
|
142
|
-
return Promise.resolve();
|
|
143
|
-
}
|
|
144
|
-
designMode = false;
|
|
145
|
-
colListChanged() {
|
|
146
|
-
this._lastNumOfColumnsInGrid = -1;
|
|
147
|
-
this._colListChangeListeners.forEach(x => x());
|
|
148
|
-
}
|
|
149
|
-
;
|
|
150
|
-
_colListChangeListeners = [];
|
|
151
|
-
onColListChange(action) {
|
|
152
|
-
this._colListChangeListeners.push(action);
|
|
153
|
-
}
|
|
154
|
-
moveCol(col, move) {
|
|
155
|
-
let currentIndex = this.items.indexOf(col);
|
|
156
|
-
let newIndex = currentIndex + move;
|
|
157
|
-
if (newIndex < 0 || newIndex >= this.items.length)
|
|
158
|
-
return;
|
|
159
|
-
this.items.splice(currentIndex, 1);
|
|
160
|
-
this.items.splice(newIndex, 0, col);
|
|
161
|
-
this.colListChanged();
|
|
162
|
-
}
|
|
163
|
-
filterRows(col) {
|
|
164
|
-
if (col.valueList)
|
|
165
|
-
col.useContainsFilter = false;
|
|
166
|
-
this.filterHelper.filterColumn(col.field, false, col.useContainsFilter);
|
|
167
|
-
}
|
|
168
|
-
clearFilter(col) {
|
|
169
|
-
this.filterHelper.filterColumn(col.field, true, false);
|
|
170
|
-
}
|
|
171
|
-
_shouldShowFilterDialog(col) {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
deleteCol(col) {
|
|
175
|
-
this.items.splice(this.items.indexOf(col), 1);
|
|
176
|
-
this.colListChanged();
|
|
177
|
-
}
|
|
178
|
-
addCol(col, newCol) {
|
|
179
|
-
this.items.splice(this.items.indexOf(col) + 1, 0, newCol);
|
|
180
|
-
this.colListChanged();
|
|
181
|
-
}
|
|
182
|
-
_getEditable(col, row) {
|
|
183
|
-
if (!this.allowUpdate())
|
|
184
|
-
return false;
|
|
185
|
-
if (!col.field)
|
|
186
|
-
return false;
|
|
187
|
-
if (col.readonly !== undefined)
|
|
188
|
-
return !valueOrEntityExpressionToValue(col.readonly, row);
|
|
189
|
-
return true;
|
|
190
|
-
}
|
|
191
|
-
_click(col, row) {
|
|
192
|
-
this.getRowColumn({ col, row }, (c, r) => { col.click(r, c); });
|
|
193
|
-
}
|
|
194
|
-
_getColDisplayValue(col, row) {
|
|
195
|
-
let r;
|
|
196
|
-
if (col.getValue) {
|
|
197
|
-
r = this.getRowColumn({ row, col }, (c, r) => col.getValue(r, c));
|
|
198
|
-
}
|
|
199
|
-
else if (col.field) {
|
|
200
|
-
if (col.valueList) {
|
|
201
|
-
for (let x of col.valueList) {
|
|
202
|
-
if (x.id == this.__getColumn(col, row).value)
|
|
203
|
-
return x.caption;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
r = this.__getColumn(col, row).displayValue;
|
|
207
|
-
}
|
|
208
|
-
return r;
|
|
209
|
-
}
|
|
210
|
-
_getColDataType(col) {
|
|
211
|
-
if (col.inputType)
|
|
212
|
-
return col.inputType;
|
|
213
|
-
return "text";
|
|
214
|
-
}
|
|
215
|
-
_getColumnClass(col, row) {
|
|
216
|
-
if (col.cssClass)
|
|
217
|
-
if (typeof col.cssClass === 'function') {
|
|
218
|
-
let anyFunc = col.cssClass;
|
|
219
|
-
return anyFunc(row);
|
|
220
|
-
}
|
|
221
|
-
else
|
|
222
|
-
return col.cssClass;
|
|
223
|
-
return '';
|
|
224
|
-
}
|
|
225
|
-
_getError(col, r) {
|
|
226
|
-
if (!col.field)
|
|
227
|
-
return undefined;
|
|
228
|
-
return this.__getColumn(col, r).error;
|
|
229
|
-
}
|
|
230
|
-
autoGenerateColumnsBasedOnData(defs) {
|
|
231
|
-
if (this.items.length == 0) {
|
|
232
|
-
if (defs) {
|
|
233
|
-
for (const c of defs.fields) {
|
|
234
|
-
if (!(c.key == 'id' && c.valueType === String))
|
|
235
|
-
this.add(c);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
__changeWidth(col, what) {
|
|
241
|
-
let width = col.width;
|
|
242
|
-
if (!width)
|
|
243
|
-
width = '50';
|
|
244
|
-
width = ((+width) + what).toString();
|
|
245
|
-
col.width = width;
|
|
246
|
-
}
|
|
247
|
-
_colValueChanged(col, row) {
|
|
248
|
-
return this.getRowColumn({ col, row }, (c, row) => {
|
|
249
|
-
if (col.valueList) {
|
|
250
|
-
let item = col.valueList.find(x => x.id == c.inputValue);
|
|
251
|
-
if (item?.entity) {
|
|
252
|
-
if (getEntitySettings(getFieldDefinition(col.field).valueType, false))
|
|
253
|
-
c.value = item.entity;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
if (!col.valueChange)
|
|
257
|
-
return false;
|
|
258
|
-
col.valueChange(row, c);
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
items = [];
|
|
262
|
-
gridColumns;
|
|
263
|
-
nonGridColumns;
|
|
264
|
-
numOfColumnsInGrid = 5;
|
|
265
|
-
_lastColumnCount;
|
|
266
|
-
_lastNumOfColumnsInGrid;
|
|
267
|
-
augmented = new Map();
|
|
268
|
-
augment(augmenter, s) {
|
|
269
|
-
if (this.augmented.get(s))
|
|
270
|
-
return;
|
|
271
|
-
augmenter(getFieldDefinition(s.field), s);
|
|
272
|
-
this.augmented.set(s, true);
|
|
273
|
-
}
|
|
274
|
-
_initColumnsArrays(augmenter) {
|
|
275
|
-
if (this._lastColumnCount != this.items.length || this._lastNumOfColumnsInGrid != this.numOfColumnsInGrid) {
|
|
276
|
-
this._lastNumOfColumnsInGrid = this.numOfColumnsInGrid;
|
|
277
|
-
this._lastColumnCount = this.items.length;
|
|
278
|
-
this.gridColumns = [];
|
|
279
|
-
this.nonGridColumns = [];
|
|
280
|
-
let i = 0;
|
|
281
|
-
for (let c of this.items) {
|
|
282
|
-
this.augment(augmenter, c);
|
|
283
|
-
if (i++ < this._lastNumOfColumnsInGrid)
|
|
284
|
-
this.gridColumns.push(c);
|
|
285
|
-
else
|
|
286
|
-
this.nonGridColumns.push(c);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
getGridColumns(augmenter) {
|
|
291
|
-
this._initColumnsArrays(augmenter);
|
|
292
|
-
return this.gridColumns;
|
|
293
|
-
}
|
|
294
|
-
getNonGridColumns(augmenter) {
|
|
295
|
-
this._initColumnsArrays(augmenter);
|
|
296
|
-
return this.nonGridColumns;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
export function valueOrEntityExpressionToValue(f, e) {
|
|
300
|
-
if (typeof f === 'function') {
|
|
301
|
-
let x = f;
|
|
302
|
-
return x(e);
|
|
303
|
-
}
|
|
304
|
-
return f;
|
|
305
|
-
}
|
|
306
|
-
function fixResult(result, inField) {
|
|
307
|
-
let field = getFieldDefinition(inField);
|
|
308
|
-
if (field?.valueType === Number) {
|
|
309
|
-
result.splice(0, result.length, ...result.map(x => ({ ...x, id: x.id?.toString() })));
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
/** returns an array of values that can be used in the value list property of a data control object */
|
|
313
|
-
export async function getEntityValueList(repository, args) {
|
|
314
|
-
if (!args) {
|
|
315
|
-
args = {};
|
|
316
|
-
}
|
|
317
|
-
if (!args.idField) {
|
|
318
|
-
args.idField = x => x.idMetadata.field;
|
|
319
|
-
}
|
|
320
|
-
if (!args.captionField) {
|
|
321
|
-
let idCol = args.idField(repository.metadata);
|
|
322
|
-
for (const keyInItem of repository.metadata.fields) {
|
|
323
|
-
if (keyInItem != idCol) {
|
|
324
|
-
args.captionField = x => x.fields.find(keyInItem);
|
|
325
|
-
break;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
let r = (await repository.find({
|
|
330
|
-
where: args.where,
|
|
331
|
-
orderBy: args.orderBy,
|
|
332
|
-
limit: 1000
|
|
333
|
-
})).map(x => {
|
|
334
|
-
return {
|
|
335
|
-
id: repository.getEntityRef(x).fields.find(args.idField(repository.metadata)).value,
|
|
336
|
-
caption: repository.getEntityRef(x).fields.find(args.captionField(repository.metadata)).value,
|
|
337
|
-
entity: x
|
|
338
|
-
};
|
|
339
|
-
});
|
|
340
|
-
return r;
|
|
341
|
-
}
|