Commit c16ab58806eabe03ecca6f2a304e28997d82a32a
Committed by
GitHub
Merge pull request #1023 from Sioxas/bugfix/modify-action-source
Fix #1022
Showing
1 changed file
with
11 additions
and
6 deletions
... | ... | @@ -244,13 +244,18 @@ function ManageWidgetActionsController($rootScope, $scope, $document, $mdDialog, |
244 | 244 | vm.widgetActions[actionSourceId] = targetActions; |
245 | 245 | } |
246 | 246 | if (prevActionId) { |
247 | - var index = getActionIndex(prevActionId, vm.allActions); | |
248 | - if (index > -1) { | |
249 | - vm.allActions[index] = action; | |
247 | + const indexInTarget = getActionIndex(prevActionId, targetActions); | |
248 | + const indexInAllActions = getActionIndex(prevActionId, vm.allActions); | |
249 | + if (indexInTarget > -1) { | |
250 | + targetActions[indexInTarget] = widgetAction; | |
251 | + } else if (indexInAllActions > -1) { | |
252 | + const prevActionSourceId = vm.allActions[indexInAllActions].actionSourceId; | |
253 | + const index = getActionIndex(prevActionId,vm.widgetActions[prevActionSourceId]); | |
254 | + vm.widgetActions[prevActionSourceId].splice(index,1); | |
255 | + targetActions.push(widgetAction); | |
250 | 256 | } |
251 | - index = getActionIndex(prevActionId, targetActions); | |
252 | - if (index > -1) { | |
253 | - targetActions[index] = widgetAction; | |
257 | + if (indexInAllActions > -1) { | |
258 | + vm.allActions[indexInAllActions] = action; | |
254 | 259 | } |
255 | 260 | } else { |
256 | 261 | vm.allActions.push(action); | ... | ... |