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
8a39bb77
Commit
8a39bb77
authored
Dec 09, 2015
by
Sean Hammond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak the drafts.update() API
parent
0b7c3122
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
12 deletions
+16
-12
annotation.js
h/static/scripts/directive/annotation.js
+6
-2
annotation-test.js
h/static/scripts/directive/test/annotation-test.js
+1
-1
drafts.js
h/static/scripts/drafts.js
+4
-4
drafts-test.js
h/static/scripts/test/drafts-test.js
+5
-5
No files found.
h/static/scripts/directive/annotation.js
View file @
8a39bb77
...
...
@@ -137,8 +137,12 @@ function restoreFromDrafts(drafts, permissions, domainModel, vm) {
*/
function
saveToDrafts
(
drafts
,
domainModel
,
vm
)
{
drafts
.
update
(
domainModel
,
vm
.
isPrivate
(),
domainModelTagsFromViewModelTags
(
vm
.
form
.
tags
),
vm
.
form
.
text
);
domainModel
,
{
isPrivate
:
vm
.
isPrivate
(),
tags
:
domainModelTagsFromViewModelTags
(
vm
.
form
.
tags
),
text
:
vm
.
form
.
text
,
});
}
/** Update domainModel from vm.
...
...
h/static/scripts/directive/test/annotation-test.js
View file @
8a39bb77
...
...
@@ -1323,7 +1323,7 @@ describe('annotation.js', function() {
assert
.
calledWith
(
fakeDrafts
.
update
,
parts
.
annotation
,
true
,
[],
'unsaved-text'
);
parts
.
annotation
,
{
isPrivate
:
true
,
tags
:[],
text
:
'unsaved-text'
}
);
});
it
(
'should not create a new draft'
,
function
()
{
...
...
h/static/scripts/drafts.js
View file @
8a39bb77
...
...
@@ -63,12 +63,12 @@ function DraftStore() {
* Update the draft version for a given annotation, replacing any
* existing draft.
*/
this
.
update
=
function
update
(
model
,
isPrivate
,
tags
,
text
)
{
this
.
update
=
function
update
(
model
,
changes
)
{
var
newDraft
=
{
model
:
model
,
isPrivate
:
isPrivate
,
tags
:
tags
,
text
:
text
isPrivate
:
changes
.
isPrivate
,
tags
:
changes
.
tags
,
text
:
changes
.
text
};
this
.
remove
(
model
);
this
.
_drafts
.
push
(
newDraft
);
...
...
h/static/scripts/test/drafts-test.js
View file @
8a39bb77
...
...
@@ -11,7 +11,7 @@ describe('drafts', function () {
it
(
'should save changes'
,
function
()
{
var
model
=
{
id
:
'foo'
};
assert
.
notOk
(
drafts
.
get
(
model
));
drafts
.
update
(
model
,
true
,
[
'foo'
],
'edit'
);
drafts
.
update
(
model
,
{
isPrivate
:
true
,
tags
:[
'foo'
],
text
:
'edit'
}
);
assert
.
deepEqual
(
drafts
.
get
(
model
),
{
isPrivate
:
true
,
tags
:
[
'foo'
],
text
:
'edit'
});
...
...
@@ -19,16 +19,16 @@ describe('drafts', function () {
it
(
'should replace existing drafts'
,
function
()
{
var
model
=
{
id
:
'foo'
};
drafts
.
update
(
model
,
true
,
[
'foo'
],
'foo'
);
drafts
.
update
(
model
,
true
,
[
'foo'
],
'bar'
);
drafts
.
update
(
model
,
{
isPrivate
:
true
,
tags
:[
'foo'
],
text
:
'foo'
}
);
drafts
.
update
(
model
,
{
isPrivate
:
true
,
tags
:[
'foo'
],
text
:
'bar'
}
);
assert
.
equal
(
drafts
.
get
(
model
).
text
,
'bar'
);
});
it
(
'should replace existing drafts with the same ID'
,
function
()
{
var
modelA
=
{
id
:
'foo'
};
var
modelB
=
{
id
:
'foo'
};
drafts
.
update
(
modelA
,
true
,
[
'foo'
],
'foo'
);
drafts
.
update
(
modelB
,
true
,
[
'foo'
],
'bar'
);
drafts
.
update
(
modelA
,
{
isPrivate
:
true
,
tags
:[
'foo'
],
text
:
'foo'
}
);
drafts
.
update
(
modelB
,
{
isPrivate
:
true
,
tags
:[
'foo'
],
text
:
'bar'
}
);
assert
.
equal
(
drafts
.
get
(
modelA
).
text
,
'bar'
);
});
});
...
...
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