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
02fa8ab5
Commit
02fa8ab5
authored
Apr 05, 2017
by
Sheetal Umesh Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show the flagged status for annotations that user has flagged.
parent
a4376d09
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
3 deletions
+48
-3
annotation.js
src/sidebar/components/annotation.js
+5
-1
annotation-test.js
src/sidebar/components/test/annotation-test.js
+1
-0
annotations.js
src/sidebar/reducers/annotations.js
+31
-0
annotation.html
src/sidebar/templates/annotation.html
+2
-2
annotation-ui-test.js
src/sidebar/test/annotation-ui-test.js
+9
-0
No files found.
src/sidebar/components/annotation.js
View file @
02fa8ab5
...
...
@@ -207,7 +207,7 @@ function AnnotationController(
};
annotationMapper
.
flagAnnotation
(
vm
.
annotation
).
then
(
function
(){
analytics
.
track
(
analytics
.
events
.
ANNOTATION_FLAGGED
);
vm
.
isFlagged
=
true
;
annotationUI
.
updateFlagStatus
(
vm
.
annotation
.
id
,
true
)
;
},
onRejected
);
};
...
...
@@ -482,6 +482,10 @@ function AnnotationController(
return
annotationUI
.
isHiddenByModerator
(
vm
.
annotation
.
id
);
};
vm
.
isFlagged
=
function
()
{
return
vm
.
annotation
.
flagged
;
};
vm
.
isReply
=
function
()
{
return
isReply
(
vm
.
annotation
);
};
...
...
src/sidebar/components/test/annotation-test.js
View file @
02fa8ab5
...
...
@@ -146,6 +146,7 @@ describe('annotation', function() {
fakeAnnotationUI
=
{
isHiddenByModerator
:
sandbox
.
stub
().
returns
(
false
),
updateFlagStatus
:
sandbox
.
stub
().
returns
(
true
),
};
fakeDrafts
=
{
...
...
src/sidebar/reducers/annotations.js
View file @
02fa8ab5
...
...
@@ -146,6 +146,20 @@ var update = {
return
{
annotations
:
[]};
},
UPDATE_FLAG_STATUS
:
function
(
state
,
action
)
{
var
annotations
=
state
.
annotations
.
map
(
function
(
annot
)
{
var
match
=
(
annot
.
id
&&
annot
.
id
===
action
.
id
);
if
(
match
)
{
return
Object
.
assign
({},
annot
,
{
flagged
:
action
.
isFlagged
,
});
}
else
{
return
annot
;
}
});
return
{
annotations
:
annotations
};
},
UPDATE_ANCHOR_STATUS
:
function
(
state
,
action
)
{
var
annotations
=
state
.
annotations
.
map
(
function
(
annot
)
{
var
match
=
(
annot
.
id
&&
annot
.
id
===
action
.
id
)
||
...
...
@@ -166,6 +180,22 @@ var update = {
var
actions
=
util
.
actionTypes
(
update
);
/**
* Updating the flagged status of an annotation.
*
* @param {string} id - Annotation ID
* @param {boolean} isFlagged - The flagged status of the annotation. True if
* the user has flagged the annotation.
*
*/
function
updateFlagStatus
(
id
,
isFlagged
)
{
return
{
type
:
actions
.
UPDATE_FLAG_STATUS
,
id
:
id
,
isFlagged
:
isFlagged
,
};
}
/** Add annotations to the currently displayed set. */
function
addAnnotations
(
annotations
,
now
)
{
now
=
now
||
new
Date
();
...
...
@@ -297,6 +327,7 @@ module.exports = {
clearAnnotations
:
clearAnnotations
,
removeAnnotations
:
removeAnnotations
,
updateAnchorStatus
:
updateAnchorStatus
,
updateFlagStatus
:
updateFlagStatus
,
},
// Selectors
...
...
src/sidebar/templates/annotation.html
View file @
02fa8ab5
...
...
@@ -190,7 +190,7 @@
</span>
<span
ng-if=
"vm.isThirdPartyUser()"
>
<button
class=
"btn btn-clean annotation-action-btn"
ng-if=
"!vm.isFlagged"
ng-if=
"!vm.isFlagged
()
"
ng-click=
"vm.flag()"
ng-disabled=
"vm.isDeleted()"
aria-label=
"Flag"
...
...
@@ -198,7 +198,7 @@
<i
class=
"h-icon-annotation-flag btn-icon"
></i>
</button>
<button
class=
"btn btn-clean annotation-action-btn"
ng-if=
"vm.isFlagged"
ng-if=
"vm.isFlagged
()
"
ng-disabled=
"vm.isDeleted()"
aria-label=
"Annotation has been flagged"
h-tooltip
>
...
...
src/sidebar/test/annotation-ui-test.js
View file @
02fa8ab5
...
...
@@ -507,6 +507,15 @@ describe('annotationUI', function () {
});
});
describe
(
'#updateFlagStatus'
,
function
()
{
it
(
'updates the flaged status of an annotation'
,
function
()
{
var
annot
=
defaultAnnotation
();
annotationUI
.
addAnnotations
([
annot
]);
annotationUI
.
updateFlagStatus
(
annot
.
id
,
true
);
assert
.
equal
(
annotationUI
.
getState
().
annotations
[
0
].
flagged
,
true
);
});
});
describe
(
'selector functions'
,
function
()
{
// The individual state management modules in reducers/*.js define various
// 'selector' functions for extracting data from the app state. These are
...
...
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