chg: [sharinggroup] Improved support of CRUDComponent
parent
adc4a776a8
commit
a4bb09253f
|
@ -223,7 +223,7 @@ class CRUDComponent extends Component
|
||||||
$data = $this->Table->patchEntity($data, $input, $patchEntityParams);
|
$data = $this->Table->patchEntity($data, $input, $patchEntityParams);
|
||||||
$savedData = $this->Table->save($data);
|
$savedData = $this->Table->save($data);
|
||||||
if ($savedData !== false) {
|
if ($savedData !== false) {
|
||||||
$message = __('{0} updated.', $this->ObjectAlias);
|
$message = __('{0} `{1}` updated.', $this->ObjectAlias, $savedData->{$this->Table->getDisplayField()});
|
||||||
if (!empty($input['metaFields'])) {
|
if (!empty($input['metaFields'])) {
|
||||||
$this->MetaFields->deleteAll(['scope' => $this->Table->metaFields, 'parent_id' => $data->id]);
|
$this->MetaFields->deleteAll(['scope' => $this->Table->metaFields, 'parent_id' => $data->id]);
|
||||||
$this->saveMetaFields($data->id, $input);
|
$this->saveMetaFields($data->id, $input);
|
||||||
|
|
|
@ -31,8 +31,9 @@ class SharingGroupsController extends AppController
|
||||||
$dropdownData = [
|
$dropdownData = [
|
||||||
'organisation' => $this->getAvailableOrgForSg($this->ACL->getUser())
|
'organisation' => $this->getAvailableOrgForSg($this->ACL->getUser())
|
||||||
];
|
];
|
||||||
if ($this->ParamHandler->isRest()) {
|
$responsePayload = $this->CRUD->getResponsePayload();
|
||||||
return $this->restResponsePayload;
|
if (!empty($responsePayload)) {
|
||||||
|
return $responsePayload;
|
||||||
}
|
}
|
||||||
$this->set(compact('dropdownData'));
|
$this->set(compact('dropdownData'));
|
||||||
$this->set('metaGroup', 'Trust Circles');
|
$this->set('metaGroup', 'Trust Circles');
|
||||||
|
@ -52,8 +53,9 @@ class SharingGroupsController extends AppController
|
||||||
public function edit($id = false)
|
public function edit($id = false)
|
||||||
{
|
{
|
||||||
$this->CRUD->edit($id);
|
$this->CRUD->edit($id);
|
||||||
if ($this->ParamHandler->isRest()) {
|
$responsePayload = $this->CRUD->getResponsePayload();
|
||||||
return $this->restResponsePayload;
|
if (!empty($responsePayload)) {
|
||||||
|
return $responsePayload;
|
||||||
}
|
}
|
||||||
$dropdownData = [
|
$dropdownData = [
|
||||||
'organisation' => $this->getAvailableOrgForSg($this->ACL->getUser())
|
'organisation' => $this->getAvailableOrgForSg($this->ACL->getUser())
|
||||||
|
@ -66,8 +68,9 @@ class SharingGroupsController extends AppController
|
||||||
public function delete($id)
|
public function delete($id)
|
||||||
{
|
{
|
||||||
$this->CRUD->delete($id);
|
$this->CRUD->delete($id);
|
||||||
if ($this->ParamHandler->isRest()) {
|
$responsePayload = $this->CRUD->getResponsePayload();
|
||||||
return $this->restResponsePayload;
|
if (!empty($responsePayload)) {
|
||||||
|
return $responsePayload;
|
||||||
}
|
}
|
||||||
$this->set('metaGroup', 'Trust Circles');
|
$this->set('metaGroup', 'Trust Circles');
|
||||||
}
|
}
|
||||||
|
@ -110,7 +113,7 @@ class SharingGroupsController extends AppController
|
||||||
} else {
|
} else {
|
||||||
$message = __('Organisation(s) could not be added to the sharing group.');
|
$message = __('Organisation(s) could not be added to the sharing group.');
|
||||||
}
|
}
|
||||||
if ($this->ParamHandler->isRest()) {
|
if ($this->ParamHandler->isRest() || $this->ParamHandler->isAjax()) {
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$this->RestResponse->saveSuccessResponse('SharingGroups', 'addOrg', $id, 'json', $message);
|
$this->RestResponse->saveSuccessResponse('SharingGroups', 'addOrg', $id, 'json', $message);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue