Commit 981f7443ce9f3f0ea1ff3d582dd1a693e78da2c6

Authored by Igor Kulikov
1 parent 8d45f32d

Improve resolveAliasFilter method

@@ -439,7 +439,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device @@ -439,7 +439,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
439 return entityId; 439 return entityId;
440 } 440 }
441 441
442 - function getStateEntityId(filter, stateParams) { 442 + function getStateEntityInfo(filter, stateParams) {
443 var entityId = null; 443 var entityId = null;
444 if (stateParams) { 444 if (stateParams) {
445 if (filter.stateEntityParamName && filter.stateEntityParamName.length) { 445 if (filter.stateEntityParamName && filter.stateEntityParamName.length) {
@@ -456,7 +456,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device @@ -456,7 +456,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
456 if (entityId) { 456 if (entityId) {
457 entityId = resolveAliasEntityId(entityId.entityType, entityId.id); 457 entityId = resolveAliasEntityId(entityId.entityType, entityId.id);
458 } 458 }
459 - return entityId; 459 + return {
  460 + entityId: entityId
  461 + };
460 } 462 }
461 463
462 function resolveAliasFilter(filter, stateParams, maxItems, failOnEmpty) { 464 function resolveAliasFilter(filter, stateParams, maxItems, failOnEmpty) {
@@ -468,7 +470,8 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device @@ -468,7 +470,8 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
468 if (filter.stateEntityParamName && filter.stateEntityParamName.length) { 470 if (filter.stateEntityParamName && filter.stateEntityParamName.length) {
469 result.entityParamName = filter.stateEntityParamName; 471 result.entityParamName = filter.stateEntityParamName;
470 } 472 }
471 - var stateEntityId = getStateEntityId(filter, stateParams); 473 + var stateEntityInfo = getStateEntityInfo(filter, stateParams);
  474 + var stateEntityId = stateEntityInfo.entityId;
472 switch (filter.type) { 475 switch (filter.type) {
473 case types.aliasFilterType.singleEntity.value: 476 case types.aliasFilterType.singleEntity.value:
474 var aliasEntityId = resolveAliasEntityId(filter.singleEntity.entityType, filter.singleEntity.id); 477 var aliasEntityId = resolveAliasEntityId(filter.singleEntity.entityType, filter.singleEntity.id);