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