Skip to content

Commit

Permalink
Merge pull request #5 from simonschaufi/neos5
Browse files Browse the repository at this point in the history
Update composer for Neos 5
  • Loading branch information
Hans Höchtl authored Feb 14, 2020
2 parents 5276809 + c1db855 commit a474df7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.idea
12 changes: 7 additions & 5 deletions Classes/Controller/AjaxFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@

class AjaxFormController extends ActionController
{

/**
* @var Context
*/
protected $securityContext;

/**
* @Flow\Inject
* @var \Neos\Flow\I18n\Service
*/
protected $i18nService;


/**
* Injects the Security Context
*
Expand All @@ -40,15 +39,18 @@ public function injectSecurityContext(Context $securityContext)
* @param string $formIdentifier
* @param string $presetName
* @param string $locale
* @throws \Neos\Flow\I18n\Exception\InvalidLocaleIdentifierException
*/
public function indexAction($formIdentifier, $presetName, $locale = '')
{
if (!empty($locale)) {
$currentLocale = new Locale($locale);
$this->i18nService->getConfiguration()->setCurrentLocale($currentLocale);
}
$this->view->assign('formIdentifier', $formIdentifier);
$this->view->assign('presetName', $presetName);
}

$this->view->assignMultiple([
'formIdentifier' => $formIdentifier,
'presetName' => $presetName,
]);
}
}
1 change: 0 additions & 1 deletion Configuration/Routes.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
-
name: 'Ajax Form Endpoint'
uriPattern: '__form/{formIdentifier}/{presetName}(/{locale})'
Expand Down
11 changes: 4 additions & 7 deletions Resources/Public/JavaScript/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ var AjaxForm = (function () {
this._form = element.querySelector('form');
if (!this._form) {
throw new Error('No form element found in ajax container');
}
else {
} else {
this.bindFormSubmitListener();
}
}
Expand All @@ -33,16 +32,14 @@ var AjaxForm = (function () {
this._form = this._delegator.querySelector('form');
if (this._form) {
this.bindFormSubmitListener();
}
else {
} else {
if (this._request.response.indexOf('data-reset-form') > -1) {
window.setTimeout(function () {
_this.ajax(null, _this.handleResponse.bind(_this));
}, 5000);
}
}
}
else {
} else {
console.error('Something went wrong with the ajax form request');
}
};
Expand All @@ -69,7 +66,7 @@ var AjaxForm = (function () {
return AjaxForm;
}());
(function () {
document.addEventListener("DOMContentLoaded", function () {
document.addEventListener('DOMContentLoaded', function () {
var ajaxForms = document.querySelectorAll('[data-ajax="ajax-form"]');
for (var i = 0; i < ajaxForms.length; i++) {
new AjaxForm(ajaxForms.item(i));
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"MIT"
],
"require": {
"neos/neos": "~3.0 | ^4.0",
"neos/nodetypes-form": "~3.0 | ^4.0"
"neos/neos": "~3.0 || ^4.0 || ^5.0",
"neos/nodetypes-form": "~3.0 || ^4.0 || ^5.0"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -94,4 +94,4 @@
"Neos.Neos.Ui-20190319094900"
]
}
}
}

0 comments on commit a474df7

Please sign in to comment.