Add original entity field to datasource.
This commit is contained in:
parent
d7a23f4048
commit
63f73c9d1e
@ -143,6 +143,11 @@ export default class AliasController {
|
|||||||
for (var i=0;i<resolvedEntities.length;i++) {
|
for (var i=0;i<resolvedEntities.length;i++) {
|
||||||
var resolvedEntity = resolvedEntities[i];
|
var resolvedEntity = resolvedEntities[i];
|
||||||
newDatasource = angular.copy(datasource);
|
newDatasource = angular.copy(datasource);
|
||||||
|
if (resolvedEntity.origEntity) {
|
||||||
|
newDatasource.entity = angular.copy(resolvedEntity.origEntity);
|
||||||
|
} else {
|
||||||
|
newDatasource.entity = {};
|
||||||
|
}
|
||||||
newDatasource.entityId = resolvedEntity.id;
|
newDatasource.entityId = resolvedEntity.id;
|
||||||
newDatasource.entityType = resolvedEntity.entityType;
|
newDatasource.entityType = resolvedEntity.entityType;
|
||||||
newDatasource.entityName = resolvedEntity.name;
|
newDatasource.entityName = resolvedEntity.name;
|
||||||
@ -164,6 +169,11 @@ export default class AliasController {
|
|||||||
} else {
|
} else {
|
||||||
var entity = aliasInfo.currentEntity;
|
var entity = aliasInfo.currentEntity;
|
||||||
if (entity) {
|
if (entity) {
|
||||||
|
if (entity.origEntity) {
|
||||||
|
datasource.entity = angular.copy(entity.origEntity);
|
||||||
|
} else {
|
||||||
|
datasource.entity = {};
|
||||||
|
}
|
||||||
datasource.entityId = entity.id;
|
datasource.entityId = entity.id;
|
||||||
datasource.entityType = entity.entityType;
|
datasource.entityType = entity.entityType;
|
||||||
datasource.entityName = entity.name;
|
datasource.entityName = entity.name;
|
||||||
|
|||||||
@ -344,17 +344,21 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
|
|||||||
}
|
}
|
||||||
|
|
||||||
function entityToEntityInfo(entity) {
|
function entityToEntityInfo(entity) {
|
||||||
return { name: entity.name, entityType: entity.id.entityType, id: entity.id.id, entityDescription: entity.additionalInfo?entity.additionalInfo.description:"" };
|
return { origEntity: entity, name: entity.name, entityType: entity.id.entityType, id: entity.id.id, entityDescription: entity.additionalInfo?entity.additionalInfo.description:"" };
|
||||||
}
|
}
|
||||||
|
|
||||||
function entityRelationInfoToEntityInfo(entityRelationInfo, direction) {
|
function entityRelationInfoToEntityInfo(entityRelationInfo, direction) {
|
||||||
|
var deferred = $q.defer();
|
||||||
var entityId = direction == types.entitySearchDirection.from ? entityRelationInfo.to : entityRelationInfo.from;
|
var entityId = direction == types.entitySearchDirection.from ? entityRelationInfo.to : entityRelationInfo.from;
|
||||||
var name = direction == types.entitySearchDirection.from ? entityRelationInfo.toName : entityRelationInfo.fromName;
|
getEntity(entityId.entityType, entityId.id, {ignoreLoading: true}).then(
|
||||||
return {
|
function success(entity) {
|
||||||
name: name,
|
deferred.resolve(entityToEntityInfo(entity));
|
||||||
entityType: entityId.entityType,
|
},
|
||||||
id: entityId.id
|
function fail() {
|
||||||
};
|
deferred.reject();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function entitiesToEntitiesInfo(entities) {
|
function entitiesToEntitiesInfo(entities) {
|
||||||
@ -368,13 +372,22 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
|
|||||||
}
|
}
|
||||||
|
|
||||||
function entityRelationInfosToEntitiesInfo(entityRelations, direction) {
|
function entityRelationInfosToEntitiesInfo(entityRelations, direction) {
|
||||||
var entitiesInfo = [];
|
var deferred = $q.defer();
|
||||||
|
var entitiesInfoTaks = [];
|
||||||
if (entityRelations) {
|
if (entityRelations) {
|
||||||
for (var d = 0; d < entityRelations.length; d++) {
|
for (var d = 0; d < entityRelations.length; d++) {
|
||||||
entitiesInfo.push(entityRelationInfoToEntityInfo(entityRelations[d], direction));
|
entitiesInfoTaks.push(entityRelationInfoToEntityInfo(entityRelations[d], direction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return entitiesInfo;
|
$q.all(entitiesInfoTaks).then(
|
||||||
|
function success(entitiesInfo) {
|
||||||
|
deferred.resolve(entitiesInfo);
|
||||||
|
},
|
||||||
|
function fail() {
|
||||||
|
deferred.reject();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -581,8 +594,15 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
|
|||||||
var limit = Math.min(allRelations.length, maxItems);
|
var limit = Math.min(allRelations.length, maxItems);
|
||||||
allRelations.length = limit;
|
allRelations.length = limit;
|
||||||
}
|
}
|
||||||
result.entities = entityRelationInfosToEntitiesInfo(allRelations, filter.direction);
|
entityRelationInfosToEntitiesInfo(allRelations, filter.direction).then(
|
||||||
deferred.resolve(result);
|
function success(entities) {
|
||||||
|
result.entities = entities;
|
||||||
|
deferred.resolve(result);
|
||||||
|
},
|
||||||
|
function fail() {
|
||||||
|
deferred.reject();
|
||||||
|
}
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
deferred.reject();
|
deferred.reject();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user