From c414b8cebcaeed82c53b502604ef345850400fbe Mon Sep 17 00:00:00 2001 From: Kim Shepherd Date: Tue, 19 Apr 2022 14:05:16 +1200 Subject: [PATCH] [TLC-254] Replace some undef/null tests with hasValue, hasNoValue --- .../models/ds-dynamic-row-array-model.ts | 8 ++++---- .../shared/form/builder/form-builder.service.ts | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-row-array-model.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-row-array-model.ts index e4b18a4feb..40b4a4acee 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-row-array-model.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-row-array-model.ts @@ -6,7 +6,7 @@ import { serializable } from '@ng-dynamic-forms/core'; import { RelationshipOptions } from '../../models/relationship-options.model'; -import { isNotUndefined } from '../../../../empty.util'; +import { hasValue, isNotUndefined } from '../../../../empty.util'; export interface DynamicRowArrayModelConfig extends DynamicFormArrayModelConfig { notRepeatable: boolean; @@ -38,13 +38,13 @@ export class DynamicRowArrayModel extends DynamicFormArrayModel { constructor(config: DynamicRowArrayModelConfig, layout?: DynamicFormControlLayout) { super(config, layout); - if (isNotUndefined(config.notRepeatable)) { + if (hasValue(config.notRepeatable)) { this.notRepeatable = config.notRepeatable; } - if (isNotUndefined(config.required)) { + if (hasValue(config.required)) { this.required = config.required; } - if (isNotUndefined(config.showButtons)) { + if (hasValue(config.showButtons)) { this.showButtons = config.showButtons; } this.submissionId = config.submissionId; diff --git a/src/app/shared/form/builder/form-builder.service.ts b/src/app/shared/form/builder/form-builder.service.ts index 862f4beb01..ec3b495aa9 100644 --- a/src/app/shared/form/builder/form-builder.service.ts +++ b/src/app/shared/form/builder/form-builder.service.ts @@ -20,7 +20,16 @@ import { } from '@ng-dynamic-forms/core'; import { isObject, isString, mergeWith } from 'lodash'; -import { hasValue, isEmpty, isNotEmpty, isNotNull, isNotUndefined, isNull, isObjectEmpty } from '../../empty.util'; +import { + hasNoValue, + hasValue, + isEmpty, + isNotEmpty, + isNotNull, + isNotUndefined, + isNull, + isObjectEmpty +} from '../../empty.util'; import { DynamicQualdropModel } from './ds-dynamic-form-ui/models/ds-dynamic-qualdrop.model'; import { SubmissionFormsModel } from '../../../core/config/models/config-submission-forms.model'; import { DYNAMIC_FORM_CONTROL_TYPE_TAG } from './ds-dynamic-form-ui/models/tag/dynamic-tag.model'; @@ -281,11 +290,11 @@ export class FormBuilderService extends DynamicFormService { }); } - if (isNull(typeBindModel)) { + if (hasNoValue(typeBindModel)) { typeBindModel = this.findById(this.typeField, rows); } - if (typeBindModel !== null) { + if (hasValue(typeBindModel)) { this.setTypeBindModel(typeBindModel); } return rows;