From 66c22ccb2a9cbad8d47bb6625d22a2c1509f32c2 Mon Sep 17 00:00:00 2001 From: Tim Fischbach Date: Fri, 29 Nov 2024 10:39:52 +0100 Subject: [PATCH] Hide caption variants select if only one item Also hide separator if last child of configuration editor tab. --- app/assets/stylesheets/pageflow/ui/forms.scss | 4 +++ .../groups/CommonContentElementAttributes.js | 30 ++++++++++--------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/assets/stylesheets/pageflow/ui/forms.scss b/app/assets/stylesheets/pageflow/ui/forms.scss index b11ec8d19a..b06764b7c5 100644 --- a/app/assets/stylesheets/pageflow/ui/forms.scss +++ b/app/assets/stylesheets/pageflow/ui/forms.scss @@ -121,6 +121,10 @@ textarea.short { .separator { border-top: solid 1px var(--ui-on-surface-color-lightest); margin: space(4) 0; + + &:last-child { + display: none; + } } } diff --git a/entry_types/scrolled/package/src/editor/views/configurationEditors/groups/CommonContentElementAttributes.js b/entry_types/scrolled/package/src/editor/views/configurationEditors/groups/CommonContentElementAttributes.js index 3beaa14d22..b41c664dc1 100644 --- a/entry_types/scrolled/package/src/editor/views/configurationEditors/groups/CommonContentElementAttributes.js +++ b/entry_types/scrolled/package/src/editor/views/configurationEditors/groups/CommonContentElementAttributes.js @@ -125,19 +125,21 @@ ConfigurationEditorTabView.groups.define( name: 'figureCaption' }); - this.input('captionVariant', SelectInputView, { - attributeTranslationKeyPrefixes: [ - 'pageflow_scrolled.editor.common_content_element_attributes' - ], - includeBlank: true, - blankTranslationKey: 'pageflow_scrolled.editor.' + - 'common_content_element_attributes.' + - 'captionVariant.blank', - values: variants, - texts, - disabledBindingModel: this.model.parent.transientState, - disabledBinding: 'hasCaption', - disabled: hasCaption => disableWhenNoCaption && !hasCaption - }); + if (variants.length) { + this.input('captionVariant', SelectInputView, { + attributeTranslationKeyPrefixes: [ + 'pageflow_scrolled.editor.common_content_element_attributes' + ], + includeBlank: true, + blankTranslationKey: 'pageflow_scrolled.editor.' + + 'common_content_element_attributes.' + + 'captionVariant.blank', + values: variants, + texts, + disabledBindingModel: this.model.parent.transientState, + disabledBinding: 'hasCaption', + disabled: hasCaption => disableWhenNoCaption && !hasCaption + }); + } } );