Skip to content

Commit

Permalink
Fix: Contributor component does not function with the setVisibility f…
Browse files Browse the repository at this point in the history
…unction (#1145)

* Added custom validation handler interface. Fields that implement this interface will manage setting and unsetting validators themselves.
Added to setVisibility of field-base so that validation can be reapplied correctly for this type of field after visibility is re-enabled.

* Fixed interface name

* Fixed syntax error

* Updated docker deploy script to support forward slashes in the branch name
  • Loading branch information
andrewbrazzatti authored Mar 29, 2023
1 parent 908c2b5 commit 7941497
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 6 additions & 0 deletions angular/shared/form/custom-validation-handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface CustomValidationHandlerField {

enableValidators();

disableValidators();
}
10 changes: 7 additions & 3 deletions angular/shared/form/field-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,13 @@ export class FieldBase<T> {
} else {
if (!that.visible) {
// restore validators
if (that.formModel) {
that.formModel.setValidators(that.validators);
that.formModel.updateValueAndValidity();
if (that.formModel) {
if(that['enableValidators'] != null && typeof(that['enableValidators']) == 'function') {
that['enableValidators']();
} else {
that.formModel.setValidators(that.validators);
}
that.formModel.updateValueAndValidity();
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion angular/shared/form/field-contributor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {FormControl, FormGroup, Validators} from '@angular/forms';
import * as _ from "lodash";
import { VocabField } from './field-vocab.component';
import { Observable} from 'rxjs/Rx';
import { CustomValidationHandlerField } from './custom-validation-handler';

/**
* Contributor Model
*
Expand All @@ -36,7 +38,7 @@ const KEY_EN = 13;
const KEY_LEFT = 37;
const KEY_RIGHT = 39;

export class ContributorField extends FieldBase<any> {
export class ContributorField extends FieldBase<any> implements CustomValidationHandlerField {
nameColHdr: string;
emailColHdr: string;
roleColHdr: string;
Expand Down

0 comments on commit 7941497

Please sign in to comment.