Skip to content

Commit

Permalink
Available plugins.Alert to element.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Apr 28, 2024
1 parent 2e1efb2 commit d850be8
Show file tree
Hide file tree
Showing 27 changed files with 221 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected function mapApiToRegistry(string $model, array $attributes): array {
*/

public function remove(
\App\Model\Entity\ExternalIdentitySource $source,
\App\Model\Entity\ExternalIdentitySource $source,
string $sorId
): array {
// We call this remove() so as not to interfere with the default table::delete().
Expand Down Expand Up @@ -293,7 +293,7 @@ protected function resultToEntityData(array $result): array {
*/

public function retrieve(
\App\Model\Entity\ExternalIdentitySource $source,
\App\Model\Entity\ExternalIdentitySource $source,
string $source_key
): array {
$ret = [
Expand Down Expand Up @@ -328,7 +328,7 @@ public function retrieve(
*/

public function search(
\App\Model\Entity\ExternalIdentitySource $source,
\App\Model\Entity\ExternalIdentitySource $source,
array $searchAttrs
): array {
$ret = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ if($vv_action == 'add' || $vv_action == 'edit') {

print '<li class="info-title"><h3>' . __d('api_connector', 'field.ApiSources.push_mode') . '</h3></li>';

print $this->Field->banner(__d('api_connector', 'information.endpoint.push', [$vv_push_endpoint]));
print $this->element('banner', [
'info' => __d('api_connector', 'information.endpoint.push', [$vv_push_endpoint])
]);

print $this->Field->control('api_user_id');

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'api_user_id',
]
]);

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@

// This view does currently not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
print $this->Field->control('filename');
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'filename',
]
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@

// This view does currently not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
print $this->Field->control('filename');

print $this->Field->control('format');

print $this->Field->control('archivedir');

print $this->Field->control('threshold_warn');

print $this->Field->control('threshold_override');
foreach([
'filename',
'format',
'archivedir',
'threshold_warn',
'threshold_override',
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field,
]
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,18 @@

// This view does currently not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
print $this->Field->control('server_id');

print $this->Field->control('table_prefix', ['default' => 'sp_']);
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'server_id',
]
]);

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'table_prefix',
'options' => [
'default' => 'sp_'
]
]
]);
}
53 changes: 7 additions & 46 deletions app/src/View/Helper/AlertHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,52 +45,13 @@
* @since COmanage Registry v5.0.0
*/
class AlertHelper extends Helper {

public $helpers = ['Html'];

public function alert(
string $message,
string $type = 'warning',
bool $dismissable = false,
string $title = null ) {

$closeButton = '';
$dismissableClass = '';
if($dismissable) {
$closeButton = '
<span class="alert-button">
<button type="button" class="btn-close nospin" data-bs-dismiss="alert" aria-label="Close"></button>
</span>
';
$dismissableClass = ' alert-dismissible';
}

$titleMarkup = '';
if(!empty($title)) {
$titleMarkup = '<span class="alert-title-text">' . $title . '</span>';
}

return '
<div class="alert alert-' . $type . $dismissableClass . ' co-alert" role="alert">
<div class="alert-body d-flex align-items-center">
<span class="alert-title d-flex align-items-center">
' . $this->getAlertIcon($type) . $titleMarkup . '
</span>
<span class="alert-message">
' . $message . '
</span>
' . $closeButton . '
</div>
</div>
';
}

public function getAlertIcon(string $type) {
switch($type) {
case('success'): return '<span class="material-icons-outlined alert-icon">check_circle</span>';
case('information'): return '<span class="material-icons-outlined alert-icon">info</span>';
default: return '<span class="material-icons-outlined alert-icon">report_problem</span>';
}
public function getAlertIcon(string $type): string
{
return match($type) {
'success' => 'check_circle',
'information' => 'info',
default => 'report_problem'
};
}

}
34 changes: 17 additions & 17 deletions app/src/View/Helper/FieeldHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,39 +273,39 @@ public function dateField(string $fieldName,
/**
* Create the actual Form element
*
* @param string $fieldName Form field
* @param array|null $options FormHelper control options
* @param string|null $labelText
* @param string $prefix Field prefix - used for API Usernames
* @param string|null $fieldType
* @param string $fieldName Form field
* @param array|null $fieldOptions The second parameter of the Form->control helper. List of element options
* @param string|null $fieldLabel Custom label thext
* @param string $fieldPrefix If the field has a specil prefix provide the value
* @param string|null $fieldType Field type to override the one calculated from the schema
*
* @return string HTML element
* @since COmanage Registry v5.0.0
*/
public function formField(string $fieldName,
array $options = null,
string $labelText = null,
string $prefix = '', // api user
array $fieldOptions = null,
string $fieldLabel = null,
string $fieldPrefix = '',
string $fieldType = null): string
{
$fieldArgs = $options ?? [];
$fieldArgs['label'] = $options['label'] ?? false;
$fieldArgs = $fieldOptions ?? [];
$fieldArgs['label'] = $fieldOptions['label'] ?? false;
$fieldArgs['readonly'] = !$this->editable
|| (isset($options['readonly']) && $options['readonly'])
|| (isset($fieldOptions['readonly']) && $fieldOptions['readonly'])
|| ($fieldName == 'plugin' && $this->action == 'edit');

// Selects, Checkboxes, and Radio Buttons use "disabled"
$fieldArgs['disabled'] = $fieldArgs['readonly'];
$fieldArgs['required'] = (bool)$this->isReqField($fieldName);
$fieldArgs['required'] = $this->isReqField($fieldName);

// Get the field type from the map of fields (e.g. 'boolean', 'string', 'timestamp')
$fieldType = $fieldType ?? $this->getFieldType($fieldName);

// Remove prefix from field value
if(!empty($prefix) && !empty($this->getEntity()->$fieldName)) {
if(!empty($fieldPrefix) && !empty($this->getEntity()->$fieldName)) {
$vv_obj = $this->getView()->get('vv_obj');
$fieldValue = $vv_obj->$fieldName;
$fieldValueTemp = str_replace($prefix, '', $fieldValue);
$fieldValueTemp = str_replace($fieldPrefix, '', $fieldValue);
$vv_obj->$fieldName = $fieldValueTemp;
$this->getView()->set('vv_obj', $vv_obj);
}
Expand All @@ -315,16 +315,16 @@ public function formField(string $fieldName,
// Note this will be ignored for non-select controls.
if(\in_array($fieldName, ['status', 'sync_status_on_delete'], true)) {
$fieldArgs['empty'] = false;
} elseif(isset($options['empty'])) {
$fieldArgs['empty'] = $options['empty'];
} elseif(isset($fieldOptions['empty'])) {
$fieldArgs['empty'] = $fieldOptions['empty'];
} else {
$fieldArgs['empty'] = true;
}

// A boolean field is a checkbox. Set the label and class to improve rendering
// and accessibility.
if($fieldType === 'boolean') {
$fieldArgs['label'] = $labelText;
$fieldArgs['label'] = $fieldLabel;
$fieldArgs['class'] = 'form-check-input';
} elseif($fieldType === 'date') {
return $this->dateField($fieldName, DateTypeEnum::DateOnly);
Expand Down
2 changes: 1 addition & 1 deletion app/templates/ApiUsers/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
// This view does not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
if($vv_cur_co->id == 1) {
print $this->element('banner', __d('information', 'api.cmp'));
print $this->element('banner', ['info' => __d('information', 'api.cmp')]);
}

// AR-ApiUser-3 For namespacing purposes, API Users are named with a prefix consisting of the string "co_#.".
Expand Down
2 changes: 1 addition & 1 deletion app/templates/Cos/select.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</div>

<?php if(count($vv_available_cos) == 0): ?>
<?= $this->Alert->alert(__d('information','cos.none'), 'warning') ?>
<?= $this->element('notify/alert', ['message' => __d('information','cos.none')]) ?>
<?php else: // vv_available_cos ?>
<p><?= __d('information', 'cos.select'); ?></p>
<div id="fpList" class="co-grid co-grid-with-header container">
Expand Down
6 changes: 5 additions & 1 deletion app/templates/Dashboards/configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@
];
?>
<div class="config-platform-notice">
<?= $this->Alert->alert(__d('information','cmp.config.notice', $noticeUrls), 'information', true) ?>
<?= $this->element('notify/alert', [
'message' => __d('information','cmp.config.notice', $noticeUrls),
'type' => 'information',
'dismissible' => true
]) ?>
</div>
<?php endif; ?>
4 changes: 2 additions & 2 deletions app/templates/Dashboards/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@

<?php if(!empty($indexBanners)): ?>
<?php foreach($indexBanners as $b): ?>
<?= $this->Alert->alert($b, 'warning') ?>
<?= $this->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $indexBanners ?>
<?php endif; // $indexBanners ?>

<?php if(!empty($banners)): ?>
<?php foreach($banners as $b): ?>
<?= $this->Alert->alert($b, 'warning') ?>
<?= $this->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $banners ?>
<?php endif; // $banners ?>
</div>
Expand Down
5 changes: 4 additions & 1 deletion app/templates/ExtIdentitySourceRecords/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ $noticeText = __d(
]
);

print $this->Alert->alert($noticeText, 'information', false);
print $this->element('notify/alert', [
'message' => $noticeText,
'type' => 'information'
]);

// This view does not support add or edit
if($vv_action == 'view') {
Expand Down
8 changes: 6 additions & 2 deletions app/templates/ExternalIdentities/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ if($vv_action == 'add' || $vv_action == 'edit' || $vv_action == 'view') {
)
]
);

print $this->Alert->alert($noticeText, 'information', false);

$this->element('notify/alert', [
'message' => $noticeText,
'type' => 'information'
]);

}

print $this->element('form/listItem', [
Expand Down
3 changes: 1 addition & 2 deletions app/templates/ExternalIdentitySources/retrieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@
);
}
?>
<?= $this->Alert->alert($noticeText, 'information', false) ?>

<?= $this->element('notify/alert', ['message' => $noticeText,'type' => 'information']) ?>
<div class="innerContent">
<div class="table-container">
<h3><?= __d('information','ExternalIdentitySourceRecords.metadata') ?></h3>
Expand Down
5 changes: 4 additions & 1 deletion app/templates/ExternalIdentitySources/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
</div>

<?php if(empty($vv_search_attrs)): ?>
<?= $this->Alert->alert(__d('information', 'ExternalIdentitySources.search.attrs.none'), 'information', false) ?>
<?= $this->element('notify/alert', [
'message' => __d('information', 'ExternalIdentitySources.search.attrs.none'),
'type' => 'information'
]) ?>
<?php else: // vv_search_attrs ?>
<?php
// Begin the form
Expand Down
4 changes: 2 additions & 2 deletions app/templates/ProvisioningTargets/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@

<?php if(!empty($indexBanners)): ?>
<?php foreach($indexBanners as $b): ?>
<?= $this->Alert->alert($b, 'warning') ?>
<?= $this->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $indexBanners ?>
<?php endif; // $indexBanners ?>

<?php if(!empty($banners)): ?>
<?php foreach($banners as $b): ?>
<?= $this->Alert->alert($b, 'warning') ?>
<?= $this->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $banners ?>
<?php endif; // $banners ?>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/element/filter/dateTimeFilters.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
<?php
// Create a text field to hold our value.
print $this->Form->label("{$key}_starts_at", __d('field', 'starts_at'), ['class' => 'filter-datepicker-lbl']);
print $this->Field->dateField("{$key}_starts_at", DateTypeEnum::DateOnly, $query)['controlCode'];
print $this->Fieeld->dateField("{$key}_starts_at", DateTypeEnum::DateOnly, $query);
?>
</div>
<!-- Ends at -->
<div class="top-search-end-date">
<?php
// Create a text field to hold our value.
print $this->Form->label("{$key}_ends_at", __d('field','ends_at'), ['class' => 'filter-datepicker-lbl']);
print $this->Field->dateField("{$key}_ends_at", DateTypeEnum::DateOnly, $query)['controlCode'];
print $this->Fieeld->dateField("{$key}_ends_at", DateTypeEnum::DateOnly, $query);
?>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/templates/element/flash.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@

<?php if(!empty($vv_index_banners)): ?>
<?php foreach($vv_index_banners as $b): ?>
<?= $this->Alert->alert($b, 'warning') ?>
<?= $this->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $vv_index_banners ?>
<?php endif; // $vv_index_banners ?>

<?php if(!empty($vv_banners)): ?>
<?php foreach($vv_banners as $b): ?>
<?= $this->Alert->alert($b, 'warning') ?>
<?= $this->element('notify/alert', ['message' => $b]) ?>
<?php endforeach; // $vv_banners ?>
<?php endif; // $vv_banners ?>
</div>
2 changes: 1 addition & 1 deletion app/templates/element/flash/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<?php /* CFM-221: while a prefix such as "Error: " or "Success: " can be sent with the Alert,
we avoid prefixes to better support LTR languages. Prefixes, if desired, should be included
directly in the language strings instead. */ ?>
<?= $this->Alert->alert($message, 'warning', true) ?>
<?= $this->element('notify/alert', ['message' => $message]) ?>
<?php endif; ?>

Loading

0 comments on commit d850be8

Please sign in to comment.