Browse Source

UI fixes (#1152)

* Fixes

* Show zero properly.

* Fix reference editor.
pull/1153/head
Sebastian Stehle 2 years ago
committed by GitHub
parent
commit
eca4f5e8c0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      frontend/src/app/features/content/shared/preview-button.component.ts
  2. 2
      frontend/src/app/features/content/shared/references/references-editor.component.html
  3. 17
      frontend/src/app/shared/state/contents.forms.spec.ts
  4. 3
      frontend/src/app/shared/state/contents.forms.visitors.ts

1
frontend/src/app/features/content/shared/preview-button.component.ts

@ -96,7 +96,6 @@ export class PreviewButtonComponent extends StatefulComponent<State> implements
const state = { ...s };
const keys = Object.keys(this.schema.previewUrls);
state.previewNameSelected = selectedName;
state.previewNamesMore = keys.removed(selectedName).sorted();

2
frontend/src/app/features/content/shared/references/references-editor.component.html

@ -5,7 +5,7 @@
</button>
</div>
<div class="col" [class.disabled]="snapshot.isDisabled">
<button class="btn btn-outline-secondary btn-dashed btn-block" (click)="contentSelectorDialog.show()">
<button class="btn btn-outline-secondary btn-dashed btn-block" (click)="contentSelectorDialog.show()" type="button">
{{ "contents.referencesSelectExisting" | sqxTranslate }}
</button>
</div>

17
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: {

3
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 };
}

Loading…
Cancel
Save