Commit 84ed34d4f051c3d0b58f74238936ec4d2e0b6802
1 parent
c2bc2871
UI: Introduce additionalParams for custom widget actions.
Showing
3 changed files
with
9 additions
and
6 deletions
... | ... | @@ -120,7 +120,7 @@ |
120 | 120 | </div> |
121 | 121 | <tb-js-func ng-if="vm.action.type == vm.types.widgetActionTypes.custom.value" |
122 | 122 | ng-model="vm.action.customFunction" |
123 | - function-args="{{ ['$event', 'widgetContext', 'entityId'] }}" | |
123 | + function-args="{{ ['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams'] }}" | |
124 | 124 | validation-args="{{ [] }}"> |
125 | 125 | </tb-js-func> |
126 | 126 | </fieldset> | ... | ... |
... | ... | @@ -444,7 +444,7 @@ export default function WidgetController($scope, $state, $timeout, $window, $ele |
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | - function handleWidgetAction($event, descriptor, entityId, entityName) { | |
447 | + function handleWidgetAction($event, descriptor, entityId, entityName, additionalParams) { | |
448 | 448 | var type = descriptor.type; |
449 | 449 | var targetEntityParamName = descriptor.stateEntityParamName; |
450 | 450 | var targetEntityId; |
... | ... | @@ -485,8 +485,11 @@ export default function WidgetController($scope, $state, $timeout, $window, $ele |
485 | 485 | var customFunction = descriptor.customFunction; |
486 | 486 | if (angular.isDefined(customFunction) && customFunction.length > 0) { |
487 | 487 | try { |
488 | - var customActionFunction = new Function('$event', 'widgetContext', 'entityId', 'entityName', customFunction); | |
489 | - customActionFunction($event, widgetContext, entityId, entityName); | |
488 | + if (!additionalParams) { | |
489 | + additionalParams = {}; | |
490 | + } | |
491 | + var customActionFunction = new Function('$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', customFunction); | |
492 | + customActionFunction($event, widgetContext, entityId, entityName, additionalParams); | |
490 | 493 | } catch (e) { |
491 | 494 | // |
492 | 495 | } | ... | ... |
... | ... | @@ -298,7 +298,7 @@ function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDia |
298 | 298 | entityId = vm.currentAlarm.originator; |
299 | 299 | entityName = vm.currentAlarm.originatorName; |
300 | 300 | } |
301 | - vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName); | |
301 | + vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, { alarm: vm.currentAlarm }); | |
302 | 302 | } |
303 | 303 | } |
304 | 304 | |
... | ... | @@ -312,7 +312,7 @@ function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDia |
312 | 312 | entityId = alarm.originator; |
313 | 313 | entityName = alarm.originatorName; |
314 | 314 | } |
315 | - vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName); | |
315 | + vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName, { alarm: vm.currentAlarm }); | |
316 | 316 | } |
317 | 317 | |
318 | 318 | function isCurrent(alarm) { | ... | ... |