[ADF-4529] Enable form configuration from e2e tests (#4738)

* [ADF-4529] Enable form configuration from e2e tests

* Improve linting

* Move form methods to new  file
This commit is contained in:
davidcanonieto
2019-05-28 15:27:26 +01:00
committed by Eugenio Romano
parent 36faed0fab
commit f2f08a5bf8
10 changed files with 1894 additions and 110 deletions

View File

@@ -16,10 +16,9 @@
*/
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormFieldModel, NotificationService, FormRenderingService } from '@alfresco/adf-core';
import { FormFieldModel, NotificationService, FormRenderingService, CoreAutomationService } from '@alfresco/adf-core';
import { FormCloud, FormCloudService, UploadCloudWidgetComponent } from '@alfresco/adf-process-services-cloud';
import { Subscription } from 'rxjs';
import { formDefinition } from './demo-form';
@Component({
templateUrl: 'cloud-form-demo.component.html',
@@ -45,7 +44,8 @@ export class FormCloudDemoComponent implements OnInit, OnDestroy {
constructor(
private notificationService: NotificationService,
private formRenderingService: FormRenderingService,
private formService: FormCloudService) {
private formService: FormCloudService,
private automationService: CoreAutomationService) {
this.formRenderingService.setComponentTypeResolver('upload', () => UploadCloudWidgetComponent, true);
}
@@ -54,7 +54,7 @@ export class FormCloudDemoComponent implements OnInit, OnDestroy {
}
ngOnInit() {
this.formConfig = formDefinition;
this.formConfig = this.automationService.forms.getFormCloudDefinition();
this.parseForm();
}

View File

@@ -1,96 +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 const formDefinition = `{
"formRepresentation": {
"id": "text-form",
"name": "test-start-form",
"version": 0,
"description": "",
"formDefinition": {
"tabs": [],
"fields": [
{
"id": "1511517333638",
"type": "container",
"fieldType": "ContainerRepresentation",
"name": "Label",
"tab": null,
"numberOfColumns": 2,
"fields": {
"1": [
{
"fieldType": "FormFieldRepresentation",
"id": "texttest",
"name": "texttest",
"type": "text",
"value": null,
"required": false,
"placeholder": "text",
"params": {
"existingColspan": 2,
"maxColspan": 6,
"inputMaskReversed": true,
"inputMask": "0#",
"inputMaskPlaceholder": "(0-9)"
}
}
],
"2": [{
"fieldType": "AttachFileFieldRepresentation",
"id": "attachfiletest",
"name": "attachfiletest",
"type": "upload",
"required": true,
"colspan": 2,
"placeholder": "attachfile",
"params": {
"existingColspan": 2,
"maxColspan": 2,
"fileSource": {
"serviceId": "local-file",
"name": "Local File"
},
"multiple": true,
"link": false
},
"visibilityCondition": {
}
}]
}
}
],
"outcomes": [],
"metadata": {
"property1": "value1",
"property2": "value2"
},
"variables": [
{
"name": "variable1",
"type": "string",
"value": "value1"
},
{
"name": "variable2",
"type": "string",
"value": "value2"
}
]
}
}}
`;

View File

@@ -16,9 +16,8 @@
*/
import { Component, Inject, OnInit } from '@angular/core';
import { FormModel, FormService, FormOutcomeEvent } from '@alfresco/adf-core';
import { FormModel, FormService, FormOutcomeEvent, CoreAutomationService } from '@alfresco/adf-core';
import { InMemoryFormService } from '../../services/in-memory-form.service';
import { DemoForm } from './demo-form';
import { FakeFormService } from './fake-form.service';
@Component({
@@ -37,7 +36,8 @@ export class FormLoadingComponent implements OnInit {
radioButtonFieldValue = '';
formattedData = {};
constructor(@Inject(FormService) private formService: InMemoryFormService) {
constructor(@Inject(FormService) private formService: InMemoryFormService,
private automationService: CoreAutomationService) {
formService.executeOutcome.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
formOutcomeEvent.preventDefault();
});
@@ -45,7 +45,7 @@ export class FormLoadingComponent implements OnInit {
ngOnInit() {
this.formattedData = {};
const formDefinitionJSON: any = DemoForm.getSimpleFormDefinition();
const formDefinitionJSON: any = this.automationService.forms.getSimpleFormDefinition();
this.form = this.formService.parseForm(formDefinitionJSON);
}

View File

@@ -16,9 +16,8 @@
*/
import { Component, Inject, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
import { FormModel, FormFieldModel, FormService, FormOutcomeEvent, NotificationService } from '@alfresco/adf-core';
import { FormModel, FormFieldModel, FormService, FormOutcomeEvent, NotificationService, CoreAutomationService } from '@alfresco/adf-core';
import { InMemoryFormService } from '../../services/in-memory-form.service';
import { DemoForm } from './demo-form';
import { Subscription } from 'rxjs';
@Component({
@@ -48,7 +47,8 @@ export class FormComponent implements OnInit, OnDestroy {
};
constructor(@Inject(FormService) private formService: InMemoryFormService,
private notificationService: NotificationService) {
private notificationService: NotificationService,
private automationService: CoreAutomationService) {
this.subscriptions.push(
formService.executeOutcome.subscribe((formOutcomeEvent: FormOutcomeEvent) => {
@@ -62,7 +62,7 @@ export class FormComponent implements OnInit, OnDestroy {
}
ngOnInit() {
const formDefinitionJSON: any = DemoForm.getDefinition();
const formDefinitionJSON: any = this.automationService.forms.getFormDefinition();
this.formConfig = JSON.stringify(formDefinitionJSON);
this.parseForm();
}