Commit 8d45f32d8d78b436f57de43f7bf2928724bf0399

Authored by Igor Kulikov
1 parent 04f18a6f

Improve entity state controller.

... ... @@ -44,8 +44,7 @@ export default function EntityStateController($scope, $timeout, $location, $stat
44 44 function openState(id, params, openRightLayout) {
45 45 if (vm.states && vm.states[id]) {
46 46 resolveEntity(params).then(
47   - function success(entityName) {
48   - params.entityName = entityName;
  47 + function success() {
49 48 var newState = {
50 49 id: id,
51 50 params: params
... ... @@ -66,8 +65,7 @@ export default function EntityStateController($scope, $timeout, $location, $stat
66 65 }
67 66 if (vm.states && vm.states[id]) {
68 67 resolveEntity(params).then(
69   - function success(entityName) {
70   - params.entityName = entityName;
  68 + function success() {
71 69 var newState = {
72 70 id: id,
73 71 params: params
... ... @@ -183,16 +181,16 @@ export default function EntityStateController($scope, $timeout, $location, $stat
183 181 params = params[params.targetEntityParamName];
184 182 }
185 183 if (params && params.entityId && params.entityId.id && params.entityId.entityType) {
186   - if (params.entityName && params.entityName.length) {
187   - deferred.resolve(params.entityName);
  184 + if (isEntityResolved(params)) {
  185 + deferred.resolve();
188 186 } else {
189 187 entityService.getEntity(params.entityId.entityType, params.entityId.id, {
190 188 ignoreLoading: true,
191 189 ignoreErrors: true
192 190 }).then(
193 191 function success(entity) {
194   - var entityName = entity.name;
195   - deferred.resolve(entityName);
  192 + params.entityName = entity.name;
  193 + deferred.resolve();
196 194 },
197 195 function fail() {
198 196 deferred.reject();
... ... @@ -200,11 +198,18 @@ export default function EntityStateController($scope, $timeout, $location, $stat
200 198 );
201 199 }
202 200 } else {
203   - deferred.resolve('');
  201 + deferred.resolve();
204 202 }
205 203 return deferred.promise;
206 204 }
207 205
  206 + function isEntityResolved(params) {
  207 + if (!params.entityName || !params.entityName.length) {
  208 + return false;
  209 + }
  210 + return true;
  211 + }
  212 +
208 213 function parseState(stateBase64) {
209 214 var result;
210 215 if (stateBase64) {
... ...