diff --git a/_build/templates/default/sass/_forms.scss b/_build/templates/default/sass/_forms.scss index 1a0a0dbce5..65e857bd9a 100644 --- a/_build/templates/default/sass/_forms.scss +++ b/_build/templates/default/sass/_forms.scss @@ -381,7 +381,54 @@ input::-moz-focus-inner { } .x-form-field-wrap { - width: auto !important; /* make sure the wrap is always full width of parent, fixes some custom TVs */ + /* make sure the wrap is always full width of parent, fixes some custom TVs */ + width: auto !important; + } + } + + .x-form-check-group, + .x-form-radio-group { + .x-column-inner { + width: unset !important; + display: flex; + flex-wrap: wrap; + text-wrap: nowrap; + gap: 0 2rem; + .x-column { + float: unset; + width: unset !important; + margin: 0 !important; + } + } + } + + .wrap-columns { + .x-form-check-group, + .x-form-radio-group { + .x-column-inner { + text-wrap: balance; + .x-form-check-wrap { + width: unset !important; + } + .x-form-cb-label { + line-height: 1.2 !important; + } + } + } + &.column-width-narrow { + .x-column { + width: 80px !important; + } + } + &.column-width-medium { + .x-column { + width: 160px !important; + } + } + &.column-width-wide { + .x-column { + width: 240px !important; + } } } diff --git a/core/lexicon/en/tv_widget.inc.php b/core/lexicon/en/tv_widget.inc.php index ca16427662..69499940fb 100644 --- a/core/lexicon/en/tv_widget.inc.php +++ b/core/lexicon/en/tv_widget.inc.php @@ -17,10 +17,16 @@ $_lang['attr_target_desc'] = 'Indicates in which window/tab or frame the linked url should open. To target a specific frame, enter its name in place of one of the provided options.'; $_lang['capitalize'] = 'Capitalize'; $_lang['checkbox'] = 'Check Box'; +$_lang['checkbox_column_direction'] = 'Column Direction'; +$_lang['checkbox_column_direction_desc'] = 'Specifies whether checkbox options are arranged vertically (top to bottom) or horizontally (left to right). (Default: “Vertical”)'; +$_lang['checkbox_column_width'] = 'Column Width'; +$_lang['checkbox_column_width_desc'] = 'When Wrap Column Text is set to “Yes,” this sets a predefined width for this TV’s columns. (Default: “Medium”)'; $_lang['checkbox_columns'] = 'Columns'; $_lang['checkbox_columns_desc'] = 'The number of columns the checkboxes are displayed in.'; $_lang['checkbox_display_switch'] = 'Display as Switch'; $_lang['checkbox_display_switch_desc'] = 'When set to “Yes,” this TV’s inputs will be rendered in the Resource editing form as switches (toggles) instead of checked boxes. (Default: “No”)'; +$_lang['checkbox_wrap_column_text'] = 'Wrap Column Text'; +$_lang['checkbox_wrap_column_text_desc'] = 'When checkbox labels contain longer text, set to “Yes“ to show text on multiple lines. (Default: “No”)'; $_lang['class'] = 'Class'; $_lang['classes'] = 'Class(es)'; $_lang['combo_allowaddnewdata'] = 'Allow Add New Items'; @@ -142,8 +148,14 @@ $_lang['number_minvalue'] = 'Min Value'; $_lang['option'] = 'Radio Options'; $_lang['parent_resources'] = 'Parent Resources'; +$_lang['radio_column_direction'] = $_lang['checkbox_column_direction']; +$_lang['radio_column_direction_desc'] = 'Specifies whether radio button options are arranged vertically (top to bottom) or horizontally (left to right). (Default: “Vertical”)'; +$_lang['radio_column_width'] = $_lang['checkbox_column_width']; +$_lang['radio_column_width_desc'] = $_lang['checkbox_column_width_desc']; $_lang['radio_columns'] = 'Columns'; $_lang['radio_columns_desc'] = 'The number of columns the radio buttons are displayed in.'; +$_lang['radio_wrap_column_text'] = $_lang['checkbox_wrap_column_text']; +$_lang['radio_wrap_column_text_desc'] = 'When radio button labels contain longer text, set to “Yes“ to show text on multiple lines. (Default: “No”)'; $_lang['rawtext'] = 'Raw Text (deprecated)'; $_lang['rawtextarea'] = 'Raw Textarea (deprecated)'; $_lang['required'] = 'Allow Blank'; diff --git a/core/src/Revolution/Processors/Element/TemplateVar/Configs/mgr/inputproperties/checkbox.php b/core/src/Revolution/Processors/Element/TemplateVar/Configs/mgr/inputproperties/checkbox.php index 23a76cd342..cfb3e7f34a 100644 --- a/core/src/Revolution/Processors/Element/TemplateVar/Configs/mgr/inputproperties/checkbox.php +++ b/core/src/Revolution/Processors/Element/TemplateVar/Configs/mgr/inputproperties/checkbox.php @@ -16,12 +16,18 @@ # Set values $columns = !empty($params['columns']) ? $params['columns'] : 1 ; $displayAsSwitch = $params['displayAsSwitch'] === 'true' || $params['displayAsSwitch'] == 1 ? 'true' : 'false' ; +$columnDirection = !empty($params['columnDirection']) ? $params['columnDirection'] : 'vertical' ; +$columnWidth = !empty($params['columnWidth']) ? $params['columnWidth'] : 'medium' ; +$wrapColumnText = $params['wrapColumnText'] === 'true' || $params['wrapColumnText'] == 1 ? 'true' : 'false' ; # Set help descriptions $descKeys = [ 'required_desc', 'checkbox_columns_desc', - 'checkbox_display_switch_desc' + 'checkbox_display_switch_desc', + 'checkbox_column_direction_desc', + 'checkbox_wrap_column_text_desc', + 'checkbox_column_width_desc' ]; $this->setHelpContent($descKeys, $expandHelp); @@ -37,7 +43,7 @@ }, items: [ { - columnWidth: 0.34, + columnWidth: 0.33, defaults: { anchor: '100%', msgTarget: 'under' @@ -79,7 +85,7 @@ }] }, { - columnWidth: 0.33, + columnWidth: 0.34, defaults: { anchor: '100%', msgTarget: 'under' @@ -101,6 +107,111 @@ }] } ] + }, + { + defaults: { + xtype: 'panel', + layout: 'form', + labelAlign: 'top', + autoHeight: true, + labelSeparator: '' + }, + items: [ + { + columnWidth: .33, + defaults: { + anchor: '100%', + msgTarget: 'under' + }, + items: [{ + xtype: 'combo', + fieldLabel: _('checkbox_column_direction'), + description: {$this->helpContent['eh_checkbox_column_direction_desc']}, + name: 'inopt_columnDirection', + hiddenName: 'inopt_columnDirection', + id: 'inopt_columnDirection{$tvId}', + mode: 'local', + store: new Ext.data.ArrayStore({ + fields: [ + 'value', + 'label' + ], + data: [ + ['vertical', 'Vertical'], + ['horizontal', 'Horizontal'] + ] + }), + valueField: 'value', + displayField: 'label', + triggerAction: 'all', + editable: false, + value: '{$columnDirection}' + },{ + xtype: '{$helpXtype}', + forId: 'inopt_columnDirection{$tvId}', + html: {$this->helpContent['checkbox_column_direction_desc']}, + cls: 'desc-under' + }] + }, + { + columnWidth: 0.33, + defaults: { + anchor: '100%', + msgTarget: 'under' + }, + items: [{ + xtype: 'combo', + fieldLabel: _('checkbox_column_width'), + description: {$this->helpContent['eh_checkbox_column_width_desc']}, + name: 'inopt_columnWidth', + hiddenName: 'inopt_columnWidth', + id: 'inopt_columnWidth{$tvId}', + mode: 'local', + store: new Ext.data.ArrayStore({ + fields: [ + 'value', + 'label' + ], + data: [ + ['narrow', 'Narrow'], + ['medium', 'Medium'], + ['wide', 'Wide'] + ] + }), + valueField: 'value', + displayField: 'label', + triggerAction: 'all', + editable: false, + value: '{$columnWidth}' + },{ + xtype: '{$helpXtype}', + forId: 'inopt_columnWidth{$tvId}', + html: {$this->helpContent['checkbox_column_width_desc']}, + cls: 'desc-under' + }] + }, + { + columnWidth: 0.34, + defaults: { + anchor: '100%', + msgTarget: 'under' + }, + items: [{ + xtype: 'combo-boolean', + fieldLabel: _('checkbox_wrap_column_text'), + description: {$this->helpContent['eh_checkbox_wrap_column_text_desc']}, + name: 'inopt_wrapColumnText', + hiddenName: 'inopt_wrapColumnText', + id: 'inopt_wrapColumnText{$tvId}', + value: {$wrapColumnText} + },{ + xtype: '{$helpXtype}', + forId: 'inopt_wrapColumnText{$tvId}', + html: {$this->helpContent['checkbox_wrap_column_text_desc']}, + cls: 'desc-under' + }] + } + ] } ] OPTSJS; diff --git a/core/src/Revolution/Processors/Element/TemplateVar/Configs/mgr/inputproperties/radio.php b/core/src/Revolution/Processors/Element/TemplateVar/Configs/mgr/inputproperties/radio.php index 86bacba022..36955daa2c 100644 --- a/core/src/Revolution/Processors/Element/TemplateVar/Configs/mgr/inputproperties/radio.php +++ b/core/src/Revolution/Processors/Element/TemplateVar/Configs/mgr/inputproperties/radio.php @@ -15,11 +15,17 @@ # Set values $columns = !empty($params['columns']) ? $params['columns'] : 1 ; +$columnDirection = !empty($params['columnDirection']) ? $params['columnDirection'] : 'vertical' ; +$columnWidth = !empty($params['columnWidth']) ? $params['columnWidth'] : 'medium' ; +$wrapColumnText = $params['wrapColumnText'] === 'true' || $params['wrapColumnText'] == 1 ? 'true' : 'false' ; # Set help descriptions $descKeys = [ 'required_desc', - 'radio_columns_desc' + 'radio_columns_desc', + 'radio_column_direction_desc', + 'radio_wrap_column_text_desc', + 'radio_column_width_desc' ]; $this->setHelpContent($descKeys, $expandHelp); @@ -27,15 +33,15 @@ [ { defaults: { + xtype: 'panel', layout: 'form', + labelAlign: 'top', + autoHeight: true, labelSeparator: '' }, items: [ { - xtype: 'panel', - columnWidth: 1, - autoHeight: true, - labelAlign: 'top', + columnWidth: .33, defaults: { anchor: '100%', msgTarget: 'under' @@ -53,9 +59,17 @@ forId: 'inopt_allowBlank{$tvId}', html: {$this->helpContent['required_desc']}, cls: 'desc-under' - },{ + }] + }, + { + columnWidth: .33, + defaults: { + anchor: '100%', + msgTarget: 'under' + }, + items: [{ xtype: 'numberfield', - fieldLabel: _('checkbox_columns'), + fieldLabel: _('radio_columns'), description: {$this->helpContent['eh_radio_columns_desc']}, name: 'inopt_columns', id: 'inopt_columns{$tvId}', @@ -68,6 +82,111 @@ html: {$this->helpContent['radio_columns_desc']}, cls: 'desc-under' }] + }, + { + columnWidth: .34, + defaults: { + anchor: '100%', + msgTarget: 'under' + }, + items: [{ + xtype: 'combo', + fieldLabel: _('radio_column_direction'), + description: {$this->helpContent['eh_radio_column_direction_desc']}, + name: 'inopt_columnDirection', + hiddenName: 'inopt_columnDirection', + id: 'inopt_columnDirection{$tvId}', + mode: 'local', + store: new Ext.data.ArrayStore({ + fields: [ + 'value', + 'label' + ], + data: [ + ['vertical', 'Vertical'], + ['horizontal', 'Horizontal'] + ] + }), + valueField: 'value', + displayField: 'label', + triggerAction: 'all', + editable: false, + value: '{$columnDirection}' + },{ + xtype: '{$helpXtype}', + forId: 'inopt_columnDirection{$tvId}', + html: {$this->helpContent['radio_column_direction_desc']}, + cls: 'desc-under' + }] + } + ] + }, + { + defaults: { + xtype: 'panel', + layout: 'form', + labelAlign: 'top', + autoHeight: true, + labelSeparator: '' + }, + items: [ + { + columnWidth: .33, + defaults: { + anchor: '100%', + msgTarget: 'under' + }, + items: [{ + xtype: 'combo', + fieldLabel: _('radio_column_width'), + description: {$this->helpContent['eh_radio_column_width_desc']}, + name: 'inopt_columnWidth', + hiddenName: 'inopt_columnWidth', + id: 'inopt_columnWidth{$tvId}', + mode: 'local', + store: new Ext.data.ArrayStore({ + fields: [ + 'value', + 'label' + ], + data: [ + ['narrow', 'Narrow'], + ['medium', 'Medium'], + ['wide', 'Wide'] + ] + }), + valueField: 'value', + displayField: 'label', + triggerAction: 'all', + editable: false, + value: '{$columnWidth}' + },{ + xtype: '{$helpXtype}', + forId: 'inopt_columnWidth{$tvId}', + html: {$this->helpContent['radio_column_width_desc']}, + cls: 'desc-under' + }] + }, + { + columnWidth: .33, + defaults: { + anchor: '100%', + msgTarget: 'under' + }, + items: [{ + xtype: 'combo-boolean', + fieldLabel: _('radio_wrap_column_text'), + description: {$this->helpContent['eh_radio_wrap_column_text_desc']}, + name: 'inopt_wrapColumnText', + hiddenName: 'inopt_wrapColumnText', + id: 'inopt_wrapColumnText{$tvId}', + value: {$wrapColumnText} + },{ + xtype: '{$helpXtype}', + forId: 'inopt_wrapColumnText{$tvId}', + html: {$this->helpContent['radio_wrap_column_text_desc']}, + cls: 'desc-under' + }] } ] } diff --git a/manager/templates/default/element/tv/renders/input/checkbox.tpl b/manager/templates/default/element/tv/renders/input/checkbox.tpl index 7f89ce6c74..f5a57fe847 100644 --- a/manager/templates/default/element/tv/renders/input/checkbox.tpl +++ b/manager/templates/default/element/tv/renders/input/checkbox.tpl @@ -9,11 +9,11 @@ Ext.onReady(function() { xtype: 'checkboxgroup', id: 'tv{$tv->id}', itemId: 'tv{$tv->id}', - vertical: true, + {if $params.columnDirection == 'vertical' || $params.columnDirection == null}vertical: true,{/if} columns: {if $params.columns|default}{$params.columns|default}{else}1{/if}, + {if $params.wrapColumnText == 1 || $params.wrapColumnText == 'true'}ctCls: 'wrap-columns column-width-{if $params.columnWidth}{$params.columnWidth|escape:"javascript"}{else}medium{/if}',{/if} renderTo: 'tv{$tv->id}-cb', name: 'tv-{$tv->id}', - width: '99%', allowBlank: {if $params.allowBlank == 1 || $params.allowBlank == 'true'}true{else}false{/if}, hideMode: 'offsets', msgTarget: 'under', diff --git a/manager/templates/default/element/tv/renders/input/radio.tpl b/manager/templates/default/element/tv/renders/input/radio.tpl index 14784b9ba4..1b81c255b4 100644 --- a/manager/templates/default/element/tv/renders/input/radio.tpl +++ b/manager/templates/default/element/tv/renders/input/radio.tpl @@ -6,26 +6,26 @@ Ext.onReady(function() { const fld = MODx.load({ {/literal} - xtype: 'radiogroup' - ,id: 'tv{$tv->id}' - ,itemId: 'tv{$tv->id}' - ,vertical: true - ,columns: {if $params.columns|default}{$params.columns|default}{else}1{/if} - ,renderTo: 'tv{$tv->id}-cb' - ,width: '99%' - ,allowBlank: {if $params.allowBlank == 1 || $params.allowBlank == 'true'}true{else}false{/if} - ,hideMode: 'offsets' - ,msgTarget: 'under' - ,items: [{foreach from=$opts item=item key=k name=cbs} + xtype: 'radiogroup', + id: 'tv{$tv->id}', + itemId: 'tv{$tv->id}', + {if $params.columnDirection == 'vertical' || $params.columnDirection == null}vertical: true,{/if} + columns: {if $params.columns|default}{$params.columns|default}{else}1{/if}, + {if $params.wrapColumnText == 1 || $params.wrapColumnText == 'true'}ctCls: 'wrap-columns column-width-{if $params.columnWidth}{$params.columnWidth|escape:"javascript"}{else}medium{/if}',{/if} + renderTo: 'tv{$tv->id}-cb', + allowBlank: {if $params.allowBlank == 1 || $params.allowBlank == 'true'}true{else}false{/if}, + hideMode: 'offsets', + msgTarget: 'under', + items: [{foreach from=$opts item=item key=k name=cbs} {literal}{{/literal} - name: 'tv{$tv->id}' - ,id: 'tv{$tv->id}-{$k}' - ,boxLabel: '{$item.text|escape:"javascript"}' - ,checked: {if $item.checked}true{else}false{/if} - ,inputValue: {$item.value} - ,value: {$item.value} + name: 'tv{$tv->id}', + id: 'tv{$tv->id}-{$k}', + boxLabel: '{$item.text|escape:"javascript"}', + checked: {if $item.checked}true{else}false{/if}, + inputValue: {$item.value}, + value: {$item.value}, {literal} - ,listeners: { + listeners: { check: MODx.fireResourceFormChange } {/literal}