Preferences: Get preferences mostly displaying again

There's still something wrong validation.
This commit is contained in:
nathan 2022-07-13 10:52:11 -06:00
parent 2c08542529
commit f8f7d1621e
4 changed files with 46 additions and 32 deletions

View File

@ -40,6 +40,11 @@ export function et2_compileLegacyJS(_code, _widget, _context)
{ {
_code = mgr.expandName(_code); _code = mgr.expandName(_code);
} }
// If replacement cleared the code, skip the rest
if(!_code)
{
return false;
}
} }
// Context is the context in which the function will run. Set context to // Context is the context in which the function will run. Set context to

View File

@ -299,13 +299,13 @@ class preferences_hooks
'default'=> $lang, 'default'=> $lang,
), ),
'country' => array( 'country' => array(
'type' => 'select-country', 'type' => 'et2-select-country',
'label' => 'Country', 'label' => 'Country',
'name' => 'country', 'name' => 'country',
'help' => 'In which country are you. This is used to set certain defaults for you.', 'help' => 'In which country are you. This is used to set certain defaults for you.',
'xmlrpc' => True, 'xmlrpc' => True,
'admin' => False, 'admin' => False,
'values' => array(''), 'values' => array(),
'default' => strtoupper($country), 'default' => strtoupper($country),
'attributes' => array( 'attributes' => array(
'tags' => true 'tags' => true

View File

@ -431,9 +431,8 @@ class preferences_settings
$setting['run_lang'] = false; // already done now $setting['run_lang'] = false; // already done now
// handle as textarea // handle as textarea
case 'textarea': case 'textarea':
$setting['type'] = is_a($tpl, 'etemplate') ? 'textarea' : 'textbox'; $setting['type'] = is_a($tpl, 'etemplate') ? 'textarea' : 'et2-textbox';
$tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiline', 'true'); $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiline', 'true');
$tpl->setElementAttribute($tab. '[' . $setting['name'] . ']','width', '99%' );
// anyway setting via css: width: 99%, height: 5em // anyway setting via css: width: 99%, height: 5em
// for old eT use size attribute // for old eT use size attribute
if(is_a($tpl, 'etemplate') && (!empty($setting['cols']) || !empty($setting['rows']))) if(is_a($tpl, 'etemplate') && (!empty($setting['cols']) || !empty($setting['rows'])))
@ -446,33 +445,41 @@ class preferences_settings
case 'vfs_dir': case 'vfs_dir':
case 'vfs_dirs': case 'vfs_dirs':
case 'input': case 'input':
$setting['type'] = 'textbox'; $setting['type'] = 'et2-textbox';
break; break;
case 'check': case 'check':
$setting['type'] = 'select'; $setting['type'] = 'et2-select';
$setting['values'] = array('1' => lang('yes'), '0' => lang('no')); $setting['values'] = array('1' => lang('yes'), '0' => lang('no'));
break; break;
case 'select':
$setting['type'] = 'et2-select';
break;
case 'multiselect': case 'multiselect':
$setting['type'] = 'select'; $setting['type'] = 'et2-select';
$tpl->setElementAttribute($tab.'['.$setting['name'].']', 'rows', 5); $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiple', true);
if (!isset($setting['size'])) $setting['size'] = '5'; // old eT
break; break;
case 'color': case 'color':
$setting['type'] = 'colorpicker'; $setting['type'] = 'et2-colorpicker';
break; break;
case 'date-duration': case 'date-duration':
if (!isset($setting['size'])) $setting['size'] = 'm,dhm,24,1'; if(!isset($setting['size']))
{
$setting['size'] = 'm,dhm,24,1';
}
$attrs = explode(',', $setting['size']); $attrs = explode(',', $setting['size']);
foreach(array("data_format","display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name) foreach(array("data_format","display_format", "hours_per_day", "empty_not_0", "short_labels") as $n => $name)
{ {
if ((string)$attrs[$n] !== '') $tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]); if ((string)$attrs[$n] !== '') $tpl->setElementAttribute($tab.'['.$setting['name'].']', $name, $attrs[$n]);
} }
$setting['type'] = 'et2-date-duration';
break; break;
case 'taglist': case 'taglist':
if($setting['no_sel_options']) if($setting['no_sel_options'])
{ {
$tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'autocomplete_url', ''); $tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'autocomplete_url', '');
} }
$setting['type'] = 'et2-select';
$tpl->setElementAttribute($tab . '[' . $setting['name'] . ']', 'multiple', true);
break; break;
} }
// move values/options to sel_options array // move values/options to sel_options array
@ -522,9 +529,10 @@ class preferences_settings
'label' => preg_replace('|<br[ /]*>|i', "\n", $setting['label']), 'label' => preg_replace('|<br[ /]*>|i', "\n", $setting['label']),
'help' => lang($setting['help']), // is html 'help' => lang($setting['help']), // is html
'default' => (string)$default !== '' ? lang('Default') . ': ' . $default : null, 'default' => (string)$default !== '' ? lang('Default') . ': ' . $default : null,
'onchange' => $setting['onchange'], 'onchange' => $setting['onchange']
'attributes' => $setting['attributes']
); );
// 'attributes' => $setting['attributes']
//error_log("appname=$appname, attribute=$attribute, setting=".array2string($setting)); //error_log("appname=$appname, attribute=$attribute, setting=".array2string($setting));
$content[$tab][$setting['name']] = $GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']]; $content[$tab][$setting['name']] = $GLOBALS['egw']->preferences->{$attribute}[$appname][$setting['name']];
//if ($old_type == 'multiselect') $content[$tab][$setting['name']] = explode(',', $content[$tab][$setting['name']]); //if ($old_type == 'multiselect') $content[$tab][$setting['name']] = explode(',', $content[$tab][$setting['name']]);

View File

@ -16,7 +16,8 @@
<description id="${row}[default]" no_lang="1" class="prefDefault"/> <description id="${row}[default]" no_lang="1" class="prefDefault"/>
</vbox> </vbox>
<box class="prefValueColumn"> <box class="prefValueColumn">
<widget type="@${row}[type]" id="@${row}[name]" onchange="@${row}[onchange]" no_lang="1" class="prefValue" attributes="@${row}[attributes]"/> <widget type="@${row}[type]" id="@${row}[name]" onchange="@${row}[onchange]" no_lang="1"
class="prefValue"/>
</box> </box>
<box class="prefHelpColumn"> <box class="prefHelpColumn">
<html id="${row}[help]" class="prefHelp"/> <html id="${row}[help]" class="prefHelp"/>