refactor: move custom adapter to providers
All checks were successful
Build and Deploy Angular App / build (push) Successful in 48s

This commit is contained in:
Polianin Nikita 2024-08-26 02:16:37 +03:00
parent 7a9bca86bc
commit dba0d3cd62

View File

@ -2,7 +2,7 @@ import {Component} from '@angular/core';
import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms"; import {FormBuilder, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {NavigationService} from "@service/navigation.service"; import {NavigationService} from "@service/navigation.service";
import SetupService from "@api/v1/setup.service"; import SetupService from "@api/v1/setup.service";
import {DateAdapter, MatNativeDateModule} from "@angular/material/core"; import {MAT_DATE_LOCALE, MatNativeDateModule} from "@angular/material/core";
import {MatFormFieldModule} from "@angular/material/form-field"; import {MatFormFieldModule} from "@angular/material/form-field";
import {MatSelectModule} from "@angular/material/select"; import {MatSelectModule} from "@angular/material/select";
import {MatInput} from "@angular/material/input"; import {MatInput} from "@angular/material/input";
@ -25,17 +25,16 @@ import {MatDatepickerModule} from "@angular/material/datepicker";
MatDatepickerModule, MatDatepickerModule,
MatNativeDateModule MatNativeDateModule
], ],
templateUrl: './schedule.component.html' templateUrl: './schedule.component.html',
providers: [{provide: MAT_DATE_LOCALE, useValue: 'ru-RU'}]
}) })
export class ScheduleComponent { export class ScheduleComponent {
protected scheduleSettings!: FormGroup; protected scheduleSettings!: FormGroup;
constructor( constructor(private navigationService: NavigationService, formBuilder: FormBuilder, private api: SetupService) {
private navigationService: NavigationService, private formBuilder: FormBuilder, private api: SetupService, private _adapter: DateAdapter<any>) { this.scheduleSettings = formBuilder.group({
this._adapter.setLocale('ru'); cron: ['0 */6 * * *', Validators.pattern(/^(\S+\s){4}\S$/)],
this.scheduleSettings = this.formBuilder.group({
cron: ['0 */6 * * *', Validators.pattern(/^([^\s]+\s){4}[^\s]{1}$/)],
startTerm: ['', Validators.required] startTerm: ['', Validators.required]
} }
); );