Skip to content

Commit

Permalink
Add case sensitive option to disable checkbox regex validation in an…
Browse files Browse the repository at this point in the history
…dsvocab component
  • Loading branch information
alejandro-bulgaris-qcif committed Dec 19, 2022
1 parent 48cf3e7 commit 6f29984
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions angular/shared/form/field-andsvocab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class ANDSVocabField extends FieldBase<any> {
public disableCheckboxRegexEnabled:boolean;
public disableCheckboxRegexPattern:string;
public disableCheckboxRegexTestValue:string;
public disableCheckboxRegexCaseSensitive: boolean;

constructor(options: any, injector: any) {
super(options, injector);
Expand All @@ -53,6 +54,7 @@ export class ANDSVocabField extends FieldBase<any> {
this.disableCheckboxRegexEnabled = options['disableCheckboxRegexEnabled'] || false;
this.disableCheckboxRegexPattern = options['disableCheckboxRegexPattern'] || "";
this.disableCheckboxRegexTestValue = options['disableCheckboxRegexTestValue'] || "";
this.disableCheckboxRegexCaseSensitive = options['disableCheckboxRegexCaseSensitive'] || true;

this.andsService = this.getFromInjector(ANDSService);
}
Expand Down Expand Up @@ -311,11 +313,16 @@ export class ANDSVocabComponent extends SimpleComponent {
if(this.field.disableCheckboxRegexEnabled) {
const data = childNode.data;
let nodeId = _.get(data,this.field.disableCheckboxRegexTestValue);
let re = new RegExp(this.field.disableCheckboxRegexPattern,'i');
let re;
if(this.field.disableCheckboxRegexCaseSensitive) {
re = new RegExp(this.field.disableCheckboxRegexPattern);
} else {
re = new RegExp(this.field.disableCheckboxRegexPattern,'i');
}
if(!_.isUndefined(nodeId)) {
let reTest = re.test(nodeId.toString());
console.log(nodeId + ' ' + this.field.disableCheckboxRegexTestValue + ' ' + reTest);
if(!reTest) {
let regexTest = re.test(nodeId.toString());
console.log('nodeId ' + nodeId + ' testValue ' + this.field.disableCheckboxRegexTestValue + ' regexTest ' + regexTest);
if(!regexTest) {
valid = false;
}
}
Expand Down

0 comments on commit 6f29984

Please sign in to comment.