modmore / ClientConfig

ClientConfig is a MODX Revolution Extra to allow clients to maintain settings in a user friendly way.
https://docs.modmore.com/en/Open_Source/ClientConfig/index.html
MIT License
28 stars 27 forks source link

Make "Field Options" input required for type "Selectbox" #182

Open Ruslan-Aleev opened 4 years ago

Ruslan-Aleev commented 4 years ago

Summary

For settings with the "Selectbox" type, the "Field Options" field must be required, otherwise an empty list is displayed for the user. And if you set only value of the field, then the logic of the list itself is lost.

list-req

Expected behavior

"Field Options" field must be required

Environment

ClientConfig 2.3

Ruslan-Aleev commented 4 years ago

This can be solved in a crooked way, replace the name: 'options' block in the grid (https://github.com/modmore/ClientConfig/blob/master/assets/components/clientconfig/js/mgr/widgets/window.settings.js#L93) with:

{
xtype: 'textarea',
id: config.id + '-options',
name: 'options',
fieldLabel: _('clientconfig.options') + '*',
description: _('clientconfig.options.desc'),
allowBlank: (config.record && (config.record.xtype === 'modx-combo')) ? false : true,
anchor: '100%',
hidden: (config.record && (config.record.xtype === 'modx-combo')) ? false : true,
value: _('clientconfig.options_default')
}

And in the clientconfig.options_default lexicon set Yes==1||No==0. As a result, we have an example for the Selectbox for the user, which is convenient and the field is now required. However, for non-Selectbox, the options parameter is not empty.

@Mark-H What do you think, should I do PR or are these corrections not particularly useful? Or is there another solution?