Files
alfresco-ng2-components/lib/process-services-cloud/src/lib/services/form-fields.interfaces.ts
T
Denys Vuika 40b15689d5 AAE-21047 Get rid of enums (#11643)
* Refactor enums to const objects and update ESLint rules

- Converted several TypeScript enums to const objects for better type inference and immutability.
- Updated ESLint configuration to disable 'no-redeclare' rule and added new restrictions on schema usage.
- Adjusted package-lock.json to mark several dependencies as peer dependencies.

* Refactor enums to const objects in site-dropdown and new-version-uploader models

- Converted TypeScript enums to const objects for improved type safety and immutability in `sites-dropdown.component.ts` and `new-version-uploader.model.ts`.
- Updated related types to reflect the changes in both files.
- Enhanced error handling in the `DropdownSitesComponent` by using the `subscribe` method with an object for better readability.

* Refactor TypeScript types and improve error handling in component tests

- Updated type annotations in `upload.service.ts` and `node-actions.service.ts` for better type safety.
- Enhanced error handling in various component tests by using more descriptive error messages in `task-attachment-list.component.spec.ts`, `attach-file-widget-dialog.component.spec.ts`, and `task-form.component.spec.ts`.
- Removed unnecessary schemas from test configurations in several component spec files to streamline the testing setup.

* Refactor TypeScript enums to const objects for improved type safety

- Converted multiple TypeScript enums to const objects across various models, including `AppConfigValues`, `Status`, `ShowHeaderMode`, `WidgetTypeEnum`, and others.
- Updated related type definitions to enhance type inference and immutability.
- Adjusted ESLint configurations by removing the 'no-redeclare' rule to streamline code quality checks.

* Refactor TypeScript types for improved type safety and consistency

- Updated type annotations in `document-list.component.ts`, `document-actions.service.ts`, and `node-actions.service.ts` to use `Observable` instead of `Subject` for better reactive programming practices.
- Enhanced type definitions in `search-date-range.component.ts` and related spec files to allow `inLastValue` to be either a string or a number, improving flexibility in handling date range inputs.
- Adjusted test cases to reflect these type changes, ensuring consistency across the application.

* Enhance type safety in ViewerComponent by specifying type for closeButtonPosition

- Updated the type annotation for `closeButtonPosition` in `viewer.component.ts` to explicitly define it as `CloseButtonPosition`, improving type safety and clarity.

* Enhance type safety in DataTableComponent by specifying type for showHeader

- Updated the type annotation for `showHeader` in `datatable.component.ts` to explicitly define it as `ShowHeaderMode`, improving type safety and clarity.

* Update PDF viewer test to accommodate varying date formats

- Modified the test for the annotation popup in `pdf-viewer.component.spec.ts` to check for the presence of date components instead of a specific date format, enhancing test robustness across different locales.
2026-02-12 16:28:45 +00:00

296 lines
6.8 KiB
TypeScript

/*!
* @license
* Copyright © 2005-2025 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 FormContent {
formRepresentation: FormRepresentation;
}
export interface FormRepresentation {
id: string;
name: string;
description: string;
version?: number;
formDefinition?: FormDefinition;
standAlone?: boolean;
displayMode?: string;
}
export interface FormTab {
id: string;
title: string;
visibilityCondition: VisibilityCondition | null;
}
export interface FormTheme {
form: {
[key: string]: string;
};
widgets: {
[key: string]: {
[key: string]: {
[key: string]: string;
};
};
};
}
export interface FormOutcome {
id: string;
name: string;
}
export interface FormDefinition {
tabs: FormTab[];
fields: Container[] | HeaderRepresentation[];
outcomes: FormOutcome[];
metadata: any;
variables: any[];
theme?: FormTheme;
}
export interface Container {
id: string;
type: string;
tab: string;
name: string;
numberOfColumns: number;
fields: {
[key: string]: FormFieldRepresentation[];
};
}
export type FormFieldRepresentation =
| DateField
| DateTimeField
| TextField
| AttachFileField
| DropDownField
| RadioField
| TypeaheadField
| PeopleField
| AmountField
| NumberField
| CheckboxField
| HyperlinkField;
export interface AttachFileField extends FormField {
required: boolean;
}
export interface TypeaheadField extends RestField {
required: boolean;
}
export interface RestField extends FormField {
required: boolean;
restUrl: string;
restResponsePath: string;
restIdProperty: string;
restLabelProperty: string;
}
export interface HeaderRepresentation extends Container {
numberOfColumns: number;
params: {
[key: string]: any;
};
visibilityCondition: VisibilityCondition;
}
export interface ColumnDefinitionRepresentation extends Container {
id: string;
name: string;
type: string;
value: any;
required: boolean;
editable: boolean;
sortable: boolean;
visible: boolean;
}
export interface DynamicTableRepresentation extends FormField {
required: boolean;
tab: string;
placeholder: string;
columnDefinitions: ColumnDefinitionRepresentation[];
}
export interface VisibilityCondition {
leftType: string;
leftValue: string;
operator: string;
rightValue: string | number | Date;
rightType: string;
nextConditionOperator?: string;
nextCondition?: VisibilityCondition;
}
export interface FormField {
id: string;
name: string;
value: any;
type: FormFieldType | string;
readOnly?: boolean;
colspan: number;
params: {
[anyKey: string]: any;
};
visibilityCondition: null | VisibilityCondition;
style?: string;
}
export interface FormOption {
id: string;
name: string;
}
export interface OptionsField {
value: any;
restUrl: string | null;
restResponsePath: string | null;
restIdProperty: string | null;
restLabelProperty: string | null;
optionType: 'manual' | 'rest';
options: FormOption[];
}
export interface AmountField extends FormField {
required: boolean;
placeholder: string | null;
minValue: number | null;
maxValue: number | null;
enableFractions: boolean;
currency: string;
}
export interface CheckboxField extends FormField {
required: boolean;
}
export interface DateField extends FormField {
required: boolean;
placeholder: string | null;
minValue: string | null;
maxValue: string | null;
dateDisplayFormat: string;
}
export interface DateTimeField extends FormField {
required: boolean;
placeholder: string | null;
minValue: string | null;
maxValue: string | null;
dateDisplayFormat: string;
}
export interface DropDownField extends OptionsField, FormField {
required: boolean;
}
export interface HyperlinkField extends FormField {
hyperlinkUrl: string | null;
displayText: string | null;
}
export interface NumberField extends FormField {
placeholder: string | null;
minValue: number | null;
maxValue: number | null;
required: boolean;
}
export interface RadioField extends OptionsField, FormField {
required: boolean;
}
export interface TextField extends FormField {
regexPattern: string | null;
required: boolean;
minLength: number;
maxLength: number;
placeholder: string | null;
}
export const PeopleModeOptions = {
single: 'single',
multiple: 'multiple'
} as const;
export type PeopleModeOptions = (typeof PeopleModeOptions)[keyof typeof PeopleModeOptions];
export interface PeopleField extends FormField {
required: boolean;
optionType: PeopleModeOptions;
}
export const FormFieldType = {
text: 'text',
multiline: 'multi-line-text',
number: 'integer',
checkbox: 'boolean',
date: 'date',
datetime: 'datetime',
dropdown: 'dropdown',
typeahead: 'typeahead',
amount: 'amount',
radio: 'radio-buttons',
people: 'people',
groupOfPeople: 'functional-group',
dynamicTable: 'dynamicTable',
hyperlink: 'hyperlink',
header: 'group',
uploadFile: 'upload',
uploadFolder: 'uploadFolder',
displayValue: 'readonly',
displayText: 'readonly-text',
fileViewer: 'file-viewer',
button: 'button'
} as const;
export type FormFieldType = (typeof FormFieldType)[keyof typeof FormFieldType];
export interface FormCloudDisplayModeConfigurationOptions {
onCompleteTask(id?: string): void;
onSaveTask(id?: string): void;
onDisplayModeOn(id?: string): void;
onDisplayModeOff(id?: string): void;
fullscreen?: boolean;
displayToolbar?: boolean;
displayCloseButton?: boolean;
trapFocus?: boolean;
[key: string]: any;
}
export interface FormCloudDisplayModeConfiguration {
displayMode: string;
options?: FormCloudDisplayModeConfigurationOptions;
default?: boolean;
}
export const FormCloudDisplayMode = {
inline: 'inline',
fullScreen: 'fullScreen',
standalone: 'standalone'
} as const;
export type FormCloudDisplayMode = (typeof FormCloudDisplayMode)[keyof typeof FormCloudDisplayMode];
export interface FormCloudDisplayModeChange {
displayMode: string;
id?: string;
}