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