Skip to content

Improvements to Plugins index view. (CFM-297) #104

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/src/Controller/PluginsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,27 @@ public function activate(string $id) {

return $this->redirect(['action' => 'index']);
}

/**
* Callback run prior to the view rendering.
*
* @since COmanage Registry v5.0.0
* @param EventInterface $event Cake Event
*/

public function beforeRender(\Cake\Event\EventInterface $event) {
// In order to get the sidebar to render we need to set the current CO,
// which for plugins is the COmanage CO.
$CosTable = $this->fetchTable('Cos');
$this->set('vv_cur_co', $CosTable->find('COmanageCO')->firstOrFail());

// The Plugins table is a "meta" table rather than configuration, but we should load the
// "configuration" breadcrumb. Override vv_bc_configuration_link to be true so that the
// breadcrumb renders.
$this->set('vv_bc_configuration_link', true);

return parent::beforeRender($event);
}

/**
* Deactivate a Plugin.
Expand Down
41 changes: 7 additions & 34 deletions app/templates/Standard/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@
break;
case 'datetime':
// XXX dates can be rendered as eg $entity->created->format(DATE_RFC850);
print !empty($entity->$col) ? $this->Time->nice($entity->$col, $vv_tz) . $suffix : "";
if(!empty($entity->$col)) {
print $this->Time->nice($entity->$col, $vv_tz) . $suffix;
}
break;
case 'enum':
if($entity->$col) {
Expand Down Expand Up @@ -427,38 +429,6 @@
$fn = $cfg['function'];
print $fn($entity);
break;
case 'datetime':
// XXX dates can be rendered as eg $entity->created->format(DATE_RFC850);
if(!empty($entity->$col)) {
print $this->Time->nice($entity->$col, $vv_tz) . $suffix;
}
break;
case 'enum':
if($entity->$col) {
// XXX Need to add badging - see index.php in Match
print __d('enumeration', $cfg['class'].'.'.$entity->$col) . $suffix;
}
break;
case 'fk':
// Assuming $col is of the form foo_id, look to see if the corresponding
// AutoViewVar $foos is set, and if so render the lookup value instead
$f = null;
if(preg_match('/^(.*?)_id$/', $col, $f)) {
$avv = Inflector::variable(Inflector::pluralize($f[1]));

if(!empty(${$avv}[$entity->$col])) {
// We found the viewvar (eg: $foos), and it has a corresponding value
// (eg: $foos[3]), so render it
print ${$avv}[$entity->$col]. $suffix; // XXX filter_var?
} else {
// No match, just render the value
print $entity->$col. $suffix;
}
} else {
// Just print the value
print $entity->$col. $suffix;
}
break;
case 'link':
case 'relatedLink':
case 'echo':
Expand Down Expand Up @@ -505,8 +475,9 @@
foreach($tryActions as $a) {
// Does this user have permission for this action?
if($vv_permission_set[$entity->id][$a]) {
// Handle $isFirstLink
$args = [];
$readOnlyIcon = '';
$readOnlyIcon = '';
if($isFirstLink) {
$linkClass = 'row-link';
if($a == 'edit') {
Expand Down Expand Up @@ -547,6 +518,7 @@
// XXX we actually need to know the permissions on the target (ie: actor person)
if(true ||
$vv_permission_set[$entity->id][$a]) {
// Handle $isFirstLink
$args = [];
$readOnlyIcon = '';
if($isFirstLink) {
Expand Down Expand Up @@ -579,6 +551,7 @@
if(!$linked) {
// Just echo the value
print $label;
$isFirstLink = false;
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion app/webroot/css/co-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,7 @@ tr.noborder td {
td.indented {
border-left: 3em solid var(--cmg-color-body-bg);
}
table.index-table tr:hover td {
tr.linked-row:hover td {
background-color: var(--cmg-color-bg-001);
cursor: pointer;
}
Expand Down