new: [open] spaces added

- public interfaces that are configurable, early iteration
remotes/origin/main
iglocska 2020-06-21 23:53:38 +02:00
parent 7d74ee7241
commit 151e033d19
No known key found for this signature in database
GPG Key ID: BEA224F1FEF113AC
6 changed files with 179 additions and 16 deletions

View File

@ -105,6 +105,7 @@ class AppController extends Controller
$this->ACL->checkAccess();
$this->set('menu', $this->{$this->modelClass}->getMenu());
$this->set('ajax', $this->request->is('ajax'));
$this->request->getParam('prefix');
}
private function authApiUser(): void

View File

@ -8,6 +8,8 @@ use Cake\Http\Exception\NotFoundException;
use Cake\Http\Exception\MethodNotAllowedException;
use Cake\Http\Exception\ForbiddenException;
use Cake\ORM\TableRegistry;
use Cake\Core\Configure;
use Cake\Core\Configure\Engine\PhpConfig;
class ACLComponent extends Component
{

View File

@ -0,0 +1,35 @@
<?php
namespace App\Controller\Open;
use App\Controller\AppController;
use Cake\Utility\Hash;
use Cake\Utility\Text;
use \Cake\Database\Expression\QueryExpression;
use Cake\Http\Exception\NotFoundException;
use Cake\Http\Exception\MethodNotAllowedException;
use Cake\Http\Exception\ForbiddenException;
use Cake\Event\EventInterface;
class OrganisationsController extends AppController
{
public function beforeFilter(EventInterface $event)
{
parent::beforeFilter($event);
$this->Authentication->allowUnauthenticated(['index']);
}
public function index()
{
$this->CRUD->index([
'filters' => ['name', 'uuid', 'nationality', 'sector', 'type', 'url', 'Alignments.id'],
'quickFilters' => ['name', 'uuid', 'nationality', 'sector', 'type', 'url'],
'contain' => ['Alignments' => 'Individuals']
]);
if ($this->ParamHandler->isRest()) {
return $this->restResponsePayload;
}
$this->set('alignmentScope', 'individuals');
$this->set('metaGroup', 'Public');
}
}

View File

@ -4,6 +4,8 @@ namespace App\Model\Table;
use Cake\ORM\Table;
use Cake\Validation\Validator;
use Cake\Core\Configure;
use Cake\Core\Configure\Engine\PhpConfig;
class AppTable extends Table
{
@ -13,6 +15,7 @@ class AppTable extends Table
public function getMenu()
{
$open = Configure::read('Cerebrate.open');
return [
'ContactDB' => [
'Individuals' => [
@ -193,6 +196,30 @@ class AppTable extends Table
]
]
]
],
'Open' => [
'Organisations' => [
'label' => __('Organisations'),
'url' => '/open/organisations/index',
'children' => [
'index' => [
'url' => '/open/organisations/index',
'label' => __('List organisations')
],
],
'open' => in_array('organisations', Configure::read('Cerebrate.open'))
],
'Individuals' => [
'label' => __('Individuals'),
'url' => '/open/individuals/index',
'children' => [
'index' => [
'url' => '/open/individuals/index',
'label' => __('List individuals')
],
],
'open' => in_array('individuals', Configure::read('Cerebrate.open'))
]
]
];
}

View File

@ -0,0 +1,95 @@
<?php
echo $this->element('genericElements/IndexTable/index_table', [
'data' => [
'data' => $data,
'top_bar' => [
'pull' => 'right',
'children' => [
[
'type' => 'simple',
'children' => [
'data' => [
'type' => 'simple',
'text' => __('Add organisation'),
'class' => 'btn btn-primary',
'popover_url' => '/organisations/add'
]
]
],
[
'type' => 'search',
'button' => __('Filter'),
'placeholder' => __('Enter value to search'),
'data' => '',
'searchKey' => 'value'
]
]
],
'fields' => [
[
'name' => '#',
'sort' => 'id',
'class' => 'short',
'data_path' => 'id',
],
[
'name' => __('Name'),
'class' => 'short',
'data_path' => 'name',
],
[
'name' => __('UUID'),
'sort' => 'uuid',
'class' => 'short',
'data_path' => 'uuid',
],
[
'name' => __('Members'),
'data_path' => 'alignments',
'element' => 'count_summary',
'url' => '/individuals/index/?Organisations.id={{url_data}}',
'url_data_path' => 'id'
],
[
'name' => __('URL'),
'sort' => 'url',
'class' => 'short',
'data_path' => 'url',
],
[
'name' => __('Nationality'),
'data_path' => 'nationality',
],
[
'name' => __('Sector'),
'data_path' => 'sector',
],
[
'name' => __('Type'),
'data_path' => 'type',
]
],
'title' => __('ContactDB Organisation Index'),
'description' => __('A list of organisations known by your Cerebrate instance. This list can get populated either directly, by adding new organisations or by fetching them from trusted remote sources.'),
'pull' => 'right',
'actions' => [
[
'url' => '/organisations/view',
'url_params_data_paths' => ['id'],
'icon' => 'eye'
],
[
'onclick' => 'populateAndLoadModal(\'/organisations/edit/[onclick_params_data_path]\');',
'onclick_params_data_path' => 'id',
'icon' => 'edit'
],
[
'onclick' => 'populateAndLoadModal(\'/organisations/delete/[onclick_params_data_path]\');',
'onclick_params_data_path' => 'id',
'icon' => 'trash'
]
]
]
]);
echo '</div>';
?>

View File

@ -1,13 +1,13 @@
<?php
/*
* echo $this->element('/genericElements/IndexTable/index_table', array(
* echo $this->element('/genericElements/IndexTable/index_table', [
* 'top_bar' => (
* // search/filter bar information compliant with ListTopBar
* ),
* 'data' => array(
* 'data' => [
// the actual data to be used
* ),
* 'fields' => array(
* 'fields' => [
* // field list with information for the paginator, the elements used for the individual cells, etc
* ),
* 'title' => optional title,
@ -32,13 +32,13 @@
}
$skipPagination = isset($data['skip_pagination']) ? $data['skip_pagination'] : 0;
if (!$skipPagination) {
$paginationData = !empty($data['paginatorOptions']) ? $data['paginatorOptions'] : array();
$paginationData = !empty($data['paginatorOptions']) ? $data['paginatorOptions'] : [];
echo $this->element(
'/genericElements/IndexTable/pagination',
array(
[
'paginationOptions' => $paginationData,
'tableRandomValue' => $tableRandomValue
)
]
);
if (!$ajax) {
echo $this->element(
@ -49,17 +49,20 @@
if (!empty($data['top_bar'])) {
echo $this->element(
'/genericElements/ListTopBar/scaffold',
array(
[
'data' => $data['top_bar'],
'tableRandomValue' => $tableRandomValue
)
]
);
}
$rows = '';
$row_element = isset($data['row_element']) ? $data['row_element'] : 'row';
$options = isset($data['options']) ? $data['options'] : array();
$actions = isset($data['actions']) ? $data['actions'] : array();
$dblclickActionArray = isset($data['actions']) ? $this->Hash->extract($data['actions'], '{n}[dbclickAction]') : array();
$options = isset($data['options']) ? $data['options'] : [];
$actions = isset($data['actions']) ? $data['actions'] : [];
if ($this->request->getParam('prefix') === 'Open') {
$actions = [];
}
$dblclickActionArray = !empty($actions) ? $this->Hash->extract($actions, '{n}[dbclickAction]') : [];
$dbclickAction = '';
foreach ($data['data'] as $k => $data_row) {
$primary = null;
@ -78,7 +81,7 @@
empty($data['class']) ? '' : h($data['row_class']),
$this->element(
'/genericElements/IndexTable/' . $row_element,
array(
[
'k' => $k,
'row' => $data_row,
'fields' => $data['fields'],
@ -86,7 +89,7 @@
'actions' => $actions,
'primary' => $primary,
'tableRandomValue' => $tableRandomValue
)
]
)
);
}
@ -96,12 +99,12 @@
$tableRandomValue,
$this->element(
'/genericElements/IndexTable/headers',
array(
[
'fields' => $data['fields'],
'paginator' => $this->Paginator,
'actions' => (empty($data['actions']) ? false : true),
'actions' => (empty($actions) ? false : true),
'tableRandomValue' => $tableRandomValue
)
]
),
$tbody
);