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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
0b5e0e4c
Commit
0b5e0e4c
authored
Aug 11, 2014
by
Robert Schilling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable label submit button if any field is empty
parent
e24589a1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
3 deletions
+48
-3
app/assets/javascripts/application.js.coffee
app/assets/javascripts/application.js.coffee
+27
-2
app/assets/javascripts/dispatcher.js.coffee
app/assets/javascripts/dispatcher.js.coffee
+2
-0
app/assets/javascripts/labels.js.coffee
app/assets/javascripts/labels.js.coffee
+18
-0
app/views/projects/labels/_form.html.haml
app/views/projects/labels/_form.html.haml
+1
-1
No files found.
app/assets/javascripts/application.js.coffee
View file @
0b5e0e4c
...
...
@@ -53,15 +53,40 @@ window.split = (val) ->
window
.
extractLast
=
(
term
)
->
return
split
(
term
).
pop
()
window
.
rstrip
=
(
val
)
->
return
val
.
replace
(
/\s+$/
,
''
)
# Disable button if text field is empty
window
.
disableButtonIfEmptyField
=
(
field_selector
,
button_selector
)
->
field
=
$
(
field_selector
)
closest_submit
=
field
.
closest
(
"form"
).
find
(
button_selector
)
closest_submit
.
disable
()
if
field
.
val
().
replace
(
/\s+$/
,
""
)
is
""
closest_submit
.
disable
()
if
rstrip
(
field
.
val
()
)
is
""
field
.
on
"input"
,
->
if
$
(
@
).
val
().
replace
(
/\s+$/
,
""
)
is
""
if
rstrip
(
$
(
@
).
val
())
is
""
closest_submit
.
disable
()
else
closest_submit
.
enable
()
# Disable button if any input field with given selector is empty
window
.
disableButtonIfEmptyField
=
(
form
,
form_selector
,
button_selector
)
->
closest_submit
=
form
.
find
(
button_selector
)
empty
=
false
form
.
find
(
'input'
).
filter
(
form_selector
).
each
->
empty
=
true
if
rstrip
(
$
(
this
).
val
())
is
""
if
empty
closest_submit
.
disable
()
else
closest_submit
.
enable
()
form
.
keyup
->
empty
=
false
form
.
find
(
'input'
).
filter
(
form_selector
).
each
->
empty
=
true
if
rstrip
(
$
(
this
).
val
())
is
""
if
empty
closest_submit
.
disable
()
else
closest_submit
.
enable
()
...
...
app/assets/javascripts/dispatcher.js.coffee
View file @
0b5e0e4c
...
...
@@ -42,6 +42,8 @@ class Dispatcher
new
TreeView
()
when
'projects:blob:show'
new
BlobView
()
when
'projects:labels:new'
new
Labels
()
switch
path
.
first
()
when
'admin'
then
new
Admin
()
...
...
app/assets/javascripts/labels.js.coffee
0 → 100644
View file @
0b5e0e4c
class
Labels
constructor
:
->
# find the form
form
=
$
(
'.label-form'
)
@
setupLabelForm
(
form
)
###
General note form setup.
deactivates the submit button when text is empty
hides the preview button when text is empty
setup GFM auto complete
show the form
###
setupLabelForm
:
(
form
)
->
disableButtonIfEmptyField
form
,
'.form-control'
,
form
.
find
(
'.js-save-button'
)
@
Labels
=
Labels
app/views/projects/labels/_form.html.haml
View file @
0b5e0e4c
...
...
@@ -28,7 +28,7 @@
.form-actions
=
f
.
submit
'Save'
,
class:
'btn btn-save'
=
f
.
submit
'Save'
,
class:
'btn btn-save
js-save-button
'
=
link_to
"Cancel"
,
project_labels_path
(
@project
),
class:
'btn btn-cancel'
...
...
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