Skip to content

Commit

Permalink
Refactor fields.inc to be configuration only (CFM-218) (#342)
Browse files Browse the repository at this point in the history
* Refactor fields.inc to be configuration only - first pass. (CFM-218)

* Fix fields.inc for EmailVerifiers to use grouped controls. (CFM-218)

* Simplify fields.inc configuration. (CFM-218)

* Remove 'edit only' blocking statements. (CFM-218)

* Remove leftover call to jsLocalOnLoad function (CFM-218)

* Standardize fields.inc 'type' and 'options'; add arbitrary HTML field (CFM-218)

* Add 'public' keyword to new FieldHelper functions (CFM-218)

* Improve tests for COmanange CO (CFM-218)

* Refactor clonable fields for configuration-only approach (CFM-218)

* Re-label clonable fields collection as "metadata" (CFM-218)

* Improve alert banner configuration (CFM-218/CFM-465)

* Adjust Passwords/fields.inc to be configuration only and work in the standard way (CFM-218)

* Cleanup small inconsistencies (CFM-218)

* Improve restructureFieldArguments method (CFM-218)
  • Loading branch information
arlen authored Nov 22, 2025
1 parent d93aa61 commit 686b45a
Show file tree
Hide file tree
Showing 133 changed files with 3,008 additions and 4,858 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ApiSourcesTable extends Table {
use \App\Lib\Traits\PrimaryLinkTrait;
use \App\Lib\Traits\TableMetaTrait;
use \App\Lib\Traits\ValidationTrait;
use \App\Lib\Traits\TabTrait;

/**
* Perform Cake Model initialization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// This view does currently not support read-only
if($vv_action == 'edit') {
if(!empty($vv_push_endpoint)) {
print $this->element('notify/banner', [
'info' => __d('api_connector', 'information.endpoint.push', [$vv_push_endpoint])
]);
}

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'external_identity_source_id',
if(!empty($vv_push_endpoint)) {
$alerts = [
[
'type' => 'information',
'message' => __d('api_connector', 'information.endpoint.push', [$vv_push_endpoint])
]
]);
];
}

$fields = [
'external_identity_source_id'
];

This file was deleted.

19 changes: 12 additions & 7 deletions app/availableplugins/ApiConnector/templates/ApiSources/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// This view does currently not support read-only
if($vv_action == 'edit') {
print '<li class="info-title"><h3>' . __d('api_connector', 'field.ApiSources.push_mode') . '</h3></li>';
$alerts = [
[
'type' => 'information',
'message' => __d('information', 'plugin.config.none')
]
];

print $this->element('notify/banner', [
'info' => __d('information', 'plugin.config.none',)
]);
}
// XXX Revisit this - what's the "Push Mode" text attempting to convey here (with no other information)?
$fields = [
'SUBTITLE' => [
'subtitle' => __d('api_connector', 'field.ApiSources.push_mode')
]
];
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// This view does currently not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'filename',
]
]);
}
$fields = [
'filename'
];
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,10 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// This view does currently not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
foreach([
'filename',
'format',
'archivedir',
'threshold_check',
'threshold_override',
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
]
]);
}
}
$fields = [
'filename',
'format',
'archivedir',
'threshold_check',
'threshold_override',
];
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,20 @@
* @since COmanage Registry v5.2.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

$fields = [
'source_mode',
'min_length',
'max_length',
'format_crypt_php',
'format_sha1_ldap',
'format_plaintext'
];

?>
<script type="text/javascript">

<script>
// JS specific to these fields

function updateGadgets(isPageLoad) {
// Hide or show gadgets according to current state
var source = document.getElementById('source-mode').value;
Expand All @@ -49,51 +59,14 @@
}
}

function jsLocalOnLoad() {
$(function() {
// run on first load
updateGadgets(true);
}
</script>

<?php
// This view does currently not support read-only, and add is not used
if($vv_action == 'edit') {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'source_mode',
'fieldOptions' => [
'onChange' => 'updateGadgets(false)'
]
]
]);

foreach(['min_length',
'max_length'
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
]
]);
}

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'format_crypt_php',
'fieldOptions' => [
// When source is Self Select we want crypt to remain checked
// (though this will also be enforced in the backend)
'onChange' => 'updateGadgets(false)'
]
]
]);

foreach(['format_sha1_ldap',
'format_plaintext'
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
]
]);
}
}
// register onchange events
// note that underscores in field names above must be represented with hyphens here.
$('#source-mode, #format_crypt_php').change(function() {
updateGadgets();
});
});
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,37 @@

// We provide the current password status in a banner message since that's all the
// information we really want to display about a password.
$alerts = [
[
'type' => 'information',
'message' => $vv_status->comment
]
];

print $this->element('notify/banner', ['info' => $vv_status->comment]);
$fields = [];

if(!$vv_status->locked) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'password',
$fields = [
'password',
'password2' => [
'type' => 'password'
]
]);
];
// Inject the parent keys
$hidden = [
'password_authenticator_id' => $vv_authenticator->password_authenticator->id,
'person_id' => $vv_status->person_id
];
} else {
$suppress_submit = true;
}

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'password2',
'fieldOptions' => [
'type' => 'password'
]
]
]);
}
$topLinks[] = [
'icon' => 'history',
'order' => 'Default',
'label' => __d('operation', 'reset'),
'link' => [
'controller' => 'authenticators',
'action' => 'reset',
]
];

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,18 @@

// There are currently no directly configurable fields for this model.)
$suppress_submit = true;
?>

// Top Links
$topLinks[] = [
'icon' => 'transform',
'order' => 'Default',
'label' => __d('pipeline_toolkit', 'controller.LoginIdentifierTypes', [99]),
'link' => [
'plugin' => 'PipelineToolkit',
'controller' => 'LoginIdentifierTypes',
'action' => 'index',
'identifier_mapper_id' => $vv_obj->id
],
'class' => ''
];
?>
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

// This view does not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
foreach (['type_id',
'login'
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field
]]);
}
}
$fields = [
'type_id',
'login'
];
Loading

0 comments on commit 686b45a

Please sign in to comment.