Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
6fc3df6d
Commit
6fc3df6d
authored
Sep 24, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX] docs view: make sort more stable for undefined values
parent
62a3a867
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
6 deletions
+31
-6
Docs_dyna_chart_and_table.js
static/lib/gargantext/Docs_dyna_chart_and_table.js
+31
-6
No files found.
static/lib/gargantext/Docs_dyna_chart_and_table.js
View file @
6fc3df6d
...
@@ -630,9 +630,23 @@ function Main_test(Data) {
...
@@ -630,9 +630,23 @@ function Main_test(Data) {
MyTable
.
data
(
'dynatable'
).
sorts
.
functions
[
"signatureSort"
]
=
makeAlphaSortFunctionOnProperty
(
'signature'
)
MyTable
.
data
(
'dynatable'
).
sorts
.
functions
[
"signatureSort"
]
=
makeAlphaSortFunctionOnProperty
(
'signature'
)
MyTable
.
data
(
'dynatable'
).
sorts
.
functions
[
"sourceSort"
]
=
function
sourceSort
(
rec1
,
rec2
,
attr
,
direction
)
{
MyTable
.
data
(
'dynatable'
).
sorts
.
functions
[
"sourceSort"
]
=
function
sourceSort
(
rec1
,
rec2
,
attr
,
direction
)
{
// like rawtitle but nested property
// like rawtitle but nested property
if
(
direction
==
1
)
return
rec1
.
hyperdata
.
source
.
localeCompare
(
rec2
.
hyperdata
.
source
)
if
(
rec1
.
hyperdata
&&
rec1
.
hyperdata
.
source
else
return
rec2
.
hyperdata
.
source
.
localeCompare
(
rec1
.
hyperdata
.
source
)
&&
rec2
.
hyperdata
&&
rec2
.
hyperdata
.
source
)
{
}
// the alphabetic sort
if
(
direction
==
1
)
return
rec1
.
hyperdata
.
source
.
localeCompare
(
rec2
.
hyperdata
.
source
)
else
return
rec2
.
hyperdata
.
source
.
localeCompare
(
rec1
.
hyperdata
.
source
)
}
else
if
(
rec1
.
hyperdata
&&
rec1
.
hyperdata
.
source
)
{
cmp
=
direction
}
else
if
(
rec2
.
hyperdata
&&
rec2
.
hyperdata
.
source
)
{
cmp
=
-
direction
}
else
{
cmp
=
0
}
if
(
cmp
==
0
)
cmp
=
RecDict
[
rec1
.
id
]
<
RecDict
[
rec2
.
id
]
?
-
1
:
1
}
// hook on page change
// hook on page change
MyTable
.
bind
(
'dynatable:page:set'
,
tidyAfterPageSet
)
MyTable
.
bind
(
'dynatable:page:set'
,
tidyAfterPageSet
)
...
@@ -736,9 +750,20 @@ function makeAlphaSortFunctionOnProperty(property) {
...
@@ -736,9 +750,20 @@ function makeAlphaSortFunctionOnProperty(property) {
return
function
(
rec1
,
rec2
,
attr
,
direction
)
{
return
function
(
rec1
,
rec2
,
attr
,
direction
)
{
var
cmp
=
null
var
cmp
=
null
// the alphabetic sort
if
(
rec1
[
property
]
&&
rec2
[
property
])
{
if
(
direction
==
1
)
cmp
=
rec1
[
property
].
localeCompare
(
rec2
[
property
])
// the alphabetic sort
else
cmp
=
rec2
[
property
].
localeCompare
(
rec1
[
property
])
if
(
direction
==
1
)
cmp
=
rec1
[
property
].
localeCompare
(
rec2
[
property
])
else
cmp
=
rec2
[
property
].
localeCompare
(
rec1
[
property
])
}
else
if
(
rec1
[
property
])
{
cmp
=
direction
}
else
if
(
rec2
[
property
])
{
cmp
=
-
direction
}
else
{
cmp
=
0
}
// second level sorting on key = id in records array
// second level sorting on key = id in records array
// (this one volontarily not reversable by direction
// (this one volontarily not reversable by direction
...
...
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