WIP allow to place custom-fields in tabs: add noVfsSelect option to filemanager custom-field and some docu tooltip for filemanager options

This commit is contained in:
ralf 2024-03-27 17:44:57 +02:00
parent 254fdc0fa3
commit a63aaad8e9
4 changed files with 37 additions and 30 deletions

View File

@ -89,7 +89,8 @@ class admin_customfields
'radio' => 'each value is a line like id[=label], or use @path to read options from a file in EGroupware directory',
'button' => 'each value is a line like label=[javascript]',
'password' => 'set length=# for minimum password length, strength=# for password strength',
'serial' => 'you can set an initial value, which gets incremented every time a new serial get generated'
'serial' => 'you can set an initial value, which gets incremented every time a new serial get generated',
'filemanager' => "use the following options:\nnoVfsSelect=1\nmime=application/pdf or /^image\//i\naccept=pdf,docx\nmax_upload_size=2M",
);
/**
@ -126,6 +127,10 @@ class admin_customfields
$this->content_types = Api\Config::get_content_types($this->appname);
}
$this->so = new Api\Storage\Base('api','egw_customfields',null,'',true);
// Make sure app css & lang get loaded, extending app might cause et2 to miss it
Framework::includeCSS('admin','app');
Api\Translation::add_app('admin');
}
/**
@ -280,10 +285,6 @@ class admin_customfields
$readonlys = null;
static::app_index($content, $sel_options, $readonlys, $preserve);
// Make sure app css & lang get loaded, extending app might cause et2 to miss it
Framework::includeCSS('admin','app');
Api\Translation::add_app('admin');
// Set app to admin to make sure actions are correctly loaded into admin
$GLOBALS['egw_info']['flags']['currentapp'] = 'admin';
$GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps'][$this->appname]['title'].' - '.lang('Custom fields');
@ -384,7 +385,7 @@ class admin_customfields
{
$values['@'] = substr($content['cf_values'], $content['cf_values'][1] === '=' ? 2:1);
}
elseif (isset($GLOBALS['egw_info']['apps'][$content['cf_type']]))
elseif (isset($GLOBALS['egw_info']['apps'][$content['cf_type']]) && $content['cf_type'] !== 'filemanager')
{
if (!empty($content['cf_values']) && ($content['cf_values'][0] !== '{' || ($values=json_decode($content['cf_values'])) === null))
{
@ -478,7 +479,7 @@ class admin_customfields
{
$readonlys['cf_values'] = true; // only allow to set start-value, but not change it after
}
if (!isset($GLOBALS['egw_info']['apps'][$content['cf_type']]))
if (!isset($GLOBALS['egw_info']['apps'][$content['cf_type']]) || $content['cf_type'] === 'filemanager')
{
$content['cf_values'] = json_decode($content['cf_values'], true);
}

View File

@ -990,6 +990,7 @@ use pure html compliant code (not fully working yet) admin de Vollständig HTML
use save or apply to store the received oauth token! admin de Benutze Speicher oder Übernehmen um das erhaltene OAuth-Token zu speichern!
use secure cookies (transmitted only via https) admin de Benutze sichere Cookies (werden nur per HTTPS übertragen)
use smtp auth admin de SMTP Authentifizierung benutzen
use the following options:\nnovfsselect=1\nmime=application/pdf or /^image\//i\naccept=pdf,docx\nmax_upload_size=2m admin de Benutzen Sie folgende Optionen:\nnoVfsSelect=1\nmime=application/pdf or /^image\//i\naccept=pdf,docx\nmax_upload_size=2M
use theme admin de Benutztes Farbschema
use tls authentication admin de TLS-Authentifizierung benutzen
use tls encryption admin de TLS-Verschlüsselung benutzen

View File

@ -990,6 +990,7 @@ use pure html compliant code (not fully working yet) admin en Use pure HTML comp
use save or apply to store the received oauth token! admin en Use save or apply to store the received OAuth token!
use secure cookies (transmitted only via https) admin en Use secure cookies (transmitted only via HTTPS)
use smtp auth admin en Use SMTP authentication
use the following options:\nnovfsselect=1\nmime=application/pdf or /^image\//i\naccept=pdf,docx\nmax_upload_size=2m admin en use the following options:\nnoVfsSelect=1\nmime=application/pdf or /^image\//i\naccept=pdf,docx\nmax_upload_size=2M
use theme admin en Use theme
use tls authentication admin en Use TLS authentication
use tls encryption admin en Use TLS encryption

View File

@ -926,30 +926,34 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
this.rows[attrs.id] = cf[0];
jQuery(widget.getDOMNode(widget)).css('vertical-align','top');
// Add a link to existing VFS file
const required = attrs.needed ?? attrs.required;
delete attrs.needed;
const select_attrs = {
...attrs,
// Filemanager select
...{
path: '~',
mode: widget.options.multiple ? 'open-multiple' : 'open',
method: 'EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_existing',
methodId: attrs.path,
buttonLabel: this.egw().lang('Link')
},
type: 'et2-vfs-select',
required: required
// should we show the VfsSelect
if (!field.values || typeof field.values !== 'object' || !field.values.noVfsSelect)
{
// Add a link to existing VFS file
const required = attrs.needed ?? attrs.required;
delete attrs.needed;
const select_attrs = {
...attrs,
// Filemanager select
...{
path: '~',
mode: widget.options.multiple ? 'open-multiple' : 'open',
method: 'EGroupware\\Api\\Etemplate\\Widget\\Link::ajax_link_existing',
methodId: attrs.path,
buttonLabel: this.egw().lang('Link')
},
type: 'et2-vfs-select',
required: required
}
select_attrs.id = attrs.id + '_vfs_select';
// This controls where the button is placed in the DOM
this.rows[select_attrs.id] = cf[0];
// Do not store in the widgets list, one name for multiple widgets would cause problems
widget = <Et2VfsSelectButton>loadWebComponent(select_attrs.type, select_attrs, this);
jQuery(widget.getDOMNode(widget)).css('vertical-align','top').prependTo(cf);
}
select_attrs.id = attrs.id + '_vfs_select';
// This controls where the button is placed in the DOM
this.rows[select_attrs.id] = cf[0];
// Do not store in the widgets list, one name for multiple widgets would cause problems
widget = <Et2VfsSelectButton>loadWebComponent(select_attrs.type, select_attrs, this);
jQuery(widget.getDOMNode(widget)).css('vertical-align','top').prependTo(cf);
}
return false;
}