From eca4f5e8c0018c473c2cdd309cb3db0943a99433 Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Fri, 20 Dec 2024 22:23:22 +0100 Subject: [PATCH] UI fixes (#1152) * Fixes * Show zero properly. * Fix reference editor. --- .../content/shared/preview-button.component.ts | 1 - .../references/references-editor.component.html | 2 +- .../src/app/shared/state/contents.forms.spec.ts | 17 +++++++++++++++++ .../app/shared/state/contents.forms.visitors.ts | 3 +-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/features/content/shared/preview-button.component.ts b/frontend/src/app/features/content/shared/preview-button.component.ts index 23ce3db0b..a54c32b22 100644 --- a/frontend/src/app/features/content/shared/preview-button.component.ts +++ b/frontend/src/app/features/content/shared/preview-button.component.ts @@ -96,7 +96,6 @@ export class PreviewButtonComponent extends StatefulComponent implements const state = { ...s }; const keys = Object.keys(this.schema.previewUrls); - state.previewNameSelected = selectedName; state.previewNamesMore = keys.removed(selectedName).sorted(); diff --git a/frontend/src/app/features/content/shared/references/references-editor.component.html b/frontend/src/app/features/content/shared/references/references-editor.component.html index fc72df346..88af66e23 100644 --- a/frontend/src/app/features/content/shared/references/references-editor.component.html +++ b/frontend/src/app/features/content/shared/references/references-editor.component.html @@ -5,7 +5,7 @@
-
diff --git a/frontend/src/app/shared/state/contents.forms.spec.ts b/frontend/src/app/shared/state/contents.forms.spec.ts index 3cd202001..c5492b01f 100644 --- a/frontend/src/app/shared/state/contents.forms.spec.ts +++ b/frontend/src/app/shared/state/contents.forms.spec.ts @@ -397,6 +397,23 @@ describe('GetContentValue', () => { }); }); + it('should resolve value from invariant field as zero', () => { + const content: any = { + data: { + field1: { + iv: 0, + }, + }, + }; + + const result = getContentValue(content, language, fieldInvariant); + + expect(result).toEqual({ + value: 0, + formatted: '0', + }); + }); + it('should resolve value from localized field', () => { const content: any = { data: { diff --git a/frontend/src/app/shared/state/contents.forms.visitors.ts b/frontend/src/app/shared/state/contents.forms.visitors.ts index 90652964e..2cdd83c68 100644 --- a/frontend/src/app/shared/state/contents.forms.visitors.ts +++ b/frontend/src/app/shared/state/contents.forms.visitors.ts @@ -48,12 +48,11 @@ export function getContentValue(content: ContentDto, language: LanguageDto, fiel const actualReference = getValue(content.referenceData, language, field, true); const actualValue = getValue(content.data, language, field); - if (!actualReference && !actualValue) { + if (Types.isUndefined(actualReference) && Types.isUndefined(actualValue)) { return { value: actualValue, formatted: '' }; } const formatted = FieldFormatter.format(field, actualValue, actualReference, allowHtml); - return { value: actualValue, formatted }; }