Creating a simple Cancel Custom Widget

1
0
-1

Hi there,

I'm trying to create a simple Cancel Custom Widget for use in Instantiation forms, for when a user realizes they don't want to do the process...

My template is:

<div>
<button type="button">Cancel</button>
</div>

and my controller is:

function($scope, $window){
    console.log("Doing it anyway!"); //#1
   
     $scope.onClick = function cancelOnClick($scope, $window) {
        console.log("cancelling!"); //#2
        $window.top.location.href = '/' + $scope.properties.bonitaWebAppName;
    };
}

with one property:

bonitaWebAppName
Label: Bonita web app name
Treat as Dynamic value
Type: text
Default value: bonita

When I execute the process I always get the "Doing it anyway!" //#1 message but when I click the Button it never seems to fire...

I'm trying to learn angularjs but, it's not that easy... :)

Thanks for the advice in advance,

regards
Sean

Update:

I've now seen how to do it...

<div>
<button type="button" ng-click="ctrl.cancelOnClick()">Cancel</button>
</div>

with controller:

function($scope, $window){
    console.log("Doing it anyway!");
   
     this.onClick = function cancelOnClick() {
        console.log("cancelling!");
        $window.top.location.href = '/' + $scope.properties.bonitaWebAppName;
    };
}

But it still doesn't work...

1 answer

1
+2
-1
This one is the BEST answer!

OK, in the end I worked it out.

Don't use a DIV around the button...

So my final code for the Cancel button template is

<button ng-click="ctrl.cancelOnClick()">Cancel</button>

and the Controller

function($scope, $window){
    this.cancelOnClick = function () {
        $window.top.location.href = '/' + $scope.properties.bonitaWebAppName;
    };
}

I've used the parameter as well

bonitaWebAppName
Label: Bonita web app name
Treat as Dynamic value
Type: text
Default value: bonita

Bonita web app name: the name of Bonita Portal web application. By default "bonita". This will be used to build REST API URL but also to redirect user to Portal welcome page if no tasks are available

Hope it helps others
regards
Sean

Notifications