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

[FIX] ADF-3: child items of the class should show file property #2979

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
5 changes: 0 additions & 5 deletions helpers/form/ElementMapFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ public function create(core_kernel_classes_Property $property): ?tao_helpers_for
return null;
}

// horrible hack to fix file widget
if ($widgetUri === AsyncFile::WIDGET_ID) {
gabrielfs7 marked this conversation as resolved.
Show resolved Hide resolved
$widgetResource = new core_kernel_classes_Resource(GenerisAsyncFile::WIDGET_ID);
}

$element = tao_helpers_form_FormFactory::getElementByWidget(
tao_helpers_Uri::encode($propertyUri),
$widgetResource
Expand Down
22 changes: 22 additions & 0 deletions helpers/form/class.Form.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -617,6 +618,27 @@ public function hasFileUpload()

return $returnValue;
}

public function hasAsyncFileUpload(): bool
gabrielfs7 marked this conversation as resolved.
Show resolved Hide resolved
{
foreach ($this->elements as $element) {
if ($element instanceof tao_helpers_form_elements_xhtml_AsyncFile) {
return true;
}
}
return false;
}

public function checkFormInstance(): bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO check seems you are validating something, which is not the case. You just need to know if this is a form instance.

Suggested change
public function checkFormInstance(): bool
public function isFormInstance(): bool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{
foreach ($this->elements as $element) {
if ($element->getName() == "tao.forms.instance" ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of having a constant added at tao_actions_form_Instance for tao.forms.instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tao.forms.instance is the name of the object of class tao_helpers_form_elements_xhtml_Hidden

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know, but it is repeating now, so I suggested to create a constant instead of repeat.

return true;
}
}
return false;
}


/**
* Enables you to know if the form is valid
Expand Down
4 changes: 4 additions & 0 deletions helpers/form/xhtml/class.Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ public function render()

$returnValue .= "<input type='hidden' class='global' name='{$this->name}_sent' value='1' />\n";

if ($this->hasAsyncFileUpload() && $this->checkFormInstance()) {
$returnValue .= "<input type='hidden' name='check-file' id='check-file' data-id='schema' value='1' />\n";
gabrielfs7 marked this conversation as resolved.
Show resolved Hide resolved
}

if (!empty($this->error)) {
$returnValue .= '<div class="xhtml_form_error">' . $this->error . '</div>';
}
Expand Down
5 changes: 2 additions & 3 deletions views/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion views/package.json
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@oat-sa/tao-core-libs": "0.4.3",
"@oat-sa/tao-core-sdk": "1.15.0",
"@oat-sa/tao-core-shared-libs": "1.0.3",
"@oat-sa/tao-core-ui": "^1.27.3",
"@oat-sa/tao-core-ui": "https://github.com/oat-sa/tao-core-ui-fe/tarball/feature/ADF-3/missing-file-property",
"async": "0.2.10",
"codemirror": "^5.54.0",
"decimal.js": "10.1.1",
Expand Down