From e768169add2f0b22621c871ee058d73530a61686 Mon Sep 17 00:00:00 2001 From: lotte Date: Tue, 14 Jan 2020 15:29:21 +0100 Subject: [PATCH] UX improvements --- ...ng-metadata-list-element.component.spec.ts | 2 +- .../dynamic-form-array.component.html | 5 +++-- .../dynamic-form-array.component.ts | 14 ++++++------- ...ic-lookup-relation-modal.component.spec.ts | 4 ++-- .../relationship.effects.spec.ts | 20 +++++++++---------- .../form/builder/parsers/field-parser.ts | 1 + src/app/shared/form/form.component.html | 6 ++++-- src/app/shared/form/form.component.ts | 3 ++- 8 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/existing-metadata-list-element/existing-metadata-list-element.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/existing-metadata-list-element/existing-metadata-list-element.component.spec.ts index 731ad3d3c4..3218dddd2f 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/existing-metadata-list-element/existing-metadata-list-element.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/existing-metadata-list-element/existing-metadata-list-element.component.spec.ts @@ -84,7 +84,7 @@ describe('ExistingMetadataListElementComponent', () => { it('should dispatch a RemoveRelationshipAction', () => { component.removeSelection(); - const action = new RemoveRelationshipAction(submissionItem, relatedItem, relationshipOptions.relationshipType); + const action = new RemoveRelationshipAction(submissionItem, relatedItem, relationshipOptions.relationshipType, '1234'); expect(store.dispatch).toHaveBeenCalledWith(action); }); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html index a5c7c68061..ab2513eadd 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.html @@ -12,9 +12,10 @@
- + {{idx}} diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.ts index ca21ce0576..89e4fbc10d 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/array-group/dynamic-form-array.component.ts @@ -82,7 +82,7 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple ) ).subscribe((item) => this.submissionItem = item); - this.updateReorderables(); + // this.updateReorderables(); } private updateReorderables(): void { @@ -185,12 +185,12 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple onChange($event) { let event = $event; - if (hasNoValue($event.context)) { - const context = Object.assign({}, $event.context, { index: this.reorderables.length }); - event = Object.assign({}, $event, { context }); - } else { - this.updateReorderables(); - } + // if (hasNoValue($event.context)) { + // const context = Object.assign({}, $event.context, { index: this.reorderables.length }); + // event = Object.assign({}, $event, { context }); + // } else { + // this.updateReorderables(); + // } super.onChange(event); } diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts index a4f77fd364..0bd60067c4 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts @@ -119,8 +119,8 @@ describe('DsDynamicLookupRelationModalComponent', () => { it('should dispatch an RemoveRelationshipAction for each deselected object', () => { component.deselect(searchResult1, searchResult2); - const action = new RemoveRelationshipAction(component.item, searchResult1.indexableObject, relationship.relationshipType); - const action2 = new RemoveRelationshipAction(component.item, searchResult2.indexableObject, relationship.relationshipType); + const action = new RemoveRelationshipAction(component.item, searchResult1.indexableObject, relationship.relationshipType, '1234'); + const action2 = new RemoveRelationshipAction(component.item, searchResult2.indexableObject, relationship.relationshipType, '1234'); expect((component as any).store.dispatch).toHaveBeenCalledWith(action); expect((component as any).store.dispatch).toHaveBeenCalledWith(action2); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/relationship.effects.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/relationship.effects.spec.ts index f9d7dabf9c..2dc9b0a484 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/relationship.effects.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/relationship.effects.spec.ts @@ -112,7 +112,7 @@ describe('RelationshipEffects', () => { describe('When it\'s the first time for this identifier', () => { let action; it('should set the current value debounceMap and the value of the initialActionMap to ADD_RELATIONSHIP', () => { - action = new AddRelationshipAction(leftItem, rightItem, relationshipType.leftwardType); + action = new AddRelationshipAction(leftItem, rightItem, relationshipType.leftwardType, '1234'); actions = hot('--a-', { a: action }); const expected = cold('--b-', { b: undefined }); expect(relationEffects.mapLastActions$).toBeObservable(expected); @@ -131,7 +131,7 @@ describe('RelationshipEffects', () => { }); it('should set the current value debounceMap to ADD_RELATIONSHIP but not change the value of the initialActionMap', () => { - action = new AddRelationshipAction(leftItem, rightItem, relationshipType.leftwardType); + action = new AddRelationshipAction(leftItem, rightItem, relationshipType.leftwardType, '1234'); actions = hot('--a-', { a: action }); const expected = cold('--b-', { b: undefined }); expect(relationEffects.mapLastActions$).toBeObservable(expected); @@ -150,7 +150,7 @@ describe('RelationshipEffects', () => { spyOn((relationEffects as any), 'addRelationship'); }); it('should call addRelationship on the effect', () => { - action = new AddRelationshipAction(leftItem, rightItem, relationshipType.leftwardType); + action = new AddRelationshipAction(leftItem, rightItem, relationshipType.leftwardType, '1234'); actions = hot('--a-', { a: action }); const expected = cold('--b-', { b: undefined }); expect(relationEffects.mapLastActions$).toBeObservable(expected); @@ -168,8 +168,8 @@ describe('RelationshipEffects', () => { spyOn((relationEffects as any), 'removeRelationship'); }); it('should not call removeRelationship or addRelationship on the effect', () => { - const actiona = new AddRelationshipAction(leftItem, rightItem, relationshipType.leftwardType); - const actionb = new RemoveRelationshipAction(leftItem, rightItem, relationshipType.leftwardType); + const actiona = new AddRelationshipAction(leftItem, rightItem, relationshipType.leftwardType, '1234'); + const actionb = new RemoveRelationshipAction(leftItem, rightItem, relationshipType.leftwardType, '1234'); actions = hot('--ab-', { a: actiona, b: actionb }); const expected = cold('--bb-', { b: undefined }); expect(relationEffects.mapLastActions$).toBeObservable(expected); @@ -184,7 +184,7 @@ describe('RelationshipEffects', () => { describe('When it\'s the first time for this identifier', () => { let action; it('should set the current value debounceMap and the value of the initialActionMap to REMOVE_RELATIONSHIP', () => { - action = new RemoveRelationshipAction(leftItem, rightItem, relationshipType.leftwardType); + action = new RemoveRelationshipAction(leftItem, rightItem, relationshipType.leftwardType, '1234'); actions = hot('--a-', { a: action }); const expected = cold('--b-', { b: undefined }); expect(relationEffects.mapLastActions$).toBeObservable(expected); @@ -203,7 +203,7 @@ describe('RelationshipEffects', () => { }); it('should set the current value debounceMap to REMOVE_RELATIONSHIP but not change the value of the initialActionMap', () => { - action = new RemoveRelationshipAction(leftItem, rightItem, relationshipType.leftwardType); + action = new RemoveRelationshipAction(leftItem, rightItem, relationshipType.leftwardType, '1234'); actions = hot('--a-', { a: action }); const expected = cold('--b-', { b: undefined }); expect(relationEffects.mapLastActions$).toBeObservable(expected); @@ -223,7 +223,7 @@ describe('RelationshipEffects', () => { }); it('should call removeRelationship on the effect', () => { - action = new RemoveRelationshipAction(leftItem, rightItem, relationshipType.leftwardType); + action = new RemoveRelationshipAction(leftItem, rightItem, relationshipType.leftwardType, '1234'); actions = hot('--a-', { a: action }); const expected = cold('--b-', { b: undefined }); expect(relationEffects.mapLastActions$).toBeObservable(expected); @@ -241,8 +241,8 @@ describe('RelationshipEffects', () => { spyOn((relationEffects as any), 'removeRelationship'); }); it('should not call addRelationship or removeRelationship on the effect', () => { - const actionb = new RemoveRelationshipAction(leftItem, rightItem, relationshipType.leftwardType); - const actiona = new AddRelationshipAction(leftItem, rightItem, relationshipType.leftwardType); + const actionb = new RemoveRelationshipAction(leftItem, rightItem, relationshipType.leftwardType, '1234'); + const actiona = new AddRelationshipAction(leftItem, rightItem, relationshipType.leftwardType, '1234'); actions = hot('--ab-', { a: actiona, b: actionb }); const expected = cold('--bb-', { b: undefined }); expect(relationEffects.mapLastActions$).toBeObservable(expected); diff --git a/src/app/shared/form/builder/parsers/field-parser.ts b/src/app/shared/form/builder/parsers/field-parser.ts index 32f4b80f37..127ea93ba7 100644 --- a/src/app/shared/form/builder/parsers/field-parser.ts +++ b/src/app/shared/form/builder/parsers/field-parser.ts @@ -86,6 +86,7 @@ export abstract class FieldParser { if (model.hasLanguages || isNotEmpty(model.relationship)) { setLayout(model, 'grid', 'control', 'col'); } + console.log(model); return [model]; } } as DynamicRowArrayModelConfig; diff --git a/src/app/shared/form/form.component.html b/src/app/shared/form/form.component.html index 3117583ca6..370a5d53d1 100644 --- a/src/app/shared/form/form.component.html +++ b/src/app/shared/form/form.component.html @@ -11,8 +11,10 @@ (dfChange)="onChange($event)" (dfFocus)="onFocus($event)"> + {{group.index}}-{{index}} + -