added input value as query in modal

This commit is contained in:
lotte
2019-12-23 15:36:39 +01:00
parent 2a686a2fc4
commit 11d3f33276
7 changed files with 16 additions and 10 deletions

View File

@@ -317,10 +317,12 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
* Open a modal where the user can select relationships to be added to item being submitted
*/
openLookup() {
console.log(this.model);
this.modalRef = this.modalService.open(DsDynamicLookupRelationModalComponent, {
size: 'lg'
});
const modalComp = this.modalRef.componentInstance;
modalComp.query = this.model.value.value;
modalComp.repeatable = this.model.repeatable;
modalComp.listId = this.listId;
modalComp.relationshipOptions = this.model.relationship;

View File

@@ -37,7 +37,7 @@ export class DynamicConcatModel extends DynamicFormGroupModel {
constructor(config: DynamicConcatModelConfig, layout?: DynamicFormControlLayout) {
super(config, layout);
console.log(config);
this.separator = config.separator + ' ';
this.relationship = config.relationship;
this.repeatable = config.repeatable;
@@ -57,8 +57,10 @@ export class DynamicConcatModel extends DynamicFormGroupModel {
return Object.assign(new FormFieldMetadataValueObject(), firstValue, { value: firstValue.value + this.separator + secondValue.value });
} else if (isNotEmpty(firstValue) && isNotEmpty(firstValue.value)) {
return Object.assign(new FormFieldMetadataValueObject(), firstValue);
} else if (isNotEmpty(secondValue) && isNotEmpty(secondValue.value)) {
return Object.assign(new FormFieldMetadataValueObject(), secondValue);
} else {
return null;
return new FormFieldMetadataValueObject();
}
}

View File

@@ -15,6 +15,7 @@
[relationship]="relationshipOptions"
[repeatable]="repeatable"
[context]="context"
[query]="query"
(selectObject)="select($event)"
(deselectObject)="deselect($event)"
class="d-block pt-3">
@@ -42,4 +43,4 @@
<div>
<button type="button" class="btn btn-danger" (click)="close()">{{ ('submission.sections.describe.relationship-lookup.close' | translate) }}</button>
</div>
</div>
</div>

View File

@@ -42,6 +42,7 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy
selection$: Observable<ListableObject[]>;
context: Context;
metadataFields: string;
query: string;
subMap: {
[uuid: string]: Subscription
} = {};

View File

@@ -3,7 +3,7 @@
[resultCount]="(resultsRD$ | async)?.payload?.totalElements"
[inPlaceSearch]="true" [showViewModes]="false"></ds-search-sidebar>
<div class="col-8">
<ds-search-form [inPlaceSearch]="true"></ds-search-form>
<ds-search-form [inPlaceSearch]="true" [query]="query"></ds-search-form>
<ds-search-labels [inPlaceSearch]="true"></ds-search-labels>
@@ -66,4 +66,4 @@
(selectObject)="selectObject.emit($event)">
</ds-search-results>
</div>
</div>
</div>

View File

@@ -39,6 +39,7 @@ import { Context } from '../../../../../../core/shared/context.model';
export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDestroy {
@Input() relationship: RelationshipOptions;
@Input() listId: string;
@Input() query: string;
@Input() repeatable: boolean;
@Input() selection$: Observable<ListableObject[]>;
@Input() context: Context;
@@ -73,8 +74,6 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest
this.resetRoute();
this.routeService.setParameter('fixedFilterQuery', this.relationship.filter);
this.routeService.setParameter('configuration', this.relationship.searchConfiguration);
this.someSelected$ = this.selection$.pipe(map((selection) => isNotEmpty(selection)));
this.resultsRD$ = this.searchConfigService.paginatedSearchOptions.pipe(
map((options) => {
return Object.assign(new PaginatedSearchOptions({}), options, { fixedFilter: this.relationship.filter, configuration: this.relationship.searchConfiguration })
@@ -101,7 +100,7 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest
*/
resetRoute() {
this.router.navigate([], {
queryParams: Object.assign({}, { page: 1, pageSize: this.initialPagination.pageSize }),
queryParams: Object.assign({}, { page: 1, pageSize: this.initialPagination.pageSize, query: this.query }),
});
}

View File

@@ -32,6 +32,8 @@ export abstract class FieldParser {
public abstract modelFactory(fieldValue?: FormFieldMetadataValueObject, label?: boolean): any;
public parse() {
console.log(this.configData);
if (((this.getInitValueCount() > 1 && !this.configData.repeatable) || (this.configData.repeatable))
&& (this.configData.input.type !== 'list')
&& (this.configData.input.type !== 'tag')
@@ -44,9 +46,8 @@ export abstract class FieldParser {
if (Array.isArray(this.configData.selectableMetadata) && this.configData.selectableMetadata.length === 1) {
metadataKey = this.configData.selectableMetadata[0].metadata;
};
}
console.log(this.getInitArrayIndex());
const config = {
id: uniqueId() + '_array',
label: this.configData.label,