Skip to content

Commit

Permalink
Initial theming commit to bring colors and certain JavaScript behavio…
Browse files Browse the repository at this point in the history
…rs up-to-date. This moves the front-end to Boostrap and merges in many of the latest features from Match 1.0. (CFM-55)
  • Loading branch information
arlen committed Jan 3, 2022
1 parent c0661db commit a1aad0d
Show file tree
Hide file tree
Showing 22 changed files with 1,816 additions and 1,914 deletions.
4 changes: 2 additions & 2 deletions app/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ root = true
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
insert_final_newline = false
trim_trailing_whitespace = false

[*.bat]
end_of_line = crlf
Expand Down
9 changes: 9 additions & 0 deletions app/resources/locales/en_US/information.po
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,14 @@ msgstr "API Users created in the COmanage CO are given full privileges to all Re
msgid "api.key"
msgstr "This newly generated API Key cannot be recovered. If it is lost a new key must be generated."

msgid "cos.none"
msgstr "No collaborations (COs) yet exist. Please have an administrator create one."

msgid "cos.select"
msgstr "Please select the collaboration (CO) you wish to manage."

msgid "pagination.format"
msgstr "Page {{page}} of {{pages}}, Viewing {{start}}-{{end}} of {{count}}"

msgid "records.none"
msgstr "There are no records to display."
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/menu.po
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ msgstr "Configuration"
msgid "co.people"
msgstr "People"

msgid "co.platform"
msgstr "Platform"

msgid "co.switch"
msgstr "Switch Collaboration"
6 changes: 4 additions & 2 deletions app/src/Controller/Component/RegistryAuthComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,10 @@ public function getAuthenticatedUser() {

public function getMenuPermissions() {
$permissions = [];

// XXX need to set permissions according to current user's roles

// XXX need to set permissions according to current user's roles
$permissions['platform'] = true;

// Can access the Configuration Dashboard for the current CO
$permissions['configuration'] = true;

Expand Down
49 changes: 24 additions & 25 deletions app/templates/Cos/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,45 @@
// XXX See registry/app/View/Pages/home.ctp for various error messages we should
// render based on the user's state, include op.home.no.collabs if empty
?>
<div class="titleNavContainer">
<div class="pageTitle">
<h1><?= __('registry.home.collab'); ?></h1>
</div>
</div>

<div id="fpDashboard">
<!-- XXX add lastlogin from registry/app/View/Pages/home.ctp -->

<h2><?= __('registry.home.collab'); ?></h2>
<!-- XXX color of div has switched from blue to gray, do we care? -->
<div id="fpCoList" class="co-grid co-grid-with-header mdl-shadow--2dp">
<div class="mdl-grid co-grid-header">
<div class="mdl-cell mdl-cell--6-col"><?= __d('field', 'name'); ?></div>
<div class="mdl-cell mdl-cell--6-col"><?= __d('field', 'description'); ?></div>
<?php if(count($vv_available_cos) == 0): ?>
<div class="co-info-topbox">
<em class="material-icons">info</em>
<?= __d('information','cos.none'); ?>
</div>
<?php else: // vv_available_cos ?>
<p><?= __d('information', 'cos.select'); ?></p>
<div id="fpList" class="co-grid co-grid-with-header container">
<div class="co-grid-header row">
<div class="col"><?= __d('field', 'name'); ?></div>
<div class="col"><?= __d('field', 'description'); ?></div>
</div>

<?php foreach($vv_available_cos as $co): ?>
<div class="mdl-grid co-row spin">
<div class="mdl-cell mdl-cell--6-col collab-name">
<div class="row co-row linked-row spin">
<div class=col collab-name">
<?= $this->Html->link(
// XXX do we need filter_var?
// XXX do we need filter_var? -- Yes -- should sanitize
$co->name,
['plugin' => null,
'controller' => 'dashboards',
'action' => 'dashboard',
'?' => [
'co_id' => $co->id
]],
['class' => 'co-link']
['class' => 'row-link']
); ?>
</div>
<div class="mdl-cell mdl-cell--6-col collab-desc">
<!-- XXX need to add "Not a Member" tag, maybe as a separate column instead of part of the link -->
<div class="col collab-desc">
<!-- XXX need to add "Not a Member" tag, maybe as a separate column instead of part of the link -->
<?= filter_var($co->description, FILTER_SANITIZE_SPECIAL_CHARS); ?>
</div>
</div>
<?php endforeach; // vv_available_cos ?>
</div>
</div>
<!-- Allow the whole div to be clicked: -->
<script type="text/javascript">
$(function() {
$("#fpCoList .co-row").click(function () {
location.href = $(this).find(".collab-name > a.co-link").attr('href');
});
});
</script>
<?php endif; ?>
130 changes: 89 additions & 41 deletions app/templates/Standard/index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* COmanage Registry Standard Index Template
* COmanage Standard Index Template
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
Expand Down Expand Up @@ -40,6 +40,10 @@
// XXX backport to match?
$tableName = \Cake\Utility\Inflector::tableize(\Cake\Utility\Inflector::singularize($this->name));

// Do we have records for this index? This will be set to true during render if we do.
// Otherwise, we'll print out a "no records" message.
$recordsExist = false;

// Our default link actions, in order of preference, unless the column config overrides it
$linkActions = ['edit', 'view'];

Expand All @@ -57,26 +61,26 @@ function _column_key($modelsName, $c, $tz=null) {
if(strpos($c, "_id", strlen($c)-3)) {
// Key is of the form field_id, use .ct label instead
$k = \Cake\Utility\Inflector::classify(\Cake\Utility\Inflector::pluralize(substr($c, 0, strlen($c)-3)));

return __d('controller' ,$k, [1]);
}

// Look for a model specific key first
$label = __d('field', $modelsName.'.'.$c);

if($label != $modelsName.'.'.$c) {
return $label;
}

if($tz) {
// If there is a timezone aware label, use that
$label = __d('field', $c.'.tz', [$tz]);

if($label != $c.'.tz') {
return $label;
}
}

// Otherwise look for the general key
return __d('field', $c);
}
Expand All @@ -85,23 +89,11 @@ function _column_key($modelsName, $c, $tz=null) {
<div class="pageTitle">
<h1><?= $vv_title; ?></h1>
</div>

<?php
if(!empty($banners)) {
foreach($banners as $b): ?>
<div class="co-info-topbox">
<em class="material-icons">info</em>
<?php print $b; ?>
</div>
<?php endforeach; // $banners
}
?>

<?php if($vv_permissions['add']): ?>
<ul id="topLinks">
<li>
<?php print $this->Html->link(
'<em class="material-icons" aria-hidden="true">add_circle</em> ' .
<?= $this->Html->link('<em class="material-icons" aria-hidden="true">add_circle</em> ' .
__d('operation', 'add.a', __d('controller', $modelsName, [1])),
['action' => 'add', '?' => $linkFilter],
['escape' => false]); ?>
Expand All @@ -116,13 +108,12 @@ function _column_key($modelsName, $c, $tz=null) {
} else {
$t['link']['?'] = $linkFilter;
}

print '
<li>' .

print '<li>' .
$this->Html->link(
'<em class="material-icons" aria-hidden="true">' . $t['icon']. '</em> ' . $t['label'],
$t['link'],
['escape' => false]
['escape' => false, 'class' => $t['class']]
) . '
</li>';
}
Expand All @@ -133,18 +124,34 @@ function _column_key($modelsName, $c, $tz=null) {
<?php endif; ?>
</div>
<?php if(!empty($indexBanners)): ?>
<?php foreach($indexBanners as $b): ?>
<div class="co-info-topbox">
<em class="material-icons">info</em>
<?php print $b; ?>
</div>
<?php endforeach; // $indexBanners ?>
<?php foreach($indexBanners as $b): ?>
<div class="co-info-topbox">
<em class="material-icons">info</em>
<?= $b; ?>
</div>
<?php endforeach; // $indexBanners ?>
<?php endif; // $indexBanners ?>

<?php if(!empty($banners)): ?>
<?php foreach($banners as $b): ?>
<div class="co-info-topbox">
<em class="material-icons">info</em>
<?= $b; ?>
</div>
<?php endforeach; // $banners ?>
<?php endif; // $banners ?>

<!-- Search block -->
<?php if(!empty($enableSearch)): ?>
<?= $this->element('search'); ?>
<?php endif; // $enableSearch ?>

<!-- Index table -->
<div class="table-container">
<table id="<?= $tableName . '-table'; ?>">
<tr>
<?php foreach($indexColumns as $col => $cfg): ?>
<th>
<th<?= !empty($cfg['cssClass']) ? ' class="' . $cfg['cssClass'] . '"' : ''; ?>>
<?php
$label = !empty($cfg['label']) ? $cfg['label'] : _column_key($modelsName, $col, $vv_tz);

Expand All @@ -165,7 +172,7 @@ function _column_key($modelsName, $c, $tz=null) {
<?php foreach($$tableName as $entity): ?>
<tr>
<?php foreach($indexColumns as $col => $cfg): ?>
<td>
<td<?= !empty($cfg['cssClass']) ? ' class="' . $cfg['cssClass'] . '"' : ''; ?>>
<?php
switch($cfg['type']) {
case 'boolean':
Expand All @@ -180,6 +187,7 @@ function _column_key($modelsName, $c, $tz=null) {
break;
case 'enum':
if($entity->$col) {
// XXX Need to add badging - see index.php in Match
print __d('enumeration', $cfg['class'].'.'.$entity->$col);
}
break;
Expand All @@ -189,7 +197,7 @@ function _column_key($modelsName, $c, $tz=null) {
$f = null;
if(preg_match('/^(.*?)_id$/', $col, $f)) {
$avv = \Cake\Utility\Inflector::variable(\Cake\Utility\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
Expand All @@ -203,34 +211,67 @@ function _column_key($modelsName, $c, $tz=null) {
print $entity->$col;
}
break;
case 'button':
if(!empty($entity->$col)) {
$buttonAttrs = [];
$buttonText = $entity->$col;
if(!empty($cfg['button']['attrs'])) {
$buttonAttrs = $cfg['button']['attrs'];
}
$buttonAttrs['type'] = 'button';
if(!empty($cfg['button']['text']) && $cfg['button']['text'] != 'fieldVal') {
$buttonText = $cfg['button']['text'];
}
if(!empty($cfg['truncate']) && is_int($cfg['truncate'])) {
// We check for $truncate + 1 because there's no point trimming
// the last character if we're just going to replace it with ...
$buttonText = (strlen($buttonText) > $cfg['truncate'] + 1) ? substr($buttonText,0,$cfg['truncate']).'...' : $buttonText;
}
if(!empty($cfg['button']['popover'])) {
if($cfg['button']['popover'] == 'fieldVal') {
$buttonAttrs['data-bs-content'] = $entity->$col;
} else {
$buttonAttrs['data-bs-content'] = $cfg['button']['popover'];
}
$label = !empty($cfg['label']) ? $cfg['label'] : _column_key($modelsName, $col, $vv_tz);
$buttonAttrs['title'] = $label;
$buttonAttrs['data-bs-toggle'] = 'popover';
$buttonAttrs['data-bs-container'] = 'body';
$buttonAttrs['data-bs-placement'] = 'top';
$buttonAttrs['data-bs-animation'] = 'false';
}
print $this->Form->button($buttonText, $buttonAttrs);
}
break;
case 'link':
case 'echo':
default:
// By default our label is the column value, but it might be overridden
$label = $entity->$col;

if(!empty($cfg['model']) && !empty($cfg['field'])) {
$m = $cfg['model'];
$f = $cfg['field'];

if(!empty($entity->$m->$f)) {
$label = $entity->$m->$f;
}
}

$linked = false;

if($cfg['type'] == 'link') {
foreach($linkActions as $a) {
// Does this user have permission for this action?
if($vv_permission_set[$entity->id][$a]) {
// XXX Check this against Match
print $this->Html->link($label, ['action' => $a, $entity->id]);
$linked = true;
break 2;
}
}
}

if(!$linked) {
// Just echo the value
print $label;
Expand All @@ -241,8 +282,10 @@ function _column_key($modelsName, $c, $tz=null) {
?>
</td>
<?php endforeach; // $indexColumns ?>
<td>
<td class="actions">
<?php

// XXX Convert this to use the actionMenu element as in Match 1.0
if($vv_permission_set[$entity->id]['edit']) {
print $this->Html->link(
__d('operation', 'edit'),
Expand All @@ -269,8 +312,9 @@ function _column_key($modelsName, $c, $tz=null) {
);
}

// Insert additional actions as per the .inc file
// XXX Check all this against Match 1.0 (which should be newer)
if(!empty($indexActions)) {
// Insert additional actions as per the .inc file

// XXX this isn't quite the right test
// if(isset($entity->status) && $entity->status == StatusEnum::Active) {
Expand Down Expand Up @@ -305,9 +349,13 @@ function _column_key($modelsName, $c, $tz=null) {
?>
</td>
</tr>
<?php $recordsExist = true; ?>
<?php endforeach; // $$tablename ?>
<?php if(!$recordsExist): ?>
<tr><td colspan="<?= count($indexColumns); ?>"><?= __d('information','records.none') ?></td></tr>
<?php endif; ?>
</table>
</div>

<?php
print $this->element("pagination");
print $this->element("pagination");
Loading

0 comments on commit a1aad0d

Please sign in to comment.