From c66c1fa2289d83a1186c8b1a71a701273822a6b7 Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Tue, 18 Jun 2024 17:54:24 -0400 Subject: [PATCH 1/2] FOUR-16549 --- ..._06_18_191149_create_process_slideshow.php | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 database/migrations/2024_06_18_191149_create_process_slideshow.php diff --git a/database/migrations/2024_06_18_191149_create_process_slideshow.php b/database/migrations/2024_06_18_191149_create_process_slideshow.php new file mode 100644 index 0000000000..081ed3f963 --- /dev/null +++ b/database/migrations/2024_06_18_191149_create_process_slideshow.php @@ -0,0 +1,37 @@ +id(); + $table->uuid('uuid')->unique(); + $table->unsignedInteger('process_id')->unique(); + $table->unsignedInteger('user_id')->nullable(); + $table->enum('published_version', ['A', 'B', 'AB']); + $table->unsignedInteger('process_version_a_id')->constrained('process_versions')->nullable(); + $table->unsignedInteger('process_version_b_id')->constrained('process_versions')->nullable(); + $table->boolean('is_enable')->default(false); + $table->string('url')->nullable()->index(); + $table->timestamps(); + // Foreign keys + $table->foreign('process_id')->references('id')->on('processes')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('process_slideshow'); + } +}; From cfaec975b515c436e51fd05058c2cb4193fa3a3a Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Wed, 26 Jun 2024 11:42:35 -0400 Subject: [PATCH 2/2] Improve the SaveMediaProcess --- ProcessMaker/Models/Media.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ProcessMaker/Models/Media.php b/ProcessMaker/Models/Media.php index 36a3d43b0f..00bdf1445a 100644 --- a/ProcessMaker/Models/Media.php +++ b/ProcessMaker/Models/Media.php @@ -219,13 +219,17 @@ public function saveProcessMedia(Process $process, $properties, $key = 'uuid', $ // Check if exist $exist = $process->media()->where($key, $properties[$key])->exists(); if (!$exist) { + // Define the custom properties + $customProperties = [ + 'media_type' => $mediaType, + 'type' => $properties['type'], + ]; + if ($mediaType === 'slideshow') { + $customProperties['node_id'] = $properties['node_id'] ?? ''; + } // Store the images related move to MEDIA $process->addMediaFromBase64($properties['url']) - ->withCustomProperties([ - 'media_type' => $mediaType, - 'type' => $properties['type'], - 'node_id' => $properties['node_id'], - ]) + ->withCustomProperties($customProperties) ->toMediaCollection($collectionName); } }