Merge pull request #1172 from theseyi/custom-input-init

compliance entity value pattern is nullable when idlogicaltype is not…
This commit is contained in:
Seyi Adebajo 2018-05-21 11:11:48 -07:00 committed by GitHub
commit e59b7dd9e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -164,7 +164,10 @@ export default class DatasetComplianceFieldTag extends Component {
* @type {ComputedProperty<boolean>}
*/
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;
});

View File

@ -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<IComplianceChangeSet, 'logicalType' | 'isDirty' | 'valuePattern'> = {
logicalType,
isDirty: true
};
// nullifies valuePattern attr if logicalType is not IdLogicalType.Custom
if (logicalType === IdLogicalType.Custom) {
properties = { ...properties, valuePattern: null };
}
setProperties(tag, properties);
},
/**

View File

@ -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;
}
/**