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

feat ariatemplates/ariatemplates#1427 Customization of widget's error messages #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions snippets/widgets/DefaultErrorMessages.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{Template {
$classpath : "snippets.widgets.DefaultErrorMessages",
$hasScript : true
}}

{macro main()}
{call static()/}
{call bound()/}
{/macro}

{macro static()}
{@aria:NumberField {
defaultErrorMessages : {
"validation" : "Local default error message for NumberField's validation."
}
}/}

{@aria:TimeField {
defaultErrorMessages : {
"validation" : "Local default error message for TimeField's validation."
}
}/}

////#static
{@aria:DateField {
defaultErrorMessages : {
"validation" : "Local default error message for DateField's validation.",
"minValue" : "Local default error message for DateField's minimum date validation.",
"maxValue" : "Local default error message for DateField's maximum date validation."
}
}/}
////#static

{@aria:AutoComplete {
resourcesHandler : this.data.resourcesHandler,
defaultErrorMessages : {
"validation" : "Local default error message for AutoComplete's validation."
}
}/}
{/macro}

{macro bound()}
{@aria:NumberField {
bind : {
defaultErrorMessages : {
inside : this.data.defaultErrorMessages,
to : "NumberField"
}
}
}/}

{@aria:TimeField {
bind : {
defaultErrorMessages : {
inside : this.data.defaultErrorMessages,
to : "TimeField"
}
}
}/}

////#bound
{@aria:DateField {
bind : {
defaultErrorMessages : {
inside : this.data.defaultErrorMessages,
to : "DateField"
}
}
}/}
////#bound

{@aria:AutoComplete {
bind : {
defaultErrorMessages : {
inside : this.data.defaultErrorMessages,
to : "AutoComplete"
}
}
}/}
{/macro}

{/Template}
48 changes: 48 additions & 0 deletions snippets/widgets/DefaultErrorMessagesScript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Aria.tplScriptDefinition({
$classpath : "snippets.widgets.DefaultErrorMessagesScript",
$dependencies : ["aria.core.AppEnvironment", "aria.resources.handlers.LCResourcesHandler"],
$prototype : {
$dataReady : function () {
var resourcesHandler = new aria.resources.handlers.LCResourcesHandler();
resourcesHandler.setSuggestions([]);
this.data.resourcesHandler = resourcesHandler;

////#datamodel
this.data.defaultErrorMessages = {};
this.data.defaultErrorMessages["DateField"] = {
"validation" : "Bound local default error message for DateField's validation.",
"minValue" : "Bound local default error message for DateField's minimum date validation.",
"maxValue" : "Bound local default error message for DateField's maximum date validation."
};
////#datamodel

this.data.defaultErrorMessages["NumberField"] = {
"validation" : "Bound local default error message for NumberField's validation."
};

this.data.defaultErrorMessages["TimeField"] = {
"validation" : "Bound local default error message for TimeField's validation."
};

this.data.defaultErrorMessages["AutoComplete"] = {
"validation" : "Bound local default error message for AutoComplete's validation."
};
},

setGlobalMessages : function() {
////#global
aria.core.AppEnvironment.setEnvironment({
"widgetSettings" : {
"defaultErrorMessages" : {
"DateField" : {
"validation" : "Global default error message for DateField's validation.",
"minValue" : "Global default error message for DateField's minimum date validation.",
"maxValue" : "Global default error message for DateField's maximum date validation."
}
}
}
}, null, true);
////#global
}
}
});