<commit_before>import {Component, forwardRef, Input, OnInit, Optional} from '@angular/core';
import {ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR} from '@angular/forms';
import {BudgetData} from "../../../budgets/budget.model";
import {TransactionDateValidatorDirective} from "../../../transactions/transaction-date-validator.directive";

@Component({
  selector: 'ec-date-field',
  styles: [`
  `],
  template: `
      <mat-form-field *ngIf="editMode; else textDisplay">
          <input #input matInput type="date" [value]="value" (input)="value=Date.parse(input.value)" [formControl]="control" class="value"/>
            <mat-error>Date is outside of budget range</mat-error>
      </mat-form-field>
      <ng-template #textDisplay>
        <span class="value">{{ value | date:'mediumDate' }}</span>
      </ng-template>
  `,
  providers: [
    { provide: NG_VALUE_ACCESSOR, multi: true, useExisting: forwardRef(() => DateFieldComponent )}
  ]
})
export class DateFieldComponent implements OnInit, ControlValueAccessor {

  @Input() value: Date;
  @Input() editMode: boolean;
  // TODO: this should NOT be needed
  /* tslint:disable no-input-rename */
  @Input('ecValidateWithinBudget') budget: BudgetData = {};
  @Input() errorMessage: string;

  control = new FormControl();

  private onChange: Function = (_: any) => {};
  private onTouch: Function = () => {};

  constructor(
    @Optional()
    private validator: TransactionDateValidatorDirective
  ) { }
<commit_msg>date field fix due to angular upgrade<commit_after>import {Component, forwardRef, Input, OnInit, Optional} from '@angular/core';
import {ControlValueAccessor, FormControl, NG_VALUE_ACCESSOR} from '@angular/forms';
import {BudgetData} from "../../../budgets/budget.model";
import {TransactionDateValidatorDirective} from "../../../transactions/transaction-date-validator.directive";

@Component({
  selector: 'ec-date-field',
  styles: [`
  `],
  template: `
      <mat-form-field *ngIf="editMode; else textDisplay">
          <input #input matInput type="date" [value]="value" (input)="value=input.value" [formControl]="control" class="value"/>
            <mat-error>Date is outside of budget range</mat-error>
      </mat-form-field>
      <ng-template #textDisplay>
        <span class="value">{{ value | date:'mediumDate' }}</span>
      </ng-template>
  `,
  providers: [
    { provide: NG_VALUE_ACCESSOR, multi: true, useExisting: forwardRef(() => DateFieldComponent )}
  ]
})
export class DateFieldComponent implements OnInit, ControlValueAccessor {

  @Input() value: Date;
  @Input() editMode: boolean;
  // TODO: this should NOT be needed
  /* tslint:disable no-input-rename */
  @Input('ecValidateWithinBudget') budget: BudgetData = {};
  @Input() errorMessage: string;

  control = new FormControl();

  private onChange: Function = (_: any) => {};
  private onTouch: Function = () => {};

  constructor(
    @Optional()
    private validator: TransactionDateValidatorDirective
  ) { }

{'fraction_non_alphanumeric': 0.15784182305630026, 'fraction_numerical': 0.0, 'mean_word_length': 4.128865979381444, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6202871', 'n_tokens_mistral': 887, 'n_tokens_neox': 882, 'n_words': 212}