chg: [crud:index] Include all meta-fields regardless of user's preference when in REST context
parent
f0ba0d8316
commit
46bafa045f
|
@ -96,8 +96,9 @@ class CRUDComponent extends Component
|
||||||
$query->order($sort . ' ' . $direction);
|
$query->order($sort . ' ' . $direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$isRestOrCSV = $this->Controller->ParamHandler->isRest() || $this->request->is('csv');
|
||||||
if ($this->metaFieldsSupported()) {
|
if ($this->metaFieldsSupported()) {
|
||||||
$query = $this->includeRequestedMetaFields($query);
|
$query = $this->includeRequestedMetaFields($query, $isRestOrCSV);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->Controller->ParamHandler->isRest()) {
|
if (!$this->Controller->ParamHandler->isRest()) {
|
||||||
|
@ -107,7 +108,7 @@ class CRUDComponent extends Component
|
||||||
}
|
}
|
||||||
$data = $this->Controller->paginate($query, $this->Controller->paginate ?? []);
|
$data = $this->Controller->paginate($query, $this->Controller->paginate ?? []);
|
||||||
$totalCount = $this->Controller->getRequest()->getAttribute('paging')[$this->TableAlias]['count'];
|
$totalCount = $this->Controller->getRequest()->getAttribute('paging')[$this->TableAlias]['count'];
|
||||||
if ($this->Controller->ParamHandler->isRest() || $this->request->is('csv')) {
|
if ($isRestOrCSV) {
|
||||||
if (isset($options['hidden'])) {
|
if (isset($options['hidden'])) {
|
||||||
$data->each(function($value, $key) use ($options) {
|
$data->each(function($value, $key) use ($options) {
|
||||||
$hidden = is_array($options['hidden']) ? $options['hidden'] : [$options['hidden']];
|
$hidden = is_array($options['hidden']) ? $options['hidden'] : [$options['hidden']];
|
||||||
|
@ -777,8 +778,11 @@ class CRUDComponent extends Component
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function includeRequestedMetaFields($query)
|
protected function includeRequestedMetaFields($query, $isREST=false)
|
||||||
{
|
{
|
||||||
|
if (!empty($isREST)) {
|
||||||
|
return $query->contain(['MetaFields']);
|
||||||
|
}
|
||||||
$user = $this->Controller->ACL->getUser();
|
$user = $this->Controller->ACL->getUser();
|
||||||
$tableSettings = IndexSetting::getTableSetting($user, $this->Table);
|
$tableSettings = IndexSetting::getTableSetting($user, $this->Table);
|
||||||
if (empty($tableSettings['visible_meta_column'])) {
|
if (empty($tableSettings['visible_meta_column'])) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ class AppModel extends Entity
|
||||||
$this->meta_fields[$i]['template_namespace'] = $templates[$templateDirectoryId]['namespace'];
|
$this->meta_fields[$i]['template_namespace'] = $templates[$templateDirectoryId]['namespace'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($options['smartFlattenMetafields'])) {
|
if (!empty($this->meta_fields) && !empty($options['smartFlattenMetafields'])) {
|
||||||
$smartFlatten = [];
|
$smartFlatten = [];
|
||||||
foreach ($this->meta_fields as $metafield) {
|
foreach ($this->meta_fields as $metafield) {
|
||||||
$key = "{$metafield['template_name']}_v{$metafield['template_version']}:{$metafield['field']}";
|
$key = "{$metafield['template_name']}_v{$metafield['template_version']}:{$metafield['field']}";
|
||||||
|
|
Loading…
Reference in New Issue