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
663224e4
Commit
663224e4
authored
8 years ago
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documents: add journal column and make date shorter
parent
497d9537
master
anoe-gargantext-light
c24b-stable
c24b-stable-patch
c24b-testing-
dev
dev-graphExplorerJSON
gargantext-light
install
remote
simon-experimental
simon-gargantext-light
simon-rest-doc
simon-testing
simon-unstable
stable
stable-help
stable-imt
stable-imt-hal
stable-imt-link
stable-imt-merge
stable-imt-notebook
stable-notebook
stable-origin
stable-patch
stable-v3-imt
testing
testing-distri
testing-graph-growth
testing-graph-public
testing-imt
testing-jwt
testing-langParsing
testing-merge
testing-mine
testing-notebook
testing-share
unstable
unstable-docker
unstable-newBdd
unstable-notebook
unstable-philoNotebook
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
8 deletions
+40
-8
Docs_dyna_chart_and_table.js
static/lib/gargantext/Docs_dyna_chart_and_table.js
+40
-8
No files found.
static/lib/gargantext/Docs_dyna_chart_and_table.js
View file @
663224e4
...
...
@@ -195,14 +195,16 @@ function transformContent2(rec_id) {
var
result
=
{}
if
(
elem
[
"del"
])
{
result
[
"id"
]
=
elem
[
"id"
]
result
[
"date"
]
=
'<strike>'
+
elem
[
"date"
]
+
'</strike>'
result
[
"short_date"
]
=
'<strike>'
+
elem
[
"short_date"
]
+
'</strike>'
result
[
"hyperdata.journal"
]
=
'<strike><small><i>'
+
elem
[
"hyperdata"
][
"journal"
]
+
'</small></i></strike>'
result
[
"docurl"
]
=
'<strike>'
+
elem
[
"docurl"
]
+
'</strike>'
result
[
"isFavorite"
]
=
favstatusToStar
(
rec_id
,
elem
[
"isFavorite"
],
boolStrike
=
true
)
result
[
"rawtitle"
]
=
elem
[
"rawtitle"
]
result
[
"del"
]
=
'<input id='
+
rec_id
+
' onclick="overRide(this)" type="checkbox" checked/>'
}
else
{
result
[
"id"
]
=
elem
[
"id"
]
result
[
"date"
]
=
elem
[
"date"
]
result
[
"short_date"
]
=
elem
[
"short_date"
]
result
[
"hyperdata.journal"
]
=
'<small><i>'
+
elem
[
"hyperdata"
][
"journal"
]
+
'</i></small>'
result
[
"docurl"
]
=
elem
[
"docurl"
]
result
[
"isFavorite"
]
=
favstatusToStar
(
rec_id
,
elem
[
"isFavorite"
])
result
[
"rawtitle"
]
=
elem
[
"rawtitle"
]
...
...
@@ -318,10 +320,12 @@ function Main_test(Data) {
var
div_table
=
'<p align="right">'
+
"
\n
"
div_table
+=
'<table id="my-ajax-table" class="table table-bordered">'
+
"
\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="
short_
date">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-calendar"></span> Date</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="docurl">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-text-size"></span> Title</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th width="100px;" data-dynatable-column="hyperdata.journal">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-book"></span> Source</th>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<th data-dynatable-column="isFavorite">'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'<span class="glyphicon glyphicon-star"></span>'
+
"
\n
"
div_table
+=
"
\
t"
+
"
\
t"
+
'</th>'
+
"
\n
"
...
...
@@ -490,7 +494,8 @@ function Main_test(Data) {
records
:
Data
,
sorts
:
{
"date"
:
1
},
sortTypes
:
{
docurl
:
'rawtitleSort'
docurl
:
'rawtitleSort'
,
'hyperdata.journal'
:
'journalSort'
}
},
features
:
{
...
...
@@ -571,6 +576,12 @@ function Main_test(Data) {
else
return
rec2
.
rawtitle
.
localeCompare
(
rec1
.
rawtitle
)
}
MyTable
.
data
(
'dynatable'
).
sorts
.
functions
[
"journalSort"
]
=
function
journalSort
(
rec1
,
rec2
,
attr
,
direction
)
{
// like rawtitle but nested property
if
(
direction
==
1
)
return
rec1
.
hyperdata
.
journal
.
localeCompare
(
rec2
.
hyperdata
.
journal
)
else
return
rec2
.
hyperdata
.
journal
.
localeCompare
(
rec1
.
hyperdata
.
journal
)
}
MyTable
.
data
(
'dynatable'
).
process
();
// re-apply search function on click
...
...
@@ -588,6 +599,16 @@ function Main_test(Data) {
return
"OK"
}
// create a sort function (alphabetic with locale-aware order)
// on any record.property with a str inside (for instance "rawtitle")
function
makeAlphaSortFunctionOnProperty
(
property
)
{
return
function
(
rec1
,
rec2
,
attr
,
direction
)
{
if
(
direction
==
1
)
return
rec1
[
property
].
localeCompare
(
rec2
[
property
])
else
return
rec2
[
property
].
localeCompare
(
rec1
[
property
])
}
}
var
dupFlag
=
false
;
$
(
"#div-table"
).
on
(
"dynatable:queries:added"
,
function
(
e
,
qname
,
qval
)
{
...
...
@@ -647,9 +668,11 @@ $.ajax({
record
.
del
=
false
;
});
//
initialize countByTitle and countByMeta census
//
loop for stats and locally created/transformed data
for
(
var
i
in
maindata
.
records
)
{
ourTitle
=
maindata
.
records
[
i
][
'rawtitle'
]
;
var
rec
=
maindata
.
records
[
i
]
// initialize countByTitle and countByMeta census
ourTitle
=
rec
[
'rawtitle'
]
;
if
(
countByTitles
.
hasOwnProperty
(
ourTitle
))
{
countByTitles
[
ourTitle
]
++
;
}
...
...
@@ -657,7 +680,7 @@ $.ajax({
countByTitles
[
ourTitle
]
=
1
;
}
ourSignature
=
metaSignature
(
maindata
.
records
[
i
]
)
ourSignature
=
metaSignature
(
rec
)
if
(
countByMeta
.
hasOwnProperty
(
ourSignature
))
{
countByMeta
[
ourSignature
]
++
;
}
...
...
@@ -665,7 +688,16 @@ $.ajax({
countByMeta
[
ourSignature
]
=
1
;
}
// also save record's "meta signature" for later lookup
maindata
.
records
[
i
].
signature
=
ourSignature
rec
.
signature
=
ourSignature
// also create a short version of the date
rec
.
short_date
=
(
rec
.
hyperdata
.
publication_year
+
"/"
+
rec
.
hyperdata
.
publication_month
+
"/"
+
rec
.
hyperdata
.
publication_day
)
}
AjaxRecords
=
maindata
.
records
;
// backup-ing in global variable!
...
...
This diff is collapsed.
Click to expand it.
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