mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-01 13:23:09 +00:00
Merge pull request #1107 from theseyi/multi-tagging-updates
5407 fix variable name casing. adds feature to remove already selecte…
This commit is contained in:
commit
2bb01b94f7
@ -10,6 +10,8 @@ import {
|
|||||||
} from 'wherehows-web/typings/app/dataset-compliance';
|
} from 'wherehows-web/typings/app/dataset-compliance';
|
||||||
import { IComplianceDataType } from 'wherehows-web/typings/api/list/compliance-datatypes';
|
import { IComplianceDataType } from 'wherehows-web/typings/api/list/compliance-datatypes';
|
||||||
import { action } from 'ember-decorators/object';
|
import { action } from 'ember-decorators/object';
|
||||||
|
import { IComplianceEntity } from 'wherehows-web/typings/api/datasets/compliance';
|
||||||
|
import { arrayFilter } from 'wherehows-web/utils/array';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant definition for an unselected field format
|
* Constant definition for an unselected field format
|
||||||
@ -21,6 +23,16 @@ const unSelectedFieldFormatValue: IDropDownOption<null> = {
|
|||||||
isDisabled: true
|
isDisabled: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a filter function that excludes options that are already included in other field tags
|
||||||
|
* @param {IComplianceEntity.identifierType} currentTagId
|
||||||
|
* @return {(fieldIdTypeTags: Array<IComplianceEntity["identifierType"]>) => ({ value }: IComplianceFieldIdentifierOption) => boolean}
|
||||||
|
*/
|
||||||
|
const resolvedOptionsFilterFn = (currentTagId: IComplianceEntity['identifierType']) => (
|
||||||
|
fieldIdTypeTags: Array<IComplianceEntity['identifierType']>
|
||||||
|
) => ({ value }: IComplianceFieldIdentifierOption): boolean =>
|
||||||
|
!fieldIdTypeTags.includes(value) || value === currentTagId;
|
||||||
|
|
||||||
export default class DatasetComplianceFieldTag extends Component {
|
export default class DatasetComplianceFieldTag extends Component {
|
||||||
tagName = 'tr';
|
tagName = 'tr';
|
||||||
|
|
||||||
@ -54,6 +66,13 @@ export default class DatasetComplianceFieldTag extends Component {
|
|||||||
*/
|
*/
|
||||||
parentHasSingleTag: boolean;
|
parentHasSingleTag: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of identifierTypes for the parent field
|
||||||
|
* @type {Array<IComplianceEntity['identifierType']>}
|
||||||
|
* @memberof DatasetComplianceFieldTag
|
||||||
|
*/
|
||||||
|
fieldIdentifiers: Array<IComplianceEntity['identifierType']>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to the compliance data types
|
* Reference to the compliance data types
|
||||||
* @type {Array<IComplianceDataType>}
|
* @type {Array<IComplianceDataType>}
|
||||||
@ -67,25 +86,28 @@ export default class DatasetComplianceFieldTag extends Component {
|
|||||||
complianceFieldIdDropdownOptions: Array<IComplianceFieldIdentifierOption>;
|
complianceFieldIdDropdownOptions: Array<IComplianceFieldIdentifierOption>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the dropdown options available for this tag by filtering out options that are not applicable /available for this tag
|
* Build the drop down options available for this tag by filtering out options that are not applicable /available for this tag
|
||||||
* @type {ComputedProperty<Array<IComplianceFieldIdentifierOption>>}
|
* @type {ComputedProperty<Array<IComplianceFieldIdentifierOption>>}
|
||||||
* @memberof DatasetComplianceFieldTag
|
* @memberof DatasetComplianceFieldTag
|
||||||
*/
|
*/
|
||||||
fieldIdDropDownOptions = computed('hasSingleTag', function(
|
fieldIdDropDownOptions = computed('hasSingleTag', 'fieldIdentifiers', function(
|
||||||
this: DatasetComplianceFieldTag
|
this: DatasetComplianceFieldTag
|
||||||
): Array<IComplianceFieldIdentifierOption> {
|
): Array<IComplianceFieldIdentifierOption> {
|
||||||
const { parentHasSingleTag, complianceFieldIdDropdownOptions: dropDownOptions } = getProperties(this, [
|
const { parentHasSingleTag, fieldIdentifiers, complianceFieldIdDropdownOptions: allOptions, tag } = getProperties(
|
||||||
'parentHasSingleTag',
|
this,
|
||||||
'complianceFieldIdDropdownOptions'
|
['parentHasSingleTag', 'fieldIdentifiers', 'complianceFieldIdDropdownOptions', 'tag']
|
||||||
]);
|
);
|
||||||
|
|
||||||
// if the parent field does not have a single tag, then no field can be tagged as ComplianceFieldIdValue.None
|
|
||||||
if (!parentHasSingleTag) {
|
if (!parentHasSingleTag) {
|
||||||
const NoneOption = dropDownOptions.findBy('value', ComplianceFieldIdValue.None);
|
const thisTagIdentifierType = get(tag, 'identifierType');
|
||||||
return dropDownOptions.without(NoneOption!);
|
const noneOption = allOptions.findBy('value', ComplianceFieldIdValue.None);
|
||||||
|
// if the parent field does not have a single tag, then no field can be tagged as ComplianceFieldIdValue.None
|
||||||
|
const options = allOptions.without(noneOption!);
|
||||||
|
|
||||||
|
return arrayFilter(resolvedOptionsFilterFn(thisTagIdentifierType)(fieldIdentifiers))(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dropDownOptions;
|
return allOptions;
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Component from '@ember/component';
|
import Component from '@ember/component';
|
||||||
import ComputedProperty, { alias, equal, bool } from '@ember/object/computed';
|
import ComputedProperty, { alias, equal, bool, mapBy } from '@ember/object/computed';
|
||||||
import { get, set, getWithDefault, getProperties, computed } from '@ember/object';
|
import { get, set, getWithDefault, getProperties, computed } from '@ember/object';
|
||||||
import { action } from 'ember-decorators/object';
|
import { action } from 'ember-decorators/object';
|
||||||
import {
|
import {
|
||||||
@ -14,12 +14,15 @@ import {
|
|||||||
SuggestionIntent,
|
SuggestionIntent,
|
||||||
fieldTagsRequiringReview,
|
fieldTagsRequiringReview,
|
||||||
tagsHaveNoneAndNotNoneType,
|
tagsHaveNoneAndNotNoneType,
|
||||||
tagsHaveNoneType
|
tagsHaveNoneType,
|
||||||
|
suggestedIdentifierTypesInList
|
||||||
} from 'wherehows-web/constants';
|
} from 'wherehows-web/constants';
|
||||||
import { getTagSuggestions } from 'wherehows-web/utils/datasets/compliance-suggestions';
|
import { getTagSuggestions } from 'wherehows-web/utils/datasets/compliance-suggestions';
|
||||||
import { IColumnFieldProps } from 'wherehows-web/typings/app/dataset-columns';
|
import { IColumnFieldProps } from 'wherehows-web/typings/app/dataset-columns';
|
||||||
import { fieldTagsHaveIdentifierType } from 'wherehows-web/constants/dataset-compliance';
|
import { fieldTagsHaveIdentifierType } from 'wherehows-web/constants/dataset-compliance';
|
||||||
import { IComplianceDataType } from 'wherehows-web/typings/api/list/compliance-datatypes';
|
import { IComplianceDataType } from 'wherehows-web/typings/api/list/compliance-datatypes';
|
||||||
|
import { arrayReduce } from 'wherehows-web/utils/array';
|
||||||
|
import { IComplianceEntity } from 'wherehows-web/typings/api/datasets/compliance';
|
||||||
|
|
||||||
export default class DatasetComplianceRollupRow extends Component.extend({
|
export default class DatasetComplianceRollupRow extends Component.extend({
|
||||||
tagName: ''
|
tagName: ''
|
||||||
@ -199,23 +202,28 @@ export default class DatasetComplianceRollupRow extends Component.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists the ComplianceFieldIdValue values this field is currently tagged with
|
||||||
|
* @type {ComputedProperty<Array<ComplianceFieldIdValue>>}
|
||||||
|
* @memberof DatasetComplianceRollupRow
|
||||||
|
*/
|
||||||
|
taggedIdentifiers: ComputedProperty<Array<IComplianceEntity['identifierType']>> = mapBy(
|
||||||
|
'fieldChangeSet',
|
||||||
|
'identifierType'
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists the identifierTypes that are suggested values but are currently in the fields tags
|
* Lists the identifierTypes that are suggested values but are currently in the fields tags
|
||||||
* @type {ComputedProperty<Array<string>>}
|
* @type {ComputedProperty<Array<string>>}
|
||||||
* @memberof DatasetComplianceRollupRow
|
* @memberof DatasetComplianceRollupRow
|
||||||
* TODO: multi valued suggestions
|
* TODO: multi valued suggestions
|
||||||
*/
|
*/
|
||||||
suggestedValuesInChangeSet = computed('fieldChangeSet.@each.identifierType', 'suggestion', function(
|
suggestedValuesInChangeSet = computed('taggedIdentifiers', 'suggestion', function(
|
||||||
this: DatasetComplianceRollupRow
|
this: DatasetComplianceRollupRow
|
||||||
): Array<string> {
|
): Array<IComplianceEntity['identifierType']> {
|
||||||
const { fieldChangeSet, suggestion } = getProperties(this, ['fieldChangeSet', 'suggestion']);
|
const { taggedIdentifiers, suggestion } = getProperties(this, ['taggedIdentifiers', 'suggestion']);
|
||||||
return fieldChangeSet.mapBy('identifierType').reduce((list, identifierType) => {
|
|
||||||
if (suggestion && suggestion.identifierType === identifierType) {
|
|
||||||
return [...list, identifierType];
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
return arrayReduce(suggestedIdentifierTypesInList(suggestion), [])(taggedIdentifiers);
|
||||||
}, []);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,7 +12,8 @@ import {
|
|||||||
IIdentifierFieldWithFieldChangeSetObject,
|
IIdentifierFieldWithFieldChangeSetObject,
|
||||||
ISchemaFieldsToPolicy,
|
ISchemaFieldsToPolicy,
|
||||||
ISchemaFieldsToSuggested,
|
ISchemaFieldsToSuggested,
|
||||||
IComplianceEntityWithMetadata
|
IComplianceEntityWithMetadata,
|
||||||
|
ISuggestedFieldTypeValues
|
||||||
} from 'wherehows-web/typings/app/dataset-compliance';
|
} from 'wherehows-web/typings/app/dataset-compliance';
|
||||||
import {
|
import {
|
||||||
IColumnFieldProps,
|
IColumnFieldProps,
|
||||||
@ -162,6 +163,17 @@ const isRecentSuggestion = (
|
|||||||
(!!suggestionModificationTime &&
|
(!!suggestionModificationTime &&
|
||||||
suggestionModificationTime - parseInt(policyModificationTime) >= lastSeenSuggestionInterval);
|
suggestionModificationTime - parseInt(policyModificationTime) >= lastSeenSuggestionInterval);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Takes a suggestion and populates a list of ComplianceFieldIdValues if the suggestion matches the identifier
|
||||||
|
* @param {ISuggestedFieldTypeValues | void} suggestion
|
||||||
|
* @return {(list: Array<ComplianceFieldIdValue>, identifierType: ComplianceFieldIdValue) => Array<ComplianceFieldIdValue>}
|
||||||
|
*/
|
||||||
|
const suggestedIdentifierTypesInList = (suggestion: ISuggestedFieldTypeValues | void) => (
|
||||||
|
list: Array<IComplianceEntity['identifierType']>,
|
||||||
|
identifierType: IComplianceEntity['identifierType']
|
||||||
|
): Array<IComplianceEntity['identifierType']> =>
|
||||||
|
suggestion && suggestion.identifierType === identifierType ? [...list, identifierType] : list;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a compliance policy changeSet field requires user attention: if a suggestion
|
* Checks if a compliance policy changeSet field requires user attention: if a suggestion
|
||||||
* is available but the user has not indicated intent or a policy for the field does not currently exist remotely
|
* is available but the user has not indicated intent or a policy for the field does not currently exist remotely
|
||||||
@ -494,6 +506,7 @@ const sortFoldedChangeSetTuples = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
suggestedIdentifierTypesInList,
|
||||||
compliancePolicyStrings,
|
compliancePolicyStrings,
|
||||||
getFieldIdentifierOption,
|
getFieldIdentifierOption,
|
||||||
getFieldIdentifierOptions,
|
getFieldIdentifierOptions,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
suggestion=suggestion
|
suggestion=suggestion
|
||||||
isReadonly=isReadonlyField
|
isReadonly=isReadonlyField
|
||||||
hasSingleTag=hasSingleTag
|
hasSingleTag=hasSingleTag
|
||||||
|
taggedIdentifiers=taggedIdentifiers
|
||||||
isReviewRequested=isReviewRequested
|
isReviewRequested=isReviewRequested
|
||||||
suggestionResolution=suggestionResolution
|
suggestionResolution=suggestionResolution
|
||||||
suggestionMatchesCurrentValue=suggestionMatchesCurrentValue
|
suggestionMatchesCurrentValue=suggestionMatchesCurrentValue
|
||||||
|
@ -240,6 +240,7 @@
|
|||||||
class="dataset-compliance-fields__tag-row"
|
class="dataset-compliance-fields__tag-row"
|
||||||
tag=tag
|
tag=tag
|
||||||
parentHasSingleTag=row.hasSingleTag
|
parentHasSingleTag=row.hasSingleTag
|
||||||
|
fieldIdentifiers=row.taggedIdentifiers
|
||||||
onTagIdentifierTypeChange=(action "tagIdentifierChanged")
|
onTagIdentifierTypeChange=(action "tagIdentifierChanged")
|
||||||
onTagLogicalTypeChange=(action "tagLogicalTypeChanged")
|
onTagLogicalTypeChange=(action "tagLogicalTypeChanged")
|
||||||
onTagOwnerChange=(action "tagOwnerChanged")
|
onTagOwnerChange=(action "tagOwnerChanged")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user