Skip to content

Commit

Permalink
Improvements to Plugins index view. (CFM-297) (#104)
Browse files Browse the repository at this point in the history
* Improvements to Plugins index view. Clean up some duplicated code in Standard/index.php. (CFM-297)

* Ensure Standard/index.php produces bulk-actions checkbox and row-link classes properly. (CFM-297)
  • Loading branch information
arlen authored Jun 28, 2023
1 parent cc1a081 commit 752bd66
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 35 deletions.
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

0 comments on commit 752bd66

Please sign in to comment.