Skip to content

Commit

Permalink
SHIBUI-1519 fixed issue with property display in filter comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathis committed Oct 8, 2019
1 parent fc2d383 commit 950ad74
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<ng-container *ngFor="let section of configuration.sections; let i = index;">
<section class="mb-4 config-section-list-item" *ngIf="section && section.properties && section.properties.length">
<div class="config-group">
<div class="numbered-header d-flex justify-content-start bg-light align-items-center">
<div class="numbered-header d-flex justify-content-start bg-light align-items-center"
ngClass="{'bg-danger': !section.differences}">
<h2 class="title h4 m-0 flex-grow-1">
<span *ngIf="numbered"
class="d-inline-block px-2 py-1 mb-0 h4 number border border-secondary bg-white rounded-lg">
Expand Down
57 changes: 41 additions & 16 deletions ui/src/app/metadata/configuration/reducer/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ import * as utils from '../../domain/utility/configuration';
import { getSplitSchema } from '../../../wizard/reducer';
import { SectionProperty } from '../model/section';

function omit(key, obj) {
if (!obj) {
return obj;
}
const { [key]: omitted, ...rest } = obj;
return rest;
}

export const rollupDifferences = (prop) => {
let updates = {
...prop
};

if (prop.properties) {
updates = {
...updates,
properties: [
...prop.properties.map(p => rollupDifferences(p))
]
};
}

prop.differences = prop.properties.some(p => p.differences);

return updates;
};

export const getConfigurationSectionsFn = (models, definition, schema): MetadataConfiguration => {
return !definition || !schema || !models ? null :
({
Expand Down Expand Up @@ -38,22 +65,20 @@ export const getConfigurationSectionsFn = (models, definition, schema): Metadata
});
};

const getDifferences = (models, prop) => {
return models.some((model, index, array) => {
if (!array) {
return false;
}
const prop1 = omit('modifiedDate', model[prop.id]);
const prop2 = omit('modifiedDate', array[0][prop.id]);
return JSON.stringify(prop1) !== JSON.stringify(prop2);
});
};

export const assignValueToProperties = (models, properties, definition: any): any[] => {
return properties.map(prop => {
const differences = models.some((model, index, array) => {
if (!array) {
return false;
}
let prop1 = model[prop.id];
let prop2 = array[0][prop.id];
if (prop1 && prop1.modifiedDate) {
let { checkedModifiedDate, checkedProp } = prop1;
let { firstModifiedDate, firstProp } = prop2;
prop1 = checkedProp;
prop2 = firstProp;
}
return JSON.stringify(prop1) !== JSON.stringify(prop2);
});
const differences = getDifferences(models, prop);

const widget = prop.type === 'array' && prop.widget && prop.widget.data ? ({
...prop.widget,
Expand All @@ -72,12 +97,12 @@ export const assignValueToProperties = (models, properties, definition: any): an
case 'object':
return {
...prop,
differences,
properties: assignValueToProperties(
models.map(model => definition.formatter(model)[prop.id] || {}),
prop.properties,
definition
)
),
differences: getDifferences(models, prop)
};
default:
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const EntityAttributesFilterConfiguration: Wizard<MetadataFilter> = {
'name',
'@type',
'resourceId',
'version',
'filterEnabled',
'relyingPartyOverrides'
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const NameIDFilterConfiguration: Wizard<MetadataFilter> = {
'filterEnabled',
'@type',
'resourceId',
'version',
'removeExistingFormats',
'formats'
]
Expand Down

0 comments on commit 950ad74

Please sign in to comment.