Skip to content

FOUR-25228: Create default email notification config when task is created in Modeler #8364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: story/FOUR-25224
Choose a base branch
from
Open
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
30 changes: 30 additions & 0 deletions ProcessMaker/Http/Controllers/Process/ModelerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use ProcessMaker\Package\Cdata\Http\Controllers\Api\CdataController;
use ProcessMaker\Package\PackagePmBlocks\Http\Controllers\Api\PmBlockController;
use ProcessMaker\PackageHelper;
use ProcessMaker\Models\Screen;
use ProcessMaker\Traits\HasControllerAddons;
use ProcessMaker\Traits\ProcessMapTrait;

Expand Down Expand Up @@ -125,6 +126,8 @@ public function prepareModelerData(
$process->load('alternativeInfo');
}

$defaultEmailNotification = $this->getDefaultEmailNotification();

return [
'process' => $process,
'manager' => $manager,
Expand All @@ -147,6 +150,33 @@ public function prepareModelerData(
'alternative' => $alternative,
'abPublish' => PackageHelper::isPackageInstalled('ProcessMaker\Package\PackageABTesting\PackageServiceProvider'),
'launchpad' => ProcessLaunchpad::getLaunchpad(true, $process->id),
'defaultEmailNotification' => $defaultEmailNotification,
];
}

/**
* Get the default email notification configuration for tasks
*
* Returns an array containing the default email notification settings including:
* - subject: The default email subject template
* - type: The notification type (screen)
* - screenRef: The ID of the default email notification screen
* - toRecipients: Array of default recipients (assigned user)
* @return array{screenRef: mixed, subject: string, toRecipients: array, type: string}
*/
private function getDefaultEmailNotification(): array
{
$screen = Screen::getScreenByKey('default-email-task-notification');
return [
'subject' => "RE: {{_user.fullName}} assigned you in {{taskName}}",
'type' => "screen",
'screenRef' => $screen->id,
'toRecipients' => [
[
'type' => "assignedUser",
'value' => null
]
],
];
}

Expand Down
43 changes: 30 additions & 13 deletions resources/js/processes/modeler/modelerInit.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
import { nextTick } from "vue";

export default {};

// Highlight the node when it is added
// TODO: This is a workaround to highlight the node when it is added
// because the highlightNode method is not working when the node is added
export const configureTaskNotifications = ({ modeler }) => {
modeler.$on("node-added", (node) => {
if (node.type.includes("task") && node.notifications) {
node.notifications.assignee = {
assigned: true,
completed: false,
due: true,
default: false,
modeler.$on("before-node-added", (node) => {
if (node.type.includes("task") && !node.notifications) {
node.notifications = {
assignee: {
assigned: true,
completed: false,
due: true,
default: false,
},
requester : {
assigned: false,
completed: false,
due: false,
},
participants : {
assigned: false,
completed: false,
due: false,
},
manager : {
assigned: false,
completed: false,
due: false,
},
};
}

if (node.type.includes("task") && !node.config) {
node.config = {
email_notifications: {},
};
}
modeler.clearSelection();
nextTick(() => {
modeler.highlightNode(node);
});
});
};

Expand Down
2 changes: 2 additions & 0 deletions resources/views/processes/modeler/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
},
]

window.ProcessMaker.defaultEmailNotification = @json($defaultEmailNotification);

window.ProcessMaker.multiplayer = {
broadcaster: "{{config('multiplayer.default')}}",
host: "{{config('multiplayer.url')}}",
Expand Down
Loading