adds explicit flags on compliance component for compliance policy and dataset classification edit modes. adds reset edit mode function to reset the aforementioned flags to initial state of false. renames isShowingAllMemberData to shouldShowAllMemberData. hides seeMore/Less button in edit mode. adds derived indicator value for datasets marked as excluding member data

This commit is contained in:
Seyi Adebajo 2017-10-11 00:16:41 -07:00
parent 53599e1f50
commit 1f3fb8b30f
2 changed files with 42 additions and 17 deletions

View File

@ -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 }) => ({

View File

@ -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"}}
<span class="dataset-tag-container">
@ -108,22 +108,26 @@
{{/each}}
{{/table.body}}
{{#table.foot}}
<td colspan="2" class="text-center">
<button
{{action "onShowAllDatasetMemberData"}}
class="nacho-button--large nacho-button--tertiary">
{{#if isShowingAllMemberData}}
{{#if (and excludesSomeMemberData (not isEditing))}}
See Less <span class="fa fa-caret-up" aria-label="See Less Dataset Member Data"></span>
{{#table.foot}}
<td colspan="2" class="text-center">
<button
{{action "onShowAllDatasetMemberData"}}
class="nacho-button--large nacho-button--tertiary">
{{#if shouldShowAllMemberData}}
{{else}}
See Less <span class="fa fa-caret-up" aria-label="See Less Dataset Member Data"></span>
See More <span class="fa fa-caret-down" aria-label="See More Dataset Member Data"></span>
{{else}}
{{/if}}
</button>
</td>
{{/table.foot}}
See More <span class="fa fa-caret-down" aria-label="See More Dataset Member Data"></span>
{{/if}}
</button>
</td>
{{/table.foot}}
{{/if}}
{{/dataset-table}}