@journeyapps-labs/reactor-mod-data-browser 3.2.1 → 3.4.0

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.
Files changed (126) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/@types/actions/schema-model/ViewHasManyAction.d.ts +12 -0
  3. package/dist/@types/core/AbstractConnection.d.ts +12 -0
  4. package/dist/@types/core/SchemaModelDefinition.d.ts +12 -5
  5. package/dist/@types/core/query/StandardModelFields.d.ts +4 -0
  6. package/dist/@types/core/query/query-simple/SimpleQueryFilterState.d.ts +4 -6
  7. package/dist/@types/core/query/widgets/BelongsToDisplayWidget.d.ts +1 -0
  8. package/dist/@types/core/query/widgets/ColumnDisplayWidget.d.ts +1 -0
  9. package/dist/@types/core/query/widgets/IDCellDisplayWidget.d.ts +5 -0
  10. package/dist/@types/core/query/widgets/PeekRelationshipButton.d.ts +1 -0
  11. package/dist/@types/core/query/widgets/SmartBelongsToDisplayWidget.d.ts +2 -0
  12. package/dist/@types/core/query/widgets/SmartColumnWidget.d.ts +8 -3
  13. package/dist/@types/core/query/widgets/SmartFilterWidget.d.ts +6 -0
  14. package/dist/@types/core/types/ManualConnection.d.ts +1 -0
  15. package/dist/@types/entities/ConnectionEntityDefinition.d.ts +2 -1
  16. package/dist/@types/entities/SchemaModelObjectEntityDefinition.d.ts +2 -1
  17. package/dist/@types/forms/types/belongs-to-filter.d.ts +10 -0
  18. package/dist/@types/forms/types/shared/type-handler.d.ts +1 -0
  19. package/dist/@types/forms/types/shared/ui.d.ts +12 -0
  20. package/dist/@types/panels/query/QueryPanelFactory.d.ts +2 -2
  21. package/dist/DataBrowserModule.js +2 -0
  22. package/dist/DataBrowserModule.js.map +1 -1
  23. package/dist/actions/schema-model/ViewHasManyAction.js +112 -0
  24. package/dist/actions/schema-model/ViewHasManyAction.js.map +1 -0
  25. package/dist/core/AbstractConnection.js +58 -5
  26. package/dist/core/AbstractConnection.js.map +1 -1
  27. package/dist/core/SchemaModelDefinition.js +70 -12
  28. package/dist/core/SchemaModelDefinition.js.map +1 -1
  29. package/dist/core/query/StandardModelFields.js +3 -0
  30. package/dist/core/query/StandardModelFields.js.map +1 -1
  31. package/dist/core/query/query-simple/SimpleQueryColumns.js +37 -12
  32. package/dist/core/query/query-simple/SimpleQueryColumns.js.map +1 -1
  33. package/dist/core/query/query-simple/SimpleQueryFilterState.js +35 -7
  34. package/dist/core/query/query-simple/SimpleQueryFilterState.js.map +1 -1
  35. package/dist/core/query/query-simple/SimpleQuerySortState.js +0 -1
  36. package/dist/core/query/query-simple/SimpleQuerySortState.js.map +1 -1
  37. package/dist/core/query/widgets/BelongsToDisplayWidget.js +1 -1
  38. package/dist/core/query/widgets/BelongsToDisplayWidget.js.map +1 -1
  39. package/dist/core/query/widgets/ColumnDisplayWidget.js +13 -2
  40. package/dist/core/query/widgets/ColumnDisplayWidget.js.map +1 -1
  41. package/dist/core/query/widgets/IDCellDisplayWidget.js +33 -0
  42. package/dist/core/query/widgets/IDCellDisplayWidget.js.map +1 -0
  43. package/dist/core/query/widgets/PeekRelationshipButton.js +23 -16
  44. package/dist/core/query/widgets/PeekRelationshipButton.js.map +1 -1
  45. package/dist/core/query/widgets/SmartBelongsToDisplayWidget.js +1 -1
  46. package/dist/core/query/widgets/SmartBelongsToDisplayWidget.js.map +1 -1
  47. package/dist/core/query/widgets/SmartColumnWidget.js +7 -14
  48. package/dist/core/query/widgets/SmartColumnWidget.js.map +1 -1
  49. package/dist/core/query/widgets/SmartFilterWidget.js +10 -7
  50. package/dist/core/query/widgets/SmartFilterWidget.js.map +1 -1
  51. package/dist/core/types/ManualConnection.js +3 -0
  52. package/dist/core/types/ManualConnection.js.map +1 -1
  53. package/dist/entities/ConnectionEntityDefinition.js +29 -6
  54. package/dist/entities/ConnectionEntityDefinition.js.map +1 -1
  55. package/dist/entities/SchemaModelObjectEntityDefinition.js +15 -14
  56. package/dist/entities/SchemaModelObjectEntityDefinition.js.map +1 -1
  57. package/dist/forms/types/attachment-handler.js +1 -0
  58. package/dist/forms/types/attachment-handler.js.map +1 -1
  59. package/dist/forms/types/belongs-to-filter.js +57 -0
  60. package/dist/forms/types/belongs-to-filter.js.map +1 -0
  61. package/dist/forms/types/boolean-handler.js +34 -1
  62. package/dist/forms/types/boolean-handler.js.map +1 -1
  63. package/dist/forms/types/date-handler.js +1 -0
  64. package/dist/forms/types/date-handler.js.map +1 -1
  65. package/dist/forms/types/image-handler.js +1 -0
  66. package/dist/forms/types/image-handler.js.map +1 -1
  67. package/dist/forms/types/location-handler.js +1 -0
  68. package/dist/forms/types/location-handler.js.map +1 -1
  69. package/dist/forms/types/multiple-choice-handler.js +1 -0
  70. package/dist/forms/types/multiple-choice-handler.js.map +1 -1
  71. package/dist/forms/types/multiple-choice-integer-handler.js +1 -0
  72. package/dist/forms/types/multiple-choice-integer-handler.js.map +1 -1
  73. package/dist/forms/types/number-handler.js +3 -2
  74. package/dist/forms/types/number-handler.js.map +1 -1
  75. package/dist/forms/types/single-choice-handler.js +1 -0
  76. package/dist/forms/types/single-choice-handler.js.map +1 -1
  77. package/dist/forms/types/single-choice-integer-handler.js +1 -0
  78. package/dist/forms/types/single-choice-integer-handler.js.map +1 -1
  79. package/dist/forms/types/text-handler.js +1 -0
  80. package/dist/forms/types/text-handler.js.map +1 -1
  81. package/dist/panels/model-json/ModelJsonPanelWidget.js +4 -3
  82. package/dist/panels/model-json/ModelJsonPanelWidget.js.map +1 -1
  83. package/dist/panels/query/QueryPanelFactory.js.map +1 -1
  84. package/dist/panels/query/table-controls/FilterControlsWidget.js +1 -0
  85. package/dist/panels/query/table-controls/FilterControlsWidget.js.map +1 -1
  86. package/dist/stores/ConnectionStore.js +15 -3
  87. package/dist/stores/ConnectionStore.js.map +1 -1
  88. package/dist/tsconfig.tsbuildinfo +1 -1
  89. package/dist-module/bundle.js +51 -35
  90. package/dist-module/bundle.js.map +1 -1
  91. package/package.json +4 -4
  92. package/src/DataBrowserModule.ts +2 -0
  93. package/src/actions/schema-model/ViewHasManyAction.ts +114 -0
  94. package/src/core/AbstractConnection.ts +45 -2
  95. package/src/core/SchemaModelDefinition.ts +90 -14
  96. package/src/core/query/StandardModelFields.ts +8 -0
  97. package/src/core/query/query-simple/SimpleQueryColumns.tsx +50 -14
  98. package/src/core/query/query-simple/SimpleQueryFilterState.ts +42 -9
  99. package/src/core/query/query-simple/SimpleQuerySortState.ts +0 -1
  100. package/src/core/query/widgets/BelongsToDisplayWidget.tsx +2 -1
  101. package/src/core/query/widgets/ColumnDisplayWidget.tsx +17 -4
  102. package/src/core/query/widgets/IDCellDisplayWidget.tsx +46 -0
  103. package/src/core/query/widgets/PeekRelationshipButton.tsx +23 -16
  104. package/src/core/query/widgets/SmartBelongsToDisplayWidget.tsx +3 -0
  105. package/src/core/query/widgets/SmartColumnWidget.tsx +27 -23
  106. package/src/core/query/widgets/SmartFilterWidget.tsx +14 -5
  107. package/src/core/types/ManualConnection.ts +4 -0
  108. package/src/entities/ConnectionEntityDefinition.tsx +32 -4
  109. package/src/entities/SchemaModelObjectEntityDefinition.ts +17 -15
  110. package/src/forms/types/attachment-handler.tsx +1 -0
  111. package/src/forms/types/belongs-to-filter.tsx +84 -0
  112. package/src/forms/types/boolean-handler.tsx +46 -2
  113. package/src/forms/types/date-handler.tsx +1 -0
  114. package/src/forms/types/image-handler.tsx +1 -0
  115. package/src/forms/types/location-handler.tsx +1 -0
  116. package/src/forms/types/multiple-choice-handler.tsx +1 -0
  117. package/src/forms/types/multiple-choice-integer-handler.tsx +1 -0
  118. package/src/forms/types/number-handler.tsx +3 -2
  119. package/src/forms/types/shared/type-handler.ts +1 -0
  120. package/src/forms/types/single-choice-handler.tsx +1 -0
  121. package/src/forms/types/single-choice-integer-handler.tsx +1 -0
  122. package/src/forms/types/text-handler.tsx +1 -0
  123. package/src/panels/model-json/ModelJsonPanelWidget.tsx +8 -6
  124. package/src/panels/query/QueryPanelFactory.tsx +2 -2
  125. package/src/panels/query/table-controls/FilterControlsWidget.tsx +1 -0
  126. package/src/stores/ConnectionStore.ts +17 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @journeyapps-labs/reactor-mod-data-browser
2
2
 
3
+ ## 3.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 4a150da: Expand Data Browser query tooling with better filtering, relationship workflows, and ID utilities.
8
+ - Show type labels under column headings.
9
+ - Add filtering support for boolean, belongs-to, and `ID` columns.
10
+ - Group Add Filter options into `Fields` and `Belongs to`.
11
+ - Make IDs easier to work with:
12
+ - Add copy actions in ID cells.
13
+ - Add copy support in relationship peek metadata.
14
+ - Allow direct UUID paste in relationship search to resolve records by ID.
15
+ - Improve relationship workflows:
16
+ - Add `View has many` from row context menus to open related records in a pre-filtered query.
17
+ - Add `Filter belongs to` from relationship peek to apply a query filter from the selected related object.
18
+ - Make the `ID` column filterable but no longer sortable.
19
+
20
+ ## 3.3.0
21
+
22
+ ### Minor Changes
23
+
24
+ - 928d844: Connections now have an online status
25
+
3
26
  ## 3.2.1
4
27
 
5
28
  ### Patch Changes
@@ -0,0 +1,12 @@
1
+ import { ComboBoxStore2, EntityAction, EntityActionEvent, NotificationStore, WorkspaceStore } from '@journeyapps-labs/reactor-mod';
2
+ import { SchemaModelObject } from '../../core/SchemaModelObject';
3
+ export declare class ViewHasManyAction extends EntityAction<SchemaModelObject> {
4
+ static ID: string;
5
+ accessor comboStore: ComboBoxStore2;
6
+ accessor workspaceStore: WorkspaceStore;
7
+ accessor notifications: NotificationStore;
8
+ constructor();
9
+ fireEvent(event: EntityActionEvent<SchemaModelObject>): Promise<any>;
10
+ private openRelationshipQuery;
11
+ static get(): ViewHasManyAction;
12
+ }
@@ -16,13 +16,20 @@ export interface AbstractConnectionSerialized {
16
16
  export interface AbstractConnectionListener {
17
17
  removed: () => any;
18
18
  }
19
+ export declare enum ConnectionOnlineState {
20
+ OFFLINE = "offline",
21
+ LOADING = "loading",
22
+ ONLINE = "online"
23
+ }
19
24
  export declare abstract class AbstractConnection extends BaseObserver<AbstractConnectionListener> {
20
25
  factory: AbstractConnectionFactory;
21
26
  id: string;
22
27
  accessor color: string;
28
+ accessor onlineState: ConnectionOnlineState;
23
29
  schema_models_collection: Collection<ObjectType>;
24
30
  schema_models: LifecycleCollection<ObjectType, SchemaModelDefinition>;
25
31
  private fetch_indexes_promise;
32
+ private initialize_online_promise;
26
33
  constructor(factory: AbstractConnectionFactory);
27
34
  abstract getBackendClient(): V4BackendClient;
28
35
  getIndexes(): Promise<{
@@ -32,11 +39,16 @@ export declare abstract class AbstractConnection extends BaseObserver<AbstractCo
32
39
  }>;
33
40
  batchSave(models: SchemaModelObject[]): Promise<void>;
34
41
  getSchemaModelDefinitionByName(name: string): SchemaModelDefinition;
42
+ get isOnline(): boolean;
43
+ get isLoadingOnline(): boolean;
35
44
  waitForSchemaModelDefinitionByName(name: string): Promise<SchemaModelDefinition>;
36
45
  abstract getConnection(): Promise<Database>;
37
46
  protected getSchema(): Promise<Schema>;
38
47
  reload(): Promise<void>;
39
48
  init(): Promise<void>;
49
+ protected connectOnline(): Promise<void>;
50
+ ensureOnline(): Promise<void>;
51
+ private initializeOnline;
40
52
  protected getSchemaModelDefinitions(): Promise<SchemaModelDefinition[]>;
41
53
  remove(): void;
42
54
  serialize(): AbstractConnectionSerialized;
@@ -1,6 +1,6 @@
1
1
  import { AbstractConnection } from './AbstractConnection';
2
2
  import { ObjectType } from '@journeyapps/parser-schema';
3
- import { Collection, Query } from '@journeyapps/db';
3
+ import { Collection, Query, Variable } from '@journeyapps/db';
4
4
  import { SchemaModelObject } from './SchemaModelObject';
5
5
  import { LifecycleModel } from '@journeyapps-labs/lib-reactor-data-layer';
6
6
  import { BaseObserver } from '@journeyapps-labs/common-utils';
@@ -19,6 +19,11 @@ export interface SchemaModelDefinitionOptions {
19
19
  connection: AbstractConnection;
20
20
  definition: ObjectType;
21
21
  }
22
+ export interface FilterableField {
23
+ key: string;
24
+ label: string;
25
+ group: 'Fields' | 'Belongs to';
26
+ }
22
27
  export declare class SchemaModelDefinition extends BaseObserver<SchemaModelDefinitionListener> implements LifecycleModel<ObjectType> {
23
28
  protected options: SchemaModelDefinitionOptions;
24
29
  cache: Map<string, SchemaModelObject>;
@@ -39,8 +44,10 @@ export declare class SchemaModelDefinition extends BaseObserver<SchemaModelDefin
39
44
  executeQuery(query: Query): Promise<SchemaModelObject[]>;
40
45
  getCollection(): Promise<Collection<import("@journeyapps/db").DatabaseObject>>;
41
46
  generateNewModelObject(): Promise<SchemaModelObject>;
42
- getFilterableFields(typeEngine: TypeEngine): {
43
- key: string;
44
- label: string;
45
- }[];
47
+ getBelongsToIdVariableForRelationship(relationshipName: string): Variable | undefined;
48
+ getBelongsToRelationshipForField(field: string): {
49
+ variable: Variable;
50
+ relationship: ObjectType['belongsTo'][string];
51
+ } | undefined;
52
+ getFilterableFields(typeEngine: TypeEngine): FilterableField[];
46
53
  }
@@ -1,5 +1,9 @@
1
+ import { Variable } from '@journeyapps/db';
1
2
  export declare enum StandardModelFields {
2
3
  ID = "id",
3
4
  UPDATED_AT = "updated_at"
4
5
  }
5
6
  export declare const STANDARD_MODEL_FIELD_LABELS: Record<StandardModelFields, string>;
7
+ export declare const idVariable: Variable & {
8
+ label?: string;
9
+ };
@@ -1,6 +1,6 @@
1
1
  import { Variable } from '@journeyapps/db';
2
2
  import { BaseObserver } from '@journeyapps-labs/common-utils';
3
- import { SchemaModelDefinition } from '../../SchemaModelDefinition';
3
+ import { FilterableField, SchemaModelDefinition } from '../../SchemaModelDefinition';
4
4
  import { SerializedSimpleFilter, SimpleFilter } from '../filters';
5
5
  import { TypeEngine } from '../../../forms/TypeEngine';
6
6
  export interface SimpleQueryFilterStateListener {
@@ -22,10 +22,7 @@ export declare class SimpleQueryFilterState extends BaseObserver<SimpleQueryFilt
22
22
  get filters(): SimpleFilter[];
23
23
  clear(): void;
24
24
  setDefinition(definition: SchemaModelDefinition | undefined): boolean;
25
- getFilterableFields(): {
26
- key: string;
27
- label: string;
28
- }[];
25
+ getFilterableFields(): FilterableField[];
29
26
  getActiveFilters(): ActiveFilterEntry[];
30
27
  getFilter(field: string): SimpleFilter | undefined;
31
28
  getSerializedFilters(): SerializedSimpleFilter[];
@@ -33,5 +30,6 @@ export declare class SimpleQueryFilterState extends BaseObserver<SimpleQueryFilt
33
30
  setFilter(field: string, filter: SimpleFilter): boolean;
34
31
  setupFilterForField(field: string, position?: MouseEvent): Promise<boolean>;
35
32
  private addFilter;
36
- private resolveAttribute;
33
+ private resolveField;
34
+ private resolveBelongsToField;
37
35
  }
@@ -7,6 +7,7 @@ export interface BelongsToDisplayWidgetProps {
7
7
  id: string;
8
8
  connection: AbstractConnection;
9
9
  open: (object: SchemaModelObject) => any;
10
+ filterBelongsTo?: (object: SchemaModelObject) => any;
10
11
  className?: any;
11
12
  }
12
13
  export declare const BelongsToDisplayWidget: React.FC<BelongsToDisplayWidgetProps>;
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  export interface ColumnDisplayWidgetProps {
3
3
  label: string;
4
+ secondaryLabel?: string;
4
5
  className?: any;
5
6
  onClick?: () => any;
6
7
  }
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export interface IDCellDisplayWidgetProps {
3
+ id: string;
4
+ }
5
+ export declare const IDCellDisplayWidget: React.FC<IDCellDisplayWidgetProps>;
@@ -3,5 +3,6 @@ import { SchemaModelObject } from '../../SchemaModelObject';
3
3
  export interface PeekRelationshipButtonProps {
4
4
  object: SchemaModelObject;
5
5
  open: (object: SchemaModelObject) => any;
6
+ filterBelongsTo?: (object: SchemaModelObject) => any;
6
7
  }
7
8
  export declare const PeekRelationshipButton: React.FC<PeekRelationshipButtonProps>;
@@ -1,10 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { PageRow } from '../Page';
3
3
  import { AbstractConnection } from '../../AbstractConnection';
4
+ import { SchemaModelObject } from '../../SchemaModelObject';
4
5
  import { Variable } from '@journeyapps/db';
5
6
  export interface SmartBelongsToDisplayWidgetProps {
6
7
  row: PageRow;
7
8
  connection: AbstractConnection;
8
9
  variable_id: Variable;
10
+ filterBelongsTo?: (object: SchemaModelObject) => any;
9
11
  }
10
12
  export declare const SmartBelongsToDisplayWidget: React.FC<SmartBelongsToDisplayWidgetProps>;
@@ -1,13 +1,18 @@
1
1
  import * as React from 'react';
2
- import { ObjectType, Variable } from '@journeyapps/db';
2
+ import { Variable } from '@journeyapps/db';
3
3
  import { SimpleFilter } from '../filters';
4
- import type { SortDirection } from '../query-simple/SimpleQuery';
4
+ import { SortDirection } from '../query-simple/SimpleQuery';
5
5
  export interface SmartColumnWidgetProps {
6
6
  variable: Variable;
7
- type?: ObjectType;
7
+ typeLabel?: string;
8
8
  filter?: SimpleFilter;
9
9
  sortDirection?: SortDirection;
10
10
  onToggleSort?: () => Promise<any> | any;
11
+ setupFilter?: (event: {
12
+ variable: Variable;
13
+ filter?: SimpleFilter;
14
+ position?: MouseEvent;
15
+ }) => Promise<SimpleFilter | null>;
11
16
  filterChanged: (filter: SimpleFilter | null) => any;
12
17
  }
13
18
  export declare const SmartColumnWidget: React.FC<SmartColumnWidgetProps>;
@@ -4,6 +4,11 @@ import { SimpleFilter } from '../filters';
4
4
  export interface SmartFilterWidgetProps {
5
5
  variable: Variable;
6
6
  filter?: SimpleFilter;
7
+ setupFilter: (event: {
8
+ variable: Variable;
9
+ filter?: SimpleFilter;
10
+ position?: MouseEvent;
11
+ }) => Promise<SimpleFilter | null>;
7
12
  filterChanged: (filter: SimpleFilter | null) => any;
8
13
  }
9
14
  export interface SmartFilterMetadataWidgetProps {
@@ -13,3 +18,4 @@ export interface SmartFilterMetadataWidgetProps {
13
18
  }
14
19
  export declare const SmartFilterMetadataWidget: React.FC<SmartFilterMetadataWidgetProps>;
15
20
  export declare const SmartFilterWidget: React.FC<SmartFilterWidgetProps>;
21
+ export declare const SmartTypeEngineFilterWidget: React.FC<Omit<SmartFilterWidgetProps, 'setupFilter'>>;
@@ -10,6 +10,7 @@ export declare class ManualConnection extends AbstractConnection {
10
10
  protected options?: ManualConnectionDetails;
11
11
  constructor(factory: ManualConnectionFactory, options?: ManualConnectionDetails);
12
12
  getConnection(): Promise<Database>;
13
+ init(): Promise<void>;
13
14
  _serialize(): ManualConnectionDetails;
14
15
  _deSerialize(data: ManualConnectionDetails): Promise<any>;
15
16
  get name(): EntityDescription;
@@ -1,10 +1,11 @@
1
- import { EntityDefinition } from '@journeyapps-labs/reactor-mod';
1
+ import { EntityDefinition, ThemeStore } from '@journeyapps-labs/reactor-mod';
2
2
  import { ConnectionStore } from '../stores/ConnectionStore';
3
3
  import { AbstractConnection } from '../core/AbstractConnection';
4
4
  import { SavedQueryStore } from '../stores/SavedQueryStore';
5
5
  export declare class ConnectionEntityDefinition extends EntityDefinition<AbstractConnection> {
6
6
  accessor connectionStore: ConnectionStore;
7
7
  accessor savedQueryStore: SavedQueryStore;
8
+ accessor themeStore: ThemeStore;
8
9
  constructor();
9
10
  matchEntity(t: any): boolean;
10
11
  getEntityUID(t: AbstractConnection): string;
@@ -1,4 +1,4 @@
1
- import { EntityDefinition } from '@journeyapps-labs/reactor-mod';
1
+ import { Action, EntityDefinition } from '@journeyapps-labs/reactor-mod';
2
2
  import { ConnectionStore } from '../stores/ConnectionStore';
3
3
  import { SchemaModelObject } from '../core/SchemaModelObject';
4
4
  export interface SchemaModelObjectEntityDefinitionEncoded {
@@ -11,4 +11,5 @@ export declare class SchemaModelObjectEntityDefinition extends EntityDefinition<
11
11
  constructor();
12
12
  matchEntity(t: any): boolean;
13
13
  getEntityUID(t: SchemaModelObject): string;
14
+ isActionAllowedForEntity(action: Action, entity: SchemaModelObject): boolean;
14
15
  }
@@ -0,0 +1,10 @@
1
+ import { Variable } from '@journeyapps/db';
2
+ import { Relationship } from '@journeyapps/parser-schema';
3
+ import { SchemaModelDefinition } from '../../core/SchemaModelDefinition';
4
+ import { SimpleFilter } from '../../core/query/filters';
5
+ export declare const setupBelongsToFilter: (options: {
6
+ definition: SchemaModelDefinition;
7
+ relationship: Relationship;
8
+ variable: Variable;
9
+ filter?: SimpleFilter;
10
+ }) => Promise<SimpleFilter>;
@@ -7,6 +7,7 @@ import { SimpleFilter } from '../../../core/query/filters';
7
7
  export type ScalarValue = string | number | boolean | null;
8
8
  export interface TypeHandler<T extends Type = Type, ENCODED = any, DECODED = any> {
9
9
  matches: (type: Type) => boolean;
10
+ getTypeLabel?: (type: T) => string;
10
11
  generateField: (event: {
11
12
  label: string;
12
13
  name: string;
@@ -234,6 +234,10 @@ declare namespace S {
234
234
  table: {
235
235
  label: string;
236
236
  colors: {
237
+ border: string;
238
+ groupBorder: string;
239
+ groupBackground: string;
240
+ even: string;
237
241
  odd: string;
238
242
  pills: string;
239
243
  text: string;
@@ -487,6 +491,10 @@ declare namespace S {
487
491
  table: {
488
492
  label: string;
489
493
  colors: {
494
+ border: string;
495
+ groupBorder: string;
496
+ groupBackground: string;
497
+ even: string;
490
498
  odd: string;
491
499
  pills: string;
492
500
  text: string;
@@ -741,6 +749,10 @@ declare namespace S {
741
749
  table: {
742
750
  label: string;
743
751
  colors: {
752
+ border: string;
753
+ groupBorder: string;
754
+ groupBackground: string;
755
+ even: string;
744
756
  odd: string;
745
757
  pills: string;
746
758
  text: string;
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import { ReactorPanelModel } from '@journeyapps-labs/reactor-mod';
3
3
  import { AbstractQuery } from '../../core/query/AbstractQuery';
4
4
  import { ConnectionStore } from '../../stores/ConnectionStore';
5
- import { WorkspaceModelFactoryEvent } from '@projectstorm/react-workspaces-core';
5
+ import { WorkspaceEngine, WorkspaceModelFactoryEvent } from '@projectstorm/react-workspaces-core';
6
6
  import { AbstractConnection } from '../../core/AbstractConnection';
7
7
  import { SharedConnectionPanelFactory } from '../_shared/SharedConnectionPanelFactory';
8
8
  import { Page } from '../../core/query/Page';
@@ -25,7 +25,7 @@ export declare class QueryPanelModel extends ReactorPanelModel {
25
25
  width: number;
26
26
  height: number;
27
27
  };
28
- fromArray(data: ReturnType<this['toArray']>, engine: any): void;
28
+ fromArray(data: ReturnType<this['toArray']>, engine: WorkspaceEngine): void;
29
29
  encodeEntities(): {
30
30
  query: AbstractQuery;
31
31
  };
@@ -16,6 +16,7 @@ import { SchemaModelObjectEntityDefinition } from './entities/SchemaModelObjectE
16
16
  import { EditSchemaModelAction } from './actions/schema-model/EditSchemaModelAction';
17
17
  import { TypeEngine } from './forms/TypeEngine';
18
18
  import { ViewSchemaModelAsJsonAction } from './actions/schema-model/ViewSchemaModelAsJsonAction';
19
+ import { ViewHasManyAction } from './actions/schema-model/ViewHasManyAction';
19
20
  import { ModelJsonPanelFactory } from './panels/model-json/ModelJsonPanelFactory';
20
21
  import { SchemaModelIndexDefinition } from './entities/SchemaModelIndexDefinition';
21
22
  import { SavedQueryStore } from './stores/SavedQueryStore';
@@ -43,6 +44,7 @@ export class DataBrowserModule extends AbstractReactorModule {
43
44
  actionStore.registerAction(new CreateModelAction());
44
45
  actionStore.registerAction(new EditSchemaModelAction());
45
46
  actionStore.registerAction(new ViewSchemaModelAsJsonAction());
47
+ actionStore.registerAction(new ViewHasManyAction());
46
48
  actionStore.registerAction(new OpenSavedQueryAction());
47
49
  actionStore.registerAction(new RemoveSavedQueryAction());
48
50
  system.addStore(ConnectionStore, connectionStore);
@@ -1 +1 @@
1
- {"version":3,"file":"DataBrowserModule.js","sourceRoot":"","sources":["../src/DataBrowserModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEvH,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,iCAAiC,EAAE,MAAM,8CAA8C,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,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AC,IAAI,iCAAiC,EAAE,CAAC,CAAC;QACnE,MAAM,CAAC,kBAAkB,CAAC,IAAI,qCAAqC,EAAE,CAAC,CAAC;QACvE,MAAM,CAAC,kBAAkB,CAAC,IAAI,iCAAiC,EAAE,CAAC,CAAC;QACnE,MAAM,CAAC,kBAAkB,CAAC,IAAI,0BAA0B,EAAE,CAAC,CAAC;QAC5D,MAAM,CAAC,kBAAkB,CAAC,IAAI,qBAAqB,EAAE,CAAC,CAAC;QACvD,MAAM,CAAC,kBAAkB,CAAC,IAAI,0BAA0B,EAAE,CAAC,CAAC;QAE5D,cAAc,CAAC,eAAe,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC;QACxD,cAAc,CAAC,eAAe,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC;QACxD,cAAc,CAAC,eAAe,CAAC,IAAI,qBAAqB,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAc;QACvB,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC;QAChC,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC;IAClC,CAAC;CACF"}
@@ -0,0 +1,112 @@
1
+ import { __classPrivateFieldGet, __classPrivateFieldSet, __esDecorate, __runInitializers } from "tslib";
2
+ import { ActionStore, ComboBoxStore2, EntityAction, NotificationStore, NotificationType, SimpleComboBoxDirective, WorkspaceStore, inject, ioc } from '@journeyapps-labs/reactor-mod';
3
+ import { DataBrowserEntities } from '../../entities';
4
+ import { QueryPanelModel } from '../../panels/query/QueryPanelFactory';
5
+ import { SimpleQuery } from '../../core/query/query-simple/SimpleQuery';
6
+ import { Condition, SimpleFilter, Statement } from '../../core/query/filters';
7
+ let ViewHasManyAction = (() => {
8
+ var _a, _ViewHasManyAction_comboStore_accessor_storage, _ViewHasManyAction_workspaceStore_accessor_storage, _ViewHasManyAction_notifications_accessor_storage;
9
+ let _classSuper = EntityAction;
10
+ let _comboStore_decorators;
11
+ let _comboStore_initializers = [];
12
+ let _comboStore_extraInitializers = [];
13
+ let _workspaceStore_decorators;
14
+ let _workspaceStore_initializers = [];
15
+ let _workspaceStore_extraInitializers = [];
16
+ let _notifications_decorators;
17
+ let _notifications_initializers = [];
18
+ let _notifications_extraInitializers = [];
19
+ return _a = class ViewHasManyAction extends _classSuper {
20
+ get comboStore() { return __classPrivateFieldGet(this, _ViewHasManyAction_comboStore_accessor_storage, "f"); }
21
+ set comboStore(value) { __classPrivateFieldSet(this, _ViewHasManyAction_comboStore_accessor_storage, value, "f"); }
22
+ get workspaceStore() { return __classPrivateFieldGet(this, _ViewHasManyAction_workspaceStore_accessor_storage, "f"); }
23
+ set workspaceStore(value) { __classPrivateFieldSet(this, _ViewHasManyAction_workspaceStore_accessor_storage, value, "f"); }
24
+ get notifications() { return __classPrivateFieldGet(this, _ViewHasManyAction_notifications_accessor_storage, "f"); }
25
+ set notifications(value) { __classPrivateFieldSet(this, _ViewHasManyAction_notifications_accessor_storage, value, "f"); }
26
+ constructor() {
27
+ super({
28
+ id: _a.ID,
29
+ name: 'View has many',
30
+ icon: 'list',
31
+ target: DataBrowserEntities.SCHEMA_MODEL_OBJECT
32
+ });
33
+ _ViewHasManyAction_comboStore_accessor_storage.set(this, __runInitializers(this, _comboStore_initializers, void 0));
34
+ _ViewHasManyAction_workspaceStore_accessor_storage.set(this, (__runInitializers(this, _comboStore_extraInitializers), __runInitializers(this, _workspaceStore_initializers, void 0)));
35
+ _ViewHasManyAction_notifications_accessor_storage.set(this, (__runInitializers(this, _workspaceStore_extraInitializers), __runInitializers(this, _notifications_initializers, void 0)));
36
+ __runInitializers(this, _notifications_extraInitializers);
37
+ }
38
+ async fireEvent(event) {
39
+ const relationships = Object.values(event.targetEntity.definition.definition.hasMany || {});
40
+ if (relationships.length === 0) {
41
+ this.notifications.showNotification({
42
+ title: 'No relationships',
43
+ description: 'This record has no has-many relationships to view.',
44
+ type: NotificationType.ERROR
45
+ });
46
+ return;
47
+ }
48
+ const directive = await this.comboStore.show(new SimpleComboBoxDirective({
49
+ title: 'View has many',
50
+ subtitle: event.targetEntity.data.display || event.targetEntity.id,
51
+ event: event.position,
52
+ items: relationships.map((relationship) => {
53
+ return {
54
+ key: relationship.foreignName || relationship.name,
55
+ title: relationship.foreignName || relationship.name,
56
+ subtitle: relationship.objectType.label || relationship.objectType.name,
57
+ action: async () => { }
58
+ };
59
+ })
60
+ }));
61
+ const selected = directive.getSelectedItem();
62
+ if (!(selected === null || selected === void 0 ? void 0 : selected.key)) {
63
+ return;
64
+ }
65
+ const relationship = relationships.find((entry) => (entry.foreignName || entry.name) === selected.key);
66
+ if (!relationship) {
67
+ return;
68
+ }
69
+ await this.openRelationshipQuery(event.targetEntity, relationship);
70
+ }
71
+ async openRelationshipQuery(parent, relationship) {
72
+ const definition = await parent.definition.connection.waitForSchemaModelDefinitionByName(relationship.objectType.name);
73
+ const variable = definition.getBelongsToIdVariableForRelationship(relationship.name);
74
+ if (!variable) {
75
+ this.notifications.showNotification({
76
+ title: 'Cannot open relationship',
77
+ description: `No belongs-to field found for ${relationship.name}.`,
78
+ type: NotificationType.ERROR
79
+ });
80
+ return;
81
+ }
82
+ variable.label = relationship.name;
83
+ const query = new SimpleQuery({
84
+ definition,
85
+ limit: 30
86
+ });
87
+ query.filterState.setFilter(variable.name, new SimpleFilter(variable, [new Statement(Condition.EQUALS, parent.id)]));
88
+ this.workspaceStore.addModel(new QueryPanelModel(query));
89
+ }
90
+ static get() {
91
+ return ioc.get(ActionStore).getActionByID(_a.ID);
92
+ }
93
+ },
94
+ _ViewHasManyAction_comboStore_accessor_storage = new WeakMap(),
95
+ _ViewHasManyAction_workspaceStore_accessor_storage = new WeakMap(),
96
+ _ViewHasManyAction_notifications_accessor_storage = new WeakMap(),
97
+ (() => {
98
+ var _b;
99
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
100
+ _comboStore_decorators = [inject(ComboBoxStore2)];
101
+ _workspaceStore_decorators = [inject(WorkspaceStore)];
102
+ _notifications_decorators = [inject(NotificationStore)];
103
+ __esDecorate(_a, null, _comboStore_decorators, { kind: "accessor", name: "comboStore", static: false, private: false, access: { has: obj => "comboStore" in obj, get: obj => obj.comboStore, set: (obj, value) => { obj.comboStore = value; } }, metadata: _metadata }, _comboStore_initializers, _comboStore_extraInitializers);
104
+ __esDecorate(_a, null, _workspaceStore_decorators, { kind: "accessor", name: "workspaceStore", static: false, private: false, access: { has: obj => "workspaceStore" in obj, get: obj => obj.workspaceStore, set: (obj, value) => { obj.workspaceStore = value; } }, metadata: _metadata }, _workspaceStore_initializers, _workspaceStore_extraInitializers);
105
+ __esDecorate(_a, null, _notifications_decorators, { kind: "accessor", name: "notifications", static: false, private: false, access: { has: obj => "notifications" in obj, get: obj => obj.notifications, set: (obj, value) => { obj.notifications = value; } }, metadata: _metadata }, _notifications_initializers, _notifications_extraInitializers);
106
+ if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
107
+ })(),
108
+ _a.ID = 'VIEW_HAS_MANY',
109
+ _a;
110
+ })();
111
+ export { ViewHasManyAction };
112
+ //# sourceMappingURL=ViewHasManyAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewHasManyAction.js","sourceRoot":"","sources":["../../../src/actions/schema-model/ViewHasManyAction.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EAEX,cAAc,EACd,YAAY,EAEZ,iBAAiB,EACjB,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,EACd,MAAM,EACN,GAAG,EACJ,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AACxE,OA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AW,EAAE,iCAAiC,YAAY,CAAC,IAAI,GAAG;wBAClE,IAAI,EAAE,gBAAgB,CAAC,KAAK;qBAC7B,CAAC,CAAC;oBACH,OAAO;gBACT,CAAC;gBAED,QAAQ,CAAC,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC;gBAEnC,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC;oBAC5B,UAAU;oBACV,KAAK,EAAE,EAAE;iBACV,CAAC,CAAC;gBAEH,KAAK,CAAC,WAAW,CAAC,SAAS,CACzB,QAAQ,CAAC,IAAI,EACb,IAAI,YAAY,CAAC,QAAQ,EAAE,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CACzE,CAAC;gBAEF,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;YAC3D,CAAC;YAED,MAAM,CAAC,GAAG;gBACR,OAAO,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,aAAa,CAAoB,EAAiB,CAAC,EAAE,CAAC,CAAC;YACrF,CAAC;;;;;;;;sCAzFA,MAAM,CAAC,cAAc,CAAC;0CAGtB,MAAM,CAAC,cAAc,CAAC;yCAGtB,MAAM,CAAC,iBAAiB,CAAC;YAL1B,iLAAS,UAAU,6BAAV,UAAU,+FAAiB;YAGpC,6LAAS,cAAc,6BAAd,cAAc,uGAAiB;YAGxC,0LAAS,aAAa,6BAAb,aAAa,qGAAoB;;;QATnC,KAAE,GAAG,eAAgB;;;SADjB,iBAAiB"}
@@ -5,24 +5,40 @@ import { v4 } from 'uuid';
5
5
  import { BaseObserver } from '@journeyapps-labs/common-utils';
6
6
  import { Collection, LifecycleCollection } from '@journeyapps-labs/lib-reactor-data-layer';
7
7
  import { when } from 'mobx';
8
- import { observable } from 'mobx';
8
+ import { computed, observable } from 'mobx';
9
9
  import { getDefaultConnectionColor } from './connection-colors';
10
+ export var ConnectionOnlineState;
11
+ (function (ConnectionOnlineState) {
12
+ ConnectionOnlineState["OFFLINE"] = "offline";
13
+ ConnectionOnlineState["LOADING"] = "loading";
14
+ ConnectionOnlineState["ONLINE"] = "online";
15
+ })(ConnectionOnlineState || (ConnectionOnlineState = {}));
10
16
  let AbstractConnection = (() => {
11
- var _a, _AbstractConnection_color_accessor_storage;
17
+ var _a, _AbstractConnection_color_accessor_storage, _AbstractConnection_onlineState_accessor_storage;
12
18
  let _classSuper = BaseObserver;
19
+ let _instanceExtraInitializers = [];
13
20
  let _color_decorators;
14
21
  let _color_initializers = [];
15
22
  let _color_extraInitializers = [];
23
+ let _onlineState_decorators;
24
+ let _onlineState_initializers = [];
25
+ let _onlineState_extraInitializers = [];
26
+ let _get_isOnline_decorators;
27
+ let _get_isLoadingOnline_decorators;
16
28
  return _a = class AbstractConnection extends _classSuper {
17
29
  get color() { return __classPrivateFieldGet(this, _AbstractConnection_color_accessor_storage, "f"); }
18
30
  set color(value) { __classPrivateFieldSet(this, _AbstractConnection_color_accessor_storage, value, "f"); }
31
+ get onlineState() { return __classPrivateFieldGet(this, _AbstractConnection_onlineState_accessor_storage, "f"); }
32
+ set onlineState(value) { __classPrivateFieldSet(this, _AbstractConnection_onlineState_accessor_storage, value, "f"); }
19
33
  constructor(factory) {
20
34
  super();
21
- this.factory = factory;
35
+ this.factory = (__runInitializers(this, _instanceExtraInitializers), factory);
22
36
  _AbstractConnection_color_accessor_storage.set(this, __runInitializers(this, _color_initializers, void 0));
23
- this.schema_models_collection = __runInitializers(this, _color_extraInitializers);
37
+ _AbstractConnection_onlineState_accessor_storage.set(this, (__runInitializers(this, _color_extraInitializers), __runInitializers(this, _onlineState_initializers, void 0)));
38
+ this.schema_models_collection = __runInitializers(this, _onlineState_extraInitializers);
24
39
  this.id = v4();
25
40
  this.color = getDefaultConnectionColor(this.id);
41
+ this.onlineState = ConnectionOnlineState.OFFLINE;
26
42
  this.schema_models_collection = new Collection();
27
43
  this.schema_models = new LifecycleCollection({
28
44
  collection: this.schema_models_collection,
@@ -68,7 +84,14 @@ let AbstractConnection = (() => {
68
84
  getSchemaModelDefinitionByName(name) {
69
85
  return this.schema_models.items.find((i) => i.definition.name === name);
70
86
  }
87
+ get isOnline() {
88
+ return this.onlineState === ConnectionOnlineState.ONLINE;
89
+ }
90
+ get isLoadingOnline() {
91
+ return this.onlineState === ConnectionOnlineState.LOADING;
92
+ }
71
93
  async waitForSchemaModelDefinitionByName(name) {
94
+ await this.ensureOnline();
72
95
  await when(() => !!this.getSchemaModelDefinitionByName(name));
73
96
  return this.getSchemaModelDefinitionByName(name);
74
97
  }
@@ -82,9 +105,32 @@ let AbstractConnection = (() => {
82
105
  return _.values(schema.objects);
83
106
  });
84
107
  }
85
- async init() {
108
+ async init() { }
109
+ async connectOnline() {
86
110
  await this.reload();
87
111
  }
112
+ async ensureOnline() {
113
+ if (this.isOnline) {
114
+ return;
115
+ }
116
+ if (!this.initialize_online_promise) {
117
+ this.initialize_online_promise = this.initializeOnline();
118
+ }
119
+ await this.initialize_online_promise;
120
+ }
121
+ async initializeOnline() {
122
+ this.onlineState = ConnectionOnlineState.LOADING;
123
+ try {
124
+ await this.connectOnline();
125
+ this.onlineState = ConnectionOnlineState.ONLINE;
126
+ }
127
+ finally {
128
+ if (this.onlineState === ConnectionOnlineState.LOADING) {
129
+ this.onlineState = ConnectionOnlineState.OFFLINE;
130
+ }
131
+ this.initialize_online_promise = null;
132
+ }
133
+ }
88
134
  async getSchemaModelDefinitions() {
89
135
  const schema = await this.getSchema();
90
136
  return _.map(schema.objects, (o) => {
@@ -112,11 +158,18 @@ let AbstractConnection = (() => {
112
158
  }
113
159
  },
114
160
  _AbstractConnection_color_accessor_storage = new WeakMap(),
161
+ _AbstractConnection_onlineState_accessor_storage = new WeakMap(),
115
162
  (() => {
116
163
  var _b;
117
164
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create((_b = _classSuper[Symbol.metadata]) !== null && _b !== void 0 ? _b : null) : void 0;
118
165
  _color_decorators = [observable];
166
+ _onlineState_decorators = [observable];
167
+ _get_isOnline_decorators = [computed];
168
+ _get_isLoadingOnline_decorators = [computed];
119
169
  __esDecorate(_a, null, _color_decorators, { kind: "accessor", name: "color", static: false, private: false, access: { has: obj => "color" in obj, get: obj => obj.color, set: (obj, value) => { obj.color = value; } }, metadata: _metadata }, _color_initializers, _color_extraInitializers);
170
+ __esDecorate(_a, null, _onlineState_decorators, { kind: "accessor", name: "onlineState", static: false, private: false, access: { has: obj => "onlineState" in obj, get: obj => obj.onlineState, set: (obj, value) => { obj.onlineState = value; } }, metadata: _metadata }, _onlineState_initializers, _onlineState_extraInitializers);
171
+ __esDecorate(_a, null, _get_isOnline_decorators, { kind: "getter", name: "isOnline", static: false, private: false, access: { has: obj => "isOnline" in obj, get: obj => obj.isOnline }, metadata: _metadata }, null, _instanceExtraInitializers);
172
+ __esDecorate(_a, null, _get_isLoadingOnline_decorators, { kind: "getter", name: "isLoadingOnline", static: false, private: false, access: { has: obj => "isLoadingOnline" in obj, get: obj => obj.isLoadingOnline }, metadata: _metadata }, null, _instanceExtraInitializers);
120
173
  if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
121
174
  })(),
122
175
  _a;