Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
UI updates for Message Templates (CFM-390) (#199)
* Add Message Templates to menu panels (CFM-390)

* Show hide message template body fields based on format (CFM-390)
arlen committed May 10, 2024
1 parent 80ef878 commit b26eba9
Showing 3 changed files with 64 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/src/Controller/DashboardsController.php
@@ -103,7 +103,7 @@ public function configuration() {
'action' => 'index'
],
__d('controller', 'MessageTemplates', [99]) => [
'icon' => 'message',
'icon' => 'email',
'controller' => 'message_templates',
'action' => 'index'
],
45 changes: 42 additions & 3 deletions app/templates/MessageTemplates/fields.inc
@@ -25,18 +25,57 @@
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/
?>

<script>
// JS specific to these fields

function updateGadgets(isPageLoad) {
// Hide or show gadgets according to current state
var format = document.getElementById('format').value;

if(format == '<?= \App\Lib\Enum\MessageFormatEnum::HTML ?>') {
hideFields(['body-text'], isPageLoad);
showFields(['body-html'], isPageLoad);
} else if(format == '<?= \App\Lib\Enum\MessageFormatEnum::PlainText ?>') {
hideFields(['body-html'], isPageLoad);
showFields(['body-text'], isPageLoad);
} else {
showFields(['body-html','body-text'], isPageLoad);
}
}

function jsLocalOnLoad() {
updateGadgets(true);
}
</script>

<?php
// This view does not support read-only
if($vv_action == 'add' || $vv_action == 'edit') {
foreach ([
'description',
'status',
'context',
'format',
] as $field) {
print $this->element('form/listItem', [
'arguments' => [
'fieldName' => $field
]]);
}

print $this->element('form/listItem', [
'arguments' => [
'fieldName' => 'format',
'fieldOptions' => [
'onChange' => 'updateGadgets()'
],
'fieldType' => 'select'
]
]);

foreach ([
'subject',
// XXX auto show/hide based on format
'body_text',
// XXX auto show/hide based on format
'body_html',
'cc',
'bcc',
26 changes: 21 additions & 5 deletions app/templates/element/menuPanel.php
@@ -434,16 +434,16 @@
?>
<a href="<?= $menuUrl ?>">
<em class="material-icons" aria-hidden="true">widgets</em>
Types
<span class="menu-panel-link-text"><?= __d('controller', 'Types', [99]) ?></span>
</a>
</li>
</ul>
</li>
</ul>

<?php /* XXX The "Personalization" links are disabled until needed, but we will leave them in the code to
<?php /* XXX Most "Personalization" links are disabled until needed, but we will leave them in the code to
provide hints to where they belong. The description ('co.configuration.panel.personalization.desc')
reads "Dashboards, custom text, and theming". When such things are ready, place them here.
reads "Dashboards, custom text, and theming". When such things are ready, place them here. */ ?>

<ul class="menu-panel-links">
<li>
@@ -455,8 +455,24 @@
<li><a href="#"><em class="material-icons" aria-hidden="true">navigation</em> CO Navigation Links</a></li>
<li><a href="#"><em class="material-icons" aria-hidden="true">dashboard</em> Dashboards</a></li>
<li><a href="#"><em class="material-icons" aria-hidden="true">book</em> Dictionaries</a></li>
<li><a href="#"><em class="material-icons" aria-hidden="true">translate</em> Localizations</a></li>
<li><a href="#"><em class="material-icons" aria-hidden="true">email</em> Message Templates</a></li>
<li><a href="#"><em class="material-icons" aria-hidden="true">translate</em> Localizations</a></li> */ ?>
<li>
<?php
$menuUrl = $this->Url->build(
['plugin' => null,
'controller' => 'message_templates',
'action' => 'index',
'?' => [
'co_id' => $vv_cur_co->id
]]
);
?>
<a href="<?= $menuUrl ?>">
<em class="material-icons" aria-hidden="true">email</em>
<span class="menu-panel-link-text"><?= __d('controller', 'MessageTemplates', [99]) ?></span>
</a>
</li>
<?php /* More placeholders:
<li><a href="#"><em class="material-icons" aria-hidden="true">room_service</em> Self Service Permissions</a></li>
<li><a href="#"><em class="material-icons" aria-hidden="true">wallpaper</em> Themes</a></li>
* / ? >

0 comments on commit b26eba9

Please sign in to comment.