Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vladyslav_Prykhodko 2019-12-24 15:10:07 +02:00
commit af63f82b91
2 changed files with 21 additions and 13 deletions

View File

@ -439,7 +439,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
return entityId; return entityId;
} }
function getStateEntityId(filter, stateParams) { function getStateEntityInfo(filter, stateParams) {
var entityId = null; var entityId = null;
if (stateParams) { if (stateParams) {
if (filter.stateEntityParamName && filter.stateEntityParamName.length) { if (filter.stateEntityParamName && filter.stateEntityParamName.length) {
@ -456,7 +456,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
if (entityId) { if (entityId) {
entityId = resolveAliasEntityId(entityId.entityType, entityId.id); entityId = resolveAliasEntityId(entityId.entityType, entityId.id);
} }
return entityId; return {
entityId: entityId
};
} }
function resolveAliasFilter(filter, stateParams, maxItems, failOnEmpty) { function resolveAliasFilter(filter, stateParams, maxItems, failOnEmpty) {
@ -468,7 +470,8 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
if (filter.stateEntityParamName && filter.stateEntityParamName.length) { if (filter.stateEntityParamName && filter.stateEntityParamName.length) {
result.entityParamName = filter.stateEntityParamName; result.entityParamName = filter.stateEntityParamName;
} }
var stateEntityId = getStateEntityId(filter, stateParams); var stateEntityInfo = getStateEntityInfo(filter, stateParams);
var stateEntityId = stateEntityInfo.entityId;
switch (filter.type) { switch (filter.type) {
case types.aliasFilterType.singleEntity.value: case types.aliasFilterType.singleEntity.value:
var aliasEntityId = resolveAliasEntityId(filter.singleEntity.entityType, filter.singleEntity.id); var aliasEntityId = resolveAliasEntityId(filter.singleEntity.entityType, filter.singleEntity.id);
@ -850,7 +853,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
function getEntityFieldKeys (entityType, searchText) { function getEntityFieldKeys (entityType, searchText) {
let entityFieldKeys = []; let entityFieldKeys = [];
let query = searchText.toLowerCase(); let query = searchText ? searchText.toLowerCase() : "";
switch(entityType) { switch(entityType) {
case types.entityType.user: case types.entityType.user:
entityFieldKeys.push(types.entityField.name.keyName); entityFieldKeys.push(types.entityField.name.keyName);

View File

@ -44,8 +44,7 @@ export default function EntityStateController($scope, $timeout, $location, $stat
function openState(id, params, openRightLayout) { function openState(id, params, openRightLayout) {
if (vm.states && vm.states[id]) { if (vm.states && vm.states[id]) {
resolveEntity(params).then( resolveEntity(params).then(
function success(entityName) { function success() {
params.entityName = entityName;
var newState = { var newState = {
id: id, id: id,
params: params params: params
@ -66,8 +65,7 @@ export default function EntityStateController($scope, $timeout, $location, $stat
} }
if (vm.states && vm.states[id]) { if (vm.states && vm.states[id]) {
resolveEntity(params).then( resolveEntity(params).then(
function success(entityName) { function success() {
params.entityName = entityName;
var newState = { var newState = {
id: id, id: id,
params: params params: params
@ -183,16 +181,16 @@ export default function EntityStateController($scope, $timeout, $location, $stat
params = params[params.targetEntityParamName]; params = params[params.targetEntityParamName];
} }
if (params && params.entityId && params.entityId.id && params.entityId.entityType) { if (params && params.entityId && params.entityId.id && params.entityId.entityType) {
if (params.entityName && params.entityName.length) { if (isEntityResolved(params)) {
deferred.resolve(params.entityName); deferred.resolve();
} else { } else {
entityService.getEntity(params.entityId.entityType, params.entityId.id, { entityService.getEntity(params.entityId.entityType, params.entityId.id, {
ignoreLoading: true, ignoreLoading: true,
ignoreErrors: true ignoreErrors: true
}).then( }).then(
function success(entity) { function success(entity) {
var entityName = entity.name; params.entityName = entity.name;
deferred.resolve(entityName); deferred.resolve();
}, },
function fail() { function fail() {
deferred.reject(); deferred.reject();
@ -200,11 +198,18 @@ export default function EntityStateController($scope, $timeout, $location, $stat
); );
} }
} else { } else {
deferred.resolve(''); deferred.resolve();
} }
return deferred.promise; return deferred.promise;
} }
function isEntityResolved(params) {
if (!params.entityName || !params.entityName.length) {
return false;
}
return true;
}
function parseState(stateBase64) { function parseState(stateBase64) {
var result; var result;
if (stateBase64) { if (stateBase64) {