Skip to content

Commit

Permalink
#9 Nefunguje mazání zpráv
Browse files Browse the repository at this point in the history
- Oprava mazání zpráv v případě, že input má asynchronní i klasická pravidla dohromady. Za určitých okolností stále mohlo dojít k zobrazení dvou chyb zároveň, protože nedošlo ke smazání zprávy z asynchronního pravidla.
  • Loading branch information
zipper committed Apr 9, 2019
1 parent 270e151 commit 9b461e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ $ cat bower.json

## Changelog

### v1.3.7
- Oprava mazání zpráv v případě, že input má asynchronní i klasická pravidla dohromady. Za určitých okolností stále mohlo dojít k zobrazení dvou chyb zároveň, protože nedošlo ke smazání zprávy z asynchronního pravidla.

### v1.3.6
- Oprava mazání zpráv v případě, že input má asynchronní i klasická pravidla dohromady.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pd-forms",
"title": "pdForms",
"description": "Customization of netteForms for use in PeckaDesign.",
"version": "1.3.6",
"version": "1.3.7",
"author": "PeckaDesign, s.r.o <support@peckadesign.cz>",
"contributors": [
"Radek Šerý <radek.sery@peckadesign.cz>",
Expand Down
14 changes: 11 additions & 3 deletions pdForms.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author Radek Šerý <radek.sery@peckadesign.cz>
* @author Vít Kutný <vit.kutny@peckadesign.cz>
*
* @version 1.3.6
* @version 1.3.7
*
* - adds custom validation rules for optional rule (non-blocking errors, form can be still submitted)
* - changes some netteForms methods
Expand Down Expand Up @@ -119,6 +119,14 @@ pdForms.validateControl = function(elem, rules, onlyCheck) {
if (! onlyCheck) {
if (! valid) {
var msg = typeof rules[id].msg === 'object' ? rules[id].msg.invalid : rules[id].msg;

// if the rules[id] is sync and we have a new message, we need to remove previous messages
// (including async rules associated); checking for message presence ensures that conditional rules
// will show their message - their evaluating goes from deepest rule (where the message is defined),
// therefore condition is evaluated at last and must not remove the message
if (msg) {
pdForms.removeMessages(elem, true);
}
pdForms.addMessage(elem, msg, rules[id].optional ? pdForms.constants.INFO_MESSAGE : pdForms.constants.ERROR_MESSAGE);
}
else if (typeof rules[id].msg === 'object' && 'valid' in rules[id].msg) {
Expand Down Expand Up @@ -492,8 +500,8 @@ Nette.addEvent = function(element, on, callback) {
* Validates single rule. If there is no validator in Nette.validators, then try to use pdForms.validators.
*/
var tmp_Nette_validateRule = Nette.validateRule;
Nette.validateRule = function(elem, op, arg) {
var ret = tmp_Nette_validateRule(elem, op.substring(0, pdForms.namespace.length) === pdForms.namespace ? op.substring(pdForms.namespace.length) : op, arg);
Nette.validateRule = function(elem, op, arg, value) {
var ret = tmp_Nette_validateRule(elem, op.substring(0, pdForms.namespace.length) === pdForms.namespace ? op.substring(pdForms.namespace.length) : op, arg, value);

if (ret === null) {
op = pdForms.formatOperation(op);
Expand Down

0 comments on commit 9b461e2

Please sign in to comment.