diff --git a/ui/src/app/entity/entity-select.directive.js b/ui/src/app/entity/entity-select.directive.js index 8e4031c9cf..2ac5228e56 100644 --- a/ui/src/app/entity/entity-select.directive.js +++ b/ui/src/app/entity/entity-select.directive.js @@ -22,14 +22,26 @@ import entitySelectTemplate from './entity-select.tpl.html'; /* eslint-enable import/no-unresolved, import/default */ /*@ngInject*/ -export default function EntitySelect($compile, $templateCache) { +export default function EntitySelect($compile, $templateCache, entityService) { var linker = function (scope, element, attrs, ngModelCtrl) { var template = $templateCache.get(entitySelectTemplate); element.html(template); scope.tbRequired = angular.isDefined(scope.tbRequired) ? scope.tbRequired : false; - scope.model = {}; + + var entityTypes = entityService.prepareAllowedEntityTypesList(scope.allowedEntityTypes, scope.useAliasEntityTypes); + + if (entityTypes.length === 1) { + scope.displayEntityTypeSelect = false; + scope.defaultEntityType = entityTypes[0]; + } else { + scope.displayEntityTypeSelect = true; + } + + scope.model = { + entityType: scope.defaultEntityType + }; scope.updateView = function () { if (!scope.disabled) { @@ -54,7 +66,7 @@ export default function EntitySelect($compile, $templateCache) { scope.model.entityType = value.entityType; scope.model.entityId = value.id; } else { - scope.model.entityType = null; + scope.model.entityType = scope.defaultEntityType; scope.model.entityId = null; } initWatchers(); @@ -106,6 +118,7 @@ export default function EntitySelect($compile, $templateCache) { theForm: '=?', tbRequired: '=?', disabled:'=ngDisabled', + allowedEntityTypes: "=?", useAliasEntityTypes: "=?" } }; diff --git a/ui/src/app/entity/entity-select.tpl.html b/ui/src/app/entity/entity-select.tpl.html index 9e5e227922..d6b6eeaba4 100644 --- a/ui/src/app/entity/entity-select.tpl.html +++ b/ui/src/app/entity/entity-select.tpl.html @@ -17,10 +17,12 @@ -->