Skip to content
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

FOUR-18107 - feature/FOUR-18103: Support for drafts (hidden variable in screen data) #7336

Merged
merged 2 commits into from
Sep 23, 2024
Merged
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
21 changes: 12 additions & 9 deletions ProcessMaker/Traits/HasScreenFields.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<?php

namespace ProcessMaker\Traits;

use Illuminate\Support\Arr;
use Log;
use ProcessMaker\Models\Column;
use ProcessMaker\Models\Screen;

trait HasScreenFields
{
private $parsedFields;

private $restrictedComponents = [
'FormImage',
];

public function getFieldsAttribute()
{
if (empty($this->parsedFields)) {
Expand All @@ -35,7 +31,6 @@ public function getFieldsAttribute()
]);
}
}

return $this->parsedFields->unique('field');
}

Expand All @@ -47,15 +42,25 @@ public function parseNestedScreen($node)
}
}

public function parseCollectionRecordControl($node)
{
$collection = Screen::find($node['config']['collection']['screen']);
foreach ($collection->fields as $field) {
$this->parsedFields->push($field);
}
}

public function walkArray($array, $key = null)
{
if (!is_array($array)) {
$array = json_decode($array);
}

foreach ($array as $subkey => $value) {

if (isset($value['component']) && $value['component'] === 'FormNestedScreen') {
$this->parseNestedScreen($value);
} elseif (isset($value['component']) && $value['component'] === 'FormCollectionRecordControl') {
$this->parseCollectionRecordControl($value);
} elseif ($key !== 'inspector' && is_array($value) && isset($value['config']['name'])) {
$this->parseItem($value);
}
Expand Down Expand Up @@ -97,11 +102,9 @@ public function parseItemLabel($item)
public function parseItemFormat($item)
{
$format = 'string';

if (isset($item['config']['dataFormat'])) {
$format = $item['config']['dataFormat'];
}

if (isset($item['component'])) {
switch ($item['component']) {
case 'FileUpload':
Expand All @@ -128,7 +131,6 @@ public function parseItemFormat($item)
break;
}
}

return $format;
}

Expand All @@ -151,6 +153,7 @@ public function parseIsSubmitButton($item)
*
* @return array
*/

public function screenFilteredFields()
{
return $this->fields->pluck('field');
Expand Down
Loading