Browse Source

Refactoring

pull/12151/head
Chantsova Ekaterina 2 years ago
parent
commit
ccc2f7592d
  1. 3
      ui-ngx/src/app/shared/components/aggregation/aggregation-type-select.component.ts
  2. 3
      ui-ngx/src/app/shared/components/time/quick-time-interval.component.ts

3
ui-ngx/src/app/shared/components/aggregation/aggregation-type-select.component.ts

@ -21,6 +21,7 @@ import { coerceBoolean } from '@shared/decorators/coercion';
import { MatFormFieldAppearance, SubscriptSizing } from '@angular/material/form-field'; import { MatFormFieldAppearance, SubscriptSizing } from '@angular/material/form-field';
import { aggregationTranslations, AggregationType } from '@shared/models/time/time.models'; import { aggregationTranslations, AggregationType } from '@shared/models/time/time.models';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { isEqual } from '@core/utils';
@Component({ @Component({
selector: 'tb-aggregation-type-select', selector: 'tb-aggregation-type-select',
@ -108,7 +109,7 @@ export class AggregationTypeSelectComponent implements ControlValueAccessor, OnI
} }
ngOnChanges({allowedAggregationTypes}: SimpleChanges): void { ngOnChanges({allowedAggregationTypes}: SimpleChanges): void {
if (!allowedAggregationTypes.firstChange && allowedAggregationTypes.currentValue !== allowedAggregationTypes.previousValue) { if (!allowedAggregationTypes.firstChange && !isEqual(allowedAggregationTypes.currentValue, allowedAggregationTypes.previousValue)) {
this.aggregationTypes = this.allowedAggregationTypes?.length ? this.allowedAggregationTypes : this.allAggregationTypes; this.aggregationTypes = this.allowedAggregationTypes?.length ? this.allowedAggregationTypes : this.allAggregationTypes;
const currentAggregationType: AggregationType = this.aggregationTypeFormGroup.get('aggregationType').value; const currentAggregationType: AggregationType = this.aggregationTypeFormGroup.get('aggregationType').value;
if (currentAggregationType && !this.aggregationTypes.includes(currentAggregationType)) { if (currentAggregationType && !this.aggregationTypes.includes(currentAggregationType)) {

3
ui-ngx/src/app/shared/components/time/quick-time-interval.component.ts

@ -20,6 +20,7 @@ import { QuickTimeInterval, QuickTimeIntervalTranslationMap } from '@shared/mode
import { MatFormFieldAppearance, SubscriptSizing } from '@angular/material/form-field'; import { MatFormFieldAppearance, SubscriptSizing } from '@angular/material/form-field';
import { coerceBoolean } from '@shared/decorators/coercion'; import { coerceBoolean } from '@shared/decorators/coercion';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { isEqual } from '@core/utils';
@Component({ @Component({
selector: 'tb-quick-time-interval', selector: 'tb-quick-time-interval',
@ -90,7 +91,7 @@ export class QuickTimeIntervalComponent implements OnInit, ControlValueAccessor,
} }
ngOnChanges({allowedIntervals}: SimpleChanges): void { ngOnChanges({allowedIntervals}: SimpleChanges): void {
if (!allowedIntervals.firstChange && allowedIntervals.currentValue !== allowedIntervals.previousValue) { if (!allowedIntervals.firstChange && !isEqual(allowedIntervals.currentValue, allowedIntervals.previousValue)) {
this.intervals = this.allowedIntervals?.length ? this.allowedIntervals : this.allAvailableIntervals; this.intervals = this.allowedIntervals?.length ? this.allowedIntervals : this.allAvailableIntervals;
const currentInterval: QuickTimeInterval = this.quickIntervalFormGroup.get('interval').value; const currentInterval: QuickTimeInterval = this.quickIntervalFormGroup.get('interval').value;
if (currentInterval && !this.intervals.includes(currentInterval)) { if (currentInterval && !this.intervals.includes(currentInterval)) {

Loading…
Cancel
Save