From 834a18358c35be8645f85f7d0d5d8283165ea650 Mon Sep 17 00:00:00 2001 From: "Sebastian G. Marinescu" Date: Mon, 27 Feb 2023 10:51:22 +0100 Subject: [PATCH 1/2] Update combos.js Add new radiogroup combo --- assets/components/clientconfig/js/mgr/widgets/combos.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/assets/components/clientconfig/js/mgr/widgets/combos.js b/assets/components/clientconfig/js/mgr/widgets/combos.js index 0a49a19..629ddf6 100755 --- a/assets/components/clientconfig/js/mgr/widgets/combos.js +++ b/assets/components/clientconfig/js/mgr/widgets/combos.js @@ -43,6 +43,7 @@ ClientConfig.combo.FieldTypes = function(config) { ['numberfield', _('clientconfig.xtype.numberfield')], ['colorpickerfield', _('clientconfig.xtype.colorpalette')], ['email', _('clientconfig.xtype.email')], + ['xradiogroup', _('clientconfig.xtype.radiogroup')], ['xcheckbox', _('clientconfig.xtype.xcheckbox')], ['datefield', _('clientconfig.xtype.datefield')], ['timefield', _('clientconfig.xtype.timefield')], @@ -113,4 +114,4 @@ Ext.reg('clientconfig-combo-contexts',ClientConfig.combo.ContextList); ClientConfig.ux.Line = Ext.extend(Ext.Component, { autoEl: 'hr' }); -Ext.reg('clientconfig-line', ClientConfig.ux.Line); \ No newline at end of file +Ext.reg('clientconfig-line', ClientConfig.ux.Line); From bd22b11d523d59b682259a05c5cc3798f986c5d2 Mon Sep 17 00:00:00 2001 From: "Sebastian G. Marinescu" Date: Mon, 27 Feb 2023 11:38:13 +0100 Subject: [PATCH 2/2] Add new radio-group setting option --- .../clientconfig/js/mgr/sections/home.js | 26 +++++++++++++++++++ .../js/mgr/widgets/window.settings.js | 4 +-- .../clientconfig/controllers/home.class.php | 2 +- .../clientconfig/lexicon/en/default.inc.php | 3 +++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/assets/components/clientconfig/js/mgr/sections/home.js b/assets/components/clientconfig/js/mgr/sections/home.js index c57d801..3121741 100755 --- a/assets/components/clientconfig/js/mgr/sections/home.js +++ b/assets/components/clientconfig/js/mgr/sections/home.js @@ -130,6 +130,32 @@ Ext.extend(ClientConfig.page.Home,MODx.Component,{ field.checked = (value.value); } + if ((field.xtype === 'radiogroup') || (field.xtype === 'xradiogroup')) { + field.xtype = 'radiogroup'; + field.columns = 4; + field.items = []; + + var options = value.options.split('||'); + Ext.each(options, function(option) { + option = option.split('=='); + if (option[1]) { + field.items.push({ + boxLabel: option[0], + inputValue: option[1], + checked: option[1] === field.value ? true : false, + name: field.name + }) + } else { + field.items.push({ + boxLabel: option[0], + inputValue: option[0], + checked: option[0] === field.value ? true : false, + name: field.name + }) + } + }); + } + if (field.xtype === 'datefield') { field.format = MODx.config.manager_date_format; } diff --git a/assets/components/clientconfig/js/mgr/widgets/window.settings.js b/assets/components/clientconfig/js/mgr/widgets/window.settings.js index 48f4f7b..89a2405 100755 --- a/assets/components/clientconfig/js/mgr/widgets/window.settings.js +++ b/assets/components/clientconfig/js/mgr/widgets/window.settings.js @@ -71,7 +71,7 @@ ClientConfig.window.Setting = function(config) { anchor: '100%', listeners: { select: {fn: function(field, record) { - if (record.data.xtype === 'modx-combo') { + if (['modx-combo', 'radiogroup', 'xradiogroup'].indexOf(record.data.xtype) !== -1) { Ext.getCmp(config.id + '-options').show(); Ext.getCmp(config.id + '-process_options').show(); } else { @@ -97,7 +97,7 @@ ClientConfig.window.Setting = function(config) { fieldLabel: _('clientconfig.options'), description: _('clientconfig.options.desc'), anchor: '100%', - hidden: (config.record && (config.record.xtype === 'modx-combo')) ? false : true + hidden: (config.record && (['modx-combo', 'radiogroup', 'xradiogroup'].indexOf(config.record.xtype) !== -1)) ? false : true },{ xtype: 'checkbox', id: config.id + '-process_options', diff --git a/core/components/clientconfig/controllers/home.class.php b/core/components/clientconfig/controllers/home.class.php index 3033e7c..bbe959d 100755 --- a/core/components/clientconfig/controllers/home.class.php +++ b/core/components/clientconfig/controllers/home.class.php @@ -42,7 +42,7 @@ public function process(array $scriptProperties = []) { $googleFontsApiKey = $this->modx->getOption('clientconfig.google_fonts_api_key', null, ''); $sa['xtype'] = empty($googleFontsApiKey) ? 'textfield' : $sa['xtype']; } - elseif ($sa['xtype'] === 'modx-combo' && $setting->get('process_options')) { + elseif ($setting->get('process_options') && in_array($sa['xtype'], ['modx-combo', 'radiogroup', 'xradiogroup'], true)) { $inputOpts = $setting->get('options'); $this->modx->getParser(); $this->modx->parser->processElementTags('', $inputOpts, true, true); diff --git a/core/components/clientconfig/lexicon/en/default.inc.php b/core/components/clientconfig/lexicon/en/default.inc.php index d253686..f6f2828 100755 --- a/core/components/clientconfig/lexicon/en/default.inc.php +++ b/core/components/clientconfig/lexicon/en/default.inc.php @@ -113,3 +113,6 @@ $_lang['clientconfig.xtype.line'] = 'Line (divider)'; $_lang['clientconfig.xtype.code'] = 'Code (requires Ace editor installed)'; $_lang['clientconfig.xtype.email'] = 'Email'; + +// New 2023-02-26 +$_lang['clientconfig.xtype.radiogroup'] = 'Radio Group';