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,7 +120,7 @@ | ||
120 | </div> | 120 | </div> |
121 | <tb-js-func ng-if="vm.action.type == vm.types.widgetActionTypes.custom.value" | 121 | <tb-js-func ng-if="vm.action.type == vm.types.widgetActionTypes.custom.value" |
122 | ng-model="vm.action.customFunction" | 122 | ng-model="vm.action.customFunction" |
123 | - function-args="{{ ['$event', 'widgetContext', 'entityId'] }}" | 123 | + function-args="{{ ['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams'] }}" |
124 | validation-args="{{ [] }}"> | 124 | validation-args="{{ [] }}"> |
125 | </tb-js-func> | 125 | </tb-js-func> |
126 | </fieldset> | 126 | </fieldset> |
@@ -444,7 +444,7 @@ export default function WidgetController($scope, $state, $timeout, $window, $ele | @@ -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 | var type = descriptor.type; | 448 | var type = descriptor.type; |
449 | var targetEntityParamName = descriptor.stateEntityParamName; | 449 | var targetEntityParamName = descriptor.stateEntityParamName; |
450 | var targetEntityId; | 450 | var targetEntityId; |
@@ -485,8 +485,11 @@ export default function WidgetController($scope, $state, $timeout, $window, $ele | @@ -485,8 +485,11 @@ export default function WidgetController($scope, $state, $timeout, $window, $ele | ||
485 | var customFunction = descriptor.customFunction; | 485 | var customFunction = descriptor.customFunction; |
486 | if (angular.isDefined(customFunction) && customFunction.length > 0) { | 486 | if (angular.isDefined(customFunction) && customFunction.length > 0) { |
487 | try { | 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 | } catch (e) { | 493 | } catch (e) { |
491 | // | 494 | // |
492 | } | 495 | } |
@@ -298,7 +298,7 @@ function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDia | @@ -298,7 +298,7 @@ function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDia | ||
298 | entityId = vm.currentAlarm.originator; | 298 | entityId = vm.currentAlarm.originator; |
299 | entityName = vm.currentAlarm.originatorName; | 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,7 +312,7 @@ function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDia | ||
312 | entityId = alarm.originator; | 312 | entityId = alarm.originator; |
313 | entityName = alarm.originatorName; | 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 | function isCurrent(alarm) { | 318 | function isCurrent(alarm) { |