[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

@@ -16,7 +16,6 @@
*/ */
export * from './content-type.service'; export * from './content-type.service';
// export * from './content-type.model';
export * from './content-type-metadata.interface'; export * from './content-type-metadata.interface';
export * from './content-type-dialog.component'; export * from './content-type-dialog.component';

View File

@@ -15,4 +15,4 @@
* limitations under the License. * limitations under the License.
*/ */
export * from './public-api'; export * from './index';

View File

@@ -17,12 +17,10 @@
/* tslint:disable:component-selector */ /* tslint:disable:component-selector */
import { FormFieldModel } from './form-field.model';
export class ContainerColumnModel { export class ContainerColumnModel {
size: number = 12; size: number = 12;
fields: FormFieldModel[] = []; fields: any[] = [];
colspan: number = 1; colspan: number = 1;
rowspan: 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 moment from 'moment-es6';
import { FormFieldTypes } from './form-field-types'; import { FormFieldTypes } from './form-field-types';
import { isNumberValue } from './form-field-utils';
import { FormFieldModel } from './form-field.model'; import { FormFieldModel } from './form-field.model';
export interface FormFieldValidator { export interface FormFieldValidator {
@@ -104,11 +105,7 @@ export class NumberFieldValidator implements FormFieldValidator {
]; ];
static isNumber(value: any): boolean { static isNumber(value: any): boolean {
if (value === null || value === undefined || value === '') { return isNumberValue(value);
return false;
}
return !isNaN(+value);
} }
isSupported(field: FormFieldModel): boolean { isSupported(field: FormFieldModel): boolean {

View File

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

View File

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

View File

@@ -18,7 +18,6 @@
import { FormFieldEvent } from './../../../events/form-field.event'; import { FormFieldEvent } from './../../../events/form-field.event';
import { ValidateFormFieldEvent } from './../../../events/validate-form-field.event'; import { ValidateFormFieldEvent } from './../../../events/validate-form-field.event';
import { ValidateFormEvent } from './../../../events/validate-form.event'; import { ValidateFormEvent } from './../../../events/validate-form.event';
import { FormService } from './../../../services/form.service';
import { ContainerModel } from './container.model'; import { ContainerModel } from './container.model';
import { FormFieldTypes } from './form-field-types'; import { FormFieldTypes } from './form-field-types';
import { FormFieldModel } from './form-field.model'; 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 { FormFieldValidator, FORM_FIELD_VALIDATORS } from './form-field-validator';
import { FormFieldTemplates } from './form-field-templates'; import { FormFieldTemplates } from './form-field-templates';
import { UploadWidgetContentLinkModel } from './upload-widget-content-link.model'; 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 { export interface FormRepresentationModel {
[key: string]: any; [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 UNSET_TASK_NAME: string = 'Nameless task';
static SAVE_OUTCOME: string = '$save'; static SAVE_OUTCOME: string = '$save';
@@ -84,7 +85,7 @@ export class FormModel {
processVariables: ProcessVariableModel[] = []; processVariables: ProcessVariableModel[] = [];
variables: FormVariableModel[] = []; 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.readOnly = readOnly;
this.json = json; this.json = json;

View File

@@ -25,6 +25,7 @@ export * from './form-field-templates';
export * from './form-widget.model'; export * from './form-widget.model';
export * from './form-field.model'; export * from './form-field.model';
export * from './form.model'; export * from './form.model';
export * from './process-form-model.interface';
export * from './container.model'; export * from './container.model';
export * from './container-column.model'; export * from './container-column.model';
export * from './tab.model'; export * from './tab.model';
@@ -41,3 +42,4 @@ export * from './process-variable.model';
export * from './upload-widget-content-link.model'; export * from './upload-widget-content-link.model';
export * from './form-field-file-source'; export * from './form-field-file-source';
export * from './form-field-rule'; 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 { WidgetVisibilityModel } from '../../../models/widget-visibility.model';
import { FormWidgetModel } from './form-widget.model'; import { FormWidgetModel } from './form-widget.model';
import { FormModel } from './form.model';
export class TabModel extends FormWidgetModel { export class TabModel extends FormWidgetModel {
@@ -33,7 +32,7 @@ export class TabModel extends FormWidgetModel {
return this.fields && this.fields.length > 0; return this.fields && this.fields.length > 0;
} }
constructor(form: FormModel, json?: any) { constructor(form: any, json?: any) {
super(form, json); super(form, json);
if (json) { if (json) {

View File

@@ -15,9 +15,9 @@
* limitations under the License. * 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 { export class DynamicRowValidationSummary extends ErrorMessageModel {

View File

@@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
import { FormModel } from './../components/widgets/core/index'; import { FormModel } from '../components/widgets/core/form.model';
import { FormEvent } from './form.event'; import { FormEvent } from './form.event';
export class FormErrorEvent extends FormEvent { export class FormErrorEvent extends FormEvent {

View File

@@ -15,14 +15,14 @@
* limitations under the License. * limitations under the License.
*/ */
import { FormFieldModel, FormModel } from './../components/widgets/core/index'; import { FormFieldModel } from '../components/widgets/core/form-field.model';
import { FormEvent } from './form.event'; import { FormEvent } from './form.event';
export class FormFieldEvent extends FormEvent { export class FormFieldEvent extends FormEvent {
readonly field: FormFieldModel; readonly field: FormFieldModel;
constructor(form: FormModel, field: FormFieldModel) { constructor(form: any, field: FormFieldModel) {
super(form); super(form);
this.field = field; this.field = field;
} }

View File

@@ -15,15 +15,13 @@
* limitations under the License. * limitations under the License.
*/ */
import { FormModel } from './../components/widgets/core/index';
export class FormEvent { export class FormEvent {
private isDefaultPrevented: boolean = false; private isDefaultPrevented: boolean = false;
readonly form: FormModel; readonly form: any;
constructor(form: FormModel) { constructor(form: any) {
this.form = form; this.form = form;
} }

View File

@@ -15,10 +15,10 @@
* limitations under the License. * limitations under the License.
*/ */
import { FormFieldModel } from '../components/widgets/core/form-field.model';
import { FormModel } from '../components/widgets/core/form.model';
import { DynamicRowValidationSummary } from '../components/widgets/dynamic-table/dynamic-row-validation-summary.model'; import { DynamicRowValidationSummary } from '../components/widgets/dynamic-table/dynamic-row-validation-summary.model';
import { DynamicTableRow } from '../components/widgets/dynamic-table/dynamic-table-row.model'; import { DynamicTableRow } from '../components/widgets/dynamic-table/dynamic-table-row.model';
import { FormFieldModel, FormModel } from './../components/widgets/core/index';
import { FormFieldEvent } from './form-field.event'; import { FormFieldEvent } from './form-field.event';
export class ValidateDynamicTableRowEvent extends FormFieldEvent { export class ValidateDynamicTableRowEvent extends FormFieldEvent {

View File

@@ -15,14 +15,14 @@
* limitations under the License. * limitations under the License.
*/ */
import { FormFieldModel, FormModel } from './../components/widgets/core/index'; import { FormFieldModel } from '../components/widgets/core/form-field.model';
import { FormFieldEvent } from './form-field.event'; import { FormFieldEvent } from './form-field.event';
export class ValidateFormFieldEvent extends FormFieldEvent { export class ValidateFormFieldEvent extends FormFieldEvent {
isValid = true; isValid = true;
constructor(form: FormModel, field: FormFieldModel) { constructor(form: any, field: FormFieldModel) {
super(form, field); super(form, field);
} }

View File

@@ -15,7 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
import { FormModel } from './../components/widgets/core/index';
import { FormEvent } from './form.event'; import { FormEvent } from './form.event';
import { FormFieldModel } from '../components/widgets/core/form-field.model'; import { FormFieldModel } from '../components/widgets/core/form-field.model';
@@ -24,7 +23,7 @@ export class ValidateFormEvent extends FormEvent {
isValid = true; isValid = true;
errorsField: FormFieldModel[] = []; errorsField: FormFieldModel[] = [];
constructor(form: FormModel) { constructor(form: any) {
super(form); super(form);
} }
} }

View File

@@ -28,6 +28,7 @@ export * from './services/activiti-alfresco.service';
export * from './services/ecm-model.service'; export * from './services/ecm-model.service';
export * from './services/form-rendering.service'; export * from './services/form-rendering.service';
export * from './services/form.service'; export * from './services/form.service';
export * from './services/form-validation-service.interface';
export * from './services/node.service'; export * from './services/node.service';
export * from './services/process-content.service'; export * from './services/process-content.service';
export * from './services/widget-visibility.service'; export * from './services/widget-visibility.service';

View File

@@ -0,0 +1,27 @@
/*!
* @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.
*/
import { Subject } from 'rxjs';
import { FormFieldEvent } from '../events/form-field.event';
import { ValidateFormFieldEvent } from '../events/validate-form-field.event';
import { ValidateFormEvent } from '../events/validate-form.event';
export interface FormValidationService {
formFieldValueChanged: Subject<FormFieldEvent>;
validateForm: Subject<ValidateFormEvent>;
validateFormField: Subject<ValidateFormFieldEvent>;
}

View File

@@ -23,11 +23,6 @@ import { Observable, Subject, from, of, throwError } from 'rxjs';
import { FormDefinitionModel } from '../models/form-definition.model'; import { FormDefinitionModel } from '../models/form-definition.model';
import { ContentLinkModel } from './../components/widgets/core/content-link.model'; import { ContentLinkModel } from './../components/widgets/core/content-link.model';
import { GroupModel } from './../components/widgets/core/group.model'; import { GroupModel } from './../components/widgets/core/group.model';
import { FormModel, FormOutcomeEvent, FormOutcomeModel, FormValues } from './../components/widgets/core/index';
import {
FormErrorEvent, FormEvent, FormFieldEvent,
ValidateDynamicTableRowEvent, ValidateFormEvent, ValidateFormFieldEvent
} from './../events/index';
import { EcmModelService } from './ecm-model.service'; import { EcmModelService } from './ecm-model.service';
import { map, catchError, switchMap, combineAll, defaultIfEmpty } from 'rxjs/operators'; import { map, catchError, switchMap, combineAll, defaultIfEmpty } from 'rxjs/operators';
import { import {
@@ -43,11 +38,22 @@ import {
UsersApi, UsersApi,
ActivitiGroupsApi ActivitiGroupsApi
} from '@alfresco/js-api'; } from '@alfresco/js-api';
import { FormOutcomeEvent } from '../components/widgets/core/form-outcome-event.model';
import { FormValues } from '../components/widgets/core/form-values';
import { FormModel } from '../components/widgets/core/form.model';
import { FormOutcomeModel } from '../components/widgets/core/form-outcome.model';
import { FormEvent } from '../events/form.event';
import { FormFieldEvent } from '../events/form-field.event';
import { FormErrorEvent } from '../events/form-error.event';
import { ValidateFormEvent } from '../events/validate-form.event';
import { ValidateFormFieldEvent } from '../events/validate-form-field.event';
import { ValidateDynamicTableRowEvent } from '../events/validate-dynamic-table-row.event';
import { FormValidationService } from './form-validation-service.interface';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class FormService { export class FormService implements FormValidationService {
static UNKNOWN_ERROR_MESSAGE: string = 'Unknown error'; static UNKNOWN_ERROR_MESSAGE: string = 'Unknown error';
static GENERIC_ERROR_MESSAGE: string = 'Server error'; static GENERIC_ERROR_MESSAGE: string = 'Server error';

View File

@@ -16,8 +16,9 @@
*/ */
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { LanguageItem, LanguageService } from '../services/language.service'; import { LanguageService } from '../services/language.service';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { LanguageItem } from '../services/language-item.interface';
@Component({ @Component({
selector: 'adf-language-menu', selector: 'adf-language-menu',

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.
*/
import { Direction } from '@angular/cdk/bidi';
export interface LanguageItem {
key: string;
label: string;
direction?: Direction;
}

View File

@@ -16,17 +16,11 @@
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Direction } from '@angular/cdk/bidi';
import { BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service'; import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { LanguageItem } from './language-item.interface';
import { UserPreferencesService } from './user-preferences.service'; import { UserPreferencesService } from './user-preferences.service';
export interface LanguageItem {
key: string;
label: string;
direction?: Direction;
}
@Injectable({providedIn: 'root'}) @Injectable({providedIn: 'root'})
export class LanguageService { export class LanguageService {

View File

@@ -67,3 +67,4 @@ export * from './oauth2.service';
export * from './language.service'; export * from './language.service';
export * from './identity-user.service.interface'; export * from './identity-user.service.interface';
export * from './identity-group.interface'; export * from './identity-group.interface';
export * from './language-item.interface';

View File

@@ -19,10 +19,10 @@ import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { Observable, BehaviorSubject } from 'rxjs'; import { Observable, BehaviorSubject } from 'rxjs';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service'; import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { LanguageItem } from './language.service';
import { StorageService } from './storage.service'; import { StorageService } from './storage.service';
import { distinctUntilChanged, map, filter } from 'rxjs/operators'; import { distinctUntilChanged, map, filter } from 'rxjs/operators';
import { AlfrescoApiService } from './alfresco-api.service'; import { AlfrescoApiService } from './alfresco-api.service';
import { LanguageItem } from './language-item.interface';
export enum UserPreferenceValues { export enum UserPreferenceValues {
PaginationSize = 'paginationSize', PaginationSize = 'paginationSize',