mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
enforce types for forms cloud (#5371)
* enforce right type form cloud * remove missing import * fix selector
This commit is contained in:
@@ -36,7 +36,7 @@ export class PeopleGroupCloudComponentPage {
|
|||||||
peopleCloudComponentTitle: ElementFinder = element(by.cssContainingText('mat-card-title', 'People Cloud Component'));
|
peopleCloudComponentTitle: ElementFinder = element(by.cssContainingText('mat-card-title', 'People Cloud Component'));
|
||||||
groupCloudComponentTitle: ElementFinder = element(by.cssContainingText('mat-card-title', 'Groups Cloud Component'));
|
groupCloudComponentTitle: ElementFinder = element(by.cssContainingText('mat-card-title', 'Groups Cloud Component'));
|
||||||
preselectValidation: ElementFinder = element.all(by.css('mat-checkbox.app-preselect-value')).first();
|
preselectValidation: ElementFinder = element.all(by.css('mat-checkbox.app-preselect-value')).first();
|
||||||
preselectValidationStatus: ElementFinder = element(by.css('mat-checkbox.app-preselect-value label input'));
|
preselectValidationStatus: ElementFinder = element.all(by.css('mat-checkbox.app-preselect-value label input')).first();
|
||||||
peopleFilterByAppName: ElementFinder = element(by.css('.app-people-control-options mat-radio-button[value="appName"]'));
|
peopleFilterByAppName: ElementFinder = element(by.css('.app-people-control-options mat-radio-button[value="appName"]'));
|
||||||
groupFilterByAppName: ElementFinder = element(by.css('.app-groups-control-options mat-radio-button[value="appName"]'));
|
groupFilterByAppName: ElementFinder = element(by.css('.app-groups-control-options mat-radio-button[value="appName"]'));
|
||||||
|
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { FormDefinitionSelectorCloudService } from '../services/form-definition-selector-cloud.service';
|
import { FormDefinitionSelectorCloudService } from '../services/form-definition-selector-cloud.service';
|
||||||
import { FormDefinitionSelectorCloudModel } from '../models/form-definition-selector-cloud.model';
|
|
||||||
import { MatSelectChange } from '@angular/material';
|
import { MatSelectChange } from '@angular/material';
|
||||||
|
import { FormRepresentation } from '../../services/form-fields.interfaces';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-cloud-form-definition-selector',
|
selector: 'adf-cloud-form-definition-selector',
|
||||||
@@ -37,7 +37,7 @@ export class FormDefinitionSelectorCloudComponent implements OnInit {
|
|||||||
@Output()
|
@Output()
|
||||||
selectForm: EventEmitter<string> = new EventEmitter<string>();
|
selectForm: EventEmitter<string> = new EventEmitter<string>();
|
||||||
|
|
||||||
forms$: Observable<FormDefinitionSelectorCloudModel[]>;
|
forms$: Observable<FormRepresentation[]>;
|
||||||
|
|
||||||
constructor(private formDefinitionCloudService: FormDefinitionSelectorCloudService) {
|
constructor(private formDefinitionCloudService: FormDefinitionSelectorCloudService) {
|
||||||
}
|
}
|
||||||
|
@@ -1,24 +0,0 @@
|
|||||||
/*!
|
|
||||||
* @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 FormDefinitionSelectorCloudModel {
|
|
||||||
id?: number;
|
|
||||||
name?: string;
|
|
||||||
description?: string;
|
|
||||||
version?: string;
|
|
||||||
standalone?: string;
|
|
||||||
}
|
|
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './models/task-variable-cloud.model';
|
export * from './models/task-variable-cloud.model';
|
||||||
export * from './models/form-definition-selector-cloud.model';
|
|
||||||
|
|
||||||
export * from './components/form-cloud.component';
|
export * from './components/form-cloud.component';
|
||||||
export * from './components/form-definition-selector-cloud.component';
|
export * from './components/form-definition-selector-cloud.component';
|
||||||
|
@@ -16,13 +16,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AlfrescoApiService, FormValues, AppConfigService, FormOutcomeModel, FormFieldOption, FormModel } from '@alfresco/adf-core';
|
import {
|
||||||
|
AlfrescoApiService,
|
||||||
|
FormValues,
|
||||||
|
AppConfigService,
|
||||||
|
FormOutcomeModel,
|
||||||
|
FormFieldOption,
|
||||||
|
FormModel
|
||||||
|
} from '@alfresco/adf-core';
|
||||||
import { Observable, from } from 'rxjs';
|
import { Observable, from } from 'rxjs';
|
||||||
import { map, switchMap } from 'rxjs/operators';
|
import { map, switchMap } from 'rxjs/operators';
|
||||||
import { TaskDetailsCloudModel } from '../../task/start-task/models/task-details-cloud.model';
|
import { TaskDetailsCloudModel } from '../../task/start-task/models/task-details-cloud.model';
|
||||||
import { CompleteFormRepresentation } from '@alfresco/js-api';
|
import { CompleteFormRepresentation } from '@alfresco/js-api';
|
||||||
import { TaskVariableCloud, ProcessStorageCloudModel } from '../models/task-variable-cloud.model';
|
import { TaskVariableCloud, ProcessStorageCloudModel } from '../models/task-variable-cloud.model';
|
||||||
import { BaseCloudService } from '../../services/base-cloud.service';
|
import { BaseCloudService } from '../../services/base-cloud.service';
|
||||||
|
import { FormContent } from '../../services/form-fields.interfaces';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -48,7 +56,7 @@ export class FormCloudService extends BaseCloudService {
|
|||||||
return this.getTask(appName, taskId).pipe(
|
return this.getTask(appName, taskId).pipe(
|
||||||
switchMap(task => {
|
switchMap(task => {
|
||||||
return this.getForm(appName, task.formKey, version).pipe(
|
return this.getForm(appName, task.formKey, version).pipe(
|
||||||
map(form => {
|
map((form: FormContent) => {
|
||||||
const flattenForm = {
|
const flattenForm = {
|
||||||
...form.formRepresentation,
|
...form.formRepresentation,
|
||||||
...form.formRepresentation.formDefinition,
|
...form.formRepresentation.formDefinition,
|
||||||
@@ -69,6 +77,7 @@ export class FormCloudService extends BaseCloudService {
|
|||||||
* Saves a task form.
|
* Saves a task form.
|
||||||
* @param appName Name of the app
|
* @param appName Name of the app
|
||||||
* @param taskId ID of the target task
|
* @param taskId ID of the target task
|
||||||
|
* @param processInstanceId ID of processInstance
|
||||||
* @param formId ID of the form to save
|
* @param formId ID of the form to save
|
||||||
* @param values Form values object
|
* @param values Form values object
|
||||||
* @returns Updated task details
|
* @returns Updated task details
|
||||||
@@ -107,14 +116,20 @@ export class FormCloudService extends BaseCloudService {
|
|||||||
* Completes a task form.
|
* Completes a task form.
|
||||||
* @param appName Name of the app
|
* @param appName Name of the app
|
||||||
* @param taskId ID of the target task
|
* @param taskId ID of the target task
|
||||||
|
* @param processInstanceId ID of processInstance
|
||||||
* @param formId ID of the form to complete
|
* @param formId ID of the form to complete
|
||||||
* @param formValues Form values object
|
* @param formValues Form values object
|
||||||
* @param outcome Form outcome
|
* @param outcome Form outcome
|
||||||
|
* @param version of the form
|
||||||
* @returns Updated task details
|
* @returns Updated task details
|
||||||
*/
|
*/
|
||||||
completeTaskForm(appName: string, taskId: string, processInstanceId: string, formId: string, formValues: FormValues, outcome: string, version: number): Observable<TaskDetailsCloudModel> {
|
completeTaskForm(appName: string, taskId: string, processInstanceId: string, formId: string, formValues: FormValues, outcome: string, version: number): Observable<TaskDetailsCloudModel> {
|
||||||
const apiUrl = `${this.getBasePath(appName)}/form/v1/forms/${formId}/submit/versions/${version}`;
|
const apiUrl = `${this.getBasePath(appName)}/form/v1/forms/${formId}/submit/versions/${version}`;
|
||||||
const completeFormRepresentation = <CompleteFormRepresentation> {values: formValues, taskId: taskId, processInstanceId: processInstanceId};
|
const completeFormRepresentation = <CompleteFormRepresentation> {
|
||||||
|
values: formValues,
|
||||||
|
taskId: taskId,
|
||||||
|
processInstanceId: processInstanceId
|
||||||
|
};
|
||||||
if (outcome) {
|
if (outcome) {
|
||||||
completeFormRepresentation.outcome = outcome;
|
completeFormRepresentation.outcome = outcome;
|
||||||
}
|
}
|
||||||
@@ -171,7 +186,7 @@ export class FormCloudService extends BaseCloudService {
|
|||||||
* @param version Version of the form
|
* @param version Version of the form
|
||||||
* @returns Form definition
|
* @returns Form definition
|
||||||
*/
|
*/
|
||||||
getForm(appName: string, formKey: string, version?: number): Observable<any> {
|
getForm(appName: string, formKey: string, version?: number): Observable<FormContent> {
|
||||||
let url = `${this.getBasePath(appName)}/form/v1/forms/${formKey}`;
|
let url = `${this.getBasePath(appName)}/form/v1/forms/${formKey}`;
|
||||||
|
|
||||||
if (version) {
|
if (version) {
|
||||||
|
@@ -18,9 +18,9 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
|
import { AlfrescoApiService, AppConfigService } from '@alfresco/adf-core';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { FormDefinitionSelectorCloudModel } from '../models/form-definition-selector-cloud.model';
|
|
||||||
import { from, Observable } from 'rxjs';
|
import { from, Observable } from 'rxjs';
|
||||||
import { BaseCloudService } from '../../services/base-cloud.service';
|
import { BaseCloudService } from '../../services/base-cloud.service';
|
||||||
|
import { FormRepresentation } from '../../services/form-fields.interfaces';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -38,13 +38,13 @@ export class FormDefinitionSelectorCloudService extends BaseCloudService {
|
|||||||
* @param appName Name of the application
|
* @param appName Name of the application
|
||||||
* @returns Details of the forms
|
* @returns Details of the forms
|
||||||
*/
|
*/
|
||||||
getForms(appName: string): Observable<FormDefinitionSelectorCloudModel[]> {
|
getForms(appName: string): Observable<FormRepresentation[]> {
|
||||||
const url = `${this.getBasePath(appName)}/form/v1/forms`;
|
const url = `${this.getBasePath(appName)}/form/v1/forms`;
|
||||||
|
|
||||||
return this.get(url).pipe(
|
return this.get(url).pipe(
|
||||||
map((data: any) => {
|
map((data: any) => {
|
||||||
return data.map((formData: any) => {
|
return data.map((formData: any) => {
|
||||||
return <FormDefinitionSelectorCloudModel> formData.formRepresentation;
|
return <FormRepresentation> formData.formRepresentation;
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -55,7 +55,7 @@ export class FormDefinitionSelectorCloudService extends BaseCloudService {
|
|||||||
* @param appName Name of the application
|
* @param appName Name of the application
|
||||||
* @returns Details of the forms
|
* @returns Details of the forms
|
||||||
*/
|
*/
|
||||||
getStandAloneTaskForms(appName: string): Observable<FormDefinitionSelectorCloudModel[]> {
|
getStandAloneTaskForms(appName: string): Observable<FormRepresentation[]> {
|
||||||
return from(this.getForms(appName)).pipe(
|
return from(this.getForms(appName)).pipe(
|
||||||
map((data: any) => {
|
map((data: any) => {
|
||||||
return data.filter((formData: any) => formData.standalone || formData.standalone === undefined);
|
return data.filter((formData: any) => formData.standalone || formData.standalone === undefined);
|
||||||
|
@@ -0,0 +1,233 @@
|
|||||||
|
/*!
|
||||||
|
* @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 { Moment } from 'moment';
|
||||||
|
|
||||||
|
export interface FormContent {
|
||||||
|
formRepresentation: FormRepresentation;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FormRepresentation {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
version?: number;
|
||||||
|
formDefinition?: FormDefinition;
|
||||||
|
standAlone?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FormTab {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
visibilityCondition: VisibilityCondition | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FormOutcome {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FormDefinition {
|
||||||
|
tabs: FormTab[];
|
||||||
|
fields: Container[] | HeaderRepresentation[];
|
||||||
|
outcomes: FormOutcome[];
|
||||||
|
metadata: {};
|
||||||
|
variables: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
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 | NumberField);
|
||||||
|
|
||||||
|
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 | Moment;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 enum PeopleModeOptions {
|
||||||
|
single = 'single',
|
||||||
|
multiple = 'multiple'
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PeopleField extends FormField {
|
||||||
|
required: boolean;
|
||||||
|
optionType: PeopleModeOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum 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'
|
||||||
|
}
|
@@ -19,3 +19,4 @@ export * from './user-preference-cloud.service';
|
|||||||
export * from './local-preference-cloud.service';
|
export * from './local-preference-cloud.service';
|
||||||
export * from './cloud-token.service';
|
export * from './cloud-token.service';
|
||||||
export * from './preference-cloud.interface';
|
export * from './preference-cloud.interface';
|
||||||
|
export * from './form-fields.interfaces';
|
||||||
|
Reference in New Issue
Block a user