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