UI: Introduce additionalParams for custom widget actions.
This commit is contained in:
parent
c2bc287158
commit
84ed34d4f0
@ -120,7 +120,7 @@
|
||||
</div>
|
||||
<tb-js-func ng-if="vm.action.type == vm.types.widgetActionTypes.custom.value"
|
||||
ng-model="vm.action.customFunction"
|
||||
function-args="{{ ['$event', 'widgetContext', 'entityId'] }}"
|
||||
function-args="{{ ['$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams'] }}"
|
||||
validation-args="{{ [] }}">
|
||||
</tb-js-func>
|
||||
</fieldset>
|
||||
|
||||
@ -444,7 +444,7 @@ export default function WidgetController($scope, $state, $timeout, $window, $ele
|
||||
}
|
||||
}
|
||||
|
||||
function handleWidgetAction($event, descriptor, entityId, entityName) {
|
||||
function handleWidgetAction($event, descriptor, entityId, entityName, additionalParams) {
|
||||
var type = descriptor.type;
|
||||
var targetEntityParamName = descriptor.stateEntityParamName;
|
||||
var targetEntityId;
|
||||
@ -485,8 +485,11 @@ export default function WidgetController($scope, $state, $timeout, $window, $ele
|
||||
var customFunction = descriptor.customFunction;
|
||||
if (angular.isDefined(customFunction) && customFunction.length > 0) {
|
||||
try {
|
||||
var customActionFunction = new Function('$event', 'widgetContext', 'entityId', 'entityName', customFunction);
|
||||
customActionFunction($event, widgetContext, entityId, entityName);
|
||||
if (!additionalParams) {
|
||||
additionalParams = {};
|
||||
}
|
||||
var customActionFunction = new Function('$event', 'widgetContext', 'entityId', 'entityName', 'additionalParams', customFunction);
|
||||
customActionFunction($event, widgetContext, entityId, entityName, additionalParams);
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDia
|
||||
entityId = vm.currentAlarm.originator;
|
||||
entityName = vm.currentAlarm.originatorName;
|
||||
}
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName);
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, descriptors[0], entityId, entityName, { alarm: vm.currentAlarm });
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ function AlarmsTableWidgetController($element, $scope, $filter, $mdMedia, $mdDia
|
||||
entityId = alarm.originator;
|
||||
entityName = alarm.originatorName;
|
||||
}
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName);
|
||||
vm.ctx.actionsApi.handleWidgetAction($event, actionDescriptor, entityId, entityName, { alarm: vm.currentAlarm });
|
||||
}
|
||||
|
||||
function isCurrent(alarm) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user