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
a22fd26e
Commit
a22fd26e
authored
Nov 06, 2018
by
Stan Hu
Committed by
Phil Hughes
Nov 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix save button not activating when original setting started as null
parent
1109c227
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
app/assets/javascripts/dirty_submit/dirty_submit_form.js
app/assets/javascripts/dirty_submit/dirty_submit_form.js
+2
-1
spec/javascripts/dirty_submit/dirty_submit_form_spec.js
spec/javascripts/dirty_submit/dirty_submit_form_spec.js
+22
-10
No files found.
app/assets/javascripts/dirty_submit/dirty_submit_form.js
View file @
a22fd26e
...
@@ -31,7 +31,7 @@ class DirtySubmitForm {
...
@@ -31,7 +31,7 @@ class DirtySubmitForm {
updateDirtyInput
(
event
)
{
updateDirtyInput
(
event
)
{
const
input
=
event
.
target
;
const
input
=
event
.
target
;
if
(
!
input
.
dataset
.
dirtySubmitOriginalValue
)
return
;
if
(
!
input
.
dataset
.
isDirtySubmitInput
)
return
;
this
.
updateDirtyInputs
(
input
);
this
.
updateDirtyInputs
(
input
);
this
.
toggleSubmission
();
this
.
toggleSubmission
();
...
@@ -65,6 +65,7 @@ class DirtySubmitForm {
...
@@ -65,6 +65,7 @@ class DirtySubmitForm {
}
}
static
initInput
(
element
)
{
static
initInput
(
element
)
{
element
.
dataset
.
isDirtySubmitInput
=
true
;
element
.
dataset
.
dirtySubmitOriginalValue
=
DirtySubmitForm
.
inputCurrentValue
(
element
);
element
.
dataset
.
dirtySubmitOriginalValue
=
DirtySubmitForm
.
inputCurrentValue
(
element
);
}
}
...
...
spec/javascripts/dirty_submit/dirty_submit_form_spec.js
View file @
a22fd26e
import
DirtySubmitForm
from
'
~/dirty_submit/dirty_submit_form
'
;
import
DirtySubmitForm
from
'
~/dirty_submit/dirty_submit_form
'
;
import
{
setInput
,
createForm
}
from
'
./helper
'
;
import
{
setInput
,
createForm
}
from
'
./helper
'
;
function
expectToToggleDisableOnDirtyUpdate
(
submit
,
input
)
{
const
originalValue
=
input
.
value
;
expect
(
submit
.
disabled
).
toBe
(
true
);
return
setInput
(
input
,
`
${
originalValue
}
changes`
)
.
then
(()
=>
expect
(
submit
.
disabled
).
toBe
(
false
))
.
then
(()
=>
setInput
(
input
,
originalValue
))
.
then
(()
=>
expect
(
submit
.
disabled
).
toBe
(
true
));
}
describe
(
'
DirtySubmitForm
'
,
()
=>
{
describe
(
'
DirtySubmitForm
'
,
()
=>
{
it
(
'
disables submit until there are changes
'
,
done
=>
{
it
(
'
disables submit until there are changes
'
,
done
=>
{
const
{
form
,
input
,
submit
}
=
createForm
();
const
{
form
,
input
,
submit
}
=
createForm
();
const
originalValue
=
input
.
value
;
new
DirtySubmitForm
(
form
);
// eslint-disable-line no-new
new
DirtySubmitForm
(
form
);
// eslint-disable-line no-new
expect
(
submit
.
disabled
).
toBe
(
true
);
return
expectToToggleDisableOnDirtyUpdate
(
submit
,
input
)
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
disables submit until there are changes when initializing with a falsy value
'
,
done
=>
{
const
{
form
,
input
,
submit
}
=
createForm
();
input
.
value
=
''
;
new
DirtySubmitForm
(
form
);
// eslint-disable-line no-new
return
setInput
(
input
,
`
${
originalValue
}
changes`
)
return
expectToToggleDisableOnDirtyUpdate
(
submit
,
input
)
.
then
(()
=>
{
expect
(
submit
.
disabled
).
toBe
(
false
);
})
.
then
(()
=>
setInput
(
input
,
originalValue
))
.
then
(()
=>
{
expect
(
submit
.
disabled
).
toBe
(
true
);
})
.
then
(
done
)
.
then
(
done
)
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
});
});
...
...
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