fix: [controllers] Return data based on the CRUD component response
parent
96248bbd00
commit
4e74da6163
|
@ -26,8 +26,9 @@ class EncryptionKeysController extends AppController
|
|||
],
|
||||
'contain' => ['Individuals', 'Organisations']
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', 'ContactDB');
|
||||
}
|
||||
|
@ -35,8 +36,9 @@ class EncryptionKeysController extends AppController
|
|||
public function delete($id)
|
||||
{
|
||||
$this->CRUD->delete($id);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', 'ContactDB');
|
||||
}
|
||||
|
@ -44,8 +46,9 @@ class EncryptionKeysController extends AppController
|
|||
public function add()
|
||||
{
|
||||
$this->CRUD->add(['redirect' => $this->referer()]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->loadModel('Organisations');
|
||||
$this->loadModel('Individuals');
|
||||
|
@ -70,8 +73,9 @@ class EncryptionKeysController extends AppController
|
|||
'redirect' => $this->referer()
|
||||
];
|
||||
$this->CRUD->edit($id, $params);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('dropdownData', []);
|
||||
$this->set('metaGroup', 'ContactDB');
|
||||
|
|
|
@ -36,8 +36,9 @@ class LocalToolsController extends AppController
|
|||
return $data;
|
||||
}
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', 'Administration');
|
||||
}
|
||||
|
@ -102,8 +103,9 @@ class LocalToolsController extends AppController
|
|||
public function add($connector = false)
|
||||
{
|
||||
$this->CRUD->add();
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$connectors = $this->LocalTools->extractMeta($this->LocalTools->getConnectors());
|
||||
$dropdownData = ['connectors' => []];
|
||||
|
@ -133,8 +135,9 @@ class LocalToolsController extends AppController
|
|||
public function edit($id)
|
||||
{
|
||||
$this->CRUD->edit($id);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
if ($this->ParamHandler->isAjax() && !empty($this->ajaxResponsePayload)) {
|
||||
return $this->ajaxResponsePayload;
|
||||
|
@ -152,8 +155,9 @@ class LocalToolsController extends AppController
|
|||
public function delete($id)
|
||||
{
|
||||
$this->CRUD->delete($id);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', 'Administration');
|
||||
}
|
||||
|
@ -193,8 +197,9 @@ class LocalToolsController extends AppController
|
|||
return $data;
|
||||
}
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', 'Administration');
|
||||
}
|
||||
|
|
|
@ -15,8 +15,9 @@ class MetaTemplateFieldsController extends AppController
|
|||
'filters' => ['field', 'type', 'meta_template_id'],
|
||||
'quickFilters' => ['field', 'type']
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', 'Administration');
|
||||
}
|
||||
|
|
|
@ -51,8 +51,9 @@ class MetaTemplatesController extends AppController
|
|||
],
|
||||
'contain' => ['MetaTemplateFields']
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('defaultTemplatePerScope', $this->MetaTemplates->getDefaultTemplatePerScope());
|
||||
$this->set('alignmentScope', 'individuals');
|
||||
|
@ -64,8 +65,9 @@ class MetaTemplatesController extends AppController
|
|||
$this->CRUD->view($id, [
|
||||
'contain' => ['MetaTemplateFields']
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', 'Administration');
|
||||
}
|
||||
|
@ -79,10 +81,9 @@ class MetaTemplatesController extends AppController
|
|||
} else {
|
||||
$this->CRUD->toggle($id, $fieldName);
|
||||
}
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
} else if($this->ParamHandler->isAjax() && $this->request->is(['post', 'put'])) {
|
||||
return $this->ajaxResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,9 @@ class IndividualsController extends AppController
|
|||
'quickFilters' => ['uuid', 'email', 'first_name', 'last_name', 'position'],
|
||||
'contain' => ['Alignments' => 'Organisations']
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('alignmentScope', 'organisations');
|
||||
$this->set('metaGroup', 'Public');
|
||||
|
|
|
@ -26,8 +26,9 @@ class OrganisationsController extends AppController
|
|||
'quickFilters' => ['name', 'uuid', 'nationality', 'sector', 'type', 'url'],
|
||||
'contain' => ['Alignments' => 'Individuals']
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('alignmentScope', 'individuals');
|
||||
$this->set('metaGroup', 'Public');
|
||||
|
|
|
@ -18,8 +18,9 @@ class RolesController extends AppController
|
|||
'filters' => ['name', 'uuid', 'perm_admin', 'Users.id'],
|
||||
'quickFilters' => ['name']
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate');
|
||||
}
|
||||
|
@ -27,8 +28,9 @@ class RolesController extends AppController
|
|||
public function add()
|
||||
{
|
||||
$this->CRUD->add();
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate');
|
||||
}
|
||||
|
@ -36,8 +38,9 @@ class RolesController extends AppController
|
|||
public function view($id)
|
||||
{
|
||||
$this->CRUD->view($id);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate');
|
||||
}
|
||||
|
@ -45,8 +48,9 @@ class RolesController extends AppController
|
|||
public function edit($id)
|
||||
{
|
||||
$this->CRUD->edit($id);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate');
|
||||
$this->render('add');
|
||||
|
@ -55,8 +59,9 @@ class RolesController extends AppController
|
|||
public function delete($id)
|
||||
{
|
||||
$this->CRUD->delete($id);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate');
|
||||
}
|
||||
|
|
|
@ -16,8 +16,9 @@ class SharingGroupsController extends AppController
|
|||
'contain' => ['SharingGroupOrgs', 'Organisations', 'Users' => ['fields' => ['id', 'username']]],
|
||||
'filters' => ['uuid', 'description', 'releasability', 'Organisations.name', 'Organisations.uuid']
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', 'Trust Circles');
|
||||
}
|
||||
|
@ -45,8 +46,9 @@ class SharingGroupsController extends AppController
|
|||
$this->CRUD->view($id, [
|
||||
'contain' => ['SharingGroupOrgs', 'Organisations', 'Users' => ['fields' => ['id', 'username']]]
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', 'Trust Circles');
|
||||
}
|
||||
|
|
|
@ -16,8 +16,9 @@ class UsersController extends AppController
|
|||
'filters' => ['Users.email', 'uuid'],
|
||||
'quickFilters' => ['uuid', ['username' => true], ['Individuals.first_name' => true], ['Individuals.last_name' => true], 'Individuals.email'],
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate');
|
||||
}
|
||||
|
@ -49,8 +50,9 @@ class UsersController extends AppController
|
|||
$this->CRUD->view($id, [
|
||||
'contain' => ['Individuals' => ['Alignments' => 'Organisations'], 'Roles']
|
||||
]);
|
||||
if ($this->ParamHandler->isRest()) {
|
||||
return $this->restResponsePayload;
|
||||
$responsePayload = $this->CRUD->getResponsePayload();
|
||||
if (!empty($responsePayload)) {
|
||||
return $responsePayload;
|
||||
}
|
||||
$this->set('metaGroup', $this->isAdmin ? 'Administration' : 'Cerebrate');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue