diff --git a/wherehows-web/app/components/dataset-compliance-field-tag.ts b/wherehows-web/app/components/dataset-compliance-field-tag.ts index 12933c30f7..92cf0d7bc0 100644 --- a/wherehows-web/app/components/dataset-compliance-field-tag.ts +++ b/wherehows-web/app/components/dataset-compliance-field-tag.ts @@ -164,7 +164,10 @@ export default class DatasetComplianceFieldTag extends Component { * @type {ComputedProperty} */ showCustomInput = computed('tag.logicalType', function(this: DatasetComplianceFieldTag): boolean { - const { logicalType } = get(this, 'tag'); + const { logicalType, valuePattern = '' } = get(this, 'tag'); + + this.actions.tagValuePatternDidChange.call(this, valuePattern); + return logicalType === IdLogicalType.Custom; }); diff --git a/wherehows-web/app/components/dataset-compliance.ts b/wherehows-web/app/components/dataset-compliance.ts index 1a0624680a..cf87f1cfb7 100644 --- a/wherehows-web/app/components/dataset-compliance.ts +++ b/wherehows-web/app/components/dataset-compliance.ts @@ -63,7 +63,7 @@ import { uniqBy } from 'lodash'; import { IColumnFieldProps } from 'wherehows-web/typings/app/dataset-columns'; import { isValidCustomValuePattern } from 'wherehows-web/utils/validators/urn'; import { emptyRegexSource } from 'wherehows-web/utils/validators/regexp'; -import { NonIdLogicalType } from 'wherehows-web/constants/datasets/compliance'; +import { IdLogicalType, NonIdLogicalType } from 'wherehows-web/constants/datasets/compliance'; import { pick } from 'lodash'; import { trackableEvent, TrackableEventCategory } from 'wherehows-web/constants/analytics/event-tracking'; @@ -957,7 +957,17 @@ export default class DatasetCompliance extends Component { * @param {IComplianceChangeSet.logicalType} logicalType the updated logical type */ tagLogicalTypeChanged(tag: IComplianceChangeSet, logicalType: IComplianceChangeSet['logicalType']): void { - setProperties(tag, { logicalType, isDirty: true }); + let properties: Pick = { + logicalType, + isDirty: true + }; + + // nullifies valuePattern attr if logicalType is not IdLogicalType.Custom + if (logicalType === IdLogicalType.Custom) { + properties = { ...properties, valuePattern: null }; + } + + setProperties(tag, properties); }, /** diff --git a/wherehows-web/app/typings/api/datasets/compliance.d.ts b/wherehows-web/app/typings/api/datasets/compliance.d.ts index d4ef20eb53..32f2ace497 100644 --- a/wherehows-web/app/typings/api/datasets/compliance.d.ts +++ b/wherehows-web/app/typings/api/datasets/compliance.d.ts @@ -32,7 +32,7 @@ export interface IComplianceEntity { // field should also be filtered from persisted policy readonly readonly?: boolean; //Optional attribute for the value of a CUSTOM regex. Required for CUSTOM field format - valuePattern?: string; + valuePattern?: string | null; } /**