Skip to content

Commit

Permalink
Add new radio-group setting option
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-marinescu committed Feb 27, 2023
1 parent 834a183 commit bd22b11
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
26 changes: 26 additions & 0 deletions assets/components/clientconfig/js/mgr/sections/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion core/components/clientconfig/controllers/home.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions core/components/clientconfig/lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit bd22b11

Please sign in to comment.