Fix data resolution for entity count datasource type.
This commit is contained in:
parent
d61890a96a
commit
43d221e5ce
@ -60,6 +60,16 @@ export class EntityDataService {
|
||||
constructor(private telemetryService: TelemetryWebsocketService,
|
||||
private utils: UtilsService) {}
|
||||
|
||||
private static isUnresolvedDatasource(datasource: Datasource, pageLink: EntityDataPageLink): boolean {
|
||||
if (datasource.type === DatasourceType.entity) {
|
||||
return !datasource.entityFilter || !pageLink;
|
||||
} else if (datasource.type === DatasourceType.entityCount) {
|
||||
return !datasource.entityFilter;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public prepareSubscription(listener: EntityDataListener,
|
||||
ignoreDataUpdateOnIntervalTick = false): Observable<EntityDataLoadResult> {
|
||||
const datasource = listener.configDatasource;
|
||||
@ -71,7 +81,7 @@ export class EntityDataService {
|
||||
null,
|
||||
false,
|
||||
ignoreDataUpdateOnIntervalTick);
|
||||
if (datasource.type === DatasourceType.entity && (!datasource.entityFilter || !datasource.pageLink)) {
|
||||
if (EntityDataService.isUnresolvedDatasource(datasource, datasource.pageLink)) {
|
||||
return of(null);
|
||||
}
|
||||
listener.subscription = new EntityDataSubscription(listener, this.telemetryService, this.utils);
|
||||
@ -100,7 +110,7 @@ export class EntityDataService {
|
||||
keyFilters,
|
||||
true,
|
||||
ignoreDataUpdateOnIntervalTick);
|
||||
if (datasource.type === DatasourceType.entity && (!datasource.entityFilter || !pageLink)) {
|
||||
if (EntityDataService.isUnresolvedDatasource(datasource, pageLink)) {
|
||||
listener.dataLoaded(emptyPageData<EntityData>(), [],
|
||||
listener.configDatasourceIndex, listener.subscriptionOptions.pageLink);
|
||||
return of(null);
|
||||
|
||||
@ -271,6 +271,7 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
|
||||
);
|
||||
} else {
|
||||
const targetEntityType = this.checkEntityType(value.entityType);
|
||||
if (value.id) {
|
||||
this.entityService.getEntity(targetEntityType, value.id, {ignoreLoading: true, ignoreErrors: true}).subscribe(
|
||||
(entity) => {
|
||||
this.modelValue = entity.id.id;
|
||||
@ -284,6 +285,13 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
this.modelValue = null;
|
||||
this.selectEntityFormGroup.get('entity').patchValue('', {emitEvent: false});
|
||||
if (value !== null) {
|
||||
this.propagateChange(this.modelValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.modelValue = null;
|
||||
|
||||
@ -818,7 +818,7 @@ export function updateDatasourceFromEntityInfo(datasource: Datasource, entity: E
|
||||
};
|
||||
datasource.entityId = entity.id;
|
||||
datasource.entityType = entity.entityType;
|
||||
if (datasource.type === DatasourceType.entity) {
|
||||
if (datasource.type === DatasourceType.entity || datasource.type === DatasourceType.entityCount) {
|
||||
datasource.entityName = entity.name;
|
||||
datasource.entityLabel = entity.label;
|
||||
datasource.name = entity.name;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user