+ [ngClass]="{'bg-diff': isDifferent(attr.key, property.value || [])}">
{{ attr.label }}
{
expect(app).toBeTruthy();
}));
+ describe('isDifferent method', () => {
+ it('should return true if the value is different between any of the lists', () => {
+ expect(app.isDifferent('foo', [['foo', 'bar', 'baz'], ['bar', 'baz']])).toBe(true);
+ expect(app.isDifferent('bar', [['bar'], null])).toBe(true);
+ });
+
+ it('should return false if the list of values is the same', () => {
+ expect(app.isDifferent('foo', [['foo', 'baz'], ['foo', 'bar']])).toBe(false);
+ });
+ });
+
describe('attributeList$ getter', () => {
it('should return an empty list when no data or dataUrl is set', () => {
app.attributeList$.subscribe((list) => {
diff --git a/ui/src/app/metadata/configuration/component/property/array-property.component.ts b/ui/src/app/metadata/configuration/component/property/array-property.component.ts
index f166aa155..7a042fa46 100644
--- a/ui/src/app/metadata/configuration/component/property/array-property.component.ts
+++ b/ui/src/app/metadata/configuration/component/property/array-property.component.ts
@@ -33,8 +33,7 @@ export class ArrayPropertyComponent extends ConfigurationPropertyComponent imple
return UriValidator.isUri(str);
}
- isDifferent(key: string): boolean {
- const model = this.property.value || [];
+ isDifferent(key: string, model: any): boolean {
return model
.map((value) => value ? value.indexOf(key) > -1 : false)
.reduce((current, val) => current !== val ? true : false, false);