Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plugin_dbui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
w2pext
plugin_dbui
Commits
7a8f0d50
Commit
7a8f0d50
authored
14 years ago
by
Renaud Le Gac
Browse files
Options
Downloads
Patches
Plain Diff
Add a method isFormValid.
Same message for all errors on forms.
parent
57683faa
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
static/plugin_dbui/src/appgridroweditor.js
+32
-6
32 additions, 6 deletions
static/plugin_dbui/src/appgridroweditor.js
with
32 additions
and
6 deletions
static/plugin_dbui/src/appgridroweditor.js
+
32
−
6
View file @
7a8f0d50
...
@@ -117,9 +117,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
...
@@ -117,9 +117,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
var
i
,
rec
,
record
;
var
i
,
rec
,
record
;
// Returns true if client-side validation on the form is successful.
if
(
!
this
.
isFormValid
())
{
if
(
!
this
.
formPanel
.
getForm
().
isValid
())
{
Ext
.
Msg
.
alert
(
'
Error
'
,
'
Few fields in the form are not valid !
'
);
return
;
return
;
}
}
...
@@ -147,9 +145,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
...
@@ -147,9 +145,7 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
var
record
;
var
record
;
// Returns true if client-side validation on the form is successful.
if
(
!
this
.
isFormValid
())
{
if
(
!
this
.
formPanel
.
getForm
().
isValid
())
{
Ext
.
Msg
.
alert
(
'
Error
'
,
'
Few fields in the form are not valid !
'
);
return
;
return
;
}
}
...
@@ -179,6 +175,36 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
...
@@ -179,6 +175,36 @@ App.grid.RowEditor = Ext.extend(Ext.Window, {
this
.
hide
();
this
.
hide
();
},
},
/**
* Private function checking that a form is valid.
* This is the case when all underlying fields satisfied validator criteria.
* Return a boolean and show a popup window in case of errors.
*/
isFormValid
:
function
()
{
var
form
,
msg
;
function
fieldsInError
(
form
)
{
var
badFields
=
[];
form
.
items
.
each
(
function
(
field
){
if
(
!
field
.
validate
())
{
badFields
.
push
(
field
.
fieldLabel
);
}
});
return
badFields
;
}
form
=
this
.
formPanel
.
getForm
();
if
(
!
form
.
isValid
())
{
badFields
=
fieldsInError
(
form
);
msg
=
'
Missing or invalid fields:
'
;
msg
+=
badFields
.
join
(
'
,
'
);
Ext
.
Msg
.
alert
(
'
Failure
'
,
msg
);
return
false
;
}
return
true
;
},
/**
/**
* Private method to return the record
* Private method to return the record
* associate to the row selected in the grid
* associate to the row selected in the grid
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment