Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

4.7 KB
Raw Blame
<div mat-dialog-title>{{ data.categoryName }} › {{ data.rule.name }}</div>

<form
  class="d-flex flex-column h-100"
  [formGroup]="settingsForm"
  (ngSubmit)="onSubmit()"
>
  <div class="py-3" mat-dialog-content>
    @if (data.rule.configuration?.threshold; as threshold) {
      @if (
        data.rule.configuration.thresholdMin &&
        data.rule.configuration.thresholdMax
      ) {
        <div class="w-100">
          <h6 class="d-flex mb-0">
            <ng-container i18n>Threshold range</ng-container>:
            <gf-value
              class="ms-1"
              [isPercent]="threshold.unit === '%'"
              [locale]="data.locale"
              [precision]="2"
              [value]="settingsForm.get('thresholdMin')?.value"
            />
            <span class="mx-1">-</span>
            <gf-value
              [isPercent]="threshold.unit === '%'"
              [locale]="data.locale"
              [precision]="2"
              [value]="settingsForm.get('thresholdMax')?.value"
            />
          </h6>
          <div class="align-items-center d-flex w-100">
            <gf-value
              [isPercent]="threshold.unit === '%'"
              [locale]="data.locale"
              [precision]="2"
              [value]="threshold.min"
            />
            <mat-slider
              class="flex-grow-1"
              [max]="threshold.max"
              [min]="threshold.min"
              [step]="threshold.step"
            >
              <input formControlName="thresholdMin" matSliderStartThumb />
              <input formControlName="thresholdMax" matSliderEndThumb />
            </mat-slider>
            <gf-value
              [isPercent]="threshold.unit === '%'"
              [locale]="data.locale"
              [precision]="2"
              [value]="threshold.max"
            />
          </div>
        </div>
      } @else {
        <div
          class="w-100"
          [class.d-none]="!data.rule.configuration.thresholdMin"
        >
          <h6 class="d-flex mb-0">
            <ng-container i18n>Threshold Min</ng-container>:
            <gf-value
              class="ms-1"
              [isPercent]="threshold.unit === '%'"
              [locale]="data.locale"
              [precision]="2"
              [value]="settingsForm.get('thresholdMin')?.value"
            />
          </h6>
          <div class="align-items-center d-flex w-100">
            <gf-value
              [isPercent]="threshold.unit === '%'"
              [locale]="data.locale"
              [precision]="2"
              [value]="threshold.min"
            />
            <mat-slider
              class="flex-grow-1"
              name="thresholdMin"
              [max]="threshold.max"
              [min]="threshold.min"
              [step]="threshold.step"
            >
              <input formControlName="thresholdMin" matSliderThumb />
            </mat-slider>
            <gf-value
              [isPercent]="threshold.unit === '%'"
              [locale]="data.locale"
              [precision]="2"
              [value]="threshold.max"
            />
          </div>
        </div>
        <div
          class="w-100"
          [class.d-none]="!data.rule.configuration.thresholdMax"
        >
          <h6 class="d-flex mb-0">
            <ng-container i18n>Threshold Max</ng-container>:
            <gf-value
              class="ms-1"
              [isPercent]="threshold.unit === '%'"
              [locale]="data.locale"
              [precision]="2"
              [value]="settingsForm.get('thresholdMax')?.value"
            />
          </h6>
          <div class="align-items-center d-flex w-100">
            <gf-value
              [isPercent]="threshold.unit === '%'"
              [locale]="data.locale"
              [precision]="2"
              [value]="threshold.min"
            />
            <mat-slider
              class="flex-grow-1"
              name="thresholdMax"
              [max]="threshold.max"
              [min]="threshold.min"
              [step]="threshold.step"
            >
              <input formControlName="thresholdMax" matSliderThumb />
            </mat-slider>
            <gf-value
              [isPercent]="threshold.unit === '%'"
              [locale]="data.locale"
              [precision]="2"
              [value]="threshold.max"
            />
          </div>
        </div>
      }
    }
  </div>

  <div align="end" mat-dialog-actions>
    <button mat-button type="button" (click)="dialogRef.close()">
      <ng-container i18n>Close</ng-container>
    </button>
    <button
      color="primary"
      mat-flat-button
      type="submit"
      [disabled]="!settingsForm.dirty"
    >
      <ng-container i18n>Save</ng-container>
    </button>
  </div>
</form>