src/app/features/change-history/change-history-changed-fields/change-history-changed-fields.component.ts

Description

Which fields one audited change touched, as labelled chips.

A write can legitimately touch no visible field, and what that means depends on the kind of write - a creation has no prior state to differ from, and a deletion replicates as a tombstone stripped of its content - so each gets its own wording rather than an empty cell.

Extends

ViewDirective< string[] >

Example

Metadata

Relationships

Used by

No results matching.

Index

Properties
Inputs

Inputs

entity
Type : AuditRecord
Inherited from ViewDirective
config
Type : C
Default value : undefined
Inherited from ViewDirective
formFieldConfig
Type : FormFieldConfig
Inherited from ViewDirective
id
Type : string
Inherited from ViewDirective
tooltip
Type : string
Inherited from ViewDirective
value
Type : T
Inherited from ViewDirective

Properties

Readonly fields
Type : unknown
Default value : computed(() => this.value() ?? [])
Readonly operation
Type : unknown
Default value : computed(() => this.entity()?.operation)
Readonly recordType
Type : unknown
Default value : computed(() => this.entity()?.recordType)

the changed record's type, which the field labels are resolved against

Readonly config
Type : unknown
Default value : computed<C>(() => { const ffc = this.formFieldConfig(); return ffc !== undefined ? (ffc.additional as C) : this._directConfig(); })
Inherited from ViewDirective
Readonly isPartiallyAnonymized
Type : unknown
Default value : computed<boolean>(() => { const entity = this.entity(); const id = this.id(); return ( (entity?.anonymized && entity?.getSchema()?.get(id)?.anonymize === "retain-anonymized") ?? false ); })
Inherited from ViewDirective
import { Component, computed, input } from "@angular/core";
import { MatChipsModule } from "@angular/material/chips";
import { ViewDirective } from "../../../core/entity/default-datatype/view.directive";
import { DynamicComponent } from "../../../core/config/dynamic-components/dynamic-component.decorator";
import { EntityFieldLabelComponent } from "../../../core/entity/entity-field-label/entity-field-label.component";
import { AuditRecord } from "../model/audit-record";

/**
 * Which fields one audited change touched, as labelled chips.
 *
 * A write can legitimately touch no visible field, and what that means depends
 * on the kind of write - a creation has no prior state to differ from, and a
 * deletion replicates as a tombstone stripped of its content - so each gets its
 * own wording rather than an empty cell.
 */
@DynamicComponent("ChangeHistoryChangedFields")
@Component({
  selector: "app-change-history-changed-fields",
  imports: [MatChipsModule, EntityFieldLabelComponent],
  template: `
    @if (fields().length > 0) {
      <mat-chip-set>
        @for (field of fields(); track field) {
          <mat-chip>
            <app-entity-field-label
              [field]="field"
              [entityType]="recordType()"
            ></app-entity-field-label>
          </mat-chip>
        }
      </mat-chip-set>
    } @else if (operation() === "create") {
      <span class="text-secondary" i18n="Change log changed fields"
        >new record</span
      >
    } @else if (operation() === "delete") {
      <span class="text-secondary" i18n="Change log changed fields"
        >record removed</span
      >
    } @else {
      <span class="text-secondary" i18n="Change log changed fields"
        >no visible field changes</span
      >
    }
  `,
})
export class ChangeHistoryChangedFieldsComponent extends ViewDirective<
  string[]
> {
  override entity = input<AuditRecord>();

  readonly fields = computed(() => this.value() ?? []);
  readonly operation = computed(() => this.entity()?.operation);
  /** the changed record's type, which the field labels are resolved against */
  readonly recordType = computed(() => this.entity()?.recordType);
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""