Skip to content

Commit 95d4a5f

Browse files
authored
Merge pull request #5721 from ProcessMaker/feature/FOUR-12577
FOUR-12577 Request Title Configuration.
2 parents 04eb225 + a7576b5 commit 95d4a5f

File tree

11 files changed

+121
-8
lines changed

11 files changed

+121
-8
lines changed

ProcessMaker/Http/Controllers/Api/ProcessController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class ProcessController extends Controller
4747
public $doNotSanitize = [
4848
'bpmn',
4949
'svg',
50+
'case_title',
5051
];
5152

5253
/**

ProcessMaker/Models/MustacheExpressionEvaluator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function __construct()
2323
* is returned
2424
*
2525
* @param string $template
26-
* @param string $data
26+
* @param array $data
2727
* @return string
2828
*/
2929
public function render($template, $data)

ProcessMaker/Models/Process.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
* @property string $bpmn
5959
* @property string $description
6060
* @property string $name
61+
* @property string $case_title
6162
* @property string $status
6263
* @property array $start_events
6364
* @property int $manager_id
@@ -68,6 +69,7 @@
6869
* schema="ProcessEditable",
6970
* @OA\Property(property="process_category_id", type="integer", format="id"),
7071
* @OA\Property(property="name", type="string"),
72+
* @OA\Property(property="case_title", type="string"),
7173
* @OA\Property(property="description", type="string"),
7274
* @OA\Property(property="status", type="string", enum={"ACTIVE", "INACTIVE", "ARCHIVED"}),
7375
* @OA\Property(property="pause_timer_start", type="integer"),

ProcessMaker/Models/ProcessRequest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
* @property string $process_collaboration_id
4040
* @property string $participant_id
4141
* @property string $name
42+
* @property string $case_title
4243
* @property string $status
43-
* @property string $data
44+
* @property array $data
4445
* @property string $collaboration_uuid
4546
* @property \Carbon\Carbon $initiated_at
4647
* @property \Carbon\Carbon $completed_at
@@ -59,6 +60,7 @@
5960
* @OA\Property(property="data", type="object"),
6061
* @OA\Property(property="status", type="string", enum={"ACTIVE", "COMPLETED", "ERROR", "CANCELED"}),
6162
* @OA\Property(property="name", type="string"),
63+
* @OA\Property(property="case_title", type="string"),
6264
* @OA\Property(property="process_id", type="integer"),
6365
* @OA\Property(property="process", type="object"),
6466
* ),
@@ -920,4 +922,16 @@ public function getErrors()
920922
->get()
921923
->toArray();
922924
}
925+
926+
public function evaluateCaseTitle(array $data): string
927+
{
928+
// check if $this->process relation is loaded
929+
if ($this->process && $this->process instanceof Process) {
930+
$mustacheTitle = $this->process->case_title;
931+
} else {
932+
$mustacheTitle = $this->process()->select('case_title')->first()->case_title;
933+
}
934+
$mustache = new MustacheExpressionEvaluator();
935+
return $mustache->render($mustacheTitle, $data);
936+
}
923937
}

ProcessMaker/Nayra/Repositories/PersistenceTokenTrait.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,17 @@ public function persistGatewayTokenConsumed(array $transaction)
165165
public function persistGatewayTokenPassed(array $transaction)
166166
{
167167
$gateway = $this->deserializer->unserializeEntity($transaction['gateway']);
168-
$transition = $this->deserializer->unserializeEntity($transaction['transition']);
168+
if (!is_numeric($transaction['transition'])) {
169+
Log::info('Invalid transition id for gateway token passed. ' . json_encode($transaction));
170+
return;
171+
}
172+
$transition = $gateway->getTransitions()[$transaction['transition']] ?? null;
173+
if (empty($transition)) {
174+
Log::info('Invalid transition for gateway token passed. ' . json_encode($transaction));
175+
return;
176+
}
169177
$tokens = $this->deserializer->unserializeTokensCollection($transaction['tokens']);
170-
$this->tokenRepository->persistGatewayTokenPassed($gateway, $tokens[0]);
178+
$this->tokenRepository->persistGatewayTokenPassed($gateway, $tokens->item(0));
171179

172180
// Comments
173181
$subscriber = new CommentsSubscriber();

ProcessMaker/Observers/ProcessRequestObserver.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,13 @@ public function saved(ProcessRequest $request)
5858
$request->scheduledTasks()->delete();
5959
}
6060
}
61+
62+
public function saving(ProcessRequest $request)
63+
{
64+
// When data is updated we update the case_title
65+
if ($request->isDirty('data')) {
66+
$data = $request->data;
67+
$request->case_title = $request->evaluateCaseTitle($data);
68+
}
69+
}
6170
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('processes', function (Blueprint $table) {
15+
$table->string('case_title', 200)->nullable();
16+
});
17+
Schema::table('process_versions', function (Blueprint $table) {
18+
$table->string('case_title', 200)->nullable();
19+
});
20+
}
21+
22+
/**
23+
* Reverse the migrations.
24+
*/
25+
public function down(): void
26+
{
27+
Schema::table('processes', function (Blueprint $table) {
28+
$table->dropColumn('case_title');
29+
});
30+
Schema::table('process_versions', function (Blueprint $table) {
31+
$table->dropColumn('case_title');
32+
});
33+
}
34+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::table('process_requests', function (Blueprint $table) {
15+
$table->string('case_title', 200)->nullable();
16+
});
17+
}
18+
19+
/**
20+
* Reverse the migrations.
21+
*/
22+
public function down(): void
23+
{
24+
Schema::table('process_requests', function (Blueprint $table) {
25+
$table->dropColumn('case_title');
26+
});
27+
}
28+
};

resources/js/requests/components/RequestsListing.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ export default {
201201
default: true,
202202
},
203203
{
204-
label: "Name",
204+
label: "Case Title",
205+
field: "case_title",
206+
sortable: true,
207+
default: true,
208+
},
209+
{
210+
label: "Process Name",
205211
field: "name",
206212
sortable: true,
207213
default: true,
@@ -356,5 +362,3 @@ export default {
356362
},
357363
};
358364
</script>
359-
<style>
360-
</style>

resources/views/processes/edit.blade.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@
9797
</select-user>
9898
<div class="invalid-feedback" role="alert" v-if="errors.manager_id">@{{errors.manager_id[0]}}</div>
9999
</div>
100+
<div class="form-group">
101+
{!! Form::label('case_title', __('Case Title')) !!}
102+
{!!Form::text('case_title', null,
103+
[ 'id'=> 'case_title',
104+
'class'=> 'form-control',
105+
'v-model'=> 'formData.case_title',
106+
'v-bind:class' => '{\'form-control\':true, \'is-invalid\':errors.case_title}'
107+
])
108+
!!}
109+
<small class="form-text text-muted" v-if="! errors.name">
110+
{{ __('This field has a limit of 200 characters when calculated') }}
111+
</small>
112+
</div>
100113
<div class="form-group p-0">
101114
{!! Form::label('cancelRequest', __('Cancel Request')) !!}
102115
<multiselect id="cancelRequest"

0 commit comments

Comments
 (0)