Skip to content

Commit 1ff1b2c

Browse files
committed
Only remove user and group assignment rules when exporting
1 parent ccb3245 commit 1ff1b2c

4 files changed

Lines changed: 27 additions & 10 deletions

File tree

‎ProcessMaker/Jobs/ExportProcess.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ private function removeAssignedEntities()
8585
foreach ($humanTasks as $humanTask) {
8686
$tasks = $this->definitions->getElementsByTagName($humanTask);
8787
foreach ($tasks as $task) {
88-
$task->removeAttributeNS(WorkflowServiceProvider::PROCESS_MAKER_NS, 'assignment');
88+
89+
$assignment = $task->getAttributeNS(WorkflowServiceProvider::PROCESS_MAKER_NS, 'assignment');
90+
// Only remove user/group assignments
91+
if (in_array($assignment, ['user', 'group', 'user_group'])) {
92+
$task->removeAttributeNS(WorkflowServiceProvider::PROCESS_MAKER_NS, 'assignment');
93+
}
94+
8995
$task->removeAttributeNS(WorkflowServiceProvider::PROCESS_MAKER_NS, 'assignedUsers');
9096
$task->removeAttributeNS(WorkflowServiceProvider::PROCESS_MAKER_NS, 'assignedGroups');
9197
}

‎ProcessMaker/Jobs/ImportProcess.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,13 @@ private function parseAssignableTasks()
298298
foreach ($humanTasks as $humanTask) {
299299
$tasks = $this->definitions->getElementsByTagName($humanTask);
300300
foreach ($tasks as $task) {
301+
302+
$assignment = $task->getAttributeNS(WorkflowServiceProvider::PROCESS_MAKER_NS, 'assignment');
303+
// If an assignment rule is already set, do not ask to set it
304+
if ($assignment) {
305+
continue;
306+
}
307+
301308
$this->assignable->push((object)[
302309
'type' => 'task',
303310
'id' => $task->getAttribute('id'),

‎database/processes/LeaveAbsenceRequest.bpmn‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ return [
2929
<bpmn:outgoing>node_12</bpmn:outgoing>
3030
<bpmn:outgoing>node_13</bpmn:outgoing>
3131
</bpmn:exclusiveGateway>
32-
<bpmn:task id="node_5" name="Fill Request" pm:screenRef="request">
32+
<bpmn:task id="node_5" name="Fill Request" pm:screenRef="request" pm:assignment="user" pm:assignedUsers="55">
3333
<bpmn:incoming>node_12</bpmn:incoming>
3434
<bpmn:outgoing>node_16</bpmn:outgoing>
3535
</bpmn:task>
36-
<bpmn:task id="node_6" name="Approval" pm:screenRef="approve">
36+
<bpmn:task id="node_6" name="Approval" pm:screenRef="approve" pm:assignment="self_service" pm:assignedUsers="" pm:assignedGroups="5">
3737
<bpmn:incoming>node_16</bpmn:incoming>
3838
<bpmn:outgoing>node_17</bpmn:outgoing>
3939
</bpmn:task>

‎tests/Feature/Processes/ExportImportTest.php‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,6 @@ private function checkScriptRefs()
135135
*/
136136
public function testExportImportProcess()
137137
{
138-
139-
140-
$this->markTestSkipped();
141-
142-
143-
144138
// Create an admin user
145139
$adminUser = factory(User::class)->create([
146140
'username' => 'admin',
@@ -193,7 +187,7 @@ public function testExportImportProcess()
193187
// Test to ensure we can download the exported file
194188
$response = $this->webCall('GET', $response->json('url'));
195189
$response->assertStatus(200);
196-
$response->assertHeader('content-disposition', 'attachment; filename=leave_absence_request.json');
190+
$response->assertHeader('content-disposition', 'attachment; filename="Leave Absence Request.json"');
197191

198192
// Get our file contents (we have to do it this way because of
199193
// Symfony's weird response API)
@@ -235,6 +229,16 @@ public function testExportImportProcess()
235229

236230
$this->assertCount(2, $screen->category->refresh()->screens);
237231
$this->assertCount(2, $secondScreenCategory->refresh()->screens);
232+
233+
// Assert that assignments are preserved, except for user and group assignments
234+
$process = Process::where('name', 'Leave Absence Request 2')->first();
235+
$definitions = $process->getDefinitions();
236+
$ns = WorkflowServiceProvider::PROCESS_MAKER_NS;
237+
$this->assertEquals("", $definitions->findElementById('node_5')->getAttributeNS($ns, 'assignment'));
238+
$this->assertEquals("", $definitions->findElementById('node_5')->getAttributeNS($ns, 'assignedUsers'));
239+
240+
$this->assertEquals("self_service", $definitions->findElementById('node_6')->getAttributeNS($ns, 'assignment'));
241+
$this->assertEquals("", $definitions->findElementById('node_6')->getAttributeNS($ns, 'assignedGroups'));
238242
}
239243

240244
/**

0 commit comments

Comments
 (0)