mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
fix eslint warnigs for core project (#7506)
This commit is contained in:
@@ -157,6 +157,7 @@ export abstract class FormBaseComponent {
|
||||
|
||||
/**
|
||||
* Invoked when user clicks outcome button.
|
||||
*
|
||||
* @param outcome Form outcome model
|
||||
*/
|
||||
onOutcomeClicked(outcome: FormOutcomeModel): boolean {
|
||||
|
@@ -33,7 +33,6 @@ import {
|
||||
import { FormRenderingService } from './../../services/form-rendering.service';
|
||||
import { WidgetVisibilityService } from './../../services/widget-visibility.service';
|
||||
import { FormFieldModel } from './../widgets/core/form-field.model';
|
||||
import { WidgetComponent } from './../widgets/widget.component';
|
||||
|
||||
declare const adf: any;
|
||||
|
||||
@@ -93,7 +92,7 @@ export class FormFieldComponent implements OnInit, OnDestroy {
|
||||
if (componentType) {
|
||||
const factory = this.componentFactoryResolver.resolveComponentFactory(componentType);
|
||||
this.componentRef = this.container.createComponent(factory);
|
||||
const instance = <WidgetComponent> this.componentRef.instance;
|
||||
const instance = this.componentRef.instance;
|
||||
instance.field = this.field;
|
||||
instance.fieldChanged.subscribe((field) => {
|
||||
if (field && this.field.form) {
|
||||
@@ -136,7 +135,7 @@ export class FormFieldComponent implements OnInit, OnDestroy {
|
||||
|
||||
const metadata = {
|
||||
selector: `runtime-component-${type}`,
|
||||
template: template
|
||||
template
|
||||
};
|
||||
|
||||
const factory = this.createComponentFactorySync(this.compiler, metadata, componentInfo.class);
|
||||
|
@@ -44,45 +44,45 @@ import { TextWidgetComponent } from './widgets';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { DebugElement } from '@angular/core';
|
||||
|
||||
function typeIntoInput(targetInput: HTMLInputElement, message: string) {
|
||||
const typeIntoInput = (targetInput: HTMLInputElement, message: string) => {
|
||||
expect(targetInput).not.toBeNull('Expected input to set to be valid and not null');
|
||||
targetInput.value = message;
|
||||
targetInput.dispatchEvent(new Event('input'));
|
||||
}
|
||||
};
|
||||
|
||||
function typeIntoDate(targetInput: DebugElement, date: { srcElement: { value: string } }) {
|
||||
const typeIntoDate = (targetInput: DebugElement, date: { srcElement: { value: string } }) => {
|
||||
expect(targetInput).not.toBeNull('Expected input to set to be valid and not null');
|
||||
targetInput.triggerEventHandler('change', date);
|
||||
}
|
||||
};
|
||||
|
||||
function expectElementToBeHidden(targetElement: HTMLElement): void {
|
||||
const expectElementToBeHidden = (targetElement: HTMLElement): void => {
|
||||
expect(targetElement).not.toBeNull();
|
||||
expect(targetElement).toBeDefined();
|
||||
expect(targetElement.hidden).toBe(true, `${targetElement.id} should be hidden but it is not`);
|
||||
}
|
||||
};
|
||||
|
||||
function expectElementToBeVisible(targetElement: HTMLElement): void {
|
||||
const expectElementToBeVisible = (targetElement: HTMLElement): void => {
|
||||
expect(targetElement).not.toBeNull();
|
||||
expect(targetElement).toBeDefined();
|
||||
expect(targetElement.hidden).toBe(false, `${targetElement.id} should be visibile but it is not`);
|
||||
}
|
||||
};
|
||||
|
||||
function expectInputElementValueIs(targetElement: HTMLInputElement, value: string): void {
|
||||
const expectInputElementValueIs = (targetElement: HTMLInputElement, value: string): void => {
|
||||
expect(targetElement).not.toBeNull();
|
||||
expect(targetElement).toBeDefined();
|
||||
expect(targetElement.value).toBe(value, `invalid value for ${targetElement.name}`);
|
||||
}
|
||||
};
|
||||
|
||||
function expectElementToBeInvalid(fieldId: string, fixture: ComponentFixture<FormRendererComponent>): void {
|
||||
const expectElementToBeInvalid = (fieldId: string, fixture: ComponentFixture<FormRendererComponent>): void => {
|
||||
const invalidElementContainer = fixture.nativeElement.querySelector(`#field-${fieldId}-container .adf-invalid`);
|
||||
expect(invalidElementContainer).not.toBeNull();
|
||||
expect(invalidElementContainer).toBeDefined();
|
||||
}
|
||||
};
|
||||
|
||||
function expectElementToBeValid(fieldId: string, fixture: ComponentFixture<FormRendererComponent>): void {
|
||||
const expectElementToBeValid = (fieldId: string, fixture: ComponentFixture<FormRendererComponent>): void => {
|
||||
const invalidElementContainer = fixture.nativeElement.querySelector(`#field-${fieldId}-container .adf-invalid`);
|
||||
expect(invalidElementContainer).toBeNull();
|
||||
}
|
||||
};
|
||||
|
||||
describe('Form Renderer Component', () => {
|
||||
|
||||
@@ -630,7 +630,7 @@ describe('Form Renderer Component', () => {
|
||||
describe('Custom Widget', () => {
|
||||
|
||||
it('Should be able to correctly display a custom process cloud widget', async () => {
|
||||
formRenderingService.register({ 'bananaforevah': () => TextWidgetComponent }, true);
|
||||
formRenderingService.register({ bananaforevah: () => TextWidgetComponent }, true);
|
||||
formRendererComponent.formDefinition = formService.parseForm(customWidgetForm.formRepresentation.formDefinition);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
@@ -641,7 +641,7 @@ describe('Form Renderer Component', () => {
|
||||
});
|
||||
|
||||
it('Should be able to correctly use visibility in a custom process cloud widget ', async () => {
|
||||
formRenderingService.register({ 'bananaforevah': () => TextWidgetComponent }, true);
|
||||
formRenderingService.register({ bananaforevah: () => TextWidgetComponent }, true);
|
||||
formRendererComponent.formDefinition = formService.parseForm(customWidgetFormWithVisibility.formRepresentation.formDefinition);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
@@ -32,7 +32,7 @@ export const formDisplayValueVisibility = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Text0bq3ar',
|
||||
name: 'Text',
|
||||
@@ -47,7 +47,7 @@ export const formDisplayValueVisibility = {
|
||||
params: { existingColspan: 1, maxColspan: 2 }
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'Displayvalue0g6092',
|
||||
name: 'Display value',
|
||||
@@ -101,7 +101,7 @@ export const formDisplayValueForm = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'DisplayValueColspan',
|
||||
name: 'DisplayValueColspan',
|
||||
@@ -240,7 +240,7 @@ export const formDisplayValueForm = {
|
||||
}
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'Text0howrc',
|
||||
name: 'Text',
|
||||
@@ -342,7 +342,7 @@ export const formDisplayValueCombinedVisibility = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Text0bq3ar',
|
||||
name: 'Text',
|
||||
@@ -357,7 +357,7 @@ export const formDisplayValueCombinedVisibility = {
|
||||
params: { existingColspan: 1, maxColspan: 2 }
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'Displayvalue0g6092',
|
||||
name: 'Display value',
|
||||
@@ -402,7 +402,7 @@ export const formDisplayValueCombinedVisibility = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'TextTwo',
|
||||
name: 'TextTwo',
|
||||
@@ -417,7 +417,7 @@ export const formDisplayValueCombinedVisibility = {
|
||||
params: { existingColspan: 1, maxColspan: 2 }
|
||||
}
|
||||
],
|
||||
'2': []
|
||||
2: []
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -445,7 +445,7 @@ export const formNumberWidgetVisibility = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Number1',
|
||||
name: 'Number1',
|
||||
@@ -462,7 +462,7 @@ export const formNumberWidgetVisibility = {
|
||||
}
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'Number2',
|
||||
name: 'Number2',
|
||||
@@ -520,7 +520,7 @@ export const formNumberTextJson = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'NumberColspan',
|
||||
name: 'NumberColspan',
|
||||
@@ -582,7 +582,7 @@ export const formNumberTextJson = {
|
||||
}
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'Text',
|
||||
name: 'Text',
|
||||
@@ -763,7 +763,7 @@ export const formRequiredNumberWidget = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Number1',
|
||||
name: 'Number1',
|
||||
@@ -780,7 +780,7 @@ export const formRequiredNumberWidget = {
|
||||
}
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'Number2',
|
||||
name: 'Number2',
|
||||
@@ -839,7 +839,7 @@ export const colspanForm = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Number0u0kiv',
|
||||
name: 'NumberColspan',
|
||||
@@ -866,7 +866,7 @@ export const colspanForm = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Number00fuuk',
|
||||
name: 'Number',
|
||||
@@ -884,7 +884,7 @@ export const colspanForm = {
|
||||
}
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'Number03u9d4',
|
||||
name: 'Number',
|
||||
@@ -911,7 +911,7 @@ export const colspanForm = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Text04sjhr',
|
||||
name: 'Text',
|
||||
@@ -957,7 +957,7 @@ export const numberNotRequiredForm = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Number0x8cbv',
|
||||
name: 'Number',
|
||||
@@ -971,7 +971,7 @@ export const numberNotRequiredForm = {
|
||||
params: { existingColspan: 1, maxColspan: 2 }
|
||||
}
|
||||
],
|
||||
'2': []
|
||||
2: []
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -999,7 +999,7 @@ export const numberMinMaxForm = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Number0him2z',
|
||||
name: 'Number',
|
||||
@@ -1016,7 +1016,7 @@ export const numberMinMaxForm = {
|
||||
}
|
||||
}
|
||||
],
|
||||
'2': []
|
||||
2: []
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -1043,7 +1043,7 @@ export const textWidgetVisibility = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'textOne',
|
||||
name: 'textOne',
|
||||
@@ -1058,7 +1058,7 @@ export const textWidgetVisibility = {
|
||||
params: { existingColspan: 1, maxColspan: 2 }
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'textTwo',
|
||||
name: 'textTwo',
|
||||
@@ -1091,7 +1091,7 @@ export const textWidgetVisibility = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'textThree',
|
||||
name: 'textThree',
|
||||
@@ -1125,7 +1125,7 @@ export const textWidgetVisibility = {
|
||||
params: { existingColspan: 1, maxColspan: 2 }
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'textFour',
|
||||
name: 'textFour',
|
||||
@@ -1187,7 +1187,7 @@ export const numberWidgetVisibilityForm = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Text0hs0gt',
|
||||
name: 'TextOne',
|
||||
@@ -1236,7 +1236,7 @@ export const numberWidgetVisibilityForm = {
|
||||
}
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'Text0cuqet',
|
||||
name: 'TextTwo',
|
||||
@@ -1280,7 +1280,7 @@ export const radioWidgetVisibiltyForm = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Text0cee7g',
|
||||
name: 'Text',
|
||||
@@ -1295,7 +1295,7 @@ export const radioWidgetVisibiltyForm = {
|
||||
params: { existingColspan: 1, maxColspan: 2 }
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'Radiobuttons03rkbo',
|
||||
name: 'Radio buttons',
|
||||
@@ -1352,7 +1352,7 @@ export const customWidgetForm = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Text0vdi18',
|
||||
name: 'herejustoshowstandardones',
|
||||
@@ -1371,7 +1371,7 @@ export const customWidgetForm = {
|
||||
}
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'bananaforevah0k8gui',
|
||||
name: 'bananaforevah',
|
||||
@@ -1416,7 +1416,7 @@ export const customWidgetFormWithVisibility = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Text0vdi18',
|
||||
name: 'herejustoshowstandardones',
|
||||
@@ -1435,7 +1435,7 @@ export const customWidgetFormWithVisibility = {
|
||||
}
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'bananaforevah0k8gui',
|
||||
name: 'bananaforevah',
|
||||
@@ -1488,7 +1488,7 @@ export const formDateVisibility = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Date0hwq20',
|
||||
name: 'Date',
|
||||
@@ -1508,7 +1508,7 @@ export const formDateVisibility = {
|
||||
dateDisplayFormat: 'YYYY-MM-DD'
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: 'Text0pqd1u',
|
||||
name: 'Text',
|
||||
@@ -1545,7 +1545,7 @@ export const formDateVisibility = {
|
||||
tab: null,
|
||||
numberOfColumns: 2,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'Text0uyqd3',
|
||||
name: 'Text',
|
||||
@@ -1573,7 +1573,7 @@ export const formDateVisibility = {
|
||||
}
|
||||
}
|
||||
],
|
||||
'2': []
|
||||
2: []
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@@ -46,7 +46,7 @@ describe('AmountWidgetComponent', () => {
|
||||
it('should setup currency from field', () => {
|
||||
const currency = 'UAH';
|
||||
widget.field = new FormFieldModel(null, {
|
||||
currency: currency
|
||||
currency
|
||||
});
|
||||
|
||||
widget.ngOnInit();
|
||||
|
@@ -37,7 +37,7 @@ export class ContainerWidgetComponentModel extends ContainerModel {
|
||||
let allowCollapse = false;
|
||||
|
||||
if (this.isGroup() && this.field.params['allowCollapse']) {
|
||||
allowCollapse = <boolean> this.field.params['allowCollapse'];
|
||||
allowCollapse = this.field.params['allowCollapse'];
|
||||
}
|
||||
|
||||
return allowCollapse;
|
||||
@@ -47,7 +47,7 @@ export class ContainerWidgetComponentModel extends ContainerModel {
|
||||
let collapseByDefault = false;
|
||||
|
||||
if (this.isCollapsible() && this.field.params['collapseByDefault']) {
|
||||
collapseByDefault = <boolean> this.field.params['collapseByDefault'];
|
||||
collapseByDefault = this.field.params['collapseByDefault'];
|
||||
}
|
||||
|
||||
return collapseByDefault;
|
||||
|
@@ -123,9 +123,9 @@ describe('ContainerWidgetComponent', () => {
|
||||
type: 'container',
|
||||
tab: null,
|
||||
fields: {
|
||||
'1' : [{ id: '1' }, { id: '2' }, { id: '3' }],
|
||||
'2' : [{ id: '4' }, { id: '5' }],
|
||||
'3' : [{ id: '6' }]
|
||||
1 : [{ id: '1' }, { id: '2' }, { id: '3' }],
|
||||
2 : [{ id: '4' }, { id: '5' }],
|
||||
3 : [{ id: '6' }]
|
||||
}
|
||||
};
|
||||
|
||||
@@ -150,7 +150,7 @@ describe('ContainerWidgetComponent', () => {
|
||||
type: 'container',
|
||||
tab: null,
|
||||
fields: {
|
||||
'1': [
|
||||
1: [
|
||||
{
|
||||
id: 'a',
|
||||
colspan: 2,
|
||||
@@ -192,7 +192,7 @@ describe('ContainerWidgetComponent', () => {
|
||||
rowspan: 1
|
||||
}
|
||||
],
|
||||
'2': [
|
||||
2: [
|
||||
{
|
||||
id: '1',
|
||||
rowspan: 3,
|
||||
@@ -208,7 +208,7 @@ describe('ContainerWidgetComponent', () => {
|
||||
colspan: 2
|
||||
}
|
||||
],
|
||||
'3': [
|
||||
3: [
|
||||
{
|
||||
id: 'white'
|
||||
},
|
||||
@@ -265,8 +265,8 @@ describe('ContainerWidgetComponent', () => {
|
||||
widget.content = container;
|
||||
|
||||
expect(widget.getColumnWith(undefined)).toBe('25');
|
||||
expect(widget.getColumnWith(<FormFieldModel> { colspan: 1 })).toBe('25');
|
||||
expect(widget.getColumnWith(<FormFieldModel> { colspan: 3 })).toBe('75');
|
||||
expect(widget.getColumnWith({ colspan: 1 } as FormFieldModel)).toBe('25');
|
||||
expect(widget.getColumnWith({ colspan: 3 } as FormFieldModel)).toBe('75');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -97,9 +97,8 @@ export class ContainerWidgetComponent extends WidgetComponent implements OnInit,
|
||||
private getMaxColumnFieldSize(): number {
|
||||
let maxFieldSize = 0;
|
||||
if (this.content?.columns?.length > 0) {
|
||||
maxFieldSize = this.content?.columns?.reduce((prevColumn, currentColumn) => {
|
||||
return currentColumn.fields.length > prevColumn?.fields?.length ? currentColumn : prevColumn;
|
||||
})?.fields?.length;
|
||||
maxFieldSize = this.content?.columns?.reduce((prevColumn, currentColumn) =>
|
||||
currentColumn.fields.length > prevColumn?.fields?.length ? currentColumn : prevColumn)?.fields?.length;
|
||||
}
|
||||
return maxFieldSize;
|
||||
}
|
||||
|
@@ -39,12 +39,12 @@ describe('ContentWidgetComponent', () => {
|
||||
let processContentService: ProcessContentService;
|
||||
let serviceContent: ContentService;
|
||||
|
||||
function createFakeImageBlob() {
|
||||
const createFakeImageBlob = () => {
|
||||
const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==');
|
||||
return new Blob([data], { type: 'image/png' });
|
||||
}
|
||||
};
|
||||
|
||||
function createFakePdfBlob(): Blob {
|
||||
const createFakePdfBlob = (): Blob => {
|
||||
const pdfData = atob(
|
||||
'JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' +
|
||||
'IC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAv' +
|
||||
@@ -60,7 +60,7 @@ describe('ContentWidgetComponent', () => {
|
||||
'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' +
|
||||
'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G');
|
||||
return new Blob([pdfData], { type: 'application/pdf' });
|
||||
}
|
||||
};
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
@@ -118,7 +118,7 @@ describe('ContentWidgetComponent', () => {
|
||||
|
||||
const contentId = 1;
|
||||
const change = new SimpleChange(null, contentId, true);
|
||||
component.ngOnChanges({ 'id': change });
|
||||
component.ngOnChanges({ id: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
@@ -129,7 +129,7 @@ describe('ContentWidgetComponent', () => {
|
||||
created: 1490354907883,
|
||||
createdBy: {
|
||||
id: 2,
|
||||
firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com'
|
||||
firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com'
|
||||
},
|
||||
relatedContent: false,
|
||||
contentAvailable: true,
|
||||
@@ -161,7 +161,7 @@ describe('ContentWidgetComponent', () => {
|
||||
|
||||
const contentId = 1;
|
||||
const change = new SimpleChange(null, contentId, true);
|
||||
component.ngOnChanges({ 'id': change });
|
||||
component.ngOnChanges({ id: change });
|
||||
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
status: 200,
|
||||
@@ -172,7 +172,7 @@ describe('ContentWidgetComponent', () => {
|
||||
created: 1490354907883,
|
||||
createdBy: {
|
||||
id: 2,
|
||||
firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com'
|
||||
firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com'
|
||||
},
|
||||
relatedContent: false,
|
||||
contentAvailable: true,
|
||||
@@ -189,7 +189,7 @@ describe('ContentWidgetComponent', () => {
|
||||
|
||||
const contentId = 1;
|
||||
const change = new SimpleChange(null, contentId, true);
|
||||
component.ngOnChanges({ 'id': change });
|
||||
component.ngOnChanges({ id: change });
|
||||
|
||||
component.contentLoaded.subscribe(() => {
|
||||
fixture.detectChanges();
|
||||
@@ -211,7 +211,7 @@ describe('ContentWidgetComponent', () => {
|
||||
created: 1490354907883,
|
||||
createdBy: {
|
||||
id: 2,
|
||||
firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com'
|
||||
firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com'
|
||||
},
|
||||
relatedContent: false,
|
||||
contentAvailable: false,
|
||||
@@ -235,7 +235,7 @@ describe('ContentWidgetComponent', () => {
|
||||
created: 1490354907883,
|
||||
createdBy: {
|
||||
id: 2,
|
||||
firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com'
|
||||
firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com'
|
||||
},
|
||||
relatedContent: false,
|
||||
contentAvailable: true,
|
||||
@@ -271,7 +271,7 @@ describe('ContentWidgetComponent', () => {
|
||||
created: 1490354907883,
|
||||
createdBy: {
|
||||
id: 2,
|
||||
firstName: 'admin', 'lastName': 'admin', 'email': 'administrator@admin.com'
|
||||
firstName: 'admin', lastName: 'admin', email: 'administrator@admin.com'
|
||||
},
|
||||
relatedContent: false,
|
||||
contentAvailable: true,
|
||||
|
@@ -78,7 +78,7 @@ describe('FormFieldValidator', () => {
|
||||
required: true
|
||||
});
|
||||
|
||||
field.emptyOption = <FormFieldOption> { id: '<empty>' };
|
||||
field.emptyOption = { id: '<empty>' } as FormFieldOption;
|
||||
expect(validator.validate(field)).toBeFalsy();
|
||||
|
||||
field.value = '<non-empty>';
|
||||
@@ -94,7 +94,7 @@ describe('FormFieldValidator', () => {
|
||||
selectionType: 'multiple'
|
||||
});
|
||||
|
||||
field.emptyOption = <FormFieldOption> { id: 'empty' };
|
||||
field.emptyOption = { id: 'empty' } as FormFieldOption;
|
||||
expect(validator.validate(field)).toBeFalsy();
|
||||
|
||||
field.value = [];
|
||||
|
@@ -816,31 +816,31 @@ describe('FormFieldModel', () => {
|
||||
form = new FormModel({
|
||||
variables: [
|
||||
{
|
||||
'id': 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2',
|
||||
'name': 'name2',
|
||||
'type': 'string',
|
||||
'value': 'default hello'
|
||||
id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2',
|
||||
name: 'name2',
|
||||
type: 'string',
|
||||
value: 'default hello'
|
||||
}
|
||||
],
|
||||
processVariables: [
|
||||
{
|
||||
'serviceName': 'denys-variable-mapping-rb',
|
||||
'serviceFullName': 'denys-variable-mapping-rb',
|
||||
'serviceVersion': '',
|
||||
'appName': 'denys-variable-mapping',
|
||||
'appVersion': '',
|
||||
'serviceType': null,
|
||||
'id': 3,
|
||||
'type': 'string',
|
||||
'name': 'variables.name1',
|
||||
'createTime': 1566989626284,
|
||||
'lastUpdatedTime': 1566989626284,
|
||||
'executionId': null,
|
||||
'value': 'hello',
|
||||
'markedAsDeleted': false,
|
||||
'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
||||
'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
||||
'taskVariable': true
|
||||
serviceName: 'denys-variable-mapping-rb',
|
||||
serviceFullName: 'denys-variable-mapping-rb',
|
||||
serviceVersion: '',
|
||||
appName: 'denys-variable-mapping',
|
||||
appVersion: '',
|
||||
serviceType: null,
|
||||
id: 3,
|
||||
type: 'string',
|
||||
name: 'variables.name1',
|
||||
createTime: 1566989626284,
|
||||
lastUpdatedTime: 1566989626284,
|
||||
executionId: null,
|
||||
value: 'hello',
|
||||
markedAsDeleted: false,
|
||||
processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
||||
taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
||||
taskVariable: true
|
||||
}
|
||||
]
|
||||
});
|
||||
|
@@ -151,30 +151,30 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
this.name = json.name;
|
||||
this.type = json.type;
|
||||
this.roles = json.roles;
|
||||
this._required = <boolean> json.required;
|
||||
this._readOnly = <boolean> json.readOnly || json.type === 'readonly';
|
||||
this.overrideId = <boolean> json.overrideId;
|
||||
this._required = json.required;
|
||||
this._readOnly = json.readOnly || json.type === 'readonly';
|
||||
this.overrideId = json.overrideId;
|
||||
this.tab = json.tab;
|
||||
this.restUrl = json.restUrl;
|
||||
this.restResponsePath = json.restResponsePath;
|
||||
this.restIdProperty = json.restIdProperty;
|
||||
this.restLabelProperty = json.restLabelProperty;
|
||||
this.colspan = <number> json.colspan;
|
||||
this.rowspan = <number> json.rowspan;
|
||||
this.minLength = <number> json.minLength || 0;
|
||||
this.maxLength = <number> json.maxLength || 0;
|
||||
this.colspan = json.colspan;
|
||||
this.rowspan = json.rowspan;
|
||||
this.minLength = json.minLength || 0;
|
||||
this.maxLength = json.maxLength || 0;
|
||||
this.minValue = json.minValue;
|
||||
this.maxValue = json.maxValue;
|
||||
this.regexPattern = json.regexPattern;
|
||||
this.options = <FormFieldOption[]> json.options || [];
|
||||
this.hasEmptyValue = <boolean> json.hasEmptyValue;
|
||||
this.options = json.options || [];
|
||||
this.hasEmptyValue = json.hasEmptyValue;
|
||||
this.className = json.className;
|
||||
this.optionType = json.optionType;
|
||||
this.params = <FormFieldMetadata> json.params || {};
|
||||
this.params = json.params || {};
|
||||
this.hyperlinkUrl = json.hyperlinkUrl;
|
||||
this.displayText = json.displayText;
|
||||
this.visibilityCondition = json.visibilityCondition ? new WidgetVisibilityModel(json.visibilityCondition) : undefined;
|
||||
this.enableFractions = <boolean> json.enableFractions;
|
||||
this.enableFractions = json.enableFractions;
|
||||
this.currency = json.currency;
|
||||
this.dateDisplayFormat = json.dateDisplayFormat || this.getDefaultDateFormat(json);
|
||||
this._value = this.parseValue(json);
|
||||
@@ -256,7 +256,7 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
}
|
||||
|
||||
private containerFactory(json: any, form: any): void {
|
||||
this.numberOfColumns = <number> json.numberOfColumns || 1;
|
||||
this.numberOfColumns = json.numberOfColumns || 1;
|
||||
|
||||
this.fields = json.fields;
|
||||
|
||||
@@ -453,6 +453,7 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
|
||||
/**
|
||||
* Skip the invalid field type
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
isInvalidFieldType(type: string) {
|
||||
|
@@ -363,9 +363,7 @@ describe('FormModel', () => {
|
||||
});
|
||||
|
||||
const field: any = {
|
||||
validate() {
|
||||
return true;
|
||||
}
|
||||
validate: () => true
|
||||
};
|
||||
form.validateField(field);
|
||||
|
||||
@@ -409,14 +407,10 @@ describe('FormModel', () => {
|
||||
|
||||
spyOn(form, 'getFormFields').and.returnValue([testField]);
|
||||
|
||||
const validator = <FormFieldValidator> {
|
||||
isSupported(): boolean {
|
||||
return true;
|
||||
},
|
||||
validate(): boolean {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
const validator = {
|
||||
isSupported: (): boolean => true,
|
||||
validate: (): boolean => true
|
||||
} as FormFieldValidator;
|
||||
|
||||
spyOn(validator, 'validate').and.callThrough();
|
||||
|
||||
@@ -449,7 +443,7 @@ describe('FormModel', () => {
|
||||
const defaultLength = FORM_FIELD_VALIDATORS.length;
|
||||
|
||||
expect(form.fieldValidators.length).toBe(defaultLength);
|
||||
form.fieldValidators.push(<any> {});
|
||||
form.fieldValidators.push({} as any);
|
||||
|
||||
expect(form.fieldValidators.length).toBe(defaultLength + 1);
|
||||
expect(FORM_FIELD_VALIDATORS.length).toBe(defaultLength);
|
||||
@@ -461,63 +455,63 @@ describe('FormModel', () => {
|
||||
beforeEach(() => {
|
||||
const variables = [
|
||||
{
|
||||
'id': 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2',
|
||||
'name': 'name1',
|
||||
'type': 'string',
|
||||
'value': 'hello'
|
||||
id: 'bfca9766-7bc1-45cc-8ecf-cdad551e36e2',
|
||||
name: 'name1',
|
||||
type: 'string',
|
||||
value: 'hello'
|
||||
},
|
||||
{
|
||||
'id': '3ed9f28a-dbae-463f-b991-47ef06658bb6',
|
||||
'name': 'name2',
|
||||
'type': 'date',
|
||||
'value': '29.09.2019'
|
||||
id: '3ed9f28a-dbae-463f-b991-47ef06658bb6',
|
||||
name: 'name2',
|
||||
type: 'date',
|
||||
value: '29.09.2019'
|
||||
},
|
||||
{
|
||||
'id': 'booleanVar',
|
||||
'name': 'bool',
|
||||
'type': 'boolean',
|
||||
'value': 'true'
|
||||
id: 'booleanVar',
|
||||
name: 'bool',
|
||||
type: 'boolean',
|
||||
value: 'true'
|
||||
}
|
||||
];
|
||||
|
||||
const processVariables = [
|
||||
{
|
||||
'serviceName': 'denys-variable-mapping-rb',
|
||||
'serviceFullName': 'denys-variable-mapping-rb',
|
||||
'serviceVersion': '',
|
||||
'appName': 'denys-variable-mapping',
|
||||
'appVersion': '',
|
||||
'serviceType': null,
|
||||
'id': 3,
|
||||
'type': 'string',
|
||||
'name': 'variables.name1',
|
||||
'createTime': 1566989626284,
|
||||
'lastUpdatedTime': 1566989626284,
|
||||
'executionId': null,
|
||||
'value': 'hello',
|
||||
'markedAsDeleted': false,
|
||||
'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
||||
'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
||||
'taskVariable': true
|
||||
serviceName: 'denys-variable-mapping-rb',
|
||||
serviceFullName: 'denys-variable-mapping-rb',
|
||||
serviceVersion: '',
|
||||
appName: 'denys-variable-mapping',
|
||||
appVersion: '',
|
||||
serviceType: null,
|
||||
id: 3,
|
||||
type: 'string',
|
||||
name: 'variables.name1',
|
||||
createTime: 1566989626284,
|
||||
lastUpdatedTime: 1566989626284,
|
||||
executionId: null,
|
||||
value: 'hello',
|
||||
markedAsDeleted: false,
|
||||
processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
||||
taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
||||
taskVariable: true
|
||||
},
|
||||
{
|
||||
'serviceName': 'denys-variable-mapping-rb',
|
||||
'serviceFullName': 'denys-variable-mapping-rb',
|
||||
'serviceVersion': '',
|
||||
'appName': 'denys-variable-mapping',
|
||||
'appVersion': '',
|
||||
'serviceType': null,
|
||||
'id': 1,
|
||||
'type': 'boolean',
|
||||
'name': 'booleanVar',
|
||||
'createTime': 1566989626283,
|
||||
'lastUpdatedTime': 1566989626283,
|
||||
'executionId': null,
|
||||
'value': 'true',
|
||||
'markedAsDeleted': false,
|
||||
'processInstanceId': '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
||||
'taskId': '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
||||
'taskVariable': true
|
||||
serviceName: 'denys-variable-mapping-rb',
|
||||
serviceFullName: 'denys-variable-mapping-rb',
|
||||
serviceVersion: '',
|
||||
appName: 'denys-variable-mapping',
|
||||
appVersion: '',
|
||||
serviceType: null,
|
||||
id: 1,
|
||||
type: 'boolean',
|
||||
name: 'booleanVar',
|
||||
createTime: 1566989626283,
|
||||
lastUpdatedTime: 1566989626283,
|
||||
executionId: null,
|
||||
value: 'true',
|
||||
markedAsDeleted: false,
|
||||
processInstanceId: '1be4785f-c982-11e9-bdd8-96d6903e4e44',
|
||||
taskId: '1beab9f6-c982-11e9-bdd8-96d6903e4e44',
|
||||
taskVariable: true
|
||||
}
|
||||
];
|
||||
|
||||
@@ -624,7 +618,7 @@ describe('FormModel', () => {
|
||||
});
|
||||
|
||||
describe('setNodeIdValueForViewersLinkedToUploadWidget', () => {
|
||||
const fakeNodeWithProperties: Node = <Node> {
|
||||
const fakeNodeWithProperties: Node = {
|
||||
id: 'fake-properties',
|
||||
name: 'fake-properties-name',
|
||||
content: {
|
||||
@@ -634,7 +628,7 @@ describe('FormModel', () => {
|
||||
'pfx:property_one': 'testValue',
|
||||
'pfx:property_two': true
|
||||
}
|
||||
};
|
||||
} as Node;
|
||||
let form: FormModel;
|
||||
|
||||
it('should set the node id to the viewers linked to the upload widget in the event', () => {
|
||||
|
@@ -248,6 +248,7 @@ export class FormModel implements ProcessFormModel {
|
||||
|
||||
/**
|
||||
* Returns a form variable that matches the identifier.
|
||||
*
|
||||
* @param identifier The `name` or `id` value.
|
||||
*/
|
||||
getFormVariable(identifier: string): FormVariableModel {
|
||||
@@ -264,6 +265,7 @@ export class FormModel implements ProcessFormModel {
|
||||
/**
|
||||
* Returns a value of the form variable that matches the identifier.
|
||||
* Provides additional conversion of types (date, boolean).
|
||||
*
|
||||
* @param identifier The `name` or `id` value
|
||||
*/
|
||||
getFormVariableValue(identifier: string): any {
|
||||
@@ -278,6 +280,7 @@ export class FormModel implements ProcessFormModel {
|
||||
|
||||
/**
|
||||
* Returns a process variable value.
|
||||
*
|
||||
* @param name Variable name
|
||||
*/
|
||||
getProcessVariableValue(name: string): any {
|
||||
@@ -338,7 +341,7 @@ export class FormModel implements ProcessFormModel {
|
||||
const field = this.fields[i];
|
||||
|
||||
if (field instanceof ContainerModel) {
|
||||
const container = <ContainerModel> field;
|
||||
const container = field;
|
||||
formFieldModel.push(container.field);
|
||||
|
||||
container.field.columns.forEach((column) => {
|
||||
@@ -356,24 +359,24 @@ export class FormModel implements ProcessFormModel {
|
||||
|
||||
protected parseOutcomes() {
|
||||
if (this.json.fields) {
|
||||
const saveOutcome = new FormOutcomeModel(<any> this, {
|
||||
const saveOutcome = new FormOutcomeModel(this, {
|
||||
id: FormModel.SAVE_OUTCOME,
|
||||
name: 'SAVE',
|
||||
isSystem: true
|
||||
});
|
||||
const completeOutcome = new FormOutcomeModel(<any> this, {
|
||||
const completeOutcome = new FormOutcomeModel(this, {
|
||||
id: FormModel.COMPLETE_OUTCOME,
|
||||
name: 'COMPLETE',
|
||||
isSystem: true
|
||||
});
|
||||
const startProcessOutcome = new FormOutcomeModel(<any> this, {
|
||||
const startProcessOutcome = new FormOutcomeModel(this, {
|
||||
id: FormModel.START_PROCESS_OUTCOME,
|
||||
name: 'START PROCESS',
|
||||
isSystem: true
|
||||
});
|
||||
|
||||
const customOutcomes = (this.json.outcomes || []).map(
|
||||
(obj) => new FormOutcomeModel(<any> this, obj)
|
||||
(obj) => new FormOutcomeModel(this, obj)
|
||||
);
|
||||
|
||||
this.outcomes = [saveOutcome].concat(
|
||||
|
@@ -57,7 +57,7 @@ describe('DateTimeWidgetComponent', () => {
|
||||
id: 'date-id',
|
||||
name: 'date-name',
|
||||
type: 'datetime',
|
||||
minValue: minValue
|
||||
minValue
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
@@ -81,7 +81,7 @@ describe('DateTimeWidgetComponent', () => {
|
||||
it('should setup max value for date picker', () => {
|
||||
const maxValue = '1982-03-13T10:00:000Z';
|
||||
widget.field = new FormFieldModel(null, {
|
||||
maxValue: maxValue
|
||||
maxValue
|
||||
});
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -157,14 +157,14 @@ describe('DateTimeWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
let dateButton = <HTMLButtonElement> element.querySelector('button');
|
||||
let dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||
expect(dateButton.disabled).toBeFalsy();
|
||||
|
||||
widget.field.readOnly = true;
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
dateButton = <HTMLButtonElement> element.querySelector('button');
|
||||
dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||
expect(dateButton.disabled).toBeTruthy();
|
||||
});
|
||||
|
||||
|
@@ -62,7 +62,7 @@ export class DateTimeWidgetComponent extends WidgetComponent implements OnInit,
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
||||
|
||||
const momentDateAdapter = <MomentDateAdapter> this.dateAdapter;
|
||||
const momentDateAdapter = this.dateAdapter as MomentDateAdapter;
|
||||
momentDateAdapter.overrideDisplayFormat = this.field.dateDisplayFormat;
|
||||
|
||||
if (this.field) {
|
||||
|
@@ -49,7 +49,7 @@ describe('DateWidgetComponent', () => {
|
||||
widget.field = new FormFieldModel(null, {
|
||||
id: 'date-id',
|
||||
name: 'date-name',
|
||||
minValue: minValue
|
||||
minValue
|
||||
});
|
||||
|
||||
widget.ngOnInit();
|
||||
@@ -61,7 +61,7 @@ describe('DateWidgetComponent', () => {
|
||||
it('should date field be present', () => {
|
||||
const minValue = '13-03-1982';
|
||||
widget.field = new FormFieldModel(null, {
|
||||
minValue: minValue
|
||||
minValue
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
@@ -73,7 +73,7 @@ describe('DateWidgetComponent', () => {
|
||||
it('should setup max value for date picker', () => {
|
||||
const maxValue = '31-03-1982';
|
||||
widget.field = new FormFieldModel(null, {
|
||||
maxValue: maxValue
|
||||
maxValue
|
||||
});
|
||||
widget.ngOnInit();
|
||||
|
||||
@@ -160,13 +160,13 @@ describe('DateWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
let dateButton = <HTMLButtonElement> element.querySelector('button');
|
||||
let dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||
expect(dateButton.disabled).toBeFalsy();
|
||||
|
||||
widget.field.readOnly = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
dateButton = <HTMLButtonElement> element.querySelector('button');
|
||||
dateButton = element.querySelector<HTMLButtonElement>('button');
|
||||
expect(dateButton.disabled).toBeTruthy();
|
||||
});
|
||||
|
||||
|
@@ -70,7 +70,7 @@ export class DateWidgetComponent extends WidgetComponent implements OnInit, OnDe
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
||||
|
||||
const momentDateAdapter = <MomentDateAdapter> this.dateAdapter;
|
||||
const momentDateAdapter = this.dateAdapter as MomentDateAdapter;
|
||||
momentDateAdapter.overrideDisplayFormat = this.field.dateDisplayFormat;
|
||||
|
||||
if (this.field) {
|
||||
|
@@ -37,10 +37,10 @@ describe('DropdownWidgetComponent', () => {
|
||||
let fixture: ComponentFixture<DropdownWidgetComponent>;
|
||||
let element: HTMLElement;
|
||||
|
||||
function openSelect() {
|
||||
const openSelect = () => {
|
||||
const dropdown = fixture.debugElement.nativeElement.querySelector('.mat-select-trigger');
|
||||
dropdown.click();
|
||||
}
|
||||
};
|
||||
|
||||
const fakeOptionList: FormFieldOption[] = [
|
||||
{ id: 'opt_1', name: 'option_1' },
|
||||
@@ -80,7 +80,7 @@ describe('DropdownWidgetComponent', () => {
|
||||
const fieldId = '<field-id>';
|
||||
|
||||
const form = new FormModel({
|
||||
taskId: taskId
|
||||
taskId
|
||||
});
|
||||
|
||||
widget.field = new FormFieldModel(form, {
|
||||
@@ -99,16 +99,14 @@ describe('DropdownWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should preserve empty option when loading fields', () => {
|
||||
const restFieldValue: FormFieldOption = <FormFieldOption> { id: '1', name: 'Option1' };
|
||||
spyOn(formService, 'getRestFieldValues').and.callFake(() => {
|
||||
return new Observable((observer) => {
|
||||
observer.next([restFieldValue]);
|
||||
observer.complete();
|
||||
});
|
||||
});
|
||||
const restFieldValue: FormFieldOption = { id: '1', name: 'Option1' } as FormFieldOption;
|
||||
spyOn(formService, 'getRestFieldValues').and.callFake(() => new Observable((observer) => {
|
||||
observer.next([restFieldValue]);
|
||||
observer.complete();
|
||||
}));
|
||||
|
||||
const form = new FormModel({ taskId: '<id>' });
|
||||
const emptyOption: FormFieldOption = <FormFieldOption> { id: 'empty', name: 'Empty' };
|
||||
const emptyOption: FormFieldOption = { id: 'empty', name: 'Empty' } as FormFieldOption;
|
||||
widget.field = new FormFieldModel(form, {
|
||||
id: '<id>',
|
||||
restUrl: '/some/url/address',
|
||||
@@ -167,9 +165,7 @@ describe('DropdownWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(visibilityService, 'refreshVisibility').and.stub();
|
||||
spyOn(formService, 'getRestFieldValues').and.callFake(() => {
|
||||
return of(fakeOptionList);
|
||||
});
|
||||
spyOn(formService, 'getRestFieldValues').and.callFake(() => of(fakeOptionList));
|
||||
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task-id' }), {
|
||||
id: 'dropdown-id',
|
||||
name: 'date-name',
|
||||
@@ -230,9 +226,7 @@ describe('DropdownWidgetComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(visibilityService, 'refreshVisibility').and.stub();
|
||||
spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => {
|
||||
return of(fakeOptionList);
|
||||
});
|
||||
spyOn(formService, 'getRestFieldValuesByProcessId').and.callFake(() => of(fakeOptionList));
|
||||
widget.field = new FormFieldModel(new FormModel({ processDefinitionId: 'fake-process-id' }), {
|
||||
id: 'dropdown-id',
|
||||
name: 'date-name',
|
||||
@@ -300,7 +294,7 @@ describe('DropdownWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const dropDownElement: HTMLSelectElement = <HTMLSelectElement> element.querySelector('#dropdown-id');
|
||||
const dropDownElement = element.querySelector<HTMLSelectElement>('#dropdown-id');
|
||||
expect(dropDownElement).not.toBeNull();
|
||||
expect(dropDownElement.getAttribute('aria-disabled')).toBe('true');
|
||||
});
|
||||
|
@@ -72,7 +72,7 @@ export class DynamicTableModel extends FormWidgetModel {
|
||||
}
|
||||
|
||||
if (field.json.value) {
|
||||
this.rows = field.json.value.map((obj) => <DynamicTableRow> {selected: false, value: obj});
|
||||
this.rows = field.json.value.map((obj) => ({ selected: false, value: obj } as DynamicTableRow));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ export class DynamicTableModel extends FormWidgetModel {
|
||||
}
|
||||
|
||||
if (definitions) {
|
||||
return definitions.map((obj) => <DynamicTableColumn> obj);
|
||||
return definitions.map((obj) => obj as DynamicTableColumn);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@@ -107,7 +107,7 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should select row on click', () => {
|
||||
const row = <DynamicTableRow> {selected: false};
|
||||
const row = {selected: false} as DynamicTableRow;
|
||||
widget.onRowClicked(row);
|
||||
|
||||
expect(row.selected).toBeTruthy();
|
||||
@@ -115,7 +115,7 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should require table to select clicked row', () => {
|
||||
const row = <DynamicTableRow> {selected: false};
|
||||
const row = {selected: false} as DynamicTableRow;
|
||||
widget.content = null;
|
||||
widget.onRowClicked(row);
|
||||
|
||||
@@ -123,7 +123,7 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should reset selected row', () => {
|
||||
const row = <DynamicTableRow> {selected: false};
|
||||
const row = {selected: false} as DynamicTableRow;
|
||||
widget.content.rows.push(row);
|
||||
widget.content.selectedRow = row;
|
||||
expect(widget.content.selectedRow).toBe(row);
|
||||
@@ -135,7 +135,7 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should check selection', () => {
|
||||
const row = <DynamicTableRow> {selected: false};
|
||||
const row = {selected: false} as DynamicTableRow;
|
||||
widget.content.rows.push(row);
|
||||
widget.content.selectedRow = row;
|
||||
expect(widget.hasSelection()).toBeTruthy();
|
||||
@@ -153,8 +153,8 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should move selection up', () => {
|
||||
const row1 = <DynamicTableRow> {};
|
||||
const row2 = <DynamicTableRow> {};
|
||||
const row1 = {} as DynamicTableRow;
|
||||
const row2 = {} as DynamicTableRow;
|
||||
widget.content.rows.push(...[row1, row2]);
|
||||
widget.content.selectedRow = row2;
|
||||
|
||||
@@ -168,8 +168,8 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should move selection down', () => {
|
||||
const row1 = <DynamicTableRow> {};
|
||||
const row2 = <DynamicTableRow> {};
|
||||
const row1 = {} as DynamicTableRow;
|
||||
const row2 = {} as DynamicTableRow;
|
||||
widget.content.rows.push(...[row1, row2]);
|
||||
widget.content.selectedRow = row1;
|
||||
|
||||
@@ -183,7 +183,7 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should delete selected row', () => {
|
||||
const row = <DynamicTableRow> {};
|
||||
const row = {} as DynamicTableRow;
|
||||
widget.content.rows.push(row);
|
||||
widget.content.selectedRow = row;
|
||||
widget.deleteSelection();
|
||||
@@ -213,7 +213,7 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
expect(widget.editMode).toBeFalsy();
|
||||
expect(widget.editRow).toBeFalsy();
|
||||
|
||||
const row = <DynamicTableRow> {value: true};
|
||||
const row = {value: true} as DynamicTableRow;
|
||||
widget.content.selectedRow = row;
|
||||
|
||||
expect(widget.editSelection()).toBeTruthy();
|
||||
@@ -223,7 +223,7 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should copy row', () => {
|
||||
const row = <DynamicTableRow> {value: {opt: {key: '1', value: 1}}};
|
||||
const row = {value: {opt: {key: '1', value: 1}}} as DynamicTableRow;
|
||||
const copy = widget.copyRow(row);
|
||||
expect(copy.value).toEqual(row.value);
|
||||
});
|
||||
@@ -235,14 +235,14 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
|
||||
it('should retrieve cell value', () => {
|
||||
const value = '<value>';
|
||||
const row = <DynamicTableRow> {value: {key: value}};
|
||||
const column = <DynamicTableColumn> {id: 'key'};
|
||||
const row = {value: {key: value}} as DynamicTableRow;
|
||||
const column = {id: 'key'} as DynamicTableColumn;
|
||||
|
||||
expect(widget.getCellValue(row, column)).toBe(value);
|
||||
});
|
||||
|
||||
it('should save changes and add new row', () => {
|
||||
const row = <DynamicTableRow> {isNew: true, value: {key: 'value'}};
|
||||
const row = {isNew: true, value: {key: 'value'}} as DynamicTableRow;
|
||||
widget.editMode = true;
|
||||
widget.editRow = row;
|
||||
|
||||
@@ -255,7 +255,7 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should save changes and update row', () => {
|
||||
const row = <DynamicTableRow> {isNew: false, value: {key: 'value'}};
|
||||
const row = {isNew: false, value: {key: 'value'}} as DynamicTableRow;
|
||||
widget.editMode = true;
|
||||
widget.editRow = row;
|
||||
widget.content.selectedRow = row;
|
||||
@@ -275,7 +275,7 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
|
||||
it('should cancel changes', () => {
|
||||
widget.editMode = true;
|
||||
widget.editRow = <DynamicTableRow> {};
|
||||
widget.editRow = {} as DynamicTableRow;
|
||||
widget.onCancelChanges();
|
||||
|
||||
expect(widget.editMode).toBeFalsy();
|
||||
@@ -311,15 +311,15 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should prepend default currency for amount columns', () => {
|
||||
const row = <DynamicTableRow> {value: {key: '100'}};
|
||||
const column = <DynamicTableColumn> {id: 'key', type: 'Amount'};
|
||||
const row = {value: {key: '100'}} as DynamicTableRow;
|
||||
const column = {id: 'key', type: 'Amount'} as DynamicTableColumn;
|
||||
const actual = widget.getCellValue(row, column);
|
||||
expect(actual).toBe('$ 100');
|
||||
});
|
||||
|
||||
it('should prepend custom currency for amount columns', () => {
|
||||
const row = <DynamicTableRow> {value: {key: '100'}};
|
||||
const column = <DynamicTableColumn> {id: 'key', type: 'Amount', amountCurrency: 'GBP'};
|
||||
const row = {value: {key: '100'}} as DynamicTableRow;
|
||||
const column = {id: 'key', type: 'Amount', amountCurrency: 'GBP'} as DynamicTableColumn;
|
||||
const actual = widget.getCellValue(row, column);
|
||||
expect(actual).toBe('GBP 100');
|
||||
});
|
||||
@@ -357,7 +357,7 @@ describe('DynamicTableWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should focus on add button when a new row is saved', async () => {
|
||||
const addNewRowButton: HTMLButtonElement = <HTMLButtonElement> element.querySelector('#fake-dynamic-table-add-row');
|
||||
const addNewRowButton = element.querySelector<HTMLButtonElement>('#fake-dynamic-table-add-row');
|
||||
|
||||
expect(element.querySelector('#dynamic-table-fake-dynamic-table')).not.toBeNull();
|
||||
expect(addNewRowButton).not.toBeNull();
|
||||
|
@@ -72,7 +72,7 @@ export class DynamicTableWidgetComponent extends WidgetComponent implements OnIn
|
||||
forceFocusOnAddButton() {
|
||||
if (this.content) {
|
||||
this.cd.detectChanges();
|
||||
const buttonAddRow = <HTMLButtonElement> this.elementRef.nativeElement.querySelector('#' + this.content.id + '-add-row');
|
||||
const buttonAddRow = this.elementRef.nativeElement.querySelector('#' + this.content.id + '-add-row');
|
||||
if (this.isDynamicTableReady(buttonAddRow)) {
|
||||
buttonAddRow.focus();
|
||||
}
|
||||
@@ -139,7 +139,7 @@ export class DynamicTableWidgetComponent extends WidgetComponent implements OnIn
|
||||
|
||||
addNewRow(): boolean {
|
||||
if (this.content && !this.readOnly) {
|
||||
this.editRow = <DynamicTableRow> {
|
||||
this.editRow = {
|
||||
isNew: true,
|
||||
selected: false,
|
||||
value: {}
|
||||
@@ -195,9 +195,7 @@ export class DynamicTableWidgetComponent extends WidgetComponent implements OnIn
|
||||
}
|
||||
|
||||
copyRow(row: DynamicTableRow): DynamicTableRow {
|
||||
return <DynamicTableRow> {
|
||||
value: this.copyObject(row.value)
|
||||
};
|
||||
return { value: this.copyObject(row.value) } as DynamicTableRow;
|
||||
}
|
||||
|
||||
private copyObject(obj: any): any {
|
||||
|
@@ -28,8 +28,8 @@ describe('AmountEditorComponent', () => {
|
||||
});
|
||||
|
||||
it('should update row value on change', () => {
|
||||
const row = <DynamicTableRow> { value: {} };
|
||||
const column = <DynamicTableColumn> { id: 'key' };
|
||||
const row = { value: {} } as DynamicTableRow;
|
||||
const column = { id: 'key' } as DynamicTableColumn;
|
||||
|
||||
const value = 100;
|
||||
const event = { target: { value } };
|
||||
|
@@ -45,7 +45,7 @@ export class AmountEditorComponent implements OnInit {
|
||||
}
|
||||
|
||||
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
||||
const value: number = Number((<HTMLInputElement> event.target).value);
|
||||
const value: number = Number(event.target.value);
|
||||
row.value[column.id] = value;
|
||||
}
|
||||
|
||||
|
@@ -29,8 +29,8 @@ describe('BooleanEditorComponent', () => {
|
||||
});
|
||||
|
||||
it('should update row value on change', () => {
|
||||
const row = <DynamicTableRow> { value: {} };
|
||||
const column = <DynamicTableColumn> { id: 'key' };
|
||||
const row = { value: {} } as DynamicTableRow;
|
||||
const column = { id: 'key' } as DynamicTableColumn;
|
||||
const event = { checked: true } ;
|
||||
|
||||
component.onValueChanged(row, column, event);
|
||||
|
@@ -39,7 +39,7 @@ export class BooleanEditorComponent {
|
||||
column: DynamicTableColumn;
|
||||
|
||||
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
||||
const value: boolean = (<HTMLInputElement> event).checked;
|
||||
const value: boolean = event.checked;
|
||||
row.value[column.id] = value;
|
||||
}
|
||||
|
||||
|
@@ -45,8 +45,8 @@ describe('DateEditorComponent', () => {
|
||||
fixture = TestBed.createComponent(DateEditorComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
row = <DynamicTableRow> { value: { date: '1879-03-14T00:00:00.000Z' } };
|
||||
column = <DynamicTableColumn> { id: 'date', type: 'Date' };
|
||||
row = { value: { date: '1879-03-14T00:00:00.000Z' } } as DynamicTableRow;
|
||||
column = { id: 'date', type: 'Date' } as DynamicTableColumn;
|
||||
const field = new FormFieldModel(new FormModel());
|
||||
table = new DynamicTableModel(field, null);
|
||||
table.rows.push(row);
|
||||
@@ -58,7 +58,7 @@ describe('DateEditorComponent', () => {
|
||||
|
||||
describe('using Date Piker', () => {
|
||||
it('should update row value on change', () => {
|
||||
const input = <MatDatepickerInputEvent<any>> {value: '14-03-2016' };
|
||||
const input = {value: '14-03-2016' } as MatDatepickerInputEvent<any>;
|
||||
|
||||
component.ngOnInit();
|
||||
component.onDateChanged(input);
|
||||
@@ -69,7 +69,7 @@ describe('DateEditorComponent', () => {
|
||||
|
||||
it('should flush value on user input', () => {
|
||||
spyOn(table, 'flushValue').and.callThrough();
|
||||
const input = <MatDatepickerInputEvent<any>> {value: '14-03-2016' };
|
||||
const input = {value: '14-03-2016' } as MatDatepickerInputEvent<any>;
|
||||
|
||||
component.ngOnInit();
|
||||
component.onDateChanged(input);
|
||||
|
@@ -70,7 +70,7 @@ export class DateEditorComponent implements OnInit, OnDestroy {
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
||||
|
||||
const momentDateAdapter = <MomentDateAdapter> this.dateAdapter;
|
||||
const momentDateAdapter = this.dateAdapter as MomentDateAdapter;
|
||||
momentDateAdapter.overrideDisplayFormat = this.DATE_FORMAT;
|
||||
|
||||
this.value = moment(this.table.getCellValue(this.row, this.column), this.DATE_FORMAT);
|
||||
|
@@ -44,8 +44,8 @@ describe('DateTimeEditorComponent', () => {
|
||||
fixture = TestBed.createComponent(DateTimeEditorComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
||||
row = <DynamicTableRow> { value: { date: '1879-03-14T00:00:00.000Z' } };
|
||||
column = <DynamicTableColumn> { id: 'datetime', type: 'Datetime' };
|
||||
row = { value: { date: '1879-03-14T00:00:00.000Z' } } as DynamicTableRow;
|
||||
column = { id: 'datetime', type: 'Datetime' } as DynamicTableColumn;
|
||||
const field = new FormFieldModel(new FormModel());
|
||||
table = new DynamicTableModel(field, null);
|
||||
table.rows.push(row);
|
||||
|
@@ -73,7 +73,7 @@ export class DateTimeEditorComponent implements OnInit, OnDestroy {
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe(locale => this.dateAdapter.setLocale(locale));
|
||||
|
||||
const momentDateAdapter = <MomentDateAdapter> this.dateAdapter;
|
||||
const momentDateAdapter = this.dateAdapter as MomentDateAdapter;
|
||||
momentDateAdapter.overrideDisplayFormat = this.DATE_TIME_FORMAT;
|
||||
|
||||
this.value = moment(this.table.getCellValue(this.row, this.column), this.DATE_TIME_FORMAT);
|
||||
|
@@ -51,14 +51,14 @@ describe('DropdownEditorComponent', () => {
|
||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||
formService = new FormService(null, alfrescoApiService, null);
|
||||
|
||||
row = <DynamicTableRow> {value: {dropdown: 'one'}};
|
||||
column = <DynamicTableColumn> {
|
||||
row = {value: {dropdown: 'one'}} as DynamicTableRow;
|
||||
column = {
|
||||
id: 'dropdown',
|
||||
options: [
|
||||
<DynamicTableColumnOption> {id: '1', name: 'one'},
|
||||
<DynamicTableColumnOption> {id: '2', name: 'two'}
|
||||
{id: '1', name: 'one'},
|
||||
{id: '2', name: 'two'}
|
||||
]
|
||||
};
|
||||
} as DynamicTableColumn;
|
||||
|
||||
form = new FormModel({taskId: '<task-id>'});
|
||||
table = new DynamicTableModel(new FormFieldModel(form, {id: '<field-id>'}), formService);
|
||||
@@ -95,9 +95,9 @@ describe('DropdownEditorComponent', () => {
|
||||
column.optionType = 'rest';
|
||||
row.value[column.id] = 'twelve';
|
||||
|
||||
const restResults = [
|
||||
<DynamicTableColumnOption> {id: '11', name: 'eleven'},
|
||||
<DynamicTableColumnOption> {id: '12', name: 'twelve'}
|
||||
const restResults: DynamicTableColumnOption[] = [
|
||||
{id: '11', name: 'eleven'},
|
||||
{id: '12', name: 'twelve'}
|
||||
];
|
||||
|
||||
spyOn(formService, 'getRestFieldValuesColumn').and.returnValue(
|
||||
@@ -192,11 +192,11 @@ describe('DropdownEditorComponent', () => {
|
||||
}, {id: 'opt_3', name: 'option_3'}];
|
||||
let dynamicTable: DynamicTableModel;
|
||||
|
||||
function openSelect() {
|
||||
const openSelect = () => {
|
||||
const dropdown = fixture.debugElement.query(By.css('.mat-select-trigger'));
|
||||
dropdown.triggerEventHandler('click', null);
|
||||
fixture.detectChanges();
|
||||
}
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DropdownEditorComponent);
|
||||
@@ -213,15 +213,15 @@ describe('DropdownEditorComponent', () => {
|
||||
beforeEach(() => {
|
||||
stubFormService = fixture.debugElement.injector.get(FormService);
|
||||
spyOn(stubFormService, 'getRestFieldValuesColumn').and.returnValue(of(fakeOptionList));
|
||||
row = <DynamicTableRow> {value: {dropdown: 'one'}};
|
||||
column = <DynamicTableColumn> {
|
||||
row = {value: {dropdown: 'one'}} as DynamicTableRow;
|
||||
column = {
|
||||
id: 'column-id',
|
||||
optionType: 'rest',
|
||||
options: [
|
||||
<DynamicTableColumnOption> {id: '1', name: 'one'},
|
||||
<DynamicTableColumnOption> {id: '2', name: 'two'}
|
||||
{id: '1', name: 'one'},
|
||||
{id: '2', name: 'two'}
|
||||
]
|
||||
};
|
||||
} as DynamicTableColumn;
|
||||
form = new FormModel({taskId: '<task-id>'});
|
||||
dynamicTable = new DynamicTableModel(new FormFieldModel(form, {id: '<field-id>'}), formService);
|
||||
dynamicTable.rows.push(row);
|
||||
@@ -261,15 +261,15 @@ describe('DropdownEditorComponent', () => {
|
||||
beforeEach(() => {
|
||||
stubFormService = fixture.debugElement.injector.get(FormService);
|
||||
spyOn(stubFormService, 'getRestFieldValuesColumnByProcessId').and.returnValue(of(fakeOptionList));
|
||||
row = <DynamicTableRow> {value: {dropdown: 'one'}};
|
||||
column = <DynamicTableColumn> {
|
||||
row = {value: {dropdown: 'one'}} as DynamicTableRow;
|
||||
column = {
|
||||
id: 'column-id',
|
||||
optionType: 'rest',
|
||||
options: [
|
||||
<DynamicTableColumnOption> {id: '1', name: 'one'},
|
||||
<DynamicTableColumnOption> {id: '2', name: 'two'}
|
||||
{id: '1', name: 'one'},
|
||||
{id: '2', name: 'two'}
|
||||
]
|
||||
};
|
||||
} as DynamicTableColumn;
|
||||
form = new FormModel({processDefinitionId: '<proc-id>'});
|
||||
dynamicTable = new DynamicTableModel(new FormFieldModel(form, {id: '<field-id>'}), formService);
|
||||
dynamicTable.rows.push(row);
|
||||
|
@@ -99,7 +99,7 @@ export class DropdownEditorComponent implements OnInit {
|
||||
}
|
||||
|
||||
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
||||
let value: any = (<HTMLInputElement> event).value;
|
||||
let value: any = event.value;
|
||||
value = column.options.find((opt) => opt.name === value);
|
||||
row.value[column.id] = value;
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@
|
||||
|
||||
import { FormFieldModel, FormModel } from '../../core';
|
||||
import { FormService } from './../../../../services/form.service';
|
||||
import { DynamicRowValidationSummary } from './../dynamic-row-validation-summary.model';
|
||||
import { DynamicTableColumn } from './../dynamic-table-column.model';
|
||||
import { DynamicTableRow } from './../dynamic-table-row.model';
|
||||
import { DynamicTableModel } from './../dynamic-table.widget.model';
|
||||
@@ -45,8 +44,8 @@ describe('RowEditorComponent', () => {
|
||||
component = new RowEditorComponent();
|
||||
const field = new FormFieldModel(new FormModel());
|
||||
component.table = new DynamicTableModel(field, new FormService(null, alfrescoApiService, null));
|
||||
component.row = <DynamicTableRow> {};
|
||||
component.column = <DynamicTableColumn> {};
|
||||
component.row = {} as DynamicTableRow;
|
||||
component.column = {} as DynamicTableColumn;
|
||||
});
|
||||
|
||||
it('should be valid upon init', () => {
|
||||
@@ -72,7 +71,7 @@ describe('RowEditorComponent', () => {
|
||||
|
||||
it('should emit [save] event', (done) => {
|
||||
spyOn(component.table, 'validateRow').and.returnValue(
|
||||
<DynamicRowValidationSummary> {isValid: true, message: null}
|
||||
{isValid: true, message: null}
|
||||
);
|
||||
component.save.subscribe((event) => {
|
||||
expect(event.table).toBe(component.table);
|
||||
@@ -85,7 +84,7 @@ describe('RowEditorComponent', () => {
|
||||
|
||||
it('should not emit [save] event for invalid row', () => {
|
||||
spyOn(component.table, 'validateRow').and.returnValue(
|
||||
<DynamicRowValidationSummary> {isValid: false, message: 'error'}
|
||||
{isValid: false, message: 'error'}
|
||||
);
|
||||
let raised = false;
|
||||
component.save.subscribe(() => raised = true);
|
||||
|
@@ -28,8 +28,8 @@ describe('TextEditorComponent', () => {
|
||||
});
|
||||
|
||||
it('should update row value on change', () => {
|
||||
const row = <DynamicTableRow> { value: {} };
|
||||
const column = <DynamicTableColumn> { id: 'key' };
|
||||
const row = { value: {} } as DynamicTableRow;
|
||||
const column = { id: 'key' } as DynamicTableColumn;
|
||||
|
||||
const value = '<value>';
|
||||
const event = { target: { value } };
|
||||
|
@@ -45,7 +45,7 @@ export class TextEditorComponent implements OnInit {
|
||||
}
|
||||
|
||||
onValueChanged(row: DynamicTableRow, column: DynamicTableColumn, event: any) {
|
||||
const value: any = (<HTMLInputElement> event.target).value;
|
||||
const value: any = event.target.value;
|
||||
row.value[column.id] = value;
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,7 @@ describe('FunctionalGroupWidgetComponent', () => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
async function typeIntoInput(text: string) {
|
||||
const typeIntoInput = async (text: string) => {
|
||||
component.searchTerm.setValue(text);
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -72,7 +72,7 @@ describe('FunctionalGroupWidgetComponent', () => {
|
||||
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
}
|
||||
};
|
||||
|
||||
it('should setup text from underlying field on init', async () => {
|
||||
const group: GroupModel = { name: 'group-1'};
|
||||
|
@@ -74,7 +74,7 @@ export class FunctionalGroupWidgetComponent extends WidgetComponent implements O
|
||||
|
||||
const params = this.field.params;
|
||||
if (params && params.restrictWithGroup) {
|
||||
const restrictWithGroup = <GroupModel> params.restrictWithGroup;
|
||||
const restrictWithGroup = params.restrictWithGroup;
|
||||
this.groupId = restrictWithGroup.id;
|
||||
}
|
||||
|
||||
|
@@ -185,7 +185,7 @@ describe('HyperlinkWidgetComponent', () => {
|
||||
const url = 'https://www.alfresco.com/';
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
hyperlinkUrl: url,
|
||||
displayText: displayText,
|
||||
displayText,
|
||||
type: FormFieldTypes.HYPERLINK
|
||||
});
|
||||
|
||||
@@ -201,7 +201,7 @@ describe('HyperlinkWidgetComponent', () => {
|
||||
widget.field = new FormFieldModel(new FormModel(), {
|
||||
id: 'hyperlink',
|
||||
hyperlinkUrl: url,
|
||||
displayText: displayText,
|
||||
displayText,
|
||||
type: FormFieldTypes.HYPERLINK,
|
||||
tooltip: 'hyperlink widget'
|
||||
});
|
||||
|
@@ -48,12 +48,8 @@ describe('PeopleWidgetComponent', () => {
|
||||
formService = TestBed.inject(FormService);
|
||||
|
||||
translationService = TestBed.inject(TranslateService);
|
||||
spyOn(translationService, 'instant').and.callFake((key) => {
|
||||
return key;
|
||||
});
|
||||
spyOn(translationService, 'get').and.callFake((key) => {
|
||||
return of(key);
|
||||
});
|
||||
spyOn(translationService, 'instant').and.callFake((key) => key);
|
||||
spyOn(translationService, 'get').and.callFake((key) => of(key));
|
||||
|
||||
element = fixture.nativeElement;
|
||||
widget = fixture.componentInstance;
|
||||
@@ -193,7 +189,7 @@ describe('PeopleWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should show an error message if the user is invalid', async () => {
|
||||
const peopleHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
||||
const peopleHTMLElement = element.querySelector<HTMLInputElement>('input');
|
||||
peopleHTMLElement.focus();
|
||||
peopleHTMLElement.value = 'K';
|
||||
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
||||
@@ -207,7 +203,7 @@ describe('PeopleWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should show the people if the typed result match', async () => {
|
||||
const peopleHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
||||
const peopleHTMLElement = element.querySelector<HTMLInputElement>('input');
|
||||
peopleHTMLElement.focus();
|
||||
peopleHTMLElement.value = 'T';
|
||||
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
||||
@@ -221,7 +217,7 @@ describe('PeopleWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should hide result list if input is empty', async () => {
|
||||
const peopleHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
||||
const peopleHTMLElement = element.querySelector<HTMLInputElement>('input');
|
||||
peopleHTMLElement.focus();
|
||||
peopleHTMLElement.value = '';
|
||||
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
||||
@@ -238,7 +234,7 @@ describe('PeopleWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const peopleHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
||||
const peopleHTMLElement = element.querySelector<HTMLInputElement>('input');
|
||||
peopleHTMLElement.focus();
|
||||
peopleHTMLElement.value = 'T';
|
||||
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
||||
@@ -253,7 +249,7 @@ describe('PeopleWidgetComponent', () => {
|
||||
|
||||
it('should emit peopleSelected if option is valid', async () => {
|
||||
const selectEmitSpy = spyOn(widget.peopleSelected, 'emit');
|
||||
const peopleHTMLElement: HTMLInputElement = <HTMLInputElement> element.querySelector('input');
|
||||
const peopleHTMLElement = element.querySelector<HTMLInputElement>('input');
|
||||
peopleHTMLElement.focus();
|
||||
peopleHTMLElement.value = 'Test01 Test01';
|
||||
peopleHTMLElement.dispatchEvent(new Event('keyup'));
|
||||
|
@@ -21,7 +21,6 @@ import { PeopleProcessService } from '../../../../services/people-process.servic
|
||||
import { UserProcessModel } from '../../../../models';
|
||||
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
|
||||
import { FormService } from '../../../services/form.service';
|
||||
import { GroupModel } from '../core/group.model';
|
||||
import { WidgetComponent } from './../widget.component';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { Observable, of } from 'rxjs';
|
||||
@@ -97,7 +96,7 @@ export class PeopleWidgetComponent extends WidgetComponent implements OnInit {
|
||||
}
|
||||
const params = this.field.params;
|
||||
if (params && params.restrictWithGroup) {
|
||||
const restrictWithGroup = <GroupModel> params.restrictWithGroup;
|
||||
const restrictWithGroup = params.restrictWithGroup;
|
||||
this.groupId = restrictWithGroup.id;
|
||||
}
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ describe('RadioButtonsWidgetComponent', () => {
|
||||
const fieldId = '<field-id>';
|
||||
|
||||
const form = new FormModel({
|
||||
taskId: taskId
|
||||
taskId
|
||||
});
|
||||
|
||||
widget.field = new FormFieldModel(form, {
|
||||
@@ -82,7 +82,7 @@ describe('RadioButtonsWidgetComponent', () => {
|
||||
const fieldId = '<field-id>';
|
||||
|
||||
const form = new FormModel({
|
||||
taskId: taskId
|
||||
taskId
|
||||
});
|
||||
|
||||
widget.field = new FormFieldModel(form, {
|
||||
@@ -105,7 +105,7 @@ describe('RadioButtonsWidgetComponent', () => {
|
||||
const fieldId = '<field-id>';
|
||||
|
||||
const form = new FormModel({
|
||||
taskId: taskId
|
||||
taskId
|
||||
});
|
||||
|
||||
widget.field = new FormFieldModel(form, {
|
||||
@@ -204,13 +204,13 @@ describe('RadioButtonsWidgetComponent', () => {
|
||||
expect(widgetLabel.innerText).toBe('radio-name-label*');
|
||||
expect(radioButtonWidget.field.isValid).toBe(false);
|
||||
|
||||
const option: HTMLElement = <HTMLElement> element.querySelector('#radio-id-opt-1 label');
|
||||
const option = element.querySelector<HTMLElement>('#radio-id-opt-1 label');
|
||||
option.click();
|
||||
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
const selectedOption: HTMLElement = <HTMLElement> element.querySelector('[class*="mat-radio-checked"]');
|
||||
const selectedOption = element.querySelector<HTMLElement>('[class*="mat-radio-checked"]');
|
||||
expect(selectedOption.innerText).toBe('opt-name-1');
|
||||
expect(radioButtonWidget.field.isValid).toBe(true);
|
||||
});
|
||||
@@ -229,7 +229,7 @@ describe('RadioButtonsWidgetComponent', () => {
|
||||
});
|
||||
|
||||
fixture.detectChanges();
|
||||
const selectedOption: HTMLElement = <HTMLElement> element.querySelector('[class*="mat-radio-checked"]');
|
||||
const selectedOption = element.querySelector<HTMLElement>('[class*="mat-radio-checked"]');
|
||||
expect(selectedOption.innerText).toBe('opt-name-2');
|
||||
expect(radioButtonWidget.field.isValid).toBe(true);
|
||||
});
|
||||
@@ -281,7 +281,7 @@ describe('RadioButtonsWidgetComponent', () => {
|
||||
});
|
||||
|
||||
it('should trigger field changed event on click', fakeAsync(() => {
|
||||
const option: HTMLElement = <HTMLElement> element.querySelector('#radio-id-opt-1-input');
|
||||
const option = element.querySelector<HTMLElement>('#radio-id-opt-1-input');
|
||||
expect(element.querySelector('#radio-id')).not.toBeNull();
|
||||
expect(option).not.toBeNull();
|
||||
option.click();
|
||||
|
@@ -51,11 +51,11 @@ export class InputMaskDirective implements OnChanges, ControlValueAccessor {
|
||||
};
|
||||
|
||||
private translationMask = {
|
||||
'0': { pattern: /\d/ },
|
||||
'9': { pattern: /\d/, optional: true },
|
||||
0: { pattern: /\d/ },
|
||||
9: { pattern: /\d/, optional: true },
|
||||
'#': { pattern: /\d/, recursive: true },
|
||||
'A': { pattern: /[a-zA-Z0-9]/ },
|
||||
'S': { pattern: /[a-zA-Z]/ }
|
||||
A: { pattern: /[a-zA-Z0-9]/ },
|
||||
S: { pattern: /[a-zA-Z]/ }
|
||||
};
|
||||
|
||||
private byPassKeys = [9, 16, 17, 18, 36, 37, 38, 39, 40, 91];
|
||||
|
@@ -47,12 +47,8 @@ describe('TypeaheadWidgetComponent', () => {
|
||||
beforeEach(() => {
|
||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||
translationService = TestBed.inject(TranslateService);
|
||||
spyOn(translationService, 'instant').and.callFake((key) => {
|
||||
return key;
|
||||
});
|
||||
spyOn(translationService, 'get').and.callFake((key) => {
|
||||
return of(key);
|
||||
});
|
||||
spyOn(translationService, 'instant').and.callFake((key) => key);
|
||||
spyOn(translationService, 'get').and.callFake((key) => of(key));
|
||||
|
||||
formService = new FormService(null, alfrescoApiService, null);
|
||||
widget = new TypeaheadWidgetComponent(formService, null);
|
||||
@@ -65,7 +61,7 @@ describe('TypeaheadWidgetComponent', () => {
|
||||
const fieldId = '<field-id>';
|
||||
|
||||
const form = new FormModel({
|
||||
taskId: taskId
|
||||
taskId
|
||||
});
|
||||
|
||||
widget.field = new FormFieldModel(form, {
|
||||
@@ -86,7 +82,7 @@ describe('TypeaheadWidgetComponent', () => {
|
||||
const fieldId = '<field-id>';
|
||||
|
||||
const form = new FormModel({
|
||||
taskId: taskId
|
||||
taskId
|
||||
});
|
||||
|
||||
widget.field = new FormFieldModel(form, {
|
||||
@@ -103,7 +99,7 @@ describe('TypeaheadWidgetComponent', () => {
|
||||
const fieldId = '<field-id>';
|
||||
|
||||
const form = new FormModel({
|
||||
taskId: taskId
|
||||
taskId
|
||||
});
|
||||
|
||||
widget.field = new FormFieldModel(form, {
|
||||
@@ -125,7 +121,7 @@ describe('TypeaheadWidgetComponent', () => {
|
||||
const fieldId = '<field-id>';
|
||||
|
||||
const form = new FormModel({
|
||||
processDefinitionId: processDefinitionId
|
||||
processDefinitionId
|
||||
});
|
||||
|
||||
widget.field = new FormFieldModel(form, {
|
||||
@@ -301,7 +297,7 @@ describe('TypeaheadWidgetComponent', () => {
|
||||
|
||||
it('should show typeahead options', async () => {
|
||||
const typeaheadElement = fixture.debugElement.query(By.css('#typeahead-id'));
|
||||
const typeaheadHTMLElement = <HTMLInputElement> typeaheadElement.nativeElement;
|
||||
const typeaheadHTMLElement = typeaheadElement.nativeElement as HTMLInputElement;
|
||||
typeaheadHTMLElement.focus();
|
||||
typeaheadWidgetComponent.value = 'F';
|
||||
typeaheadHTMLElement.value = 'F';
|
||||
@@ -318,7 +314,7 @@ describe('TypeaheadWidgetComponent', () => {
|
||||
|
||||
it('should hide the option when the value is empty', async () => {
|
||||
const typeaheadElement = fixture.debugElement.query(By.css('#typeahead-id'));
|
||||
const typeaheadHTMLElement = <HTMLInputElement> typeaheadElement.nativeElement;
|
||||
const typeaheadHTMLElement = typeaheadElement.nativeElement as HTMLInputElement;
|
||||
typeaheadHTMLElement.focus();
|
||||
typeaheadWidgetComponent.value = 'F';
|
||||
typeaheadHTMLElement.value = 'F';
|
||||
|
@@ -31,50 +31,48 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { RelatedContentRepresentation } from '@alfresco/js-api';
|
||||
|
||||
const fakePngAnswer = new RelatedContentRepresentation({
|
||||
'id': 1155,
|
||||
'name': 'a_png_file.png',
|
||||
'created': '2017-07-25T17:17:37.099Z',
|
||||
'createdBy': { 'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin' },
|
||||
'relatedContent': false,
|
||||
'contentAvailable': true,
|
||||
'link': false,
|
||||
'mimeType': 'image/png',
|
||||
'simpleType': 'image',
|
||||
'previewStatus': 'queued',
|
||||
'thumbnailStatus': 'queued'
|
||||
id: 1155,
|
||||
name: 'a_png_file.png',
|
||||
created: '2017-07-25T17:17:37.099Z',
|
||||
createdBy: { id: 1001, firstName: 'Admin', lastName: 'admin', email: 'admin' },
|
||||
relatedContent: false,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'image/png',
|
||||
simpleType: 'image',
|
||||
previewStatus: 'queued',
|
||||
thumbnailStatus: 'queued'
|
||||
});
|
||||
|
||||
const fakeJpgAnswer = {
|
||||
'id': 1156,
|
||||
'name': 'a_jpg_file.jpg',
|
||||
'created': '2017-07-25T17:17:37.118Z',
|
||||
'createdBy': { 'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin' },
|
||||
'relatedContent': false,
|
||||
'contentAvailable': true,
|
||||
'link': false,
|
||||
'mimeType': 'image/jpeg',
|
||||
'simpleType': 'image',
|
||||
'previewStatus': 'queued',
|
||||
'thumbnailStatus': 'queued'
|
||||
id: 1156,
|
||||
name: 'a_jpg_file.jpg',
|
||||
created: '2017-07-25T17:17:37.118Z',
|
||||
createdBy: { id: 1001, firstName: 'Admin', lastName: 'admin', email: 'admin' },
|
||||
relatedContent: false,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'image/jpeg',
|
||||
simpleType: 'image',
|
||||
previewStatus: 'queued',
|
||||
thumbnailStatus: 'queued'
|
||||
};
|
||||
|
||||
describe('UploadWidgetComponent', () => {
|
||||
|
||||
function fakeCreationFile (name: string, id: string | number) {
|
||||
return {
|
||||
'id': id,
|
||||
'name': name,
|
||||
'created': '2017-07-25T17:17:37.118Z',
|
||||
'createdBy': { 'id': 1001, 'firstName': 'Admin', 'lastName': 'admin', 'email': 'admin' },
|
||||
'relatedContent': false,
|
||||
'contentAvailable': true,
|
||||
'link': false,
|
||||
'mimeType': 'image/jpeg',
|
||||
'simpleType': 'image',
|
||||
'previewStatus': 'queued',
|
||||
'thumbnailStatus': 'queued'
|
||||
};
|
||||
}
|
||||
const fakeCreationFile = (name: string, id: string | number) => ({
|
||||
id,
|
||||
name,
|
||||
created: '2017-07-25T17:17:37.118Z',
|
||||
createdBy: { id: 1001, firstName: 'Admin', lastName: 'admin', email: 'admin' },
|
||||
relatedContent: false,
|
||||
contentAvailable: true,
|
||||
link: false,
|
||||
mimeType: 'image/jpeg',
|
||||
simpleType: 'image',
|
||||
previewStatus: 'queued',
|
||||
thumbnailStatus: 'queued'
|
||||
});
|
||||
|
||||
let contentService: ProcessContentService;
|
||||
|
||||
@@ -231,7 +229,7 @@ describe('UploadWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const deleteButton = <HTMLInputElement> element.querySelector('#file-1155-remove');
|
||||
const deleteButton = element.querySelector<HTMLInputElement>('#file-1155-remove');
|
||||
deleteButton.click();
|
||||
|
||||
expect(uploadWidgetComponent.field.updateForm).toHaveBeenCalled();
|
||||
@@ -261,7 +259,7 @@ describe('UploadWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
inputElement = <HTMLInputElement> element.querySelector('#upload-id');
|
||||
inputElement = element.querySelector<HTMLInputElement>('#upload-id');
|
||||
expect(inputElement).toBeDefined();
|
||||
expect(inputElement).not.toBeNull();
|
||||
expect(uploadWidgetComponent.field.value).not.toBeNull();
|
||||
@@ -379,7 +377,7 @@ describe('UploadWidgetComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const buttonElement = <HTMLButtonElement> element.querySelector('#file-1156-remove');
|
||||
const buttonElement = element.querySelector<HTMLButtonElement>('#file-1156-remove');
|
||||
buttonElement.click();
|
||||
fixture.detectChanges();
|
||||
const jpegElement = element.querySelector('#file-1156');
|
||||
|
Reference in New Issue
Block a user