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
ba0f19a4
Commit
ba0f19a4
authored
May 04, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
document table: 1)sorting before duplicates filter 2) (to test) overall better sorting on titles
parent
01bd3349
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
21 deletions
+57
-21
Docs_dyna_chart_and_table.js
static/js/gargantext/Docs_dyna_chart_and_table.js
+57
-21
No files found.
static/js/gargantext/Docs_dyna_chart_and_table.js
View file @
ba0f19a4
...
@@ -120,8 +120,8 @@ function Final_UpdateTable( action ) {
...
@@ -120,8 +120,8 @@ function Final_UpdateTable( action ) {
// STEP 01:
// STEP 01:
// remember url elements
// remember url elements
var
id_from_url
=
function
(
name
)
{
var
id_from_url
=
function
(
n
oden
ame
)
{
var
regex
=
new
RegExp
(
name
+
'/(
\\
d+)'
);
var
regex
=
new
RegExp
(
n
oden
ame
+
'/(
\\
d+)'
);
var
result
=
regex
.
exec
(
location
.
href
);
var
result
=
regex
.
exec
(
location
.
href
);
return
result
?
result
[
1
]
:
null
;
return
result
?
result
[
1
]
:
null
;
};
};
...
@@ -156,17 +156,19 @@ function getRecords() {
...
@@ -156,17 +156,19 @@ function getRecords() {
function
transformContent2
(
rec_id
)
{
function
transformContent2
(
rec_id
)
{
// pr("\t\ttransformContent2: "+rec_id)
// pr("\t\ttransformContent2: "+rec_id)
var
elem
=
AjaxRecords
[
rec_id
];
var
elem
=
AjaxRecords
[
rec_id
];
// pr("\t"+elem.title)
// pr("\t"+elem.
raw
title)
var
result
=
{}
var
result
=
{}
if
(
elem
[
"del"
])
{
if
(
elem
[
"del"
])
{
result
[
"id"
]
=
elem
[
"id"
]
result
[
"id"
]
=
elem
[
"id"
]
result
[
"date"
]
=
'<strike>'
+
elem
[
"date"
]
+
'</strike>'
result
[
"date"
]
=
'<strike>'
+
elem
[
"date"
]
+
'</strike>'
result
[
"name"
]
=
'<strike>'
+
elem
[
"name"
]
+
'</strike>'
result
[
"docurl"
]
=
'<strike>'
+
elem
[
"docurl"
]
+
'</strike>'
result
[
"rawtitle"
]
=
elem
[
"rawtitle"
]
result
[
"del"
]
=
'<input id='
+
rec_id
+
' onclick="overRide(this)" type="checkbox" checked/>'
result
[
"del"
]
=
'<input id='
+
rec_id
+
' onclick="overRide(this)" type="checkbox" checked/>'
}
else
{
}
else
{
result
[
"id"
]
=
elem
[
"id"
]
result
[
"id"
]
=
elem
[
"id"
]
result
[
"date"
]
=
elem
[
"date"
]
result
[
"date"
]
=
elem
[
"date"
]
result
[
"name"
]
=
elem
[
"name"
]
result
[
"docurl"
]
=
elem
[
"docurl"
]
result
[
"rawtitle"
]
=
elem
[
"rawtitle"
]
result
[
"del"
]
=
'<input id='
+
rec_id
+
' onclick="overRide(this)" type="checkbox"/>'
result
[
"del"
]
=
'<input id='
+
rec_id
+
' onclick="overRide(this)" type="checkbox"/>'
}
}
return
result
;
return
result
;
...
@@ -264,11 +266,11 @@ function Main_test(Data) {
...
@@ -264,11 +266,11 @@ function Main_test(Data) {
div_table
+=
'<table id="my-ajax-table" class="table table-bordered">'
+
"
\n
"
div_table
+=
'<table id="my-ajax-table" class="table table-bordered">'
+
"
\n
"
div_table
+=
"
\
t"
+
'<thead>'
+
"
\n
"
div_table
+=
"
\
t"
+
'<thead>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th width="100px;" data-dynatable-column="date">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th width="100px;" data-dynatable-column="date">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-calendar"
aria-hidden="true"
></span> Date</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-calendar"></span> Date</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="
name
">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="
docurl
">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-text-size"
aria-hidden="true"
></span> Title</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-text-size"></span> Title</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="del" data-dynatable-no-sort="true">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="del" data-dynatable-no-sort="true">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-trash"
aria-hidden="true"
></span>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-trash"></span>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
'</thead>'
+
"
\n
"
div_table
+=
"
\
t"
+
'</thead>'
+
"
\n
"
div_table
+=
"
\
t"
+
'<tbody>'
+
"
\n
"
div_table
+=
"
\
t"
+
'<tbody>'
+
"
\n
"
...
@@ -282,7 +284,7 @@ function Main_test(Data) {
...
@@ -282,7 +284,7 @@ function Main_test(Data) {
var
date
=
Data
[
i
][
"date"
];
var
date
=
Data
[
i
][
"date"
];
if
(
!
justdates
[
date
]
)
justdates
[
date
]
=
0
;
if
(
!
justdates
[
date
]
)
justdates
[
date
]
=
0
;
justdates
[
date
]
++
;
justdates
[
date
]
++
;
// console.log(Data[i]["date"]+" : originalRecords["+arr_id+"] <- "+orig_id+" | "+Data[i]["
name
"])
// console.log(Data[i]["date"]+" : originalRecords["+arr_id+"] <- "+orig_id+" | "+Data[i]["
docurl
"])
}
}
var
t0
=
get_node_date
(
AjaxRecords
[
0
]);
var
t0
=
get_node_date
(
AjaxRecords
[
0
]);
...
@@ -427,13 +429,17 @@ function Main_test(Data) {
...
@@ -427,13 +429,17 @@ function Main_test(Data) {
MyTable
=
[]
MyTable
=
[]
MyTable
=
$
(
'#my-ajax-table'
).
dynatable
({
MyTable
=
$
(
'#my-ajax-table'
).
dynatable
({
dataset
:
{
dataset
:
{
records
:
Data
records
:
Data
,
sorts
:
{
"date"
:
1
},
sortTypes
:
{
docurl
:
'rawtitleSort'
}
},
},
features
:
{
features
:
{
pushState
:
false
,
pushState
:
false
,
// prevent default title search which can't do title vs abstract
// prevent default title search which can't do title vs abstract
search
:
false
,
search
:
false
,
// sort: false //i need to fix the sorting function... the current one just sucks
sort
:
true
},
},
inputs
:
{
inputs
:
{
// our own search which differentiates title vs abstract queries
// our own search which differentiates title vs abstract queries
...
@@ -446,7 +452,7 @@ function Main_test(Data) {
...
@@ -446,7 +452,7 @@ function Main_test(Data) {
});
});
MyTable
.
data
(
'dynatable'
).
paginationPage
.
set
(
1
);
MyTable
.
data
(
'dynatable'
).
paginationPage
.
set
(
1
);
MyTable
.
data
(
'dynatable'
).
process
();
//
MyTable.data('dynatable').process();
if
(
$
(
".imadiv"
).
length
>
0
)
return
1
;
if
(
$
(
".imadiv"
).
length
>
0
)
return
1
;
$
(
'<br><br><div class="imadiv"></div>'
).
insertAfter
(
".dynatable-per-page"
)
$
(
'<br><br><div class="imadiv"></div>'
).
insertAfter
(
".dynatable-per-page"
)
...
@@ -463,7 +469,7 @@ function Main_test(Data) {
...
@@ -463,7 +469,7 @@ function Main_test(Data) {
// NB searchString == $("#doubleSearch").val()
// NB searchString == $("#doubleSearch").val()
// by default we always decide to search in the title
// by default we always decide to search in the title
matchInTexts
=
[
record
.
title
]
matchInTexts
=
[
record
.
raw
title
]
// if box is checked we'll also search in the abstracts
// if box is checked we'll also search in the abstracts
if
(
doAbstractsSearch
)
{
if
(
doAbstractsSearch
)
{
...
@@ -485,20 +491,25 @@ function Main_test(Data) {
...
@@ -485,20 +491,25 @@ function Main_test(Data) {
}
}
return
contains
;
return
contains
;
}
}
MyTable
.
data
(
'dynatable'
).
process
();
//
MyTable.data('dynatable').process();
// also append another bound filter for duplicates
// also append another bound filter for duplicates
MyTable
.
data
(
'dynatable'
).
queries
MyTable
.
data
(
'dynatable'
).
queries
.
functions
[
'dupFilter'
]
=
function
(
record
,
selected
)
{
.
functions
[
'dupFilter'
]
=
function
(
record
,
selected
)
{
return
(
selected
==
'filter_all'
)
||
(
countByTitles
[
record
.
title
]
>
1
)
return
(
selected
==
'filter_all'
)
||
(
countByTitles
[
record
.
raw
title
]
>
1
)
}
}
// and set this filter's initial status to 'filter_all'
// and set this filter's initial status to 'filter_all'
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'dupFilter'
]
=
'filter_all'
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'dupFilter'
]
=
'filter_all'
MyTable
.
data
(
'dynatable'
).
process
();
MyTable
.
data
(
'dynatable'
).
process
MyTable
.
data
(
'dynatable'
).
sorts
.
functions
[
"rawtitleSort"
]
=
function
testSort
(
rec1
,
rec2
)
{
// sorts on rawtitle instead of derived docurl
// and sorts with locale-aware order
return
rec1
.
rawtitle
.
localeCompare
(
rec2
.
rawtitle
)
}
MyTable
.
data
(
'dynatable'
).
process
();
// re-apply search function on click
// re-apply search function on click
$
(
'#searchAB'
).
click
(
function
()
{
$
(
'#searchAB'
).
click
(
function
()
{
...
@@ -514,6 +525,29 @@ function Main_test(Data) {
...
@@ -514,6 +525,29 @@ function Main_test(Data) {
return
"OK"
return
"OK"
}
}
var
dupFlag
=
false
;
$
(
"#div-table"
).
on
(
"dynatable:queries:added"
,
function
(
e
,
qname
,
qval
)
{
if
(
!
dupFlag
&&
qname
==
'dupFilter'
&&
qval
==
"filter_dupl"
)
{
MyTable
.
data
(
'dynatable'
).
queries
.
remove
(
'dupFilter'
)
// to avoid recursion when we'll call this filter again in 4 lines
dupFlag
=
true
;
// sort alphabetically **before** duplicates filter
MyTable
.
data
(
'dynatable'
).
sorts
.
clear
();
MyTable
.
data
(
'dynatable'
).
sorts
.
add
(
'rawtitle'
,
-
1
)
// -1 <==> DESC (ASC doesn't work well ?)
MyTable
.
data
(
'dynatable'
).
queries
.
add
(
'dupFilter'
,
'filter_dupl'
)
MyTable
.
data
(
'dynatable'
).
process
();
}
});
$
(
"#div-table"
).
on
(
"dynatable:queries:removed"
,
function
(
e
,
qname
)
{
if
(
qname
==
'dupFilter'
)
{
dupFlag
=
false
;
}
});
// FIRST portion of code to be EXECUTED:
// FIRST portion of code to be EXECUTED:
// (3) Get records and hyperdata for paginator
// (3) Get records and hyperdata for paginator
$
.
ajax
({
$
.
ajax
({
...
@@ -526,15 +560,17 @@ $.ajax({
...
@@ -526,15 +560,17 @@ $.ajax({
var
orig_id
=
parseInt
(
record
.
id
);
var
orig_id
=
parseInt
(
record
.
id
);
var
arr_id
=
parseInt
(
i
)
var
arr_id
=
parseInt
(
i
)
RecDict
[
orig_id
]
=
arr_id
;
RecDict
[
orig_id
]
=
arr_id
;
record
.
title
=
record
.
name
;
record
.
rawtitle
=
record
.
name
;
record
.
name
=
'<a target="_blank" href="/projects/'
+
project_id
+
'/corpora/'
+
corpus_id
+
'/documents/'
+
record
.
id
+
'">'
+
record
.
name
+
'</a>'
;
// trick to have a clickable title in docurl slot, but could be done in transformContent2
record
.
docurl
=
'<a target="_blank" href="/projects/'
+
project_id
+
'/corpora/'
+
corpus_id
+
'/documents/'
+
record
.
id
+
'">'
+
record
.
name
+
'</a>'
;
record
.
date
=
get_node_date
(
record
);
record
.
date
=
get_node_date
(
record
);
record
.
del
=
false
;
record
.
del
=
false
;
});
});
// initialize CountByTitle census
// initialize CountByTitle census
for
(
var
i
in
data
.
records
)
{
for
(
var
i
in
data
.
records
)
{
ourTitle
=
data
.
records
[
i
][
'title'
]
;
ourTitle
=
data
.
records
[
i
][
'
raw
title'
]
;
if
(
countByTitles
.
hasOwnProperty
(
ourTitle
))
{
if
(
countByTitles
.
hasOwnProperty
(
ourTitle
))
{
countByTitles
[
ourTitle
]
++
;
countByTitles
[
ourTitle
]
++
;
}
}
...
...
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