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
7826718d
Commit
7826718d
authored
Apr 06, 2016
by
Nick Stenning
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3179 from hypothesis/314-annotation-sort-order
Fix 'Location' sort order for annotations
parents
349c5a4e
0a69ccd0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
4 deletions
+40
-4
app-controller.js
h/static/scripts/app-controller.js
+3
-1
polyfills.js
h/static/scripts/polyfills.js
+1
-0
app-controller-test.js
h/static/scripts/test/app-controller-test.js
+36
-3
No files found.
h/static/scripts/app-controller.js
View file @
7826718d
...
...
@@ -89,7 +89,9 @@ module.exports = function AppController(
predicateFn
=
[
'-!!message'
,
'message.updated'
];
break
;
case
'Location'
:
predicateFn
=
annotationMetadata
.
location
;
predicateFn
=
function
(
thread
)
{
return
annotationMetadata
.
location
(
thread
.
message
);
};
break
;
}
$scope
.
sort
=
{
...
...
h/static/scripts/polyfills.js
View file @
7826718d
...
...
@@ -3,6 +3,7 @@
// ES2015 polyfills
require
(
'core-js/es6/promise'
);
require
(
'core-js/fn/array/find'
);
require
(
'core-js/fn/array/find-index'
);
require
(
'core-js/fn/object/assign'
);
// URL constructor, required by IE 10/11,
...
...
h/static/scripts/test/app-controller-test.js
View file @
7826718d
'use strict'
;
var
angular
=
require
(
'angular'
);
var
proxyquire
=
require
(
'proxyquire'
);
var
annotationFixtures
=
require
(
'./annotation-fixtures'
);
var
events
=
require
(
'../events'
);
var
util
=
require
(
'./util'
);
describe
(
'AppController'
,
function
()
{
var
$controller
=
null
;
var
$scope
=
null
;
var
$rootScope
=
null
;
var
fakeAnnotationMetadata
=
null
;
var
fakeAnnotationUI
=
null
;
var
fakeAuth
=
null
;
var
fakeDrafts
=
null
;
...
...
@@ -28,9 +32,18 @@ describe('AppController', function () {
return
$controller
(
'AppController'
,
locals
);
};
before
(
function
()
{
return
angular
.
module
(
'h'
,
[])
.
controller
(
'AppController'
,
require
(
'../app-controller'
))
beforeEach
(
function
()
{
fakeAnnotationMetadata
=
{
location
:
function
()
{
return
0
;
},
};
var
AppController
=
proxyquire
(
'../app-controller'
,
util
.
noCallThru
({
'angular'
:
angular
,
'./annotation-metadata'
:
fakeAnnotationMetadata
,
}));
angular
.
module
(
'h'
,
[])
.
controller
(
'AppController'
,
AppController
)
.
controller
(
'AnnotationUIController'
,
angular
.
noop
);
});
...
...
@@ -263,4 +276,24 @@ describe('AppController', function () {
assert
.
equal
(
fakeWindow
.
confirm
.
callCount
,
0
);
});
});
describe
(
'sorting'
,
function
()
{
function
annotationThread
()
{
return
{
message
:
annotationFixtures
.
defaultAnnotation
()};
}
it
(
'sorts threads by location when sort name is "Location"'
,
function
()
{
var
threads
=
[
annotationThread
(),
annotationThread
()];
fakeAnnotationMetadata
.
location
=
function
(
annotation
)
{
return
threads
.
findIndex
(
function
(
thread
)
{
return
thread
.
message
===
annotation
;
});
};
createController
();
$scope
.
sort
.
name
=
'Location'
;
$scope
.
$digest
();
assert
.
equal
(
$scope
.
sort
.
predicate
(
threads
[
0
]),
0
);
assert
.
equal
(
$scope
.
sort
.
predicate
(
threads
[
1
]),
1
);
});
});
});
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