From 752bd66c21d4e91fa018ee3a59b9d68ea6a9751b Mon Sep 17 00:00:00 2001 From: Arlen Johnson Date: Wed, 28 Jun 2023 12:28:50 -0400 Subject: [PATCH] Improvements to Plugins index view. (CFM-297) (#104) * 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) --- app/src/Controller/PluginsController.php | 21 ++++++++++++ app/templates/Standard/index.php | 41 ++++-------------------- app/webroot/css/co-base.css | 2 +- 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/app/src/Controller/PluginsController.php b/app/src/Controller/PluginsController.php index 3d6d0ce7c..c8255cab6 100644 --- a/app/src/Controller/PluginsController.php +++ b/app/src/Controller/PluginsController.php @@ -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. diff --git a/app/templates/Standard/index.php b/app/templates/Standard/index.php index ac931a4db..84d2fff99 100644 --- a/app/templates/Standard/index.php +++ b/app/templates/Standard/index.php @@ -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) { @@ -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': @@ -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') { @@ -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) { @@ -579,6 +551,7 @@ if(!$linked) { // Just echo the value print $label; + $isFirstLink = false; } break; } diff --git a/app/webroot/css/co-base.css b/app/webroot/css/co-base.css index 73c6d8b99..d34afc39e 100644 --- a/app/webroot/css/co-base.css +++ b/app/webroot/css/co-base.css @@ -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; }