Skip to content

Commit

Permalink
Update package nette/forms (#320)
Browse files Browse the repository at this point in the history
 - nette/forms updated from v3.2.2 to v3.2.3 patch
   See changes: nette/forms@v3.2.2...v3.2.3
   Release notes: https://github.com/nette/forms/releases/tag/v3.2.3

Replace #317
Close #319
  • Loading branch information
spaze authored May 8, 2024
2 parents abdf40e + 47b3e66 commit b0ec2cd
Show file tree
Hide file tree
Showing 30 changed files with 412 additions and 468 deletions.
5 changes: 2 additions & 3 deletions site/app/Form/TrainingApplicationAdminFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ public function create(callable $onSuccess, callable $onStatusHistoryDeleteSucce
$this->addDeletableFieldCheckbox($companyInputs->getCompanyTaxId(), $form->addCheckbox('companyTaxIdSet'), $application->getCompanyTaxId());
$this->addDeletableFieldCheckbox($noteInput, $form->addCheckbox('noteSet'), $application->getNote());

$containerName = 'statusHistoryDelete';
$historyContainer = $form->addContainer($containerName);
$historyContainer = $form->addContainer('statusHistoryDelete');
foreach ($this->trainingApplicationStatusHistory->getStatusHistory($application->getId()) as $history) {
$historyContainer
->addSubmit((string)$history->getId())
->setValidationScope([$form[$containerName]])
->setValidationScope([$historyContainer])
->onClick[] = function (SubmitButton $button) use ($application, $onStatusHistoryDeleteSuccess): void {
$this->trainingApplicationStatusHistory->deleteHistoryRecord($application->getId(), (int)$button->getName());
$onStatusHistoryDeleteSuccess();
Expand Down
12 changes: 6 additions & 6 deletions site/composer.lock

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

14 changes: 7 additions & 7 deletions site/vendor/composer/installed.json

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

6 changes: 3 additions & 3 deletions site/vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@
),
),
'nette/forms' => array(
'pretty_version' => 'v3.2.2',
'version' => '3.2.2.0',
'reference' => 'a20fdb1f81f5b406cdc99a450e0a327d5790f9b5',
'pretty_version' => 'v3.2.3',
'version' => '3.2.3.0',
'reference' => '441926313d3f7ef78e9bc6996661310ae6f1c2f7',
'type' => 'library',
'install_path' => __DIR__ . '/../nette/forms',
'aliases' => array(),
Expand Down
17 changes: 0 additions & 17 deletions site/vendor/nette/forms/.eslintrc.js

This file was deleted.

30 changes: 30 additions & 0 deletions site/vendor/nette/forms/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import globals from 'globals';
import pluginJs from '@eslint/js';

export default [
pluginJs.configs.recommended,
{
ignores: ['**/*.min.js'],
},
{
languageOptions: {
ecmaVersion: 2021,
globals: {
...globals.browser,
'Tracy': 'writeable',
'define': 'readable',
'module': 'readable',
},
},
rules: {
indent: ['error', 'tab'],
quotes: ['error', 'single'],
semi: ['error', 'always'],
'func-style': ['error', 'declaration', {'allowArrowFunctions': true}],
'prefer-arrow-callback': ['error'],
'arrow-parens': ['error'],
'arrow-spacing': ['error'],
'no-var': ['error'],
},
},
];
7 changes: 2 additions & 5 deletions site/vendor/nette/forms/examples/html5.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@
->setHtmlType('search')
->setHtmlAttribute('autofocus');

$form->addText('count', 'Number of results:')
->setHtmlType('number')
$form->addInteger('count', 'Number of results:')
->setDefaultValue(10)
->addRule($form::Integer, 'Must be numeric value')
->addRule($form::Range, 'Must be in range from %d to %d', [1, 100]);

$form->addText('precision', 'Precision:')
$form->addFloat('precision', 'Precision:')
->setHtmlType('range')
->setDefaultValue(50)
->addRule($form::Integer, 'Precision must be numeric value')
->addRule($form::Range, 'Precision must be in range from %d to %d', [0, 100]);

$form->addEmail('email', 'Send to email:')
Expand Down
43 changes: 24 additions & 19 deletions site/vendor/nette/forms/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
{
"name": "nette-forms",
"version": "3.3.6",
"description": "Client side script for Nette Forms Component",
"keywords": [
"nette",
"validation",
"forms"
],
"homepage": "https://nette.org",
"author": "David Grudl (https://davidgrudl.com)",
"license": "BSD-3-Clause",
"main": "src/assets/netteForms.js",
"files": [
"src/assets"
],
"repository": {
"type": "git",
"url": "git+https://github.com/nette/forms.git"
}
"name": "nette-forms",
"version": "3.4.0",
"description": "Client side script for Nette Forms Component",
"keywords": [
"nette",
"validation",
"forms"
],
"homepage": "https://nette.org",
"author": "David Grudl (https://davidgrudl.com)",
"license": "BSD-3-Clause",
"main": "src/assets/netteForms.js",
"files": [
"src/assets"
],
"repository": {
"type": "git",
"url": "git+https://github.com/nette/forms.git"
},
"devDependencies": {
"@eslint/js": "^9.1.1",
"eslint": "^9.1.1",
"globals": "^15.1.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct()
}


public function afterCompile(Nette\PhpGenerator\ClassType $class)
public function afterCompile(Nette\PhpGenerator\ClassType $class): void
{
$initialize = $this->initialization ?? $class->getMethod('initialize');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function print(PrintContext $context): string
}


private function init(Tag $tag)
private function init(Tag $tag): void
{
$el = $tag->htmlElement;
$usedAttributes = self::findUsedAttributes($el);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function print(PrintContext $context): string
}


private function init(Tag $tag)
private function init(Tag $tag): void
{
$el = $tag->htmlElement;

Expand Down
2 changes: 1 addition & 1 deletion site/vendor/nette/forms/src/Forms/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public function generateDataClass(
}
}

if (!$input->isRequired()) {
if (!$input->isRequired() && $input->isNullable()) {
$type = '?' . $type;
}
} elseif ($input instanceof Controls\UploadControl) {
Expand Down
41 changes: 11 additions & 30 deletions site/vendor/nette/forms/src/Forms/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ class Container extends Nette\ComponentModel\Container implements \ArrayAccess
public function setDefaults(array|object $data, bool $erase = false): static
{
$form = $this->getForm(false);
if (!$form || !$form->isAnchored() || !$form->isSubmitted()) {
$this->setValues($data, $erase);
}

$this->setValues($data, $erase, $form?->isAnchored() && $form->isSubmitted());
return $this;
}

Expand All @@ -61,29 +58,20 @@ public function setDefaults(array|object $data, bool $erase = false): static
* Fill-in with values.
* @internal
*/
public function setValues(array|object $data, bool $erase = false): static
public function setValues(array|object $values, bool $erase = false, bool $onlyDisabled = false): static
{
if ($data instanceof \Traversable) {
$values = iterator_to_array($data);

} elseif (is_object($data) || is_array($data) || $data === null) {
$values = (array) $data;
}
$values = $values instanceof \Traversable
? iterator_to_array($values)
: (array) $values;

foreach ($this->getComponents() as $name => $control) {
if ($control instanceof Control) {
if (array_key_exists($name, $values)) {
$control->setValue($values[$name]);

} elseif ($erase) {
$control->setValue(null);
if ((array_key_exists($name, $values) && (!$onlyDisabled || $control->isDisabled())) || $erase) {
$control->setValue($values[$name] ?? null);
}
} elseif ($control instanceof self) {
if (isset($values[$name])) {
$control->setValues($values[$name], $erase);

} elseif ($erase) {
$control->setValues([], $erase);
if (isset($values[$name]) || $erase) {
$control->setValues($values[$name] ?? [], $erase, $onlyDisabled);
}
}
}
Expand Down Expand Up @@ -186,7 +174,6 @@ public function getUnsafeValues($returnType, ?array $controls = null)
}


/** @return static */
public function setMappedType(string $type): static
{
$this->mappedType = $type;
Expand Down Expand Up @@ -287,10 +274,7 @@ public function addComponent(
): static
{
parent::addComponent($component, $name, $insertBefore);
if ($this->currentGroup !== null) {
$this->currentGroup->add($component);
}

$this->currentGroup?->add($component);
return $this;
}

Expand Down Expand Up @@ -577,10 +561,7 @@ public function addContainer(string|int $name): self
{
$control = new self;
$control->currentGroup = $this->currentGroup;
if ($this->currentGroup !== null) {
$this->currentGroup->add($control);
}

$this->currentGroup?->add($control);
return $this[$name] = $control;
}

Expand Down
13 changes: 7 additions & 6 deletions site/vendor/nette/forms/src/Forms/Controls/BaseControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function isFilled(): bool
*/
public function setDefaultValue($value)
{
$form = $this->getForm(false);
$form = $this->getForm(throw: false);
if ($this->isDisabled() || !$form || !$form->isAnchored() || !$form->isSubmitted()) {
$this->setValue($value);
}
Expand All @@ -182,11 +182,12 @@ public function setDefaultValue($value)
* Disables or enables control.
* @return static
*/
public function setDisabled(bool $value = true)
public function setDisabled(bool $state = true)
{
if ($this->disabled = (bool) $value) {
$this->disabled = $state;
if ($state) {
$this->setValue(null);
} elseif (($form = $this->getForm(false)) && $form->isAnchored() && $form->isSubmitted()) {
} elseif (($form = $this->getForm(throw: false)) && $form->isAnchored() && $form->isSubmitted()) {
$this->loadHttpData();
}

Expand All @@ -206,9 +207,9 @@ public function isDisabled(): bool
/**
* Sets whether control value is excluded from $form->getValues() result.
*/
public function setOmitted(bool $value = true): static
public function setOmitted(bool $state = true): static
{
$this->omitted = $value;
$this->omitted = $state;
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion site/vendor/nette/forms/src/Forms/Controls/Checkbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(string|Stringable|null $label = null)
public function setValue($value)
{
if (!is_scalar($value) && $value !== null) {
throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or null, %s given in field '%s'.", get_debug_type($value), $this->name));
throw new Nette\InvalidArgumentException(sprintf("Value must be scalar or null, %s given in field '%s'.", get_debug_type($value), $this->getName()));
}

$this->value = (bool) $value;
Expand Down
Loading

0 comments on commit b0ec2cd

Please sign in to comment.