* REST API: fix PATCHing of custom-fields

This commit is contained in:
ralf 2024-02-21 17:27:49 +02:00
parent f5476ef133
commit 158f683e69
4 changed files with 14 additions and 5 deletions

View File

@ -200,7 +200,7 @@ class JsBase
foreach($definitions as $name => $definition) foreach($definitions as $name => $definition)
{ {
$data = $cfs[$name]; $data = $cfs[$name] ?? null;
if (isset($data)) if (isset($data))
{ {
if (is_scalar($data) || is_array($data) && !isset($data['value'])) if (is_scalar($data) || is_array($data) && !isset($data['value']))
@ -357,9 +357,17 @@ class JsBase
$target = &$target[$part]; $target = &$target[$part];
} }
if (isset($value)) if (isset($value))
{
// objects need to be merged, to not unset all not given attributes
if (is_array($value) && !array_key_exists(0, $value))
{
$target = array_merge($target, $value);
}
else
{ {
$target = $value; $target = $value;
} }
}
else else
{ {
unset($parent[$part]); unset($parent[$part]);

View File

@ -179,7 +179,7 @@ class JsCalendar extends JsBase
break; break;
case 'egroupware.org:customfields': case 'egroupware.org:customfields':
$event += self::parseCustomfields($value, $strict); $event = array_merge($event, self::parseCustomfields($value, $strict));
break; break;
case 'prodId': case 'prodId':

View File

@ -188,7 +188,7 @@ class JsContact extends Api\CalDAV\JsBase
break; break;
case 'egroupware.org:customfields': case 'egroupware.org:customfields':
$contact += self::parseCustomfields($value); $contact = array_merge($contact, self::parseCustomfields($value));
break; break;
case 'egroupware.org:assistant': case 'egroupware.org:assistant':

View File

@ -154,7 +154,7 @@ class JsTimesheet extends Api\CalDAV\JsBase
break; break;
case 'egroupware.org:customfields': case 'egroupware.org:customfields':
$timesheet += self::parseCustomfields($value); $timesheet = array_merge($timesheet, self::parseCustomfields($value));
break; break;
case 'prodId': case 'prodId':
@ -163,6 +163,7 @@ class JsTimesheet extends Api\CalDAV\JsBase
case 'modifier': case 'modifier':
case self::AT_TYPE: case self::AT_TYPE:
case 'id': case 'id':
case 'etag':
break; break;
default: default: