remult 0.22.3 → 0.22.4
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/angular/interfaces/index.d.ts +1 -0
- package/esm/angular/interfaces/index.js +1 -0
- package/esm/angular/interfaces/src/column-collection.d.ts +70 -0
- package/esm/angular/interfaces/src/column-collection.js +341 -0
- package/esm/angular/interfaces/src/data-area-settings.d.ts +15 -0
- package/esm/angular/interfaces/src/data-area-settings.js +35 -0
- package/esm/angular/interfaces/src/data-control-interfaces.d.ts +36 -0
- package/esm/angular/interfaces/src/data-control-interfaces.js +57 -0
- package/esm/angular/interfaces/src/dataList.d.ts +13 -0
- package/esm/angular/interfaces/src/dataList.js +42 -0
- package/esm/angular/interfaces/src/filter-helper.d.ts +13 -0
- package/esm/angular/interfaces/src/filter-helper.js +59 -0
- package/esm/angular/interfaces/src/grid-settings.d.ts +145 -0
- package/esm/angular/interfaces/src/grid-settings.js +387 -0
- package/esm/angular/interfaces/src/public_api.d.ts +4 -0
- package/esm/angular/interfaces/src/public_api.js +4 -0
- package/esm/angular/src/angular/RemultAngularPluginsService.d.ts +4 -0
- package/esm/angular/src/angular/RemultAngularPluginsService.js +3 -0
- package/esm/angular/src/angular/data-control/data-control2.component.d.ts +49 -0
- package/esm/angular/src/angular/data-control/data-control2.component.js +138 -0
- package/esm/core/SseSubscriptionServer.d.ts +33 -0
- package/esm/core/SseSubscriptionServer.js +107 -0
- package/esm/core/assign.d.ts +1 -0
- package/esm/core/assign.js +5 -0
- package/esm/core/classType.d.ts +3 -0
- package/esm/core/classType.js +1 -0
- package/esm/core/index.d.ts +27 -0
- package/esm/core/index.js +25 -0
- package/esm/core/inputTypes.d.ts +9 -0
- package/esm/core/inputTypes.js +9 -0
- package/esm/core/live-query/data-provider-live-query-storage.d.ts +22 -0
- package/esm/core/live-query/data-provider-live-query-storage.js +71 -0
- package/esm/core/postgres/index.d.ts +2 -0
- package/esm/core/postgres/index.js +2 -0
- package/esm/core/postgres/postgres-data-provider.d.ts +36 -0
- package/esm/core/postgres/postgres-data-provider.js +120 -0
- package/esm/core/postgres/schema-builder.d.ts +17 -0
- package/esm/core/postgres/schema-builder.js +153 -0
- package/esm/core/remult-fresh.d.ts +17 -0
- package/esm/core/remult-fresh.js +29 -0
- package/esm/core/remult-knex/index.d.ts +30 -0
- package/esm/core/remult-knex/index.js +446 -0
- package/esm/core/remult-mongo.d.ts +24 -0
- package/esm/core/remult-mongo.js +254 -0
- package/esm/core/server/JsonEntityFileStorage.d.ts +10 -0
- package/esm/core/server/JsonEntityFileStorage.js +25 -0
- package/esm/core/server/core.d.ts +4 -0
- package/esm/core/server/core.js +4 -0
- package/esm/core/server/expressBridge.d.ts +182 -0
- package/esm/core/server/expressBridge.js +938 -0
- package/esm/core/server/index.d.ts +6 -0
- package/esm/core/server/index.js +9 -0
- package/esm/core/server/initAsyncHooks.d.ts +1 -0
- package/esm/core/server/initAsyncHooks.js +9 -0
- package/esm/core/server/initDataProvider.d.ts +2 -0
- package/esm/core/server/initDataProvider.js +14 -0
- package/esm/core/src/__EntityValueProvider.d.ts +11 -0
- package/esm/core/src/__EntityValueProvider.js +1 -0
- package/esm/core/src/__RowsOfDataForTesting.d.ts +3 -0
- package/esm/core/src/__RowsOfDataForTesting.js +1 -0
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.d.ts +6 -0
- package/esm/core/src/backend-tests/backend-database-test-setup.backend-spec.js +147 -0
- package/{src → esm/core/src}/backend-tests/my-test.backend-spec.d.ts +1 -1
- package/esm/core/src/backend-tests/my-test.backend-spec.js +197 -0
- package/esm/core/src/backend-tests/test-http-server.backend-spec.d.ts +1 -0
- package/esm/core/src/backend-tests/test-http-server.backend-spec.js +167 -0
- package/esm/core/src/buildRestDataProvider.d.ts +31 -0
- package/esm/core/src/buildRestDataProvider.js +113 -0
- package/esm/core/src/column-interfaces.d.ts +154 -0
- package/esm/core/src/column-interfaces.js +7 -0
- package/esm/core/src/column.d.ts +58 -0
- package/esm/core/src/column.js +174 -0
- package/esm/core/src/context.d.ts +134 -0
- package/esm/core/src/context.js +286 -0
- package/esm/core/src/data-api.d.ts +39 -0
- package/esm/core/src/data-api.js +279 -0
- package/esm/core/src/data-interfaces.d.ts +41 -0
- package/esm/core/src/data-interfaces.js +12 -0
- package/esm/core/src/data-providers/array-entity-data-provider.d.ts +22 -0
- package/esm/core/src/data-providers/array-entity-data-provider.js +252 -0
- package/esm/core/src/data-providers/in-memory-database.d.ts +9 -0
- package/esm/core/src/data-providers/in-memory-database.js +14 -0
- package/esm/core/src/data-providers/json-data-provider.d.ts +12 -0
- package/esm/core/src/data-providers/json-data-provider.js +55 -0
- package/esm/core/src/data-providers/rest-data-provider.d.ts +49 -0
- package/esm/core/src/data-providers/rest-data-provider.js +256 -0
- package/esm/core/src/data-providers/sql-database.d.ts +33 -0
- package/esm/core/src/data-providers/sql-database.js +384 -0
- package/esm/core/src/data-providers/web-sql-data-provider.d.ts +24 -0
- package/esm/core/src/data-providers/web-sql-data-provider.js +143 -0
- package/esm/core/src/entity.d.ts +91 -0
- package/esm/core/src/entity.js +1 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.d.ts +50 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-sql-request.js +150 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.d.ts +1 -0
- package/esm/core/src/filter/filter-consumer-bridge-to-url-builder.js +1 -0
- package/esm/core/src/filter/filter-interfaces.d.ts +85 -0
- package/esm/core/src/filter/filter-interfaces.js +477 -0
- package/esm/core/src/live-query/LiveQueryClient.d.ts +20 -0
- package/esm/core/src/live-query/LiveQueryClient.js +188 -0
- package/esm/core/src/live-query/SseSubscriptionClient.d.ts +5 -0
- package/esm/core/src/live-query/SseSubscriptionClient.js +86 -0
- package/esm/core/src/live-query/SubscriptionChannel.d.ts +72 -0
- package/esm/core/src/live-query/SubscriptionChannel.js +123 -0
- package/esm/core/src/live-query/SubscriptionServer.d.ts +53 -0
- package/esm/core/src/live-query/SubscriptionServer.js +111 -0
- package/esm/core/src/live-query/live-query-tests.spec.d.ts +6 -0
- package/esm/core/src/live-query/live-query-tests.spec.js +952 -0
- package/esm/core/src/remult-proxy.d.ts +35 -0
- package/esm/core/src/remult-proxy.js +113 -0
- package/esm/core/src/remult3/DecoratorReplacer.d.ts +10 -0
- package/esm/core/src/remult3/DecoratorReplacer.js +20 -0
- package/esm/core/src/remult3/RepositoryImplementation.d.ts +355 -0
- package/esm/core/src/remult3/RepositoryImplementation.js +2109 -0
- package/esm/core/src/remult3/index.d.ts +2 -0
- package/esm/core/src/remult3/index.js +2 -0
- package/esm/core/src/remult3/remult3.d.ts +395 -0
- package/esm/core/src/remult3/remult3.js +2 -0
- package/esm/core/src/server-action.d.ts +81 -0
- package/esm/core/src/server-action.js +394 -0
- package/esm/core/src/shared-tests/db-tests-setup.d.ts +32 -0
- package/esm/core/src/shared-tests/db-tests-setup.js +78 -0
- package/esm/core/src/shared-tests/db-tests.db-tests.d.ts +25 -0
- package/esm/core/src/shared-tests/db-tests.db-tests.js +810 -0
- package/esm/core/src/shared-tests/deleteAll.d.ts +2 -0
- package/esm/core/src/shared-tests/deleteAll.js +4 -0
- package/esm/core/src/shared-tests/entityWithValidations.d.ts +14 -0
- package/esm/core/src/shared-tests/entityWithValidations.js +43 -0
- package/esm/core/src/shared-tests/index.d.ts +4 -0
- package/esm/core/src/shared-tests/index.js +4 -0
- package/esm/core/src/shared-tests/test-custom-id-column.spec.d.ts +1 -0
- package/esm/core/src/shared-tests/test-custom-id-column.spec.js +67 -0
- package/esm/core/src/shared-tests/test-special-value.spec.d.ts +10 -0
- package/esm/core/src/shared-tests/test-special-value.spec.js +73 -0
- package/esm/core/src/shared-tests/test-update-with-null.spec.d.ts +1 -0
- package/esm/core/src/shared-tests/test-update-with-null.spec.js +31 -0
- package/esm/core/src/sort.d.ts +16 -0
- package/esm/core/src/sort.js +103 -0
- package/esm/core/src/sql-command.d.ts +19 -0
- package/esm/core/src/sql-command.js +1 -0
- package/esm/core/src/test.d.ts +3 -0
- package/esm/core/src/test.js +12 -0
- package/esm/core/src/tests/Done.d.ts +5 -0
- package/esm/core/src/tests/Done.js +9 -0
- package/esm/core/src/tests/RowProvider.spec.d.ts +16 -0
- package/esm/core/src/tests/RowProvider.spec.js +631 -0
- package/esm/core/src/tests/TestDataApiResponse.d.ts +10 -0
- package/esm/core/src/tests/TestDataApiResponse.js +22 -0
- package/esm/core/src/tests/basicRowFunctionality.spec.d.ts +8 -0
- package/esm/core/src/tests/basicRowFunctionality.spec.js +2103 -0
- package/esm/core/src/tests/c.d.ts +8 -0
- package/esm/core/src/tests/c.js +13 -0
- package/esm/core/src/tests/createData.d.ts +7 -0
- package/esm/core/src/tests/createData.js +22 -0
- package/esm/core/src/tests/d.d.ts +6 -0
- package/esm/core/src/tests/d.js +11 -0
- package/esm/core/src/tests/dWithPrefilter.d.ts +7 -0
- package/esm/core/src/tests/dWithPrefilter.js +18 -0
- package/esm/core/src/tests/entityForCustomFilter.d.ts +16 -0
- package/esm/core/src/tests/entityForCustomFilter.js +33 -0
- package/esm/core/src/tests/entityWithValidationsOnColumn.d.ts +5 -0
- package/esm/core/src/tests/entityWithValidationsOnColumn.js +13 -0
- package/esm/core/src/tests/frontend-database-tests-setup.spec.d.ts +4 -0
- package/esm/core/src/tests/frontend-database-tests-setup.spec.js +37 -0
- package/esm/core/src/tests/h.d.ts +6 -0
- package/esm/core/src/tests/h.js +24 -0
- package/esm/core/src/tests/remult-3-basic-tests.spec.d.ts +1 -0
- package/esm/core/src/tests/remult-3-basic-tests.spec.js +236 -0
- package/esm/core/src/tests/remult-3-entities.d.ts +23 -0
- package/esm/core/src/tests/remult-3-entities.js +39 -0
- package/esm/core/src/tests/tasks.d.ts +6 -0
- package/esm/core/src/tests/tasks.js +10 -0
- 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 +1 -0
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.d.ts +1 -0
- package/esm/core/src/tests/test-data-api/predefined-filter.spec.js +389 -0
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.d.ts +5 -0
- package/esm/core/src/tests/test-data-api/test-put-with-validation.spec.js +152 -0
- package/esm/core/src/tests/test-decorator-precedence.spec.d.ts +1 -0
- package/esm/core/src/tests/test-decorator-precedence.spec.js +38 -0
- package/esm/core/src/tests/test-default-value.spec.d.ts +1 -0
- package/esm/core/src/tests/test-default-value.spec.js +33 -0
- package/esm/core/src/tests/test-entity-inheritance.spec.d.ts +14 -0
- package/esm/core/src/tests/test-entity-inheritance.spec.js +82 -0
- package/esm/core/src/tests/test-exceptions.spec.d.ts +1 -0
- package/esm/core/src/tests/test-exceptions.spec.js +375 -0
- package/esm/core/src/tests/test-json.spec.d.ts +1 -0
- package/esm/core/src/tests/test-json.spec.js +115 -0
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.d.ts +9 -0
- package/esm/core/src/tests/test-many-to-one-relation-in-entity.spec.js +809 -0
- package/esm/core/src/tests/test-non-active-record.spec.d.ts +1 -0
- package/esm/core/src/tests/test-non-active-record.spec.js +66 -0
- package/esm/core/src/tests/test-object-column.spec.d.ts +1 -0
- package/esm/core/src/tests/test-object-column.spec.js +189 -0
- package/esm/core/src/tests/test-paged-foreach.spec.d.ts +1 -0
- package/esm/core/src/tests/test-paged-foreach.spec.js +328 -0
- package/esm/core/src/tests/test-remult-angular.spec.d.ts +1 -0
- package/esm/core/src/tests/test-remult-angular.spec.js +23 -0
- package/esm/core/src/tests/test-server-controller.spec.d.ts +7 -0
- package/esm/core/src/tests/test-server-controller.spec.js +489 -0
- package/esm/core/src/tests/test-server-expressions.spec.d.ts +1 -0
- package/esm/core/src/tests/test-server-expressions.spec.js +178 -0
- package/esm/core/src/tests/test-server-method-on-entity.spec.d.ts +1 -0
- package/esm/core/src/tests/test-server-method-on-entity.spec.js +306 -0
- package/esm/core/src/tests/test-sql-expression.spec.d.ts +5 -0
- package/esm/core/src/tests/test-sql-expression.spec.js +205 -0
- package/esm/core/src/tests/test-sql.spec.d.ts +1 -0
- package/esm/core/src/tests/test-sql.spec.js +170 -0
- package/esm/core/src/tests/test-subscribe.spec.d.ts +1 -0
- package/esm/core/src/tests/test-subscribe.spec.js +135 -0
- package/esm/core/src/tests/test-type-recovery.spec.d.ts +1 -0
- package/esm/core/src/tests/test-type-recovery.spec.js +49 -0
- package/esm/core/src/tests/test-where-api.spec.d.ts +1 -0
- package/esm/core/src/tests/test-where-api.spec.js +434 -0
- package/esm/core/src/tests/testHelper.spec.d.ts +36 -0
- package/esm/core/src/tests/testHelper.spec.js +226 -0
- package/esm/core/src/tests/testModel/models.d.ts +16 -0
- package/esm/core/src/tests/testModel/models.js +25 -0
- package/esm/core/src/validators.d.ts +14 -0
- package/esm/core/src/validators.js +33 -0
- package/{valueConverters.d.ts → esm/core/src/valueConverters.d.ts} +13 -12
- package/esm/core/src/valueConverters.js +197 -0
- package/esm/core/urlBuilder.d.ts +6 -0
- package/esm/core/urlBuilder.js +20 -0
- package/esm/graphql.js +27 -27
- package/esm/postgres/schema-builder.js +4 -4
- package/esm/src/remult3/RepositoryImplementation.d.ts +1 -1
- package/esm/src/remult3/RepositoryImplementation.js +27 -4
- package/esm/src/shared-tests/db-tests.db-tests.js +57 -0
- package/esm/test-servers/shared/Task.d.ts +9 -0
- package/esm/test-servers/shared/Task.js +32 -0
- package/esm/test.d.ts +5 -0
- package/esm/test.js +6 -0
- package/package.json +1 -1
- package/src/remult3/RepositoryImplementation.d.ts +1 -1
- package/src/remult3/RepositoryImplementation.js +88 -63
- package/src/shared-tests/db-tests.db-tests.js +97 -0
- package/esm/src/id-entity.d.ts +0 -4
- package/esm/src/id-entity.js +0 -8
- package/postgres/postgresColumnSyntax.d.ts +0 -2
- package/postgres/postgresColumnSyntax.js +0 -34
- package/remult-middleware.d.ts +0 -2
- package/remult-middleware.js +0 -70
- package/server/register-actions-on-server.d.ts +0 -3
- package/server/register-actions-on-server.js +0 -50
- package/server/register-entities-on-server.d.ts +0 -3
- package/server/register-entities-on-server.js +0 -19
- package/src/backend-tests/my-test.backend-spec.js +0 -217
- package/src/backend-tests/test-http-server.backend-spec.d.ts +0 -6
- package/src/backend-tests/test-http-server.backend-spec.js +0 -342
- package/src/id-entity.d.ts +0 -4
- package/src/id-entity.js +0 -17
- package/valueConverters.js +0 -168
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/public_api';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/public_api';
|
|
@@ -0,0 +1,70 @@
|
|
|
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;
|
|
@@ -0,0 +1,341 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FieldsMetadata } from "remult";
|
|
2
|
+
import { FieldCollection } from "./column-collection";
|
|
3
|
+
import { DataControlInfo, DataControlSettings } from "./data-control-interfaces";
|
|
4
|
+
export interface IDataAreaSettings<rowType = any> {
|
|
5
|
+
fields?: (rowType: FieldsMetadata<rowType>) => DataAreaFieldsSetting<rowType>[];
|
|
6
|
+
numberOfColumnAreas?: number;
|
|
7
|
+
labelWidth?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class DataAreaSettings<rowType = any> {
|
|
10
|
+
settings?: IDataAreaSettings<rowType> | undefined;
|
|
11
|
+
fields?: FieldCollection<rowType> | undefined;
|
|
12
|
+
lines: DataControlSettings[][];
|
|
13
|
+
constructor(settings?: IDataAreaSettings<rowType> | undefined, fields?: FieldCollection<rowType> | undefined, entity?: FieldsMetadata<rowType>);
|
|
14
|
+
}
|
|
15
|
+
export type DataAreaFieldsSetting<rowType = any> = DataControlInfo<rowType> | DataControlInfo<rowType>[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { FieldCollection } from "./column-collection";
|
|
2
|
+
export class DataAreaSettings {
|
|
3
|
+
settings;
|
|
4
|
+
fields;
|
|
5
|
+
lines = [];
|
|
6
|
+
constructor(settings, fields, entity) {
|
|
7
|
+
this.settings = settings;
|
|
8
|
+
this.fields = fields;
|
|
9
|
+
if (fields == undefined) {
|
|
10
|
+
fields = new FieldCollection(() => undefined, () => true, undefined, () => true, () => undefined);
|
|
11
|
+
fields.numOfColumnsInGrid = 0;
|
|
12
|
+
this.fields = fields;
|
|
13
|
+
}
|
|
14
|
+
if (settings && settings.fields) {
|
|
15
|
+
for (const colSettings of settings.fields(entity)) {
|
|
16
|
+
if (Array.isArray(colSettings)) {
|
|
17
|
+
let x = fields.items.length;
|
|
18
|
+
//@ts-ignore
|
|
19
|
+
fields.add(...colSettings);
|
|
20
|
+
let line = [];
|
|
21
|
+
for (let index = x; index < fields.items.length; index++) {
|
|
22
|
+
line.push(fields.items[index]);
|
|
23
|
+
}
|
|
24
|
+
this.lines.push(line);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
fields.add(colSettings);
|
|
28
|
+
let x = fields.items[fields.items.length - 1];
|
|
29
|
+
x.width = '';
|
|
30
|
+
this.lines.push([x]);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FieldRef, FieldMetadata, ValueListItem, Remult } from "remult";
|
|
2
|
+
export type DataControlInfo<rowType> = DataControlSettings<rowType> | FieldRef<any, any>;
|
|
3
|
+
export interface DataControlSettings<entityType = any, valueType = any> {
|
|
4
|
+
field?: FieldMetadata | FieldRef<any, any>;
|
|
5
|
+
getValue?: (row: entityType, val: FieldRef<entityType, valueType>) => any;
|
|
6
|
+
readonly?: ValueOrEntityExpression<boolean, entityType>;
|
|
7
|
+
cssClass?: (string | ((row: entityType) => string));
|
|
8
|
+
caption?: string;
|
|
9
|
+
visible?: (row: entityType, val: FieldRef<entityType, valueType>) => boolean;
|
|
10
|
+
click?: (row: entityType, val: FieldRef<entityType, valueType>) => void;
|
|
11
|
+
valueChange?: (row: entityType, val: FieldRef<entityType, valueType>) => void;
|
|
12
|
+
allowClick?: (row: entityType, val: FieldRef<entityType, valueType>) => boolean;
|
|
13
|
+
clickIcon?: string;
|
|
14
|
+
valueList?: ValueListItem[] | string[] | any[] | Promise<ValueListItem[]> | ((remult: Remult) => Promise<ValueListItem[]>) | ((remult: any) => ValueListItem[]);
|
|
15
|
+
inputType?: string;
|
|
16
|
+
hideDataOnInput?: boolean;
|
|
17
|
+
useContainsFilter?: boolean;
|
|
18
|
+
width?: string;
|
|
19
|
+
customComponent?: {
|
|
20
|
+
component: any;
|
|
21
|
+
args?: any;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface CustomDataComponent<argsType = any> {
|
|
25
|
+
args: CustomComponentArgs<argsType>;
|
|
26
|
+
}
|
|
27
|
+
export declare type CustomComponentArgs<argsType = any> = {
|
|
28
|
+
fieldRef: FieldRef;
|
|
29
|
+
settings: DataControlSettings;
|
|
30
|
+
args?: argsType;
|
|
31
|
+
};
|
|
32
|
+
export declare const configDataControlField: unique symbol;
|
|
33
|
+
export declare function getFieldDefinition(col: FieldMetadata | FieldRef<any, any>): any;
|
|
34
|
+
export declare function decorateDataSettings(colInput: FieldMetadata | FieldRef<any, any>, x: DataControlSettings): void;
|
|
35
|
+
export declare type ValueOrEntityExpression<valueType, entityType> = valueType | ((e: entityType) => valueType);
|
|
36
|
+
export declare function DataControl<entityType = any, colType = any>(settings: DataControlSettings<entityType, colType>): (target: any, key?: any) => any;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ValueListInfo } from "remult";
|
|
2
|
+
export const configDataControlField = Symbol('configDataControlField');
|
|
3
|
+
export function getFieldDefinition(col) {
|
|
4
|
+
if (!col)
|
|
5
|
+
return undefined;
|
|
6
|
+
let r = col;
|
|
7
|
+
let c = col;
|
|
8
|
+
if (c.metadata)
|
|
9
|
+
r = c.metadata;
|
|
10
|
+
return r;
|
|
11
|
+
}
|
|
12
|
+
export function decorateDataSettings(colInput, x) {
|
|
13
|
+
let col = getFieldDefinition(colInput);
|
|
14
|
+
if (col.target) {
|
|
15
|
+
let settingsOnColumnLevel = Reflect.getMetadata(configDataControlField, col.target, col.key);
|
|
16
|
+
if (settingsOnColumnLevel) {
|
|
17
|
+
for (const key in settingsOnColumnLevel) {
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(settingsOnColumnLevel, key)) {
|
|
19
|
+
const element = settingsOnColumnLevel[key];
|
|
20
|
+
if (x[key] === undefined)
|
|
21
|
+
x[key] = element;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (col.valueType) {
|
|
27
|
+
let settingsOnColumnLevel = Reflect.getMetadata(configDataControlField, col.valueType);
|
|
28
|
+
if (settingsOnColumnLevel) {
|
|
29
|
+
for (const key in settingsOnColumnLevel) {
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(settingsOnColumnLevel, key)) {
|
|
31
|
+
const element = settingsOnColumnLevel[key];
|
|
32
|
+
if (x[key] === undefined)
|
|
33
|
+
x[key] = element;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (x.valueList === undefined && col && col.valueConverter instanceof ValueListInfo)
|
|
39
|
+
x.valueList = col.valueConverter.getValues();
|
|
40
|
+
if (!x.caption && col.caption)
|
|
41
|
+
x.caption = col.caption;
|
|
42
|
+
if (!x.inputType && col.inputType)
|
|
43
|
+
x.inputType = col.inputType;
|
|
44
|
+
if (x.readonly == undefined) {
|
|
45
|
+
if (col.dbReadOnly)
|
|
46
|
+
x.readonly = true;
|
|
47
|
+
if (typeof col.options?.allowApiUpdate === 'boolean')
|
|
48
|
+
x.readonly = !col.options.allowApiUpdate;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function DataControl(settings) {
|
|
52
|
+
return (target, key) => {
|
|
53
|
+
Reflect.defineMetadata(configDataControlField, settings, target, key);
|
|
54
|
+
if (key === undefined)
|
|
55
|
+
return target;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EntityFilter, FindOptions, Repository } from "remult/src/remult3";
|
|
2
|
+
export declare class DataList<T> implements Iterable<T> {
|
|
3
|
+
private repository;
|
|
4
|
+
[Symbol.iterator](): Iterator<T>;
|
|
5
|
+
items: T[];
|
|
6
|
+
constructor(repository: Repository<T>);
|
|
7
|
+
removeItem(item: T): void;
|
|
8
|
+
private map;
|
|
9
|
+
lastGetId: number;
|
|
10
|
+
count(where?: EntityFilter<T>): any;
|
|
11
|
+
get(options?: FindOptions<T>): any;
|
|
12
|
+
add(): T;
|
|
13
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export class DataList {
|
|
2
|
+
repository;
|
|
3
|
+
[Symbol.iterator]() {
|
|
4
|
+
return this.items[Symbol.iterator]();
|
|
5
|
+
}
|
|
6
|
+
items = [];
|
|
7
|
+
constructor(repository) {
|
|
8
|
+
this.repository = repository;
|
|
9
|
+
repository.addEventListener({
|
|
10
|
+
deleted: entity => {
|
|
11
|
+
this.removeItem(entity);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
removeItem(item) {
|
|
16
|
+
let i = this.items.indexOf(item);
|
|
17
|
+
if (i >= 0)
|
|
18
|
+
this.items.splice(i, 1);
|
|
19
|
+
}
|
|
20
|
+
map(item) {
|
|
21
|
+
return item;
|
|
22
|
+
}
|
|
23
|
+
lastGetId = 0;
|
|
24
|
+
count(where) {
|
|
25
|
+
return this.repository.count(where);
|
|
26
|
+
}
|
|
27
|
+
get(options) {
|
|
28
|
+
let getId = ++this.lastGetId;
|
|
29
|
+
return this.repository.find(options).then(r => {
|
|
30
|
+
let x = r;
|
|
31
|
+
let result = r.map((x) => this.map(x));
|
|
32
|
+
if (getId == this.lastGetId)
|
|
33
|
+
this.items = result;
|
|
34
|
+
return result;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
add() {
|
|
38
|
+
let x = this.map(this.repository.create());
|
|
39
|
+
this.items.push(x);
|
|
40
|
+
return x;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FieldRef, FindOptions, Repository } from "remult";
|
|
2
|
+
import { FieldMetadata } from "remult";
|
|
3
|
+
export declare class FilterHelper<rowType> {
|
|
4
|
+
private reloadData;
|
|
5
|
+
private repository;
|
|
6
|
+
filterRow: rowType;
|
|
7
|
+
filterColumns: FieldMetadata[];
|
|
8
|
+
forceEqual: FieldMetadata[];
|
|
9
|
+
constructor(reloadData: () => void, repository: Repository<rowType>);
|
|
10
|
+
isFiltered(columnInput: FieldMetadata | FieldRef<any, any>): boolean;
|
|
11
|
+
filterColumn(columnInput: FieldMetadata | FieldRef<any, any>, clearFilter: boolean, useContainsFilter: boolean): void;
|
|
12
|
+
addToFindOptions(opt: FindOptions<rowType>): void;
|
|
13
|
+
}
|