Custom widget to masking text

1
0
-1

Hello,

I need to create a masking custom widget. My use case is as follows.

The text in the textbox should be masked based on pattern specified. The initial use case is, if the number is "68966486" then the widget should render "****6486". I wanted it to extend it so that it could mask based on the regular expression to make it more generic.

In order to achieve it, I tried the following so far.

**1. Custom Filter: **
Created custom filter but when I tried to import the widget it throws errors. To me, it looks like Bonita widget does not support custom angularjs filters. Please let me know if my assumption is wrong and if there is any sample code that anyone could share, would be great.

2. Alter the value in Controller:
Tried to read the text from inside an expression and then alter the value. Code snippet below

** widget.json**
property name ="text", which is bound to a variable from UI.

{
      "label" : "Text",
      "name" : "text",
      "caption" : "some caption",
      "type" : "html",
      "defaultValue" : "Basic html <br/>to format the <b>value</b>.",
      "bond":"expression"
    }, 

** controller.js**

function pbMaskText($scope, $log){

  // trying to read the value, but the below line always returns **undefined**. 
  var valueToMask = $scope.properties.text;

  // this below line also has no impact. It never gets assigned.
  $scope.properties.text = "my masked value"
 ....

}

But when I check in chrome developer window, I could see there is value in $scope.properties.text (but in controller.js, when I try to access it it's coming as undefined).

bonitacapture.JPG?raw=1

Comments

Submitted by purem23_1391351 on Fri, 06/21/2019 - 11:42

Any pointers from anyone??

No answers yet.
Notifications