fix bug in dataset template editor when a field is an admin-input api and couldn't fetch results
This commit is contained in:
parent
2db9ea613f
commit
0918e55ac9
|
@ -70,4 +70,12 @@ public class DatasetProfileController extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(items);
|
return ResponseEntity.status(HttpStatus.OK).body(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/search/autocompleteOptions"}, consumes = "application/json", produces = "application/json")
|
||||||
|
public ResponseEntity<Object> getDataForAutocompleteOptions(@RequestBody RequestItem<AutoCompleteOptionsLookupItem> lookupItem) {
|
||||||
|
AutoCompleteData data = new AutoCompleteData();
|
||||||
|
data.setAutoCompleteSingleDataList(lookupItem.getCriteria().getAutoCompleteSingleDataList());
|
||||||
|
List<ExternalAutocompleteFieldModel> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike());
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(items);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.eudat.models.data.helpers.common;
|
||||||
|
|
||||||
|
import eu.eudat.data.dao.criteria.Criteria;
|
||||||
|
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class AutoCompleteOptionsLookupItem extends Criteria<AutoCompleteOptionsLookupItem> {
|
||||||
|
|
||||||
|
private List<AutoCompleteData.AutoCompleteSingleData> autoCompleteSingleDataList;
|
||||||
|
|
||||||
|
public List<AutoCompleteData.AutoCompleteSingleData> getAutoCompleteSingleDataList() {
|
||||||
|
return autoCompleteSingleDataList;
|
||||||
|
}
|
||||||
|
public void setAutoCompleteSingleDataList(List<AutoCompleteData.AutoCompleteSingleData> autoCompleteSingleDataList) {
|
||||||
|
this.autoCompleteSingleDataList = autoCompleteSingleDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -4,5 +4,8 @@ import { BaseCriteria } from "../base-criteria";
|
||||||
export class DatasetExternalAutocompleteCriteria extends BaseCriteria {
|
export class DatasetExternalAutocompleteCriteria extends BaseCriteria {
|
||||||
public profileID: String;
|
public profileID: String;
|
||||||
public fieldID: String;
|
public fieldID: String;
|
||||||
public autocompleteOptions: AutoCompleteSingleData;
|
}
|
||||||
|
|
||||||
|
export class DatasetExternalAutocompleteOptionsCriteria extends BaseCriteria {
|
||||||
|
public autoCompleteSingleDataList: AutoCompleteSingleData[];
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { environment } from '../../../../environments/environment';
|
import { environment } from '../../../../environments/environment';
|
||||||
import { DatasetExternalAutocompleteCriteria } from '../../query/dataset/daatset-external-autocomplete-criteria';
|
import { DatasetExternalAutocompleteCriteria, DatasetExternalAutocompleteOptionsCriteria } from '../../query/dataset/daatset-external-autocomplete-criteria';
|
||||||
import { RequestItem } from '../../query/request-item';
|
import { RequestItem } from '../../query/request-item';
|
||||||
import { DatasetProfileService } from '../dataset-profile/dataset-profile.service';
|
import { DatasetProfileService } from '../dataset-profile/dataset-profile.service';
|
||||||
import { ConfigurationService } from '../configuration/configuration.service';
|
import { ConfigurationService } from '../configuration/configuration.service';
|
||||||
|
@ -17,7 +17,7 @@ export class DatasetExternalAutocompleteService {
|
||||||
private httpClient: HttpClient,
|
private httpClient: HttpClient,
|
||||||
private datasetProfileService: DatasetProfileService,
|
private datasetProfileService: DatasetProfileService,
|
||||||
private configurationService: ConfigurationService) {
|
private configurationService: ConfigurationService) {
|
||||||
this.actionUrl = configurationService.server + 'datasets/';
|
this.actionUrl = configurationService.server + '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
getDatasetProfileById(datasetProfileID) {
|
getDatasetProfileById(datasetProfileID) {
|
||||||
|
@ -28,14 +28,8 @@ export class DatasetExternalAutocompleteService {
|
||||||
return this.httpClient.post(this.configurationService.server + 'search/autocomplete', lookUpItem);
|
return this.httpClient.post(this.configurationService.server + 'search/autocomplete', lookUpItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
queryApi(requestItem: RequestItem<DatasetExternalAutocompleteCriteria>):Observable<any>{ //TODO
|
queryApi(lookUpItem: RequestItem<DatasetExternalAutocompleteOptionsCriteria>): Observable<any>{
|
||||||
|
return this.httpClient.post(this.configurationService.server + 'search/autocompleteOptions', lookUpItem);
|
||||||
return of([
|
|
||||||
{
|
|
||||||
label:'Preview not supported yet',
|
|
||||||
source:''
|
|
||||||
}
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -204,7 +204,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div [id]="'preview_container'+ form.get('id').value" class="w-100" style="margin-right: -15px; margin-left: -15px;" >
|
<div [id]="'preview_container'+ form.get('id').value" class="w-100" style="margin-right: -15px; margin-left: -15px;" >
|
||||||
<div *ngIf="previewForm && showPreview && firstField?.get('viewStyle').get('renderStyle').value" [@fade-in-fast]>
|
<div *ngIf="previewForm && showPreview && firstField?.get('viewStyle').get('renderStyle').value" [@fade-in-fast]>
|
||||||
<app-form-section-inner [form]="previewForm" [tableView]="form.getRawValue().multiplicity?.tableView">
|
<app-form-section-inner [form]="previewForm" [tableView]="form.getRawValue().multiplicity?.tableView" [datasetProfileId]="datasetProfileId">
|
||||||
</app-form-section-inner>
|
</app-form-section-inner>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -69,6 +69,8 @@ export class DatasetProfileEditorCompositeFieldComponent extends BaseComponent i
|
||||||
@Input() indexPath: string;
|
@Input() indexPath: string;
|
||||||
@Input() viewOnly: boolean;
|
@Input() viewOnly: boolean;
|
||||||
|
|
||||||
|
@Input() datasetProfileId?: string;
|
||||||
|
|
||||||
@Input() numbering: string;
|
@Input() numbering: string;
|
||||||
@Input() hasFocus: boolean = false;
|
@Input() hasFocus: boolean = false;
|
||||||
@ViewChild("inputs") inputs: TransitionGroupComponent;
|
@ViewChild("inputs") inputs: TransitionGroupComponent;
|
||||||
|
|
|
@ -74,7 +74,8 @@
|
||||||
<app-dataset-profile-editor-composite-field-component [form]="fieldset"
|
<app-dataset-profile-editor-composite-field-component [form]="fieldset"
|
||||||
[viewOnly]="viewOnly"
|
[viewOnly]="viewOnly"
|
||||||
[numbering]="numbering + '.'+ (i+1)"
|
[numbering]="numbering + '.'+ (i+1)"
|
||||||
[hasFocus]="fieldset.get('id').value === selectedFieldSetId">
|
[hasFocus]="fieldset.get('id').value === selectedFieldSetId"
|
||||||
|
[datasetProfileId]="datasetProfileId">
|
||||||
</app-dataset-profile-editor-composite-field-component>
|
</app-dataset-profile-editor-composite-field-component>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|
|
@ -26,6 +26,8 @@ export class DatasetProfileEditorSectionFieldSetComponent implements OnInit, OnC
|
||||||
// @Input() numbering: string;
|
// @Input() numbering: string;
|
||||||
@Input() tocentry: ToCEntry;
|
@Input() tocentry: ToCEntry;
|
||||||
|
|
||||||
|
@Input() datasetProfileId?: string;
|
||||||
|
|
||||||
@Output() selectedEntryId = new EventEmitter<string>();
|
@Output() selectedEntryId = new EventEmitter<string>();
|
||||||
@Output() dataNeedsRefresh = new EventEmitter<void> ();
|
@Output() dataNeedsRefresh = new EventEmitter<void> ();
|
||||||
@Output() removeFieldSet = new EventEmitter<string>();
|
@Output() removeFieldSet = new EventEmitter<string>();
|
||||||
|
|
|
@ -290,6 +290,7 @@
|
||||||
<app-dataset-profile-editor-section-fieldset-component
|
<app-dataset-profile-editor-section-fieldset-component
|
||||||
[tocentry]="selectedTocEntry"
|
[tocentry]="selectedTocEntry"
|
||||||
[viewOnly]="viewOnly"
|
[viewOnly]="viewOnly"
|
||||||
|
[datasetProfileId]="datasetProfileId"
|
||||||
(addNewFieldSet)="addNewEntry({childType: tocEntryEnumValues.FieldSet,parent: {form: $event}})"
|
(addNewFieldSet)="addNewEntry({childType: tocEntryEnumValues.FieldSet,parent: {form: $event}})"
|
||||||
(removeFieldSet)="onRemoveEntry(_findTocEntryById($event, toCEntries))"
|
(removeFieldSet)="onRemoveEntry(_findTocEntryById($event, toCEntries))"
|
||||||
(cloneFieldSet)="cloneFieldSet($event)"
|
(cloneFieldSet)="cloneFieldSet($event)"
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profil
|
||||||
import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style';
|
import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style';
|
||||||
import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type';
|
import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type';
|
||||||
import { DataTableRequest } from '@app/core/model/data-table/data-table-request';
|
import { DataTableRequest } from '@app/core/model/data-table/data-table-request';
|
||||||
import { DatasetExternalAutocompleteCriteria } from '@app/core/query/dataset/daatset-external-autocomplete-criteria';
|
import { DatasetExternalAutocompleteCriteria, DatasetExternalAutocompleteOptionsCriteria } from '@app/core/query/dataset/daatset-external-autocomplete-criteria';
|
||||||
import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria';
|
import { DatasetCriteria } from '@app/core/query/dataset/dataset-criteria';
|
||||||
import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria';
|
import { DmpCriteria } from '@app/core/query/dmp/dmp-criteria';
|
||||||
import { RequestItem } from '@app/core/query/request-item';
|
import { RequestItem } from '@app/core/query/request-item';
|
||||||
|
@ -61,7 +61,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
||||||
@Input() form: FormGroup;
|
@Input() form: FormGroup;
|
||||||
@Input() datasetProfileId: any;
|
@Input() datasetProfileId: any;
|
||||||
@Input() isChild: Boolean = false;
|
@Input() isChild: Boolean = false;
|
||||||
@Input() autocompleteOptions: AutoCompleteSingleData;
|
autocompleteOptions: AutoCompleteSingleData[];
|
||||||
|
|
||||||
visible: boolean = true;
|
visible: boolean = true;
|
||||||
_renderStyle: DatasetProfileFieldViewStyle = null;
|
_renderStyle: DatasetProfileFieldViewStyle = null;
|
||||||
|
@ -189,6 +189,9 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
||||||
subtitleFn: (item) => { try { return item['source'] ? this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-SUBTITLE') + item['source'] : this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-NO-SOURCE') } catch { return '' } }
|
subtitleFn: (item) => { try { return item['source'] ? this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-SUBTITLE') + item['source'] : this.language.instant('DATASET-WIZARD.EDITOR.FIELDS.EXTERNAL-AUTOCOMPLETE-NO-SOURCE') } catch { return '' } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(isNullOrUndefined(this.datasetProfileId)){
|
||||||
|
this.autocompleteOptions = this.form.get('data').value.autoCompleteSingleDataList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (this.form.get('viewStyle').value.renderStyle) {
|
switch (this.form.get('viewStyle').value.renderStyle) {
|
||||||
|
@ -385,29 +388,32 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
searchFromAutocomplete(query: string) {
|
searchFromAutocomplete(query: string) {
|
||||||
const autocompleteRequestItem: RequestItem<DatasetExternalAutocompleteCriteria> = new RequestItem();
|
|
||||||
autocompleteRequestItem.criteria = new DatasetExternalAutocompleteCriteria();
|
|
||||||
let parseIdArray: string[] = this.form.get('id').value.split('_');
|
|
||||||
if(parseIdArray.length > 1) {
|
|
||||||
autocompleteRequestItem.criteria.fieldID = parseIdArray[parseIdArray.length - 1];
|
|
||||||
} else {
|
|
||||||
autocompleteRequestItem.criteria.fieldID = this.form.get('id').value;
|
|
||||||
}
|
|
||||||
if (typeof this.datasetProfileId === 'string') {
|
|
||||||
autocompleteRequestItem.criteria.profileID = this.datasetProfileId;
|
|
||||||
} else if (this.datasetProfileId != null) {
|
|
||||||
autocompleteRequestItem.criteria.profileID = this.datasetProfileId.id;
|
|
||||||
} else if (this.autocompleteOptions != null) {
|
|
||||||
autocompleteRequestItem.criteria.autocompleteOptions = this.autocompleteOptions;
|
|
||||||
} else {
|
|
||||||
throw "Could not load autocomplete options.";
|
|
||||||
}
|
|
||||||
autocompleteRequestItem.criteria.like = query;
|
|
||||||
|
|
||||||
if (this.autocompleteOptions) {
|
if (this.autocompleteOptions) {
|
||||||
|
const autocompleteRequestItem: RequestItem<DatasetExternalAutocompleteOptionsCriteria> = new RequestItem();
|
||||||
|
autocompleteRequestItem.criteria = new DatasetExternalAutocompleteOptionsCriteria();
|
||||||
|
autocompleteRequestItem.criteria.autoCompleteSingleDataList = this.autocompleteOptions;
|
||||||
|
autocompleteRequestItem.criteria.like = query;
|
||||||
return this.datasetExternalAutocompleteService.queryApi(autocompleteRequestItem);
|
return this.datasetExternalAutocompleteService.queryApi(autocompleteRequestItem);
|
||||||
}
|
}
|
||||||
return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem);
|
else{
|
||||||
|
const autocompleteRequestItem: RequestItem<DatasetExternalAutocompleteCriteria> = new RequestItem();
|
||||||
|
autocompleteRequestItem.criteria = new DatasetExternalAutocompleteCriteria();
|
||||||
|
let parseIdArray: string[] = this.form.get('id').value.split('_');
|
||||||
|
if(parseIdArray.length > 1) {
|
||||||
|
autocompleteRequestItem.criteria.fieldID = parseIdArray[parseIdArray.length - 1];
|
||||||
|
} else {
|
||||||
|
autocompleteRequestItem.criteria.fieldID = this.form.get('id').value;
|
||||||
|
}
|
||||||
|
if (typeof this.datasetProfileId === 'string') {
|
||||||
|
autocompleteRequestItem.criteria.profileID = this.datasetProfileId;
|
||||||
|
}
|
||||||
|
else if (this.datasetProfileId != null) {
|
||||||
|
autocompleteRequestItem.criteria.profileID = this.datasetProfileId.id;
|
||||||
|
}
|
||||||
|
autocompleteRequestItem.criteria.like = query;
|
||||||
|
return this.datasetExternalAutocompleteService.queryAutocomplete(autocompleteRequestItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
searchResearchers(query: string) {
|
searchResearchers(query: string) {
|
||||||
|
|
Loading…
Reference in New Issue