[TLC-254] Replace some undef/null tests with hasValue, hasNoValue

This commit is contained in:
Kim Shepherd
2022-04-19 14:05:16 +12:00
parent 617717069b
commit c414b8cebc
2 changed files with 16 additions and 7 deletions

View File

@@ -6,7 +6,7 @@ import {
serializable serializable
} from '@ng-dynamic-forms/core'; } from '@ng-dynamic-forms/core';
import { RelationshipOptions } from '../../models/relationship-options.model'; import { RelationshipOptions } from '../../models/relationship-options.model';
import { isNotUndefined } from '../../../../empty.util'; import { hasValue, isNotUndefined } from '../../../../empty.util';
export interface DynamicRowArrayModelConfig extends DynamicFormArrayModelConfig { export interface DynamicRowArrayModelConfig extends DynamicFormArrayModelConfig {
notRepeatable: boolean; notRepeatable: boolean;
@@ -38,13 +38,13 @@ export class DynamicRowArrayModel extends DynamicFormArrayModel {
constructor(config: DynamicRowArrayModelConfig, layout?: DynamicFormControlLayout) { constructor(config: DynamicRowArrayModelConfig, layout?: DynamicFormControlLayout) {
super(config, layout); super(config, layout);
if (isNotUndefined(config.notRepeatable)) { if (hasValue(config.notRepeatable)) {
this.notRepeatable = config.notRepeatable; this.notRepeatable = config.notRepeatable;
} }
if (isNotUndefined(config.required)) { if (hasValue(config.required)) {
this.required = config.required; this.required = config.required;
} }
if (isNotUndefined(config.showButtons)) { if (hasValue(config.showButtons)) {
this.showButtons = config.showButtons; this.showButtons = config.showButtons;
} }
this.submissionId = config.submissionId; this.submissionId = config.submissionId;

View File

@@ -20,7 +20,16 @@ import {
} from '@ng-dynamic-forms/core'; } from '@ng-dynamic-forms/core';
import { isObject, isString, mergeWith } from 'lodash'; 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 { DynamicQualdropModel } from './ds-dynamic-form-ui/models/ds-dynamic-qualdrop.model';
import { SubmissionFormsModel } from '../../../core/config/models/config-submission-forms.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'; 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); typeBindModel = this.findById(this.typeField, rows);
} }
if (typeBindModel !== null) { if (hasValue(typeBindModel)) {
this.setTypeBindModel(typeBindModel); this.setTypeBindModel(typeBindModel);
} }
return rows; return rows;