chg: migrate sharing_views/view/[id] to factory

pull/7641/head
Luciano Righetti 2021-08-11 10:50:47 +02:00
parent 559e11acab
commit 8cd5953d39
3 changed files with 124 additions and 107 deletions

View File

@ -441,7 +441,7 @@ class SharingGroupsController extends AppController
$this->set('mayModify', $this->SharingGroup->checkIfAuthorisedExtend($this->Auth->user(), $sg['SharingGroup']['id'])); $this->set('mayModify', $this->SharingGroup->checkIfAuthorisedExtend($this->Auth->user(), $sg['SharingGroup']['id']));
$this->set('id', $sg['SharingGroup']['id']); $this->set('id', $sg['SharingGroup']['id']);
$this->set('sg', $sg); $this->set('sg', $sg);
$this->set('title_for_layout', __('Sharing Group %s', $sg['SharingGroup']['name'])); $this->set('menuData', ['menuList' => 'globalActions', 'menuItem' => 'viewSG']);
} }
private function __initialiseSGQuickEdit($id, $request) private function __initialiseSGQuickEdit($id, $request)

View File

@ -0,0 +1,3 @@
<?php
echo isset($data['Organisation']['id']) ? $this->OrgImg->getNameWithImg($data) : __('Unknown');

View File

@ -1,92 +1,106 @@
<div class="roles view">
<h2><?= __('Sharing Group %s', h($sg['SharingGroup']['name']));?></h2>
<div class="row-fluid"><div class="span8" style="margin:0">
<?php <?php
$tableData = [
['key' => __('ID'), 'value' => $sg['SharingGroup']['id']], echo $this->element(
['key' => __('UUID'), 'value' => $sg['SharingGroup']['uuid'], 'value_class' => 'quickSelect'], 'genericElements/SingleViews/single_view',
['key' => __('Name'), 'value' => $sg['SharingGroup']['name']], [
['key' => __('Releasability'), 'value' => $sg['SharingGroup']['releasability']], 'title' => __('Sharing Group %s', $sg['SharingGroup']['name']),
['key' => __('Description'), 'value' => $sg['SharingGroup']['description']], 'data' => $sg,
['key' => __('Selectable'), 'boolean' => $sg['SharingGroup']['active']], 'fields' => [
[
'key' => __('ID'),
'path' => 'SharingGroup.id'
],
[
'key' => __('UUID'),
'path' => 'SharingGroup.uuid'
],
[
'key' => __('Name'),
'path' => 'SharingGroup.name'
],
[
'key' => __('Releasability'),
'path' => 'SharingGroup.releasability'
],
[
'key' => __('Description'),
'path' => 'SharingGroup.description'
],
[
'key' => __('Selectable'),
'path' => 'SharingGroup.active',
'type' => 'boolean'
],
[ [
'key' => __('Created by'), 'key' => __('Created by'),
'html' => isset($sg['Organisation']['id']) ? $this->OrgImg->getNameWithImg($sg) : __('Unknown'), 'path' => 'Organisation',
'type' => 'org'
], ],
]; [
if ($sg['SharingGroup']['sync_user_id']) {
$tableData[] = [
'key' => __('Synced by'), 'key' => __('Synced by'),
'html' => isset($sg['SharingGroup']['sync_org']) ? $this->OrgImg->getNameWithImg($sg['SharingGroup']['sync_org']) : __('Unknown'), 'path' => 'SharingGroup.sync_org',
]; 'type' => 'org',
} 'requirement' => isset($sg['SharingGroup']['sync_org'])
$eventsLink = $baseurl . '/events/index/searchsharinggroup:' . $sg['SharingGroup']['id']; ],
$tableData[] = [ [
'key' => __('Events'), 'key' => __('Events'),
'html' => '<a href="' . $eventsLink . '">' . __n('%s event', '%s events', $sg['SharingGroup']['event_count'], $sg['SharingGroup']['event_count']) . '</a>', 'raw' => __n('%s event', '%s events', $sg['SharingGroup']['event_count'], $sg['SharingGroup']['event_count']),
]; 'url' => sprintf('/events/index/searchsharinggroup:%s', h($sg['SharingGroup']['id']))
if (isset($sg['SharingGroup']['org_count'])) { ],
$tableData[] = [ [
'key' => __('Organisations'), 'key' => __('Organisations'),
'html' => __n('%s organisation', '%s organisations', $sg['SharingGroup']['org_count'], $sg['SharingGroup']['org_count']), 'type' => 'custom',
]; 'function' => function ($sharingGroup) {
echo sprintf(
'<div class="span6">
<table class="table table-striped table-hover table-condensed">
<tr>
<th>%s</th>
<th>%s</th>
<th>%s</th>
</tr>',
__('Name'),
__('Is local'),
__('Can extend')
);
foreach ($sharingGroup['SharingGroupOrg'] as $sgo) {
echo '<tr>';
echo sprintf('<td>%s</td>', $this->OrgImg->getNameWithImg($sgo));
echo sprintf('<td><span class="%s"></span></td>', $sgo['Organisation']['local'] ? 'fas fa-check' : 'fas fa-times');
echo sprintf('<td><span class="%s"></span></td>', $sgo['extend'] ? 'fas fa-check' : 'fas fa-times');
echo '</tr>';
} }
echo $this->element('genericElements/viewMetaTable', ['table_data' => $tableData]); echo '</table>
?> </div>';
</div></div> }
<br /> ],
<div class="row" style="width:100%;"> [
<?php 'key' => __('Instances'),
if (isset($sg['SharingGroupOrg'])): 'type' => 'custom',
?> 'function' => function ($sharingGroup) {
<div class="span6"> echo sprintf(
<b><?php echo __('Organisations');?></b> '<div class="span6">
<table class="table table-striped table-hover table-condensed"> <table class="table table-striped table-hover table-condensed">
<tr> <tr>
<th><?= __('Name') ?></th> <th>%s</th>
<th><?= __('Is local') ?></th> <th>%s</th>
<th><?= __('Can extend') ?></th> <th>%s</th>
</tr> </tr>',
<?php __('Name'),
foreach ($sg['SharingGroupOrg'] as $sgo): __('URL'),
?> __('All orgs')
<tr> );
<td><?= $this->OrgImg->getNameWithImg($sgo) ?></td> foreach ($sharingGroup['SharingGroupServer'] as $sgs) {
<td><span class="<?= $sgo['Organisation']['local'] ? 'fas fa-check' : 'fas fa-times' ?>"></span></td> echo '<tr>';
<td><span class="<?= $sgo['extend'] ? 'fas fa-check' : 'fas fa-times' ?>"></span></td> echo sprintf('<td>%s</td>', h($sgs['Server']['name']));
</tr> echo sprintf('<td>%s</td>', h($sgs['Server']['url']));
<?php echo sprintf('<td><span class="%s"></span></td>', $sgs['all_orgs'] ? 'fas fa-check' : 'fas fa-times');
endforeach; echo '</tr>';
?> }
</table> echo '</table>
</div> </div>';
<?php }
endif; ]
if (!$sg['SharingGroup']['roaming'] && isset($sg['SharingGroupServer'])): ]
?> ]
<div class="span6"> );
<b>Instances</b>
<table class="table table-striped table-hover table-condensed">
<tr>
<th><?= __('Name') ?></th>
<th><?= __('URL') ?></th>
<th><?= __('All orgs') ?></th>
</tr>
<?php
foreach ($sg['SharingGroupServer'] as $sgs): ?>
<tr>
<td><?= h($sgs['Server']['name']) ?></td>
<td><?= h($sgs['Server']['url']) ?></td>
<td><span class="<?= $sgs['all_orgs'] ? 'fas fa-check' : 'fas fa-times' ?>"></span></td>
</tr>
<?php
endforeach;
?>
</table>
</div>
<?php
endif;
?>
</div>
</div>
<?= $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'globalActions', 'menuItem' => 'viewSG'));