Skip to content

Commit

Permalink
set validation badge when widget is placed in tab container
Browse files Browse the repository at this point in the history
  • Loading branch information
lindski committed Nov 4, 2016
1 parent a3b4269 commit ed75a72
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions src/AutoCompleteForMendix/widget/AutoCompleteForMendix.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
========================
@file : AutoCompleteForMendix.js
@version : 2.1.1
@version : 2.1.0
@author : Iain Lindsay
@date : 2016-04-12
@date : 2016-11-04
@copyright : AuraQ Limited 2016
@license : Apache V2
Expand Down Expand Up @@ -77,6 +77,7 @@ require({
_contextObj: null,
_$alertdiv: null,
_alertDiv: null,
_hadValidationFeedback: false,

// dojo.declare.constructor is called to construct the widget instance. Implement to initialize non-primitive properties.
constructor: function() {
Expand Down Expand Up @@ -316,9 +317,20 @@ require({
} else {
if (message) {
this._addValidation(message);
validation.removeAttribute(this._reference);

if(!this._hadValidationFeedback) {
this._hadValidationFeedback = true;
this._increaseValidationNotification();
}

validation.removeAttribute(this._reference);
}
}

if(this._hadValidationFeedback && !message) {
this._decreaseValidationNotification();
this._hadValidationFeedback = false;
}
},

// Clear validations.
Expand All @@ -337,6 +349,24 @@ require({
this._$combo.parent().addClass('has-error').append( this._$alertdiv );
},


_increaseValidationNotification : function() {
//increase notifications in case the widget is inside tab
//Warning: This is not documented in official API and might break when the API changes.
if (this.validator) {
this.validator.addNotification();

}
},

_decreaseValidationNotification : function() {
//decrease notifications in case the widget is inside tab
//Warning: This is not documented in official API and might break when the API changes.
if (this.validator) {
this.validator.removeNotification();
}
},

// Reset subscriptions.
_resetSubscriptions: function() {
logger.debug(this.id + "._resetSubscriptions");
Expand Down
Binary file modified test/Test.mpr
Binary file not shown.
Binary file modified test/widgets/AutoCompleteForMendix.mpk
Binary file not shown.

0 comments on commit ed75a72

Please sign in to comment.