Skip to content

Commit

Permalink
* fix(SFT-1801): preventing errors in form import when no template fo…
Browse files Browse the repository at this point in the history
…lders defined, Form Export was not working with prefixed tables (#1802)

* fix(SFT-1801): preventing errors in form import when no template folders defined
* fix: Form Export was not working with prefixed tables
* fix: fixed button spacing

---------

Co-authored-by: kjmartens <[email protected]>
  • Loading branch information
gustavs-gutmanis and kjmartens authored Feb 14, 2025
1 parent b965c69 commit 09884eb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const ImportExpressForms: React.FC = () => {

<button
className={classes(
'btn',
'field btn',
'submit',
active && 'disabled',
!options.forms.length &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function collectDataPreview(): ImportPreview

$submissions = FFSubmission::find()
->select("COUNT({$table}.[[id]]) as count")
->innerJoin(FormRecord::TABLE.' f', "[[f]].[[id]] = {$table}.[[formId]]")
->innerJoin(FormRecord::TABLE_STD.' f', "[[f]].[[id]] = {$table}.[[formId]]")
->groupBy('f.[[uid]]')
->orderBy([])
->indexBy('f.uid')
Expand Down
35 changes: 19 additions & 16 deletions packages/plugin/src/Models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,19 +358,26 @@ public function __construct(array $config = [])
public function prepareFolderStructure(): void
{
$templatesPath = \Craft::$app->path->getSiteTemplatesPath();
$formattingPath = FileHelper::absolutePath($this->formTemplateDirectory, $templatesPath);
if (!is_dir($formattingPath)) {
FileHelper::createDirectory($formattingPath, 0777);

if ($this->formTemplateDirectory) {
$formattingPath = FileHelper::absolutePath($this->formTemplateDirectory, $templatesPath);
if (!is_dir($formattingPath)) {
FileHelper::createDirectory($formattingPath, 0777);
}
}

$emailTemplatesPath = FileHelper::absolutePath($this->emailTemplateDirectory, $templatesPath);
if (!is_dir($emailTemplatesPath)) {
FileHelper::createDirectory($emailTemplatesPath, 0777);
if ($this->emailTemplateDirectory) {
$emailTemplatesPath = FileHelper::absolutePath($this->emailTemplateDirectory ?? '', $templatesPath);
if (!is_dir($emailTemplatesPath)) {
FileHelper::createDirectory($emailTemplatesPath, 0777);
}
}

$successTemplatesPath = FileHelper::absolutePath($this->successTemplateDirectory, $templatesPath);
if (!is_dir($successTemplatesPath)) {
FileHelper::createDirectory($successTemplatesPath, 0777);
if ($this->successTemplateDirectory) {
$successTemplatesPath = FileHelper::absolutePath($this->successTemplateDirectory ?? '', $templatesPath);
if (!is_dir($successTemplatesPath)) {
FileHelper::createDirectory($successTemplatesPath, 0777);
}
}
}

Expand Down Expand Up @@ -408,10 +415,8 @@ public function folderExists(string $attribute)

/**
* If a form template directory has been set and it exists - return its absolute path.
*
* @return null|string
*/
public function getAbsoluteFormTemplateDirectory()
public function getAbsoluteFormTemplateDirectory(): ?string
{
if ($this->formTemplateDirectory) {
$absolutePath = $this->getAbsolutePath($this->formTemplateDirectory);
Expand All @@ -434,10 +439,8 @@ public function canManageEmailTemplates(): bool

/**
* If an email template directory has been set and it exists - return its absolute path.
*
* @return null|string
*/
public function getAbsoluteEmailTemplateDirectory()
public function getAbsoluteEmailTemplateDirectory(): ?string
{
if ($this->emailTemplateDirectory) {
$absolutePath = $this->getAbsolutePath($this->emailTemplateDirectory);
Expand Down Expand Up @@ -467,7 +470,7 @@ public function getEmailTemplateDefault(): string
};
}

public function getAbsoluteSuccessTemplateDirectory()
public function getAbsoluteSuccessTemplateDirectory(): ?string
{
if ($this->successTemplateDirectory) {
$absolutePath = $this->getAbsolutePath($this->successTemplateDirectory);
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/Resources/js/client/client.js

Large diffs are not rendered by default.

0 comments on commit 09884eb

Please sign in to comment.