WIP allow to place custom-fields in tabs:

- set size of cf name in all apps to 65 chars (calendar, resources, projectmanager had only 40)
- allow units like K or MB for integer values e.g. et2_files max_file_size
- allow to pass accept, mime and max_file_size from Filemanager custom-field to vfs-upload
- allow to use name of "app:$cont[id]:relative-path/" as name for Filemanager custom-field
ToDo/Missing: automatic saving of uploads for not yet saved entries via Api\Storage class
This commit is contained in:
ralf 2024-03-26 12:40:51 +02:00
parent 57c643ad8e
commit 25b343be7c
10 changed files with 75 additions and 13 deletions

View File

@ -17,7 +17,7 @@
</row>
<row>
<et2-description value="Label"></et2-description>
<et2-textbox statustext="the text displayed to the user" id="cf_label" maxlength="255" span="3"></et2-textbox>
<et2-textbox statustext="the text displayed to the user" id="cf_label" maxlength="128" span="3"></et2-textbox>
</row>
<row>
<et2-description value="Type of field"></et2-description>
@ -31,10 +31,10 @@
<et2-description value="Private"></et2-description>
<et2-select-account statustext="Select accounts for which the custom field should be visible" id="cf_private" rows="3" span="3" multiple="1" placeholder="Add user or group" accountType="both"></et2-select-account>
</row>
<row disabled="!@use_readonly">
<!-- disabled until implemented row disabled="!@use_readonly">
<et2-description value="Readonly"></et2-description>
<et2-select-account statustext="Select accounts for which the custom field should be readonly" id="cf_readonly" rows="3" span="3" multiple="1" placeholder="Add user or group" accountType="both"></et2-select-account>
</row>
</row-->
<row>
<et2-description statustext="each value is a line like id[=label], or use @path to read options from a file in EGroupware directory" value="Options"></et2-description>
<et2-textarea statustext="@statustext" id="cf_values" rows="5" cols="30" span="3" width="99%"></et2-textarea>
@ -68,8 +68,8 @@
</columns>
<rows>
<row class="dialogHeader" height="28">
<et2-description statustext="the name used internaly (&amp;lt;= 20 chars), changeing it makes existing data unavailible" value="Name"></et2-description>
<et2-textbox statustext="the name used internaly (&lt;= 20 chars), changeing it makes existing data unavailible" id="cf_name" maxlength="32" span="2" required="true"></et2-textbox>
<et2-description value="Name"></et2-description>
<et2-textbox statustext="internal name max. 64 chars" id="cf_name" maxlength="64" span="2" required="true"></et2-textbox>
<et2-appicon></et2-appicon>
</row>
<row>

View File

@ -193,6 +193,27 @@ export function et2_checkType(_val, _type, _attr, _widget)
// parseInt(_val) to the value itself.
if (_type == "integer")
{
const unit_reg_exp = /^(\d+)([kmg]{0,1}b?)$/i;
// allow to use b, k, kb, m, mb, g or gb postfix
if (typeof _val === "string" && _val.match(unit_reg_exp))
{
const matches = _val.match(unit_reg_exp);
switch(matches[2][0].toLowerCase())
{
case 'b':
_val = parseInt(matches[1]);
break;
case 'k':
_val = parseInt(matches[1])*1024;
break;
case 'm':
_val = parseInt(matches[1])*1024*1024;
break;
case 'g':
_val = parseInt(matches[1])*1024*1024*1024;
break;
}
}
if (parseInt(_val) == _val)
{
return parseInt(_val);
@ -779,4 +800,4 @@ export function et2_rangeSubstract(_ar1, _ar2)
export function html_entity_decode(_str)
{
return _str && _str.indexOf('&') != -1 ? jQuery('<span>'+_str+'</span>').text() : _str;
}
}

View File

@ -880,6 +880,23 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
attrs.type = 'vfs-upload';
delete(attrs.label);
// fix vfs-upload id="$app:$id:$rest" e.g. "infolog:$cont[info_id]:test.pdf"
const vfs_app_id_regexp = /^#([a-z_]+):([@$][^:]+):(.*)$/;
if (attrs.id.match(vfs_app_id_regexp))
{
attrs.id = <string>this.getArrayMgr('content').expandName(attrs.id);
}
// allow to set/pass further et2_file attributes to the vfs-upload
if (field.values && typeof field.values === 'object')
{
['mime', 'accept', 'max_file_size'].forEach((name) => {
if (typeof field.values[name] !== 'undefined')
{
attrs[name] = field.values[name];
}
});
}
if (this.getType() == 'customfields-list')
{
// No special UI needed?

View File

@ -39,7 +39,7 @@ export class et2_file extends et2_inputWidget
"name": "Maximum file size",
"type": "integer",
"default":0,
"description": "Largest file accepted, in bytes. Subject to server limitations. 8MB = 8388608"
"description": "Largest file accepted, in bytes or with units: K, KB, M, MB, G or GB. Subject to server limitations."
},
"mime": {
"name": "Allowed file types",

View File

@ -9,7 +9,7 @@
*/
$setup_info['calendar']['name'] = 'calendar';
$setup_info['calendar']['version'] = '23.1';
$setup_info['calendar']['version'] = '23.1.001';
$setup_info['calendar']['app_order'] = 3;
$setup_info['calendar']['enable'] = 1;
$setup_info['calendar']['index'] = 'calendar.calendar_uiviews.index&ajax=true';

View File

@ -74,7 +74,7 @@ $phpgw_baseline = array(
'egw_cal_extra' => array(
'fd' => array(
'cal_id' => array('type' => 'int','precision' => '4','nullable' => False),
'cal_extra_name' => array('type' => 'varchar','meta' => 'cfname','precision' => '40','nullable' => False),
'cal_extra_name' => array('type' => 'varchar','meta' => 'cfname','precision' => '64','nullable' => False),
'cal_extra_value' => array('type' => 'varchar','meta' => 'cfvalue','precision' => '16384','nullable' => False,'default' => '')
),
'pk' => array('cal_id','cal_extra_name'),

View File

@ -2829,4 +2829,16 @@ function calendar_upgrade20_1()
function calendar_upgrade21_1()
{
return $GLOBALS['setup_info']['calendar']['currentver'] = '23.1';
}
}
function calendar_upgrade23_1()
{
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_cal_extra','cal_extra_name',array(
'type' => 'varchar',
'meta' => 'cfname',
'precision' => '64',
'nullable' => False
));
return $GLOBALS['setup_info']['calendar']['currentver'] = '23.1.001';
}

View File

@ -12,7 +12,7 @@
$setup_info['resources']['name'] = 'resources';
$setup_info['resources']['title'] = 'Resources';
$setup_info['resources']['version'] = '23.1';
$setup_info['resources']['version'] = '23.1.001';
$setup_info['resources']['app_order'] = 5;
$setup_info['resources']['tables'] = array('egw_resources','egw_resources_extra');
$setup_info['resources']['enable'] = 1;

View File

@ -43,7 +43,7 @@ $phpgw_baseline = array(
'egw_resources_extra' => array(
'fd' => array(
'extra_id' => array('type' => 'int','precision' => '4','nullable' => False),
'extra_name' => array('type' => 'varchar','meta' => 'cfname','precision' => '40','nullable' => False),
'extra_name' => array('type' => 'varchar','meta' => 'cfname','precision' => '64','nullable' => False),
'extra_owner' => array('type' => 'int','meta' => 'account','precision' => '4','nullable' => False,'default' => '-1'),
'extra_value' => array('type' => 'varchar','meta' => 'cfvalue','precision' => '16384','nullable' => False,'default' => '')
),

View File

@ -447,4 +447,16 @@ function resources_upgrade20_1()
function resources_upgrade21_1()
{
return $GLOBALS['setup_info']['resources']['currentver'] = '23.1';
}
}
function resources_upgrade23_1()
{
$GLOBALS['egw_setup']->oProc->AlterColumn('egw_resources_extra','extra_name',array(
'type' => 'varchar',
'meta' => 'cfname',
'precision' => '64',
'nullable' => False
));
return $GLOBALS['setup_info']['resources']['currentver'] = '23.1.001';
}