src/app/features/dashboard-widgets/entity-count-dashboard-widget/entity-count-dashboard-settings.component/entity-count-dashboard-settings.component.ts

Metadata

Relationships

Used by

No results matching.

Depends on

import {
  Component,
  ChangeDetectionStrategy,
  effect,
  input,
  linkedSignal,
} from "@angular/core";
import { FormsModule, FormControl } from "@angular/forms";
import { DynamicComponent } from "../../../../core/config/dynamic-components/dynamic-component.decorator";
import { EntityTypeSelectComponent } from "../../../../core/entity/entity-type-select/entity-type-select.component";
import { EntityFieldSelectComponent } from "../../../../core/entity/entity-field-select/entity-field-select.component";
import { MatInputModule } from "@angular/material/input";
import { MatFormFieldModule } from "@angular/material/form-field";
import { MatButtonModule } from "@angular/material/button";
import { MatIconModule } from "@angular/material/icon";
import { MatTooltipModule } from "@angular/material/tooltip";
import { MatSelectModule } from "@angular/material/select";
import { FaIconComponent } from "@fortawesome/angular-fontawesome";

export interface EntityCountDashboardConfig {
  entityType?: string;
  groupBy?: string[];
}

@DynamicComponent("EntityCountDashboardSettings")
@Component({
  changeDetection: ChangeDetectionStrategy.OnPush,
  selector: "app-entity-count-dashboard-settings",
  standalone: true,
  imports: [
    MatFormFieldModule,
    MatInputModule,
    MatButtonModule,
    MatIconModule,
    MatTooltipModule,
    MatSelectModule,
    FormsModule,
    EntityTypeSelectComponent,
    EntityFieldSelectComponent,
    FaIconComponent,
  ],
  templateUrl: "./entity-count-dashboard-settings.component.html",
  styleUrls: ["./entity-count-dashboard-settings.component.scss"],
})
export class EntityCountDashboardSettingsComponent {
  formControl = input.required<FormControl<EntityCountDashboardConfig>>();

  entityType = linkedSignal(() => this.formControl().value?.entityType);
  groupBy = linkedSignal(() => [...(this.formControl().value?.groupBy ?? [])]);

  constructor() {
    effect(() => {
      this.formControl().setValue({
        entityType: this.entityType(),
        groupBy: this.groupBy(),
      });
    });
  }
}
<div style="padding: 16px">
  <div style="margin-bottom: 32px">
    <h3 i18n>Record Type to Count</h3>
    <mat-form-field appearance="fill" class="full-width">
      <mat-label i18n>Select Record Type</mat-label>
      <app-entity-type-select
        [ngModel]="entityType()"
        (ngModelChange)="entityType.set($event)"
      ></app-entity-type-select>
    </mat-form-field>
    <mat-hint i18n
      >Select which record type to count and display statistics for</mat-hint
    >
  </div>

  <div>
    <h3 i18n>
      Group By Fields
      <span
        matTooltip="You can select one or more filters to segregate the dashboard data further, providing a more detailed analysis."
        i18n-matTooltip
      >
        <fa-icon icon="question-circle"></fa-icon>
      </span>
    </h3>
    <mat-form-field appearance="fill" class="full-width">
      <mat-label i18n>Select Group By Fields</mat-label>
      <app-entity-field-select
        [entityType]="entityType()"
        [ngModel]="groupBy()"
        (ngModelChange)="groupBy.set($event)"
        [multi]="true"
        [placeholder]="'Select Group By Fields'"
        i18n-placeholder
      ></app-entity-field-select>
    </mat-form-field>
  </div>
</div>

./entity-count-dashboard-settings.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""