From 6f2998439725e551cdeb81c45f00f3cd3c0326de Mon Sep 17 00:00:00 2001 From: ADBC Date: Mon, 19 Dec 2022 00:38:59 +0000 Subject: [PATCH] Add case sensitive option to disable checkbox regex validation in andsvocab component --- angular/shared/form/field-andsvocab.component.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/angular/shared/form/field-andsvocab.component.ts b/angular/shared/form/field-andsvocab.component.ts index e47c3a2296..71fdc05e02 100644 --- a/angular/shared/form/field-andsvocab.component.ts +++ b/angular/shared/form/field-andsvocab.component.ts @@ -45,6 +45,7 @@ export class ANDSVocabField extends FieldBase { public disableCheckboxRegexEnabled:boolean; public disableCheckboxRegexPattern:string; public disableCheckboxRegexTestValue:string; + public disableCheckboxRegexCaseSensitive: boolean; constructor(options: any, injector: any) { super(options, injector); @@ -53,6 +54,7 @@ export class ANDSVocabField extends FieldBase { this.disableCheckboxRegexEnabled = options['disableCheckboxRegexEnabled'] || false; this.disableCheckboxRegexPattern = options['disableCheckboxRegexPattern'] || ""; this.disableCheckboxRegexTestValue = options['disableCheckboxRegexTestValue'] || ""; + this.disableCheckboxRegexCaseSensitive = options['disableCheckboxRegexCaseSensitive'] || true; this.andsService = this.getFromInjector(ANDSService); } @@ -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; } }