Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
4264663f
Commit
4264663f
authored
Nov 30, 2015
by
Robert Knight
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2754 from hypothesis/dont-save-null-data-to-draft-store
Don't save null permissions/tags/text to drafts store
parents
eeace932
40e2b6f3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
10 deletions
+23
-10
annotation.coffee
h/static/scripts/directive/annotation.coffee
+8
-5
annotation-test.coffee
h/static/scripts/directive/test/annotation-test.coffee
+15
-5
No files found.
h/static/scripts/directive/annotation.coffee
View file @
4264663f
...
...
@@ -241,11 +241,14 @@ AnnotationController = [
# Drafts only preserve the text, tags and permissions of the annotation
# (i.e. only the bits that the user can edit), changes to other
# properties are not preserved.
drafts.update(model, {
text: draft.text
tags: draft.tags
permissions: draft.permissions
})
changes = {}
if draft.text?
changes.text = draft.text
if draft.tags?
changes.tags = draft.tags
if draft.permissions?
changes.permissions = draft.permissions
drafts.update(model, changes)
###
*
# @ngdoc method
...
...
h/static/scripts/directive/test/annotation-test.coffee
View file @
4264663f
...
...
@@ -540,11 +540,21 @@ describe 'annotation', ->
it
"creates a draft when editing an annotation"
,
->
createDirective
()
controller
.
edit
()
assert
.
calledWith
(
fakeDrafts
.
update
,
annotation
,
{
text
:
annotation
.
text
,
tags
:
annotation
.
tags
,
permissions
:
annotation
.
permissions
})
assert
.
calledWith
(
fakeDrafts
.
update
,
annotation
)
it
"creates a draft with only editable fields which are non-null"
,
->
# When a draft is saved, we shouldn't save any fields to the draft
# "changes" object that aren't actually set on the annotation. In this
# case, both permissions and tags are null so shouldn't be saved in the
# draft.
createDirective
()
annotation
.
permissions
=
null
annotation
.
text
=
'Hello!'
annotation
.
tags
=
null
controller
.
edit
()
assert
.
calledWith
(
fakeDrafts
.
update
,
annotation
,
{
text
:
'Hello!'
})
it
"starts editing immediately if there is a draft"
,
->
fakeDrafts
.
get
.
returns
({
...
...
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