Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI fixes #1152

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/app/shared/state/contents.forms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/shared/state/contents.forms.visitors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down
Loading