2.48.0 • Published 4 months ago

@memberjunction/ng-data-context v2.48.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

@memberjunction/ng-data-context

Angular component package for displaying and editing MemberJunction Data Contexts - collections of data items from different sources that can be used together for analysis, reporting, or other data operations.

Overview

This package provides Angular components to display Data Contexts and their associated items in a clean, user-friendly interface. Data Contexts in MemberJunction are powerful constructs that allow users to group related data from various sources (SQL queries, views, entities, etc.) into a single logical unit.

Features

  • Display Data Context Details: View comprehensive information about a data context including ID, name, and description
  • View Data Context Items: Display all items within a data context in a sortable, scrollable grid format
  • Dialog Wrapper: Ready-to-use dialog component for popup displays
  • Metadata Provider Integration: Seamlessly integrates with MemberJunction's metadata system
  • Loading State Management: Built-in loading indicators for better user experience
  • Virtual Scrolling: Efficiently handle large datasets with Kendo Grid's virtual scrolling
  • Responsive Design: Components adapt to different screen sizes

Installation

npm install @memberjunction/ng-data-context

Usage

Import the Module

import { DataContextModule } from '@memberjunction/ng-data-context';

@NgModule({
  imports: [
    DataContextModule,
    // other imports
  ],
  // ...
})
export class YourModule { }

Basic Component Usage

<!-- Display a data context using its ID -->
<mj-data-context
  [dataContextId]="'your-data-context-id'"
  [Provider]="customMetadataProvider">
</mj-data-context>

Dialog Component Usage

<!-- Show data context in a dialog -->
<mj-data-context-dialog
  *ngIf="showDataContextDialog"
  [dataContextId]="selectedDataContextId"
  [Provider]="metadataProvider"
  (dialogClosed)="showDataContextDialog = false">
</mj-data-context-dialog>

Complete TypeScript Example

import { Component } from '@angular/core';
import { IMetadataProvider, Metadata } from '@memberjunction/core';

@Component({
  selector: 'app-data-context-viewer',
  template: `
    <div class="data-context-container">
      <h2>Data Context Viewer</h2>
      
      <!-- Inline component usage -->
      <mj-data-context
        [dataContextId]="selectedDataContextId"
        [Provider]="metadataProvider">
      </mj-data-context>
      
      <!-- Dialog trigger button -->
      <button (click)="showDialog()">View in Dialog</button>
      
      <!-- Dialog component -->
      <mj-data-context-dialog
        *ngIf="isDialogVisible"
        [dataContextId]="selectedDataContextId"
        [Provider]="metadataProvider"
        (dialogClosed)="onDialogClose()">
      </mj-data-context-dialog>
    </div>
  `,
  styles: [`
    .data-context-container {
      padding: 20px;
    }
  `]
})
export class DataContextViewerComponent {
  isDialogVisible = false;
  selectedDataContextId = '12345-67890-abcdef';
  metadataProvider: IMetadataProvider;
  
  constructor() {
    // Use the global metadata provider or inject your own
    this.metadataProvider = Metadata.Provider;
  }
  
  showDialog(): void {
    this.isDialogVisible = true;
  }
  
  onDialogClose(): void {
    this.isDialogVisible = false;
    // Additional cleanup or refresh logic here
  }
}

API Reference

DataContextComponent

The main component for displaying a data context and its items.

Selector: mj-data-context

Inputs

InputTypeRequiredDefaultDescription
dataContextIdstringYes-The ID of the data context to display
ProviderIMetadataProvider \| nullNoMetadata.ProviderCustom metadata provider. If not provided, uses the global MemberJunction metadata provider

Properties

PropertyTypeDescription
dataContextRecordDataContextEntity \| undefinedThe loaded data context entity
dataContextItemsany[]Array of data context items
showLoaderbooleanLoading state indicator

DataContextDialogComponent

Dialog wrapper component that displays the DataContextComponent in a Kendo dialog.

Selector: mj-data-context-dialog

Inputs

InputTypeRequiredDefaultDescription
dataContextIdstringYes-The ID of the data context to display
ProviderIMetadataProvider \| nullNonullCustom metadata provider

Outputs

OutputTypeDescription
dialogClosedEventEmitter<void>Emitted when the dialog is closed

DataContextModule

The NgModule that exports both components.

Exports:

  • DataContextComponent
  • DataContextDialogComponent

Data Context Structure

A data context in MemberJunction consists of:

  1. Context Record (DataContextEntity)

    • ID: Unique identifier
    • Name: Display name
    • Description: Detailed description
    • Additional metadata fields
  2. Context Items (Data Context Items entity)

    • Type: The type of data item (SQL, View, Query, Entity, Record)
    • SQL: Direct SQL query (if applicable)
    • ViewID: Reference to a view
    • QueryID: Reference to a saved query
    • EntityID: Reference to an entity
    • RecordID: Specific record reference

Grid Features

The component uses Kendo Grid with the following features enabled:

  • Virtual Scrolling: Efficiently handles large datasets
  • Sorting: Click column headers to sort
  • Resizable Columns: Drag column borders to resize
  • Keyboard Navigation: Navigate cells with keyboard
  • Page Size: Default 100 items per virtual page

Styling

The components use Kendo UI for Angular styling. You can override styles by targeting the component selectors:

/* Custom styling example */
mj-data-context {
  /* Your custom styles */
}

.kendo-grid-container {
  height: 500px; /* Adjust grid height */
}

Dependencies

Runtime Dependencies

  • @memberjunction/core (v2.43.0): Core MemberJunction functionality
  • @memberjunction/core-entities (v2.43.0): Entity type definitions
  • @memberjunction/global (v2.43.0): Global utilities
  • tslib (^2.3.0): TypeScript runtime helpers

Peer Dependencies

  • @angular/common (18.0.2)
  • @angular/core (18.0.2)
  • @progress/kendo-angular-grid (16.2.0)
  • @progress/kendo-angular-indicators (16.2.0)
  • @progress/kendo-angular-dialog (imported via module)
  • @progress/kendo-angular-buttons (imported via module)

Integration with MemberJunction

This package integrates seamlessly with other MemberJunction packages:

  • Uses the MemberJunction metadata system for entity loading
  • Leverages RunView for efficient data retrieval
  • Compatible with MemberJunction's security and permission system
  • Works with custom metadata providers for multi-tenant scenarios

Build and Development

To build this package individually:

cd packages/Angular/Generic/data-context
npm run build

The package uses Angular CLI's ngc compiler for building the library.

Error Handling

The component includes built-in error handling:

  • Logs errors using MemberJunction's LogError function
  • Hides the loader on error
  • Gracefully handles missing or invalid data context IDs

Best Practices

  1. Provider Usage: Only provide a custom Provider if you need to override the global metadata provider
  2. Dialog Management: Always handle the dialogClosed event to properly manage dialog state
  3. Performance: The virtual scrolling is optimized for datasets up to several thousand items
  4. Error Handling: Monitor console logs for any data loading errors

License

ISC

2.27.1

8 months ago

2.23.2

8 months ago

2.46.0

4 months ago

2.23.1

8 months ago

2.27.0

8 months ago

2.34.0

6 months ago

2.30.0

7 months ago

2.19.4

9 months ago

2.19.5

9 months ago

2.19.2

9 months ago

2.19.3

9 months ago

2.19.0

9 months ago

2.19.1

9 months ago

2.15.2

9 months ago

2.34.2

6 months ago

2.15.0

9 months ago

2.34.1

6 months ago

2.15.1

9 months ago

2.38.0

5 months ago

2.45.0

5 months ago

2.22.1

8 months ago

2.22.0

8 months ago

2.41.0

5 months ago

2.22.2

8 months ago

2.26.1

8 months ago

2.26.0

8 months ago

2.33.0

6 months ago

2.18.3

9 months ago

2.18.1

9 months ago

2.18.2

9 months ago

2.18.0

9 months ago

2.37.1

5 months ago

2.37.0

5 months ago

2.14.0

9 months ago

2.21.0

9 months ago

2.44.0

5 months ago

2.40.0

5 months ago

2.29.0

7 months ago

2.29.2

7 months ago

2.29.1

7 months ago

2.25.0

8 months ago

2.48.0

4 months ago

2.32.0

7 months ago

2.32.2

7 months ago

2.32.1

7 months ago

2.17.0

9 months ago

2.13.4

10 months ago

2.36.0

6 months ago

2.13.2

11 months ago

2.13.3

10 months ago

2.13.0

11 months ago

2.36.1

6 months ago

2.13.1

11 months ago

2.43.0

5 months ago

2.20.2

9 months ago

2.20.3

9 months ago

2.20.0

9 months ago

2.20.1

9 months ago

2.28.0

8 months ago

2.47.0

4 months ago

2.24.1

8 months ago

2.24.0

8 months ago

2.31.0

7 months ago

2.12.0

12 months ago

2.39.0

5 months ago

2.16.1

9 months ago

2.35.1

6 months ago

2.35.0

6 months ago

2.16.0

9 months ago

2.42.1

5 months ago

2.42.0

5 months ago

2.23.0

8 months ago

2.11.0

12 months ago

2.10.0

12 months ago

2.9.0

12 months ago

2.8.0

1 year ago

2.7.0

1 year ago

2.7.1

1 year ago

2.6.1

1 year ago

2.6.0

1 year ago

2.5.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

2.4.1

1 year ago

2.4.0

1 year ago

2.0.0

1 year ago

1.5.3

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

2.3.0

1 year ago

2.3.2

1 year ago

2.3.1

1 year ago

2.3.3

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.5.0

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.5.1

1 year ago

2.1.5

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.11

1 year ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.8-next.6

2 years ago

1.0.8-next.5

2 years ago

1.0.8-next.4

2 years ago

1.0.8-next.3

2 years ago

1.0.8-next.2

2 years ago

1.0.8-next.1

2 years ago

1.0.8-next.0

2 years ago

1.0.7-next.0

2 years ago

1.0.8-beta.0

2 years ago

1.0.6

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.9.53

2 years ago

0.9.54

2 years ago

0.9.55

2 years ago

0.9.51

2 years ago

0.9.50

2 years ago

0.9.49

2 years ago

0.9.48

2 years ago

0.9.45

2 years ago

0.9.46

2 years ago

0.9.47

2 years ago

0.9.44

2 years ago

0.9.41

2 years ago

0.9.42

2 years ago

0.9.43

2 years ago

0.9.40

2 years ago

0.9.38

2 years ago

0.9.36

2 years ago

0.9.37

2 years ago

0.9.34

2 years ago

0.9.35

2 years ago

0.9.33

2 years ago

0.9.30

2 years ago

0.9.31

2 years ago

0.9.32

2 years ago

0.9.28

2 years ago

0.9.27

2 years ago

0.9.25

2 years ago

0.9.26

2 years ago

0.9.24

2 years ago

0.9.23

2 years ago

0.9.22

2 years ago

0.9.14

2 years ago

0.9.15

2 years ago

0.9.20

2 years ago

0.9.21

2 years ago

0.9.17

2 years ago

0.9.18

2 years ago

0.9.19

2 years ago

0.9.13

2 years ago

0.9.12

2 years ago

0.9.8

2 years ago

0.9.7

2 years ago

0.9.9

2 years ago

0.9.10

2 years ago

0.9.6

2 years ago

0.9.11

2 years ago

0.9.5

2 years ago

0.9.4

2 years ago

0.9.3

2 years ago

0.9.2

2 years ago