2.48.0 • Published 4 months ago

@memberjunction/ng-simple-record-list v2.48.0

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

@memberjunction/ng-simple-record-list

A lightweight, reusable Angular component for displaying, editing, creating, and deleting records in any MemberJunction entity. This component provides a streamlined grid interface with built-in CRUD operations and customizable actions.

Features

  • Simple Grid Display: Clean table layout for entity records with automatic column detection
  • CRUD Operations: Built-in support for Create, Read, Update, and Delete operations
  • Automatic Column Detection: Intelligently selects columns based on entity metadata
  • Custom Actions: Support for custom actions with dynamic icons and tooltips
  • Confirmation Dialogs: Built-in dialogs for delete and custom action confirmations
  • Responsive Design: Loading indicators and scrollable content area
  • Entity Form Integration: Seamless integration with MemberJunction's entity form dialog
  • Sorting Support: Client-side sorting capability for displayed records
  • Click-to-Select: Row selection with event emission for parent handling

Installation

npm install @memberjunction/ng-simple-record-list

Usage

Module Import

Import the module in your Angular application:

import { SimpleRecordListModule } from '@memberjunction/ng-simple-record-list';

@NgModule({
  imports: [
    CommonModule,
    SimpleRecordListModule
  ]
})
export class YourModule { }

Basic Implementation

Simple usage with automatic column detection:

<mj-simple-record-list
  EntityName="Users"
  (RecordSelected)="handleRecordSelected($event)"
></mj-simple-record-list>

Advanced Implementation

Full-featured implementation with custom columns and actions:

<mj-simple-record-list
  EntityName="Users"
  [Columns]="['Name', 'Email', 'IsActive', 'CreatedAt']"
  SortBy="Name"
  [AllowDelete]="true"
  [AllowNew]="true"
  [AllowEdit]="true"
  EditSectionName="user-details"
  (RecordSelected)="onUserSelected($event)"
  (RecordEdited)="onUserEdited($event)"
  (RecordCreated)="onUserCreated($event)"
></mj-simple-record-list>

Component Implementation

import { Component } from '@angular/core';
import { BaseEntity, UserEntity } from '@memberjunction/core-entities';

@Component({
  selector: 'app-user-management',
  templateUrl: './user-management.component.html'
})
export class UserManagementComponent {
  
  onUserSelected(user: BaseEntity): void {
    console.log('User selected:', user.Get('Name'));
    // Navigate to detail view or perform other actions
  }
  
  onUserEdited(user: BaseEntity): void {
    console.log('User edited:', user.Get('ID'));
    // Handle post-edit logic
  }
  
  onUserCreated(user: BaseEntity): void {
    console.log('New user created:', user.Get('ID'));
    // Handle post-creation logic
  }
}

API Documentation

Input Properties

PropertyTypeDefaultDescription
EntityNamestring''Required. Name of the MemberJunction entity to display records for
Columnsstring[][]List of column names to display. If empty, columns are auto-detected based on entity metadata
SortBystring''Column name to sort by. Uses client-side string comparison sorting
AllowDeletebooleantrueShows/hides delete button for each record
AllowNewbooleantrueShows/hides the "New" button above the grid
AllowEditbooleantrueShows/hides edit button for each record
AllowCustomActionbooleanfalseEnables custom action button for each record
CustomActionIconstring''Font Awesome icon class for custom action (e.g., 'fa-user-lock')
CustomActionIconFunctionFunctionnullFunction to dynamically determine icon based on record
CustomActionTooltipstring''Tooltip text for custom action button
CustomActionTooltipFunctionFunctionnullFunction to dynamically determine tooltip based on record
CustomActionDialogTitlestring'Confirm Action'Title for custom action confirmation dialog
CustomActionDialogMessagestring'Are you sure you want to perform this action?'Message for custom action dialog. Supports {{recordName}} placeholder
CustomActionDialogInfostring''Additional information shown in custom action dialog
EditSectionNamestring'details'Section name passed to entity form dialog for edit/new operations

Output Events

EventTypeDescription
RecordSelectedEventEmitter<BaseEntity>Fired when a record row is clicked
RecordEditedEventEmitter<BaseEntity>Fired after a record is successfully edited
RecordCreatedEventEmitter<BaseEntity>Fired after a new record is successfully created
CustomActionClickedEventEmitter<BaseEntity>Fired when custom action button is clicked (before confirmation)
CustomActionConfirmedEventEmitter<BaseEntity>Fired when custom action is confirmed in dialog

Column Auto-Detection Logic

When no columns are specified, the component uses the following logic:

  1. If the entity has fewer than 10 fields, all fields are displayed
  2. If the entity has 10+ fields:
    • Fields with DefaultInView = true are selected
    • If no fields have DefaultInView = true, the first 10 fields are used

Custom Actions

Example: Toggle User Activation

import { Component } from '@angular/core';
import { BaseEntity, UserEntity } from '@memberjunction/core-entities';

@Component({
  selector: 'app-user-list',
  template: `
    <mj-simple-record-list
      EntityName="Users"
      [Columns]="['Name', 'Email', 'IsActive']"
      [AllowDelete]="false"
      [AllowCustomAction]="true"
      [CustomActionIconFunction]="getUserToggleIcon"
      [CustomActionTooltipFunction]="getUserToggleTooltip"
      CustomActionDialogTitle="Toggle User Activation"
      CustomActionDialogMessage="Are you sure you want to toggle activation for {{recordName}}?"
      CustomActionDialogInfo="Active users can log in. Inactive users cannot."
      (CustomActionConfirmed)="toggleUserActivation($event)"
    ></mj-simple-record-list>
  `
})
export class UserListComponent {
  
  getUserToggleIcon = (record: BaseEntity): string => {
    const user = record as UserEntity;
    return user.IsActive ? 'fa-user-lock' : 'fa-user-check';
  }
  
  getUserToggleTooltip = (record: BaseEntity): string => {
    const user = record as UserEntity;
    return user.IsActive ? 'Deactivate user' : 'Activate user';
  }
  
  async toggleUserActivation(record: BaseEntity): Promise<void> {
    const user = record as UserEntity;
    user.IsActive = !user.IsActive;
    
    if (await user.Save()) {
      console.log('User activation toggled successfully');
    } else {
      console.error('Failed to toggle user activation:', user.LatestResult.Message);
    }
  }
}

Record Name Resolution

The component determines display names for records using this hierarchy:

  1. First field marked with IsNameField = true in entity metadata
  2. Field named "Name" if it exists
  3. Concatenated primary key values with "Record: " prefix

Styling

The component uses:

  • Font Awesome icons (must be included in your application)
  • Kendo UI Angular theme styles
  • Custom CSS with scrollable table and sticky headers
  • Hover effects for better user interaction

CSS Classes

  • .wrapper: Main container with padding and scrolling
  • .grid: Table styling with collapsed borders
  • .sticky-header: Keeps table headers visible during scroll
  • .icon: Styling for action buttons with cursor pointer

Dependencies

Production Dependencies

  • @memberjunction/core: Core MemberJunction functionality
  • @memberjunction/core-entities: Entity base classes
  • @memberjunction/global: Global utilities
  • @memberjunction/ng-container-directives: Layout directives
  • @memberjunction/ng-notifications: Notification service
  • @memberjunction/ng-entity-form-dialog: Entity form dialog component
  • @progress/kendo-angular-*: Kendo UI components

Peer Dependencies

  • @angular/common: ^18.0.2
  • @angular/core: ^18.0.2
  • @angular/forms: ^18.0.2
  • @angular/router: ^18.0.2

Integration with MemberJunction

This component is designed to work seamlessly with the MemberJunction framework:

  • Entity Metadata: Automatically reads entity configuration from MJ metadata
  • Entity Objects: Uses MJ's BaseEntity class for all operations
  • RunView: Leverages MJ's RunView for efficient data loading
  • Entity Forms: Integrates with MJ's entity form dialog for editing
  • Notifications: Uses MJ's notification service for user feedback

Best Practices

  1. Column Selection: Specify columns explicitly for better performance and control
  2. Custom Actions: Use function-based icons/tooltips for dynamic UI updates
  3. Event Handling: Always handle the output events for proper integration
  4. Error Handling: Check entity save results and handle failures appropriately
  5. Performance: For large datasets, consider implementing server-side pagination

Troubleshooting

Common Issues

  1. No records displayed: Verify EntityName matches exactly with MJ metadata
  2. Columns not showing: Check that column names match entity field names
  3. Edit form not opening: Ensure EditSectionName exists in entity form configuration
  4. Custom actions not working: Verify function bindings use arrow functions or proper binding

Debug Tips

  • Check browser console for entity loading errors
  • Verify MemberJunction metadata is properly initialized
  • Ensure all required Angular and Kendo modules are imported
  • Check that Font Awesome is properly included for icons

Examples

Minimal Setup

// app.component.ts
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: `
    <mj-simple-record-list 
      EntityName="Employees"
    ></mj-simple-record-list>
  `
})
export class AppComponent { }

Read-Only Grid

<mj-simple-record-list
  EntityName="AuditLogs"
  [Columns]="['Timestamp', 'User', 'Action', 'Description']"
  SortBy="Timestamp"
  [AllowNew]="false"
  [AllowEdit]="false"
  [AllowDelete]="false"
></mj-simple-record-list>

With Custom Filtering

@Component({
  template: `
    <mj-simple-record-list
      EntityName="Products"
      [Columns]="['Name', 'Category', 'Price', 'InStock']"
      [AllowCustomAction]="true"
      CustomActionIcon="fa-filter"
      CustomActionTooltip="Toggle out of stock items"
      (CustomActionConfirmed)="toggleStockFilter($event)"
    ></mj-simple-record-list>
  `
})
export class ProductListComponent {
  private showOutOfStock = true;

  async toggleStockFilter(record: BaseEntity): Promise<void> {
    this.showOutOfStock = !this.showOutOfStock;
    // Implement filtering logic
  }
}

Building

To build this package individually:

cd packages/Angular/Explorer/simple-record-list
npm run build

Contributing

When contributing to this component:

  1. Follow the MemberJunction coding standards
  2. Ensure all TypeScript compiles without errors
  3. Test with various entity types
  4. Update this README for any API changes
  5. Add appropriate TSDoc comments for public methods

License

This package is part of the MemberJunction framework and follows the same license terms.

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.34.1

6 months ago

2.15.1

9 months ago

2.38.0

5 months ago

2.45.0

4 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

8 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

8 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.6.1

1 year ago

2.6.0

1 year ago

2.7.0

1 year ago

2.5.2

1 year ago

2.7.1

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago

1.6.1

1 year ago

1.6.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

2.4.1

1 year ago

2.4.0

1 year ago

2.0.0

1 year ago

1.7.1

1 year ago

1.5.3

1 year ago

1.7.0

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.3.3

1 year ago

1.5.0

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

2.3.0

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.5.0

1 year ago

2.3.2

1 year ago

2.1.4

1 year ago

2.3.1

1 year ago

2.1.3

1 year ago

2.5.1

1 year ago

2.3.3

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-beta.0

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.6

2 years ago

1.0.4

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.9.25

2 years ago

0.9.23

2 years ago

0.9.24

2 years ago

0.9.21

2 years ago

0.9.22

2 years ago

0.9.18

2 years ago

0.9.15

2 years ago

0.9.16

2 years ago

0.9.17

2 years ago

0.9.14

2 years ago

0.9.12

2 years ago

0.9.13

2 years ago

0.9.10

2 years ago

0.9.11

2 years ago

0.9.8

2 years ago

0.9.9

2 years ago

0.9.7

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