src/app/core/import/import-entity-type/import-entity-type.component.ts

Description

Import sub-step: Let user select which entity type data should be imported as.

Example

Metadata

Relationships

Used by

Depends on

Index

Properties
Methods
Inputs
Outputs

Inputs

entityType
Type : string

user selected entity type

Outputs

entityType
Type : string

user selected entity type

Methods

onSelectedTypeChange
onSelectedTypeChange(newType: unknown)
Parameters :
Name Type Optional
newType unknown No
Returns : void

Properties

expertMode
Type : unknown
Default value : signal(false)

Whether to show all, including administrative, entity types for selection.

hideTypeOption
Type : unknown
Default value : () => {...}
import {
  Component,
  ChangeDetectionStrategy,
  inject,
  model,
  signal,
} from "@angular/core";
import { MatInputModule } from "@angular/material/input";
import { MatSelectModule } from "@angular/material/select";
import { HelpButtonComponent } from "../../common-components/help-button/help-button.component";
import { MatSlideToggleModule } from "@angular/material/slide-toggle";
import { FormsModule } from "@angular/forms";
import { EntityTypeSelectComponent } from "../../entity/entity-type-select/entity-type-select.component";
import { EntityConstructor } from "../../entity/model/entity";
import { EntityAbility } from "../../permissions/ability/entity-ability";

/**
 * Import sub-step: Let user select which entity type data should be imported as.
 */
@Component({
  changeDetection: ChangeDetectionStrategy.OnPush,
  selector: "app-import-entity-type",
  templateUrl: "./import-entity-type.component.html",
  styleUrls: ["./import-entity-type.component.scss"],
  imports: [
    MatInputModule,
    MatSelectModule,
    HelpButtonComponent,
    MatSlideToggleModule,
    FormsModule,
    EntityTypeSelectComponent,
  ],
})
export class ImportEntityTypeComponent {
  private readonly ability = inject(EntityAbility);

  /** user selected entity type */
  entityType = model<string>();

  /**
   * Whether to show all, including administrative, entity types for selection.
   */
  expertMode = signal(false);

  hideTypeOption = (type: EntityConstructor) =>
    this.ability.initialized && this.ability.cannot("create", type);

  onSelectedTypeChange(newType) {
    this.entityType.set(newType);
  }

  // TODO: infer entityType automatically -> pre-select + UI explanatory text
}
<p i18n>Select the import target type:</p>

<div class="flex-row align-center">
  <mat-form-field class="full-width">
    <mat-label i18n>Import as</mat-label>
    <app-entity-type-select
      [ngModel]="entityType()"
      (ngModelChange)="onSelectedTypeChange($event)"
      [multi]="false"
      [showInternalTypes]="expertMode()"
      [hideOption]="hideTypeOption"
    ></app-entity-type-select>
    <mat-hint i18n>
      Only record types you have permission to create are available.
    </mat-hint>
  </mat-form-field>

  <app-help-button
    text="What type of records should your imported data become in the system? Select the target record type here. (e.g. are you trying to import participants, events or team members etc.)"
    i18n-text="import - select type - help text"
  >
  </app-help-button>

  <mat-slide-toggle
    [ngModel]="expertMode()"
    (ngModelChange)="expertMode.set($event)"
    i18n="Toggle label"
    >Expert Mode</mat-slide-toggle
  >
</div>

./import-entity-type.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""