[AAE-7119] Fix circular dependencies (#7472)

* fix language item dependency

* fix public-api export

* dependency fixes

* fix circular deps

* fix circular deps

* fix circular deps

* fix circular deps

* fix circular dependency

* workaround for circular deps

* fix lint
This commit is contained in:
Denys Vuika
2022-01-28 14:14:42 +00:00
committed by GitHub
parent e8871e7867
commit 3aa629d4be
27 changed files with 144 additions and 56 deletions

View File

@@ -17,12 +17,10 @@
/* tslint:disable:component-selector */
import { FormFieldModel } from './form-field.model';
export class ContainerColumnModel {
size: number = 12;
fields: FormFieldModel[] = [];
fields: any[] = [];
colspan: number = 1;
rowspan: number = 1;

View File

@@ -0,0 +1,24 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export const isNumberValue = (value: any): boolean => {
if (value === null || value === undefined || value === '') {
return false;
}
return !isNaN(+value);
};

View File

@@ -19,6 +19,7 @@
import moment from 'moment-es6';
import { FormFieldTypes } from './form-field-types';
import { isNumberValue } from './form-field-utils';
import { FormFieldModel } from './form-field.model';
export interface FormFieldValidator {
@@ -104,11 +105,7 @@ export class NumberFieldValidator implements FormFieldValidator {
];
static isNumber(value: any): boolean {
if (value === null || value === undefined || value === '') {
return false;
}
return !isNaN(+value);
return isNumberValue(value);
}
isSupported(field: FormFieldModel): boolean {

View File

@@ -23,10 +23,10 @@ import { ErrorMessageModel } from './error-message.model';
import { FormFieldMetadata } from './form-field-metadata';
import { FormFieldOption } from './form-field-option';
import { FormFieldTypes } from './form-field-types';
import { NumberFieldValidator } from './form-field-validator';
import { FormWidgetModel } from './form-widget.model';
import { FormModel } from './form.model';
import { FormFieldRule } from './form-field-rule';
import { ProcessFormModel } from './process-form-model.interface';
import { isNumberValue } from './form-field-utils';
// Maps to FormFieldRepresentation
export class FormFieldModel extends FormWidgetModel {
@@ -143,7 +143,7 @@ export class FormFieldModel extends FormWidgetModel {
return this._isValid;
}
constructor(form: FormModel, json?: any) {
constructor(form: any, json?: any) {
super(form, json);
if (json) {
this.fieldType = json.fieldType;
@@ -247,7 +247,7 @@ export class FormFieldModel extends FormWidgetModel {
return name + '_LABEL';
}
private getProcessVariableValue(field: any, form: FormModel): any {
private getProcessVariableValue(field: any, form: ProcessFormModel): any {
let fieldName = field.name;
if (this.isTypeaheadFieldType(field.type)) {
fieldName = this.getFieldNameWithLabel(field.id);
@@ -255,7 +255,7 @@ export class FormFieldModel extends FormWidgetModel {
return form.getProcessVariableValue(fieldName);
}
private containerFactory(json: any, form: FormModel): void {
private containerFactory(json: any, form: any): void {
this.numberOfColumns = <number> json.numberOfColumns || 1;
this.fields = json.fields;
@@ -332,7 +332,7 @@ export class FormFieldModel extends FormWidgetModel {
if (this.isDateField(json) || this.isDateTimeField(json)) {
if (value) {
let dateValue;
if (NumberFieldValidator.isNumber(value)) {
if (isNumberValue(value)) {
dateValue = moment(value);
} else {
dateValue = this.isDateTimeField(json) ? moment.utc(value, 'YYYY-MM-DD hh:mm A') : moment.utc(value.split('T')[0], 'YYYY-M-D');

View File

@@ -18,7 +18,6 @@
/* tslint:disable:component-selector */
import { FormWidgetModel } from './form-widget.model';
import { FormModel } from './form.model';
import { WidgetVisibilityModel } from './../../../models/widget-visibility.model';
export class FormOutcomeModel extends FormWidgetModel {
@@ -32,7 +31,7 @@ export class FormOutcomeModel extends FormWidgetModel {
isVisible: boolean = true;
visibilityCondition: WidgetVisibilityModel;
constructor(form: FormModel, json?: any) {
constructor(form: any, json?: any) {
super(form, json);
if (json) {

View File

@@ -17,8 +17,6 @@
/* tslint:disable:component-selector */
import { FormModel } from './form.model';
export abstract class FormWidgetModel {
readonly fieldType: string;
@@ -31,7 +29,7 @@ export abstract class FormWidgetModel {
readonly json: any;
readonly field: any;
protected constructor(form: FormModel, json: any) {
protected constructor(form: any, json: any) {
this.form = form;
this.json = json;

View File

@@ -18,7 +18,6 @@
import { FormFieldEvent } from './../../../events/form-field.event';
import { ValidateFormFieldEvent } from './../../../events/validate-form-field.event';
import { ValidateFormEvent } from './../../../events/validate-form.event';
import { FormService } from './../../../services/form.service';
import { ContainerModel } from './container.model';
import { FormFieldTypes } from './form-field-types';
import { FormFieldModel } from './form-field.model';
@@ -32,6 +31,8 @@ import { FormOutcomeModel } from './form-outcome.model';
import { FormFieldValidator, FORM_FIELD_VALIDATORS } from './form-field-validator';
import { FormFieldTemplates } from './form-field-templates';
import { UploadWidgetContentLinkModel } from './upload-widget-content-link.model';
import { FormValidationService } from '../../../services/form-validation-service.interface';
import { ProcessFormModel } from './process-form-model.interface';
export interface FormRepresentationModel {
[key: string]: any;
@@ -54,7 +55,7 @@ export interface FormRepresentationModel {
};
}
export class FormModel {
export class FormModel implements ProcessFormModel {
static UNSET_TASK_NAME: string = 'Nameless task';
static SAVE_OUTCOME: string = '$save';
@@ -84,7 +85,7 @@ export class FormModel {
processVariables: ProcessVariableModel[] = [];
variables: FormVariableModel[] = [];
constructor(json?: any, formValues?: FormValues, readOnly: boolean = false, protected formService?: FormService, enableFixedSpace?: boolean) {
constructor(json?: any, formValues?: FormValues, readOnly: boolean = false, protected formService?: FormValidationService, enableFixedSpace?: boolean) {
this.readOnly = readOnly;
this.json = json;

View File

@@ -25,6 +25,7 @@ export * from './form-field-templates';
export * from './form-widget.model';
export * from './form-field.model';
export * from './form.model';
export * from './process-form-model.interface';
export * from './container.model';
export * from './container-column.model';
export * from './tab.model';
@@ -41,3 +42,4 @@ export * from './process-variable.model';
export * from './upload-widget-content-link.model';
export * from './form-field-file-source';
export * from './form-field-rule';
export * from './form-field-utils';

View File

@@ -0,0 +1,20 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface ProcessFormModel {
getProcessVariableValue(name: string): any;
}

View File

@@ -19,7 +19,6 @@
import { WidgetVisibilityModel } from '../../../models/widget-visibility.model';
import { FormWidgetModel } from './form-widget.model';
import { FormModel } from './form.model';
export class TabModel extends FormWidgetModel {
@@ -33,7 +32,7 @@ export class TabModel extends FormWidgetModel {
return this.fields && this.fields.length > 0;
}
constructor(form: FormModel, json?: any) {
constructor(form: any, json?: any) {
super(form, json);
if (json) {

View File

@@ -15,9 +15,9 @@
* limitations under the License.
*/
/* tslint:disable:component-selector */
import { ErrorMessageModel } from '../core/error-message.model';
import { ErrorMessageModel } from '../core/index';
/* tslint:disable:component-selector */
export class DynamicRowValidationSummary extends ErrorMessageModel {