mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-08 14:51:32 +00:00
AAE-2073 - reverted partially the changes on the parsing form of form… (#5517)
* AAE-2073 - reverted partially the changes on the parsing form of form service * AAE-2073 - reverted changes on form service
This commit is contained in:
@@ -74,7 +74,7 @@ describe('Form Renderer Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should be able to see Display value widget when visibility condition refers to another field with specific value', async () => {
|
it('Should be able to see Display value widget when visibility condition refers to another field with specific value', async () => {
|
||||||
formRendererComponent.formDefinition = formService.parseForm(formDisplayValueVisibility);
|
formRendererComponent.formDefinition = formService.parseForm(formDisplayValueVisibility.formRepresentation.formDefinition);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ describe('Form Renderer Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should be able to see Display value widget when visibility condition refers to a form variable and a field', async () => {
|
it('Should be able to see Display value widget when visibility condition refers to a form variable and a field', async () => {
|
||||||
formRendererComponent.formDefinition = formService.parseForm(formDisplayValueForm);
|
formRendererComponent.formDefinition = formService.parseForm(formDisplayValueForm.formRepresentation.formDefinition);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
let displayValueElementContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-DisplayValueOne-container');
|
let displayValueElementContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-DisplayValueOne-container');
|
||||||
@@ -116,7 +116,7 @@ describe('Form Renderer Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should be able to see Display value widget when visibility condition refers to another field and form variable', async () => {
|
it('Should be able to see Display value widget when visibility condition refers to another field and form variable', async () => {
|
||||||
formRendererComponent.formDefinition = formService.parseForm(formDisplayValueForm);
|
formRendererComponent.formDefinition = formService.parseForm(formDisplayValueForm.formRepresentation.formDefinition);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
let displayValueElementContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-DisplayValueVariableField-container');
|
let displayValueElementContainer: HTMLDivElement = fixture.nativeElement.querySelector('#field-DisplayValueVariableField-container');
|
||||||
@@ -140,7 +140,7 @@ describe('Form Renderer Component', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('Should be able to see Display value widget when has multiple visibility conditions and next condition operators', async () => {
|
it('Should be able to see Display value widget when has multiple visibility conditions and next condition operators', async () => {
|
||||||
formRendererComponent.formDefinition = formService.parseForm(formDisplayValueCombinedVisibility);
|
formRendererComponent.formDefinition = formService.parseForm(formDisplayValueCombinedVisibility.formRepresentation.formDefinition);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
const textInputElement: HTMLInputElement = fixture.nativeElement.querySelector('#Text0bq3ar');
|
const textInputElement: HTMLInputElement = fixture.nativeElement.querySelector('#Text0bq3ar');
|
||||||
|
@@ -15,7 +15,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const formDisplayValueVisibility = {formRepresentation: {
|
export const formDisplayValueVisibility = {
|
||||||
|
formRepresentation: {
|
||||||
id: 'form-3175b074-53c6-4b5b-92df-246b62108db3',
|
id: 'form-3175b074-53c6-4b5b-92df-246b62108db3',
|
||||||
name: 'displayValueVisibility',
|
name: 'displayValueVisibility',
|
||||||
description: '',
|
description: '',
|
||||||
|
@@ -102,18 +102,7 @@ export class FormService {
|
|||||||
*/
|
*/
|
||||||
parseForm(json: any, data?: FormValues, readOnly: boolean = false): FormModel {
|
parseForm(json: any, data?: FormValues, readOnly: boolean = false): FormModel {
|
||||||
if (json) {
|
if (json) {
|
||||||
const flattenForm = {
|
const form = new FormModel(json, data, readOnly, this);
|
||||||
...json.formRepresentation,
|
|
||||||
...json.formRepresentation.formDefinition
|
|
||||||
};
|
|
||||||
delete flattenForm.formDefinition;
|
|
||||||
|
|
||||||
const formValues: FormValues = {};
|
|
||||||
(data || []).forEach(variable => {
|
|
||||||
formValues[variable.name] = variable.value;
|
|
||||||
});
|
|
||||||
|
|
||||||
const form = new FormModel(flattenForm, formValues, readOnly);
|
|
||||||
if (!json.fields) {
|
if (!json.fields) {
|
||||||
form.outcomes = [
|
form.outcomes = [
|
||||||
new FormOutcomeModel(<any> form, {
|
new FormOutcomeModel(<any> form, {
|
||||||
|
Reference in New Issue
Block a user