Skip to content

UI updates for Message Templates (CFM-390) #199

Merged
merged 2 commits into from
May 10, 2024
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
2 changes: 1 addition & 1 deletion app/src/Controller/DashboardsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function configuration() {
'action' => 'index'
],
__d('controller', 'MessageTemplates', [99]) => [
'icon' => 'message',
'icon' => 'email',
'controller' => 'message_templates',
'action' => 'index'
],
Expand Down
45 changes: 42 additions & 3 deletions app/templates/MessageTemplates/fields.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
26 changes: 21 additions & 5 deletions app/templates/element/menuPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
* / ? >
Expand Down