trying to fix query in submission entities

This commit is contained in:
lotte
2020-02-06 16:28:39 +01:00
parent 2fc1e6e827
commit 0f539ea7d7
8 changed files with 22 additions and 25 deletions

View File

@@ -72,6 +72,7 @@ import { WorkspaceItem } from '../../../../core/submission/models/workspaceitem.
import { of as observableOf } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { createSuccessfulRemoteDataObject } from '../../../testing/utils'; import { createSuccessfulRemoteDataObject } from '../../../testing/utils';
import { FormService } from '../../form.service'; import { FormService } from '../../form.service';
import { SubmissionService } from '../../../../submission/submission.service';
describe('DsDynamicFormControlContainerComponent test suite', () => { describe('DsDynamicFormControlContainerComponent test suite', () => {
@@ -177,6 +178,7 @@ describe('DsDynamicFormControlContainerComponent test suite', () => {
{ provide: RelationshipService, useValue: {} }, { provide: RelationshipService, useValue: {} },
{ provide: SelectableListService, useValue: {} }, { provide: SelectableListService, useValue: {} },
{ provide: FormService, useValue: {} }, { provide: FormService, useValue: {} },
{ provide: SubmissionService, useValue: {} },
{ {
provide: SubmissionObjectDataService, provide: SubmissionObjectDataService,
useValue: { useValue: {

View File

@@ -99,6 +99,7 @@ import { MetadataValue } from '../../../../core/shared/metadata.models';
import { FormService } from '../../form.service'; import { FormService } from '../../form.service';
import { deepClone } from 'fast-json-patch'; import { deepClone } from 'fast-json-patch';
import { SelectableListState } from '../../../object-list/selectable-list/selectable-list.reducer'; import { SelectableListState } from '../../../object-list/selectable-list/selectable-list.reducer';
import { SubmissionService } from '../../../../submission/submission.service';
export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type<DynamicFormControl> | null { export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type<DynamicFormControl> | null {
switch (model.type) { switch (model.type) {
@@ -224,7 +225,8 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
private store: Store<AppState>, private store: Store<AppState>,
private submissionObjectService: SubmissionObjectDataService, private submissionObjectService: SubmissionObjectDataService,
private ref: ChangeDetectorRef, private ref: ChangeDetectorRef,
private formService: FormService private formService: FormService,
private submissionService: SubmissionService
) { ) {
super(componentFactoryResolver, layoutService, validationService, dynamicFormInstanceService); super(componentFactoryResolver, layoutService, validationService, dynamicFormInstanceService);
} }
@@ -318,11 +320,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
* Open a modal where the user can select relationships to be added to item being submitted * Open a modal where the user can select relationships to be added to item being submitted
*/ */
openLookup() { openLookup() {
// const event = this.createDynamicFormControlEvent(new CustomEvent('open'), 'change');
// event.control = this.control;
// event.model = this.model;
// this.onChange(event);
this.formService.removeForm(this.formId);
this.modalRef = this.modalService.open(DsDynamicLookupRelationModalComponent, { this.modalRef = this.modalService.open(DsDynamicLookupRelationModalComponent, {
size: 'lg' size: 'lg'
}); });
@@ -330,8 +328,11 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
modalComp.query = this.model.value ? this.model.value.value : ''; modalComp.query = this.model.value ? this.model.value.value : '';
if (hasValue(this.model.value)) { if (hasValue(this.model.value)) {
modalComp.selectEvent.pipe(take(1)).subscribe(() => this.model.value = ''); this.model.valueUpdates.next('');
this.change.emit();
} }
this.submissionService.dispatchSave(this.model.submissionId);
modalComp.repeatable = this.model.repeatable; modalComp.repeatable = this.model.repeatable;
modalComp.listId = this.listId; modalComp.listId = this.listId;
modalComp.relationshipOptions = this.model.relationship; modalComp.relationshipOptions = this.model.relationship;

View File

@@ -73,11 +73,6 @@ export class ReorderableFormFieldMetadataValue extends Reorderable {
} }
update(): Observable<FormFieldMetadataValueObject> { update(): Observable<FormFieldMetadataValueObject> {
// this.metadataValue.place = this.newIndex;
// this.model.valueUpdates.next(this.metadataValue.value);
// console.log('this.model', this.model);
// this.control.markAsDirty();
// console.log('this.control.value', this.control.value);
this.oldIndex = this.newIndex; this.oldIndex = this.newIndex;
return observableOf(this.metadataValue); return observableOf(this.metadataValue);
} }

View File

@@ -185,13 +185,12 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple
onChange($event) { onChange($event) {
let event = $event; let event = $event;
if (hasNoValue($event.context)) { if (hasValue($event) && hasNoValue($event.context)) {
const context = Object.assign({}, $event.context, { index: this.reorderables.length }); const context = Object.assign({}, $event.context, { index: this.reorderables.length });
event = Object.assign({}, $event, { context }); event = Object.assign({}, $event, { context });
} else { } else {
this.updateReorderables(); this.updateReorderables();
} }
super.onChange(event); super.onChange(event);
} }
} }

View File

@@ -2,7 +2,7 @@ import { DynamicFormControlLayout, DynamicFormGroupModel, DynamicFormGroupModelC
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { isNotEmpty } from '../../../../empty.util'; import { hasNoValue, isNotEmpty } from '../../../../empty.util';
import { DsDynamicInputModel } from './ds-dynamic-input.model'; import { DsDynamicInputModel } from './ds-dynamic-input.model';
import { FormFieldMetadataValueObject } from '../../models/form-field-metadata-value.model'; import { FormFieldMetadataValueObject } from '../../models/form-field-metadata-value.model';
import { RelationshipOptions } from '../../models/relationship-options.model'; import { RelationshipOptions } from '../../models/relationship-options.model';
@@ -72,6 +72,9 @@ export class DynamicConcatModel extends DynamicFormGroupModel {
} else { } else {
tempValue = value.value; tempValue = value.value;
} }
if (hasNoValue(tempValue)) {
tempValue = '';
}
values = [...tempValue.split(this.separator), null].map((v) => values = [...tempValue.split(this.separator), null].map((v) =>
Object.assign(new FormFieldMetadataValueObject(), value, { display: v, value: v })); Object.assign(new FormFieldMetadataValueObject(), value, { display: v, value: v }));

View File

@@ -11,19 +11,13 @@ import { ListableObject } from '../../../../object-collection/shared/listable-ob
import { RelationshipOptions } from '../../models/relationship-options.model'; import { RelationshipOptions } from '../../models/relationship-options.model';
import { SearchResult } from '../../../../search/search-result.model'; import { SearchResult } from '../../../../search/search-result.model';
import { Item } from '../../../../../core/shared/item.model'; import { Item } from '../../../../../core/shared/item.model';
import { import { getAllSucceededRemoteData, getRemoteDataPayload } from '../../../../../core/shared/operators';
getAllSucceededRemoteData,
getRemoteDataPayload,
getSucceededRemoteData
} from '../../../../../core/shared/operators';
import { AddRelationshipAction, RemoveRelationshipAction, UpdateRelationshipAction } from './relationship.actions'; import { AddRelationshipAction, RemoveRelationshipAction, UpdateRelationshipAction } from './relationship.actions';
import { RelationshipService } from '../../../../../core/data/relationship.service'; import { RelationshipService } from '../../../../../core/data/relationship.service';
import { RelationshipTypeService } from '../../../../../core/data/relationship-type.service'; import { RelationshipTypeService } from '../../../../../core/data/relationship-type.service';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '../../../../../app.reducer'; import { AppState } from '../../../../../app.reducer';
import { Context } from '../../../../../core/shared/context.model'; import { Context } from '../../../../../core/shared/context.model';
import { Relationship } from '../../../../../core/shared/item-relationships/relationship.model';
import { MetadataValue } from '../../../../../core/shared/metadata.models';
import { LookupRelationService } from '../../../../../core/data/lookup-relation.service'; import { LookupRelationService } from '../../../../../core/data/lookup-relation.service';
import { RemoteData } from '../../../../../core/data/remote-data'; import { RemoteData } from '../../../../../core/data/remote-data';
import { PaginatedList } from '../../../../../core/data/paginated-list'; import { PaginatedList } from '../../../../../core/data/paginated-list';
@@ -150,7 +144,6 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
* @param selectableObjects * @param selectableObjects
*/ */
select(...selectableObjects: Array<SearchResult<Item>>) { select(...selectableObjects: Array<SearchResult<Item>>) {
this.selectEvent.emit(selectableObjects);
this.zone.runOutsideAngular( this.zone.runOutsideAngular(
() => { () => {
const obs: Observable<any[]> = combineLatest(...selectableObjects.map((sri: SearchResult<Item>) => { const obs: Observable<any[]> = combineLatest(...selectableObjects.map((sri: SearchResult<Item>) => {

View File

@@ -302,10 +302,13 @@ export class FormComponent implements OnDestroy, OnInit {
insertItem($event, arrayContext: DynamicFormArrayModel, index: number): void { insertItem($event, arrayContext: DynamicFormArrayModel, index: number): void {
const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as FormArray; const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as FormArray;
this.formBuilderService.addFormArrayGroup(formArrayControl, arrayContext); this.formBuilderService.addFormArrayGroup(formArrayControl, arrayContext);
this.addArrayItem.emit(this.getEvent($event, arrayContext, index, 'add'));
const value = formArrayControl.controls[index].value; const value = formArrayControl.controls[index].value;
formArrayControl.controls[formArrayControl.length - 1].setValue(value); formArrayControl.controls[formArrayControl.length - 1].setValue(value);
formArrayControl.controls[index].reset();
this.addArrayItem.emit(this.getEvent($event, arrayContext, index, 'add')); this.formBuilderService.removeFormArrayGroup(index, formArrayControl, arrayContext);
this.formBuilderService.insertFormArrayGroup(index, formArrayControl, arrayContext);
this.formService.changeForm(this.formId, this.formModel); this.formService.changeForm(this.formId, this.formModel);
} }

View File

@@ -333,6 +333,7 @@ export class SubmissionObjectEffects {
if (notify && !currentState.sections[sectionId].enabled) { if (notify && !currentState.sections[sectionId].enabled) {
this.submissionService.notifyNewSection(submissionId, sectionId, currentState.sections[sectionId].sectionType); this.submissionService.notifyNewSection(submissionId, sectionId, currentState.sections[sectionId].sectionType);
} }
console.log(submissionId, sectionId, sectionData, sectionErrors);
mappedActions.push(new UpdateSectionDataAction(submissionId, sectionId, sectionData, sectionErrors)); mappedActions.push(new UpdateSectionDataAction(submissionId, sectionId, sectionData, sectionErrors));
} }