diff --git a/wherehows-web/app/components/dataset-compliance.js b/wherehows-web/app/components/dataset-compliance.js index 30a9b33c48..9b5ee00518 100644 --- a/wherehows-web/app/components/dataset-compliance.js +++ b/wherehows-web/app/components/dataset-compliance.js @@ -100,6 +100,8 @@ export default Component.extend({ helpText, fieldIdentifierOptions, hiddenTrackingFields: hiddenTrackingFieldsMsg, + isEditingDatasetClassification: false, + isEditingCompliancePolicy: false, classNames: ['compliance-container'], classNameBindings: ['isEditing:compliance-container--edit-mode'], /** @@ -195,6 +197,7 @@ export default Component.extend({ didReceiveAttrs() { this._super(...Array.from(arguments)); + this.resetEdit(); // Perform validation step on the received component attributes this.validateAttrs(); }, @@ -268,6 +271,14 @@ export default Component.extend({ this.disableDomCloaking(); }, + /** + * Resets the editable state of the component, defaults to state returned in isEditing, + * currently driven by `isNewComplianceInfo` flag + */ + resetEdit() { + return setProperties(this, { isEditingCompliancePolicy: false, isEditingDatasetClassification: false }); + }, + /** * Ensure that props received from on this component * are valid, otherwise flag @@ -336,11 +347,22 @@ export default Component.extend({ .every(({ value }) => [true, false].includes(value)); }), + /** + * Checks if any of the attributes on the dataset classification is false + * @type {Ember.ComputedProperty} + * @return {boolean} + */ + excludesSomeMemberData: computed(datasetClassificationKey, function() { + const sourceDatasetClassification = get(this, datasetClassificationKey) || {}; + + return Object.values(sourceDatasetClassification).some(hasMemberData => !hasMemberData); + }), + /** * Determines if all member data fields should be shown in the member data table i.e. show only fields contained in * this dataset or otherwise */ - isShowingAllMemberData: computed.or('showAllDatasetMemberData', 'isEditing'), + shouldShowAllMemberData: computed.or('showAllDatasetMemberData', 'isEditing'), /** * Determines if the save feature is allowed for the current dataset, otherwise e.g. interface should be disabled @@ -430,8 +452,7 @@ export default Component.extend({ * @type {Ember.computed} */ columnIdFieldsToCurrentPrivacyPolicy: computed( - 'truncatedColumnFields', - `${policyComplianceEntitiesKey}.[]`, + `{truncatedColumnFields,${policyComplianceEntitiesKey}.[]}`, function() { // Truncated list of Dataset field names and data types currently returned from the column endpoint const columnFieldProps = get(this, 'truncatedColumnFields').map(({ fieldName, dataType }) => ({ diff --git a/wherehows-web/app/templates/datasets/dataset-compliance/-dataset-classification.hbs b/wherehows-web/app/templates/datasets/dataset-compliance/-dataset-classification.hbs index 86051eb310..3897a59827 100644 --- a/wherehows-web/app/templates/datasets/dataset-compliance/-dataset-classification.hbs +++ b/wherehows-web/app/templates/datasets/dataset-compliance/-dataset-classification.hbs @@ -42,7 +42,7 @@ {{/table.head}} {{#table.body as |body|}} - {{#each (if isShowingAllMemberData table.data (filter-by "value" true table.data)) as |classification|}} + {{#each (if shouldShowAllMemberData table.data (filter-by "value" true table.data)) as |classification|}} {{#body.row as |row|}} {{#row.cell class="dataset-field-content__prompt"}} @@ -108,22 +108,26 @@ {{/each}} {{/table.body}} - {{#table.foot}} -