Skip to content

Changelog and entity-metadata layout (CFM-476) #349

Merged
merged 3 commits into from
Nov 12, 2025
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
9 changes: 9 additions & 0 deletions app/resources/locales/en_US/field.po
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ msgstr "Country Code"
msgid "created"
msgstr "Created"

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

msgid "cri"
msgstr "Change Request Identifier"

Expand Down Expand Up @@ -155,6 +158,9 @@ msgstr "Frozen"
msgid "id"
msgstr "ID"

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

msgid "item"
msgstr "Item"

Expand Down Expand Up @@ -221,6 +227,9 @@ msgstr "Modifiable"
msgid "modified"
msgstr "Modified"

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

msgid "name"
msgstr "Name"

Expand Down
11 changes: 7 additions & 4 deletions app/resources/locales/en_US/information.po
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@ msgid "api.key"
msgstr "This newly generated API Key cannot be recovered. If it is lost a new key must be generated."

msgid "changelog"
msgstr "Change Log"
msgstr "Changelog"

msgid "changelog.archived"
msgstr "This is an archive record"

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

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

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

Expand All @@ -51,9 +57,6 @@ 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.id"
msgstr "ID: {0}"

msgid "noattrs"
msgstr "No attributes"

Expand Down
5 changes: 4 additions & 1 deletion app/resources/locales/en_US/operation.po
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ msgid "cancel"
msgstr "Cancel"

msgid "changelog.view"
msgstr "View Change Log"
msgstr "View Changelog"

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

msgid "clear"
msgstr "Clear"
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 archive 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 changelog 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 archive records if we are the current active record,
// or just the current metadata if we are an archive 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('operation','changelog.return') ?>
</div>
</a>
<?php endif; ?>
</div>
</li>
</ul>
<?php endif; // $vv_archives ?>
</div>
</div>
</div>
</div>
<?php endif; // $vv_archives ?>
Loading