Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3c536bcc
Commit
3c536bcc
authored
Oct 07, 2016
by
Bryce Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve method naming in gl_field_errors.
parent
349caec3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
21 deletions
+22
-21
app/assets/javascripts/gl_field_errors.js.es6
app/assets/javascripts/gl_field_errors.js.es6
+22
-21
No files found.
app/assets/javascripts/gl_field_errors.js.es6
View file @
3c536bcc
...
...
@@ -35,7 +35,7 @@
initFieldValidation() {
// hidden when injected into DOM
this.inputElement.after(this.fieldErrorElement);
this.inputElement.off('invalid').on('invalid', this.handleInvalid
Inpu
t.bind(this));
this.inputElement.off('invalid').on('invalid', this.handleInvalid
Submi
t.bind(this));
this.scopedSiblings = this.safelySelectSiblings();
}
...
...
@@ -52,29 +52,25 @@
}
renderValidity() {
this.
setClearState
();
this.
renderClear
();
if (this.state.valid) {
return this.
setValidState
();
return this.
renderValid
();
}
if (this.state.empty) {
return this.
setEmptyState
();
return this.
renderEmpty
();
}
if (!this.state.valid) {
return this.
setInvalidState
();
return this.
renderInvalid
();
}
}
accessCurrentVal(newVal) {
return newVal ? this.inputElement.val(newVal) : this.inputElement.val();
}
handleInvalidInput(event) {
handleInvalidSubmit(event) {
event.preventDefault();
const currentValue = this.accessCurrentVal();
const currentValue = this.accessCurrentVal
ue
();
this.state.valid = false;
this.state.empty = currentValue === '';
...
...
@@ -86,36 +82,41 @@
}
/* Get or set current input value */
accessCurrentValue(newVal) {
return newVal ? this.inputElement.val(newVal) : this.inputElement.val();
}
getInputValidity() {
return this.inputDomElement.validity.valid;
}
updateValidity
State
() {
const inputVal = this.accessCurrentVal();
updateValidity() {
const inputVal = this.accessCurrentVal
ue
();
this.state.empty = !inputVal.length;
this.state.valid = this.getInputValidity();
this.renderValidity();
}
setValidState
() {
return this.
setClearState
();
renderValid
() {
return this.
renderClear
();
}
setEmptyState
() {
return this.
setInvalidState
();
renderEmpty
() {
return this.
renderInvalid
();
}
setInvalidState
() {
renderInvalid
() {
this.inputElement.addClass(inputErrorClass);
this.scopedSiblings.hide();
return this.fieldErrorElement.show();
}
setClearState
() {
const inputVal = this.accessCurrentVal();
renderClear
() {
const inputVal = this.accessCurrentVal
ue
();
if (!inputVal.split(' ').length) {
const trimmedInput = inputVal.trim();
this.accessCurrentVal(trimmedInput);
this.accessCurrentVal
ue
(trimmedInput);
}
this.inputElement.removeClass(inputErrorClass);
this.scopedSiblings.hide();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment