mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
AAE-41225 update typescript target to es2022 and fix FormService propagation (#11508)
* update targets * update targets * fixed FormService propagation [ci:force] * fixed FormService propagation [ci:force]
This commit is contained in:
@@ -23,7 +23,6 @@ import { FormsModule } from '@angular/forms';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { ErrorWidgetComponent } from '../error/error.component';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
import { filter, isObservable, Observable } from 'rxjs';
|
||||
@@ -87,12 +86,11 @@ export class AmountWidgetComponent extends WidgetComponent implements OnInit {
|
||||
}
|
||||
|
||||
constructor(
|
||||
public formService: FormService,
|
||||
@Optional() @Inject(ADF_AMOUNT_SETTINGS) settings: Observable<AmountWidgetSettings> | AmountWidgetSettings,
|
||||
private currencyPipe: CurrencyPipe,
|
||||
private translationService: TranslationService
|
||||
) {
|
||||
super(formService);
|
||||
super();
|
||||
if (isObservable(settings)) {
|
||||
settings.pipe(takeUntilDestroyed()).subscribe((data: AmountWidgetSettings) => {
|
||||
this.updateSettingsBasedProperties(data);
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { ViewerComponent } from '../../../../viewer';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { ErrorWidgetComponent } from '../error/error.component';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
|
||||
@@ -35,10 +34,6 @@ import { WidgetComponent } from '../widget.component';
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class BaseViewerWidgetComponent extends WidgetComponent implements OnInit {
|
||||
constructor(formService: FormService) {
|
||||
super(formService);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.field?.value) {
|
||||
if (Array.isArray(this.field.value) && this.field.value.length > 0) {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
@@ -37,10 +36,6 @@ import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
export class ButtonWidgetComponent extends WidgetComponent {
|
||||
readonly tooltipShowDelay: number = 500;
|
||||
|
||||
constructor(public formService: FormService) {
|
||||
super(formService);
|
||||
}
|
||||
|
||||
get hostClasses(): string {
|
||||
return `adf-button-widget ${this.field?.className || ''}`;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatCheckboxModule } from '@angular/material/checkbox';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { ErrorWidgetComponent } from '../error/error.component';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
|
||||
@@ -51,10 +50,4 @@ import { WidgetComponent } from '../widget.component';
|
||||
imports: [NgClass, MatCheckboxModule, FormsModule, TranslatePipe, ErrorWidgetComponent, NgIf],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class CheckboxWidgetComponent extends WidgetComponent {
|
||||
checkboxValue: boolean;
|
||||
|
||||
constructor(public formService: FormService) {
|
||||
super(formService);
|
||||
}
|
||||
}
|
||||
export class CheckboxWidgetComponent extends WidgetComponent {}
|
||||
|
||||
@@ -21,7 +21,6 @@ import { FormsModule } from '@angular/forms';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { ErrorWidgetComponent } from '../error/error.component';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
|
||||
@@ -43,8 +42,4 @@ import { WidgetComponent } from '../widget.component';
|
||||
imports: [NgIf, TranslatePipe, MatFormFieldModule, MatInputModule, FormsModule, ErrorWidgetComponent],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DecimalWidgetComponent extends WidgetComponent {
|
||||
constructor(public formService: FormService) {
|
||||
super(formService);
|
||||
}
|
||||
}
|
||||
export class DecimalWidgetComponent extends WidgetComponent {}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
|
||||
@Component({
|
||||
@@ -40,8 +39,4 @@ import { WidgetComponent } from '../widget.component';
|
||||
imports: [TranslatePipe],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DisplayTextWidgetComponent extends WidgetComponent {
|
||||
constructor(public formService: FormService) {
|
||||
super(formService);
|
||||
}
|
||||
}
|
||||
export class DisplayTextWidgetComponent extends WidgetComponent {}
|
||||
|
||||
@@ -21,7 +21,6 @@ import { animate, state, style, transition, trigger } from '@angular/animations'
|
||||
import { NgIf } from '@angular/common';
|
||||
import { Component, Input, OnChanges, SimpleChanges, ViewEncapsulation } from '@angular/core';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { ErrorMessageModel } from '../core';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
import { IconModule } from '../../../../icon/icon.module';
|
||||
@@ -64,13 +63,8 @@ export class ErrorWidgetComponent extends WidgetComponent implements OnChanges {
|
||||
required: string;
|
||||
|
||||
translateParameters: any = null;
|
||||
|
||||
subscriptAnimationState: string = '';
|
||||
|
||||
constructor(public formService: FormService) {
|
||||
super(formService);
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if (changes['required']) {
|
||||
this.required = changes.required.currentValue;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { FormFieldModel } from '../core';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
|
||||
@@ -48,10 +47,6 @@ export class HyperlinkWidgetComponent extends WidgetComponent implements OnInit
|
||||
linkUrl: string = '#';
|
||||
linkText: string = null;
|
||||
|
||||
constructor(public formService: FormService) {
|
||||
super(formService);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.field) {
|
||||
this.linkUrl = this.getHyperlinkUrl(this.field);
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, inject, ViewEncapsulation } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { EditJsonDialogSettings, EditJsonDialogComponent } from '../../../../dialogs/edit-json/edit-json.dialog';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
@@ -42,9 +41,7 @@ import { TranslatePipe } from '@ngx-translate/core';
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class JsonWidgetComponent extends WidgetComponent {
|
||||
constructor(public formService: FormService, private dialog: MatDialog) {
|
||||
super(formService);
|
||||
}
|
||||
private dialog = inject(MatDialog);
|
||||
|
||||
view() {
|
||||
const rawValue = this.field.value;
|
||||
|
||||
@@ -23,7 +23,6 @@ import { FormsModule } from '@angular/forms';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { ErrorWidgetComponent } from '../error/error.component';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
|
||||
@@ -45,8 +44,4 @@ import { WidgetComponent } from '../widget.component';
|
||||
imports: [MatFormFieldModule, NgIf, TranslatePipe, MatInputModule, FormsModule, ErrorWidgetComponent],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class MultilineTextWidgetComponentComponent extends WidgetComponent {
|
||||
constructor(public formService: FormService) {
|
||||
super(formService);
|
||||
}
|
||||
}
|
||||
export class MultilineTextWidgetComponentComponent extends WidgetComponent {}
|
||||
|
||||
@@ -18,13 +18,12 @@
|
||||
/* eslint-disable @angular-eslint/component-selector, @angular-eslint/no-input-rename */
|
||||
|
||||
import { NgIf } from '@angular/common';
|
||||
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { DecimalNumberPipe } from '../../../../pipes';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { ErrorWidgetComponent } from '../error/error.component';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
|
||||
@@ -50,9 +49,7 @@ import { WidgetComponent } from '../widget.component';
|
||||
export class NumberWidgetComponent extends WidgetComponent implements OnInit {
|
||||
displayValue: number;
|
||||
|
||||
constructor(public formService: FormService, private decimalNumberPipe: DecimalNumberPipe) {
|
||||
super(formService);
|
||||
}
|
||||
private decimalNumberPipe = inject(DecimalNumberPipe);
|
||||
|
||||
ngOnInit() {
|
||||
if (this.field.readOnly) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import { FormsModule } from '@angular/forms';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { ErrorWidgetComponent } from '../error/error.component';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
import { InputMaskDirective } from './text-mask.component';
|
||||
@@ -51,10 +50,6 @@ export class TextWidgetComponent extends WidgetComponent implements OnInit {
|
||||
placeholder: string;
|
||||
isMaskReversed: boolean;
|
||||
|
||||
constructor(public formService: FormService) {
|
||||
super(formService);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.field.params) {
|
||||
this.mask = this.field.params['inputMask'];
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
import { Component, ViewEncapsulation } from '@angular/core';
|
||||
import { MatListModule } from '@angular/material/list';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { WidgetComponent } from '../widget.component';
|
||||
import { IconModule } from '../../../../icon/icon.module';
|
||||
|
||||
@@ -48,8 +47,4 @@ import { IconModule } from '../../../../icon/icon.module';
|
||||
imports: [MatListModule, IconModule],
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class UnknownWidgetComponent extends WidgetComponent {
|
||||
constructor(public formService: FormService) {
|
||||
super(formService);
|
||||
}
|
||||
}
|
||||
export class UnknownWidgetComponent extends WidgetComponent {}
|
||||
|
||||
@@ -20,17 +20,20 @@ import { filter } from 'rxjs/operators';
|
||||
import { FormRulesEvent } from '../../events';
|
||||
import { FormFieldModel, FormModel } from './core';
|
||||
import { WidgetComponent } from './widget.component';
|
||||
import { FormService } from '@alfresco/adf-core';
|
||||
|
||||
describe('WidgetComponent', () => {
|
||||
let widget: WidgetComponent;
|
||||
let fixture: ComponentFixture<WidgetComponent>;
|
||||
let element: HTMLElement;
|
||||
let formService: FormService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [WidgetComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(WidgetComponent);
|
||||
formService = fixture.debugElement.injector.get(FormService);
|
||||
|
||||
element = fixture.nativeElement;
|
||||
widget = fixture.componentInstance;
|
||||
@@ -40,7 +43,7 @@ describe('WidgetComponent', () => {
|
||||
|
||||
describe('Events', () => {
|
||||
it('should click event be redirect on the form event service', fakeAsync(() => {
|
||||
widget.formService.formEvents.subscribe((event) => {
|
||||
formService.formEvents.subscribe((event) => {
|
||||
expect(event).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -48,7 +51,7 @@ describe('WidgetComponent', () => {
|
||||
}));
|
||||
|
||||
it('should click event be redirect on the form rules event service', fakeAsync(() => {
|
||||
widget.formService.formRulesEvent.pipe(filter((event) => event.type === 'click')).subscribe((event) => {
|
||||
formService.formRulesEvent.pipe(filter((event) => event.type === 'click')).subscribe((event) => {
|
||||
expect(event).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -95,7 +98,7 @@ describe('WidgetComponent', () => {
|
||||
const fakeField = new FormFieldModel(fakeForm, { id: 'fakeField', value: 'fakeValue' });
|
||||
|
||||
let lastValue: FormRulesEvent;
|
||||
widget.formService.formRulesEvent.subscribe((event) => (lastValue = event));
|
||||
formService.formRulesEvent.subscribe((event) => (lastValue = event));
|
||||
|
||||
widget.onFieldChanged(fakeField);
|
||||
expect(lastValue.type).toEqual('fieldValueChanged');
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
/* eslint-disable @angular-eslint/component-selector */
|
||||
|
||||
import { AfterViewInit, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { AfterViewInit, Component, EventEmitter, Input, Output, ViewEncapsulation, inject } from '@angular/core';
|
||||
import { FormFieldEvent, FormRulesEvent } from '../../events';
|
||||
import { FormService } from '../../services/form.service';
|
||||
import { FormFieldModel } from './core';
|
||||
@@ -60,7 +60,7 @@ export class WidgetComponent implements AfterViewInit {
|
||||
|
||||
touched: boolean = false;
|
||||
|
||||
constructor(public formService?: FormService) {}
|
||||
protected formService = inject(FormService);
|
||||
|
||||
hasField(): boolean {
|
||||
return !!this.field;
|
||||
|
||||
Reference in New Issue
Block a user