angular-patternfly icon indicating copy to clipboard operation
angular-patternfly copied to clipboard

Improve pf-wizard validation

Open benjaminapetersen opened this issue 8 years ago • 0 comments

Original issue in origin-web-console.

The example in the original issue is this:

var validityWatcher;
// ...
// in a setup fn:
validityWatcher = $scope.$watch("ctrl.selectionForm.$valid", function(isValid) {
     ctrl.steps[0].valid = isValid;
});
// ... 
// in another fn:
      if (validityWatcher) {
        validityWatcher();
        validityWatcher = undefined;
      }
// 
// in a cleanup fn:
    ctrl.$onDestroy = function() {
      if (validityWatcher) {
        validityWatcher();
        validityWatcher = undefined;
      }
// ...

There is a lot of bookkeeping involved for validation & it feels a bit out of sync with typical angular validation. The ideal option is to get it in the view, but a secondary option might be to get a validation function added to the steps & hide the setup/tear down code from the user (hide by adding an ng-form behind the scenes, perhaps w/a name = to the step.id or step.id+rand and then toggling its $valid property based on the validator fn).

benjaminapetersen avatar Jun 14 '17 20:06 benjaminapetersen