Skip to content

Commit

Permalink
updating block admin enque
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Jan 16, 2024
1 parent 25beeb3 commit e612e93
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 24 deletions.
24 changes: 24 additions & 0 deletions src/Config/UtilsConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,30 @@ class UtilsConfig
*/
public const ROUTE_OUTPUT_SUCCESS_REDIRECT_DATA_KEY = 'successRedirectData';

// ------------------------------------------------------------------
// Form Data Refference
// ------------------------------------------------------------------

public const FDR_DIRECT_IMPORT = 'directImport';
public const FDR_ITEM_ID = 'itemId';
public const FDR_INNER_ID = 'innerId';
public const FDR_TYPE = 'type';
public const FDR_FORM_ID = 'formId';
public const FDR_POST_ID = 'postId';
public const FDR_PARAMS = 'params';
public const FDR_PARAMS_RAW = 'paramsRaw';
public const FDR_FILES = 'files';

public const FDR_SETTINGS_TYPE = 'settingsType';
public const FDR_FIELDS_ONLY = 'fieldsOnly';
public const FDR_FILES_UPLOAD = 'filesUpload';
public const FDR_ACTION = 'action';
public const FDR_ACTION_EXTERNAL = 'actionExternal';
public const FDR_API_STEPS = 'apiSteps';
public const FDR_CAPTCHA = 'captcha';
public const FDR_STORAGE = 'storage';
public const FDR_ADDON_DATA = 'addonData';

// ------------------------------------------------------------------
// CAPS
// ------------------------------------------------------------------
Expand Down
48 changes: 24 additions & 24 deletions src/Rest/Routes/AbstractUtilsBaseRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,14 @@ protected function getFormDataReference($request): array

// Get form directImport from params.
if (isset($params['directImport'])) {
$formDataReference['directImport'] = true;
$formDataReference['itemId'] = $params['itemId'] ?? '';
$formDataReference['innerId'] = $params['innerId'] ?? '';
$formDataReference['type'] = $params['type'] ?? '';
$formDataReference['formId'] = $params['formId'] ?? '';
$formDataReference['postId'] = $params['postId'] ?? '';
$formDataReference['params'] = $params['params'] ?? [];
$formDataReference['files'] = $params['files'] ?? [];
$formDataReference[UtilsConfig::FDR_DIRECT_IMPORT] = true;
$formDataReference[UtilsConfig::FDR_ITEM_ID] = $params['itemId'] ?? '';
$formDataReference[UtilsConfig::FDR_INNER_ID] = $params['innerId'] ?? '';
$formDataReference[UtilsConfig::FDR_TYPE] = $params['type'] ?? '';
$formDataReference[UtilsConfig::FDR_FORM_ID] = $params['formId'] ?? '';
$formDataReference[UtilsConfig::FDR_POST_ID] = $params['postId'] ?? '';
$formDataReference[UtilsConfig::FDR_PARAMS] = $params['params'] ?? [];
$formDataReference[UtilsConfig::FDR_FILES] = $params['files'] ?? [];
} else {
// Get form id from params.
$formId = $params['formId'] ?? '';
Expand All @@ -413,48 +413,48 @@ protected function getFormDataReference($request): array
$settingsName = \apply_filters(UtilsConfig::FILTER_SETTINGS_DATA, [])[$formSettingsType][$type] ?? '';

$formDataReference = [
'formId' => $formId,
'type' => $type,
'itemId' => '',
'innerId' => '',
'fieldsOnly' => !empty($settingsName) ? \apply_filters($settingsName, $formId) : [],
UtilsConfig::FDR_FORM_ID => $formId,
UtilsConfig::FDR_TYPE => $type,
UtilsConfig::FDR_ITEM_ID => '',
UtilsConfig::FDR_INNER_ID => '',
UtilsConfig::FDR_FIELDS_ONLY => !empty($settingsName) ? \apply_filters($settingsName, $formId) : [],
];
} else {
$formDataReference = UtilsGeneralHelper::getFormDetailsById($formId);
}

// Populare params.
$formDataReference['params'] = $params['params'] ?? [];
$formDataReference[UtilsConfig::FDR_PARAMS] = $params['params'] ?? [];

// Populare params raw.
$formDataReference['paramsRaw'] = $params['paramsRaw'] ?? [];
$formDataReference[UtilsConfig::FDR_PARAMS_RAW] = $params['paramsRaw'] ?? [];

// Populate files from uploaded ID.
$formDataReference['files'] = $params['files'] ?? [];
$formDataReference[UtilsConfig::FDR_FILES] = $params['files'] ?? [];

// Populare files on upload. Only populated on file upload.
$formDataReference['filesUpload'] = $this->prepareFile($request->get_file_params(), $params['params'] ?? []);
$formDataReference[UtilsConfig::FDR_FILES_UPLOAD] = $this->prepareFile($request->get_file_params(), $params['params'] ?? []);

// Populare action.
$formDataReference['action'] = $params['action'] ?? '';
$formDataReference[UtilsConfig::FDR_ACTION] = $params['action'] ?? '';

// Populare action external.
$formDataReference['actionExternal'] = $params['actionExternal'] ?? '';
$formDataReference[UtilsConfig::FDR_ACTION_EXTERNAL] = $params['actionExternal'] ?? '';

// Populare step fields.
$formDataReference['apiSteps'] = $params['apiSteps'] ?? [];
$formDataReference[UtilsConfig::FDR_API_STEPS] = $params['apiSteps'] ?? [];

// Get form captcha from params.
$formDataReference['captcha'] = $params['captcha'] ?? [];
$formDataReference[UtilsConfig::FDR_CAPTCHA] = $params['captcha'] ?? [];

// Get form post Id from params.
$formDataReference['postId'] = $params['postId'] ?? '';
$formDataReference[UtilsConfig::FDR_POST_ID] = $params['postId'] ?? '';

// Get form storage from params.
$formDataReference['storage'] = \json_decode($params['storage'] ?? '', true) ?? [];
$formDataReference[UtilsConfig::FDR_STORAGE] = \json_decode($params['storage'] ?? '', true) ?? [];

// Create placeholder for addon data.
$formDataReference['addonData'] = [];
$formDataReference[UtilsConfig::FDR_ADDON_DATA] = [];
}

return $formDataReference;
Expand Down

0 comments on commit e612e93

Please sign in to comment.