Skip to content

Commit

Permalink
Changelog and entity-metadata layout (CFM-476)
Browse files Browse the repository at this point in the history
  • Loading branch information
arlen committed Oct 31, 2025
1 parent 9830997 commit c73f768
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 159 deletions.
15 changes: 15 additions & 0 deletions app/resources/locales/en_US/information.po
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,18 @@ msgstr "Change Log"
msgid "changelog.archived"
msgstr "This is an archive record"

msgid "changelog.aria.collapsed"
msgstr "Change Log, collapsed, button, click to expand"

msgid "changelog.aria.expanded"
msgstr "Change Log, expanded, button, click to collapse"

msgid "changelog.deleted"
msgstr "This record has been deleted"

msgid "changelog.return"
msgstr "Return to parent record"

msgid "cos.none"
msgstr "You are not an active member in any collaboration. If your request for enrollment is still being processed, you will not be able to login until it is approved. Please contact an administrator for assistance."

Expand All @@ -51,9 +60,15 @@ msgstr "<a href="{0}">Platform-wide configurations</a> are available in the <a h
msgid "cmp.co.notice"
msgstr "This is the COmanage CO, which is used for platform wide <a href="{0}">configurations</a>."

msgid "entity.created"
msgstr "Created: {0}"

msgid "entity.id"
msgstr "ID: {0}"

msgid "entity.modified"
msgstr "Modified: {0}"

msgid "noattrs"
msgstr "No attributes"

Expand Down
5 changes: 3 additions & 2 deletions app/src/Lib/Enum/ApplicationStateEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
namespace App\Lib\Enum;

class ApplicationStateEnum extends StandardEnum {
const UiDrawerState = 'UD';
const SearchBlockOptions = 'SO';
const ChangeLogState = 'CL';
const PaginationLimit = 'PL';
const ProfileDarkMode = 'PM';
const ProfileDensity = 'PD';
const SearchBlockOptions = 'SO';
const VerifyEmailBlocked = 'VE';
const UiDrawerState = 'UD';
}
33 changes: 22 additions & 11 deletions app/templates/Standard/add-edit-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@
<h2><?= $title ?></h2>
<?php endif; ?>
</div>
<?php
// XXX temporary for CFM-24
$clfield = $vv_obj->changelogAttributeName();

if($vv_obj->deleted) {
print __d('information', 'changelog.deleted');
} elseif(!empty($vv_obj->$clfield)) {
print __d('information', 'changelog.archived');
}
?>
<?php
// Action list for top menu dropdown / button listing
$action_args = array();
Expand Down Expand Up @@ -190,6 +180,26 @@
<?= $this->element('flash') ?>
<?php endif; ?>

<?php
// XXX temporary for CFM-24
// XXX after merge of PR-342 pass these banners in as configuration above
$clfield = $vv_obj->changelogAttributeName();

if($vv_obj->deleted) {
print $this->element('notify/alert',
['type' => 'information',
'message' => __d('information', 'changelog.deleted'),
'dismissible ' => false]
);
} elseif(!empty($vv_obj->$clfield)) {
print $this->element('notify/alert',
['type' => 'information',
'message' => __d('information', 'changelog.archived'),
'dismissible ' => false]
);
}
?>

<?php
$linkId = null;

Expand Down Expand Up @@ -238,6 +248,7 @@
}

if($vv_action != 'add') {
// Insert changelog
// Insert object metadata and changelog
print $this->element('entityMetadata');
print $this->element('changelog');
}
233 changes: 133 additions & 100 deletions app/templates/element/changelog.php
Original file line number Diff line number Diff line change
@@ -1,108 +1,141 @@
<?php
/*
* COmanage Registry Changelog Element
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.2.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/
/*
* COmanage Registry Changelog Element
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.2.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

use App\Lib\Enum\ApplicationStateEnum;

if(empty($vv_obj)) {
return;
}

if(empty($vv_obj))
return;
// If this is an archived record, include a link to the parent (active) record
$clAttr = $vv_obj->changelogAttributeName();
$parentUrl = null;

// If this is an archived record, include a link to the parent (active) record
$clAttr = $vv_obj->changelogAttributeName();
$parentLink = null;
if(!empty($vv_obj->$clAttr)) {
$parentUrl = $this->Url->build(
['action' => 'edit', $vv_obj->$clAttr]
);
}

if(!empty($vv_obj->$clAttr)) {
$parentLink = $this->Html->link(
$vv_obj->$clAttr,
['action' => 'edit', $vv_obj->$clAttr]
);
}
// Get the change log open/closed state
$changeLogState = $this->ApplicationState->getValue(ApplicationStateEnum::ChangeLogState, '');
$changeLogStateId = $this->ApplicationState->getId(ApplicationStateEnum::ChangeLogState);

// We'll render an index of all archived records if we are the current active record,
// or just the current metadata if we are an archived record
// We'll render an index of all archived records if we are the current active record,
// or just the current metadata if we are an archived record
?>

<?= __d('information', 'changelog') ?>

<?php if(!empty($vv_archives)): // $vv_obj is an active record ?>
<div class="table-container">
<table>
<tr>
<th><?= __d('field', 'id') ?></th>
<th><?= __d('field', 'changelog.revision') ?></th>
<th><?= __d('field', 'modified') ?></th>
<th><?= __d('field', 'changelog.actor_identifier') ?></th>
</tr>
<!-- start with the current record -->
<tr>
<td><?=
// In general it's confusing to have a link back to the record currently being displayed,
// so just echo the ID without making it a link
$vv_obj->id
?></td>
<td><?= $vv_obj->revision ?></td>
<td><?= $vv_obj->modified ?></td>
<td><?= $vv_obj->actor_identifier ?></td>
</tr>
<?php foreach($vv_archives as $archive): ?>
<tr>
<td><?=
$this->Html->link(
$archive->id,
['action' => 'view', $archive->id]
)
?></td>
<td><?= $archive->revision ?></td>
<td><?= $archive->modified ?></td>
<td><?= $archive->actor_identifier ?></td>
</tr>
<?php endforeach; // $archive ?>
</table>
</div>
<?php else: // $vv_archives -- $vv_obj is an archive record ?>
<div class="table-container">
<table>
<tr>
<th><?= __d('field', 'changelog.deleted') ?></th>
<td><?= __d('enumeration', 'YesBooleanEnum.'.($vv_obj->deleted ? '1' : '0')) ?></td>
</tr>
<tr>
<th><?= __d('field', 'changelog.revision') ?></th>
<td><?= $vv_obj->revision; ?></td>
</tr>
<tr>
<th><?= __d('field', 'modified') ?></th>
<td><?= $vv_obj->modified ?></td>
</tr>
<tr>
<th><?= __d('field', 'changelog.actor_identifier') ?></th>
<td><?= $vv_obj->actor_identifier ?></td>
</tr>
<tr>
<th><?= __d('field', 'changelog.parent') ?></th>
<td><?= $parentLink ?></td>
</tr>
</table>
<div id="changelog-container" class="accordion">
<div class="accordion-item">
<h2 class="accordion-header">
<button class="accordion-button<?= $changeLogState !== 'show' ? ' collapsed' : ''?>"
type="button"
data-coid="<?= $vv_cur_co->id ?? '' ?>"
data-appstateid="<?= $changeLogStateId ?>"
data-stateattr="<?= ApplicationStateEnum::ChangeLogState?>"
data-webroot="<?= $this->request->getAttribute('webroot') ?>"
data-username="<?= $vv_user['username'] ?? '' ?>"
data-personid="<?= $vv_person_id ?? '' ?>"
data-bs-toggle="collapse"
data-bs-target="#changelog"
aria-expanded="false"
aria-controls="changelog"
aria-label="<?= $changeLogState === 'show' ?
__d('information','changelog.aria.expanded') :
__d('information','changelog.aria.collapsed')?>">
<?= __d('information', 'changelog') ?>
</button>
</h2>
<div id="changelog" class="accordion-collapse collapse <?= $changeLogState ?>" data-bs-parent="#changelog-container">
<div class="accordion-body">
<?php if(empty($vv_obj->$clAttr && !empty($vv_archives))): // $vv_obj is an active record ?>
<table>
<tr>
<th><?= __d('field', 'id') ?></th>
<th><?= __d('field', 'changelog.revision') ?></th>
<th><?= __d('field', 'modified') ?></th>
<th><?= __d('field', 'changelog.actor_identifier') ?></th>
</tr>
<!-- start with the current record -->
<tr>
<td><?=
// In general it's confusing to have a link back to the record currently being displayed,
// so just echo the ID without making it a link
$vv_obj->id
?></td>
<td><?= $vv_obj->revision ?></td>
<td><?= $vv_obj->modified ?></td>
<td><?= $vv_obj->actor_identifier ?></td>
</tr>
<?php foreach($vv_archives as $archive): ?>
<tr>
<td><?=
$this->Html->link(
$archive->id,
['action' => 'view', $archive->id]
)
?></td>
<td><?= $archive->revision ?></td>
<td><?= $archive->modified ?></td>
<td><?= $archive->actor_identifier ?></td>
</tr>
<?php endforeach; // $archive ?>
</table>
<?php else: // $vv_archives -- $vv_obj is an archive record ?>
<ul>
<li>
<div class="fieldname"><?= __d('field', 'changelog.deleted') ?></div>
<div class="fieldval"><?= __d('enumeration', 'YesBooleanEnum.' . ($vv_obj->deleted ? '1' : '0')) ?></div>
</li>
<li>
<div class="fieldname"><?= __d('field', 'changelog.revision') ?></div>
<div class="fieldval"><?= $vv_obj->revision; ?></div>
</li>
<li>
<div class="fieldname"><?= __d('field', 'changelog.actor_identifier') ?></div>
<div class="fieldval"><?= $vv_obj->actor_identifier ?></div>
</li>
<li>
<div class="fieldname"><?= __d('field', 'changelog.parent') ?></div>
<div class="fieldval">
<?php if(!empty($vv_obj->$clAttr)): ?>
<a class="changelog-parent-link" href="<?= $parentUrl ?>">
<div class="changelog-parent-id"><?= $vv_obj->$clAttr ?></div>
<div class="changelog-parent-link-button btn btn-sm btn-primary">
<?= __d('information','changelog.return') ?>
</div>
</a>
<?php endif; ?>
</div>
</li>
</ul>
<?php endif; // $vv_archives ?>
</div>
</div>
</div>
</div>
<?php endif; // $vv_archives ?>
45 changes: 45 additions & 0 deletions app/templates/element/entityMetadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
* COmanage Registry Entity Metadata Element
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry
* @since COmanage Registry v5.3.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types = 1);
?>

<?php if(isset($vv_obj?->id)): ?>
<div id="entity-metadata">
<div id="cm-entity-id">
<?= __d('information', 'entity.id', $vv_obj->id) ?>
</div>
<div id="cm-entity-created">
<?= __d('information', 'entity.created', $vv_obj->created) ?>
</div>
<?php if($vv_obj->created != $vv_obj->modified): ?>
<div id="cm-entity-modified">
<?= __d('information', 'entity.modified', $vv_obj->modified) ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
Loading

0 comments on commit c73f768

Please sign in to comment.