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
84ddd28b
Commit
84ddd28b
authored
Sep 15, 2016
by
delanoe
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/romain-testing' into testing
parents
044a07df
ecd23e32
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
16 deletions
+119
-16
NGrams_dyna_chart_and_table.js
static/lib/gargantext/NGrams_dyna_chart_and_table.js
+113
-12
terms.html
templates/pages/corpora/terms.html
+6
-4
No files found.
static/lib/gargantext/NGrams_dyna_chart_and_table.js
View file @
84ddd28b
...
...
@@ -174,6 +174,98 @@ var tableSpan ;
var
corpusesList
=
{}
// =============================================================================
// CACHE MANAGEMENT
// =============================================================================
/**
* a local cache to remember active filters and page after reload
* cf. saveParamsToCache()
* restoreSettingsFromCache()
*
* TODO localStorage.clear() after expiry date
*/
window
.
onbeforeunload
=
saveParamsToCache
;
// always called at page close/quit
// £TODO use url instead of corpusId+'/terms' as prefix
function
saveParamsToCache
()
{
var
corpusId
=
getIDFromURL
(
"corpora"
)
var
search_filter_status
=
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'search'
]
var
state_filter_status
=
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'my_state_filter'
]
var
type_filter_status
=
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'my_termtype_filter'
]
// var page_status = document.getElementsByClassName("dynatable-page-link dynatable-active-page")[0].getAttribute("data-dynatable-page")
var
per_page_status
=
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
perPage
// keys and values are str only so we use path-like keys
if
(
search_filter_status
)
{
localStorage
[
corpusId
+
'/terms/search'
]
=
search_filter_status
}
else
{
localStorage
.
removeItem
(
corpusId
+
'/terms/search'
)
}
if
(
state_filter_status
)
{
localStorage
[
corpusId
+
'/terms/state'
]
=
state_filter_status
}
else
{
localStorage
.
removeItem
(
corpusId
+
'/terms/state'
)
}
if
(
type_filter_status
)
{
localStorage
[
corpusId
+
'/terms/type'
]
=
type_filter_status
}
else
{
localStorage
.
removeItem
(
corpusId
+
'/terms/type'
)
}
// if (page_status) {
// localStorage[corpusId+'/terms/page'] = page_status
// }
// else {
// localStorage.removeItem(corpusId+'/terms/page')
// }
if
(
per_page_status
)
{
localStorage
[
corpusId
+
'/terms/perPage'
]
=
per_page_status
}
else
{
localStorage
.
removeItem
(
corpusId
+
'/terms/perPage'
)
}
return
null
;
}
// always called after MyTable init
function
restoreSettingsFromCache
()
{
var
corpusId
=
getIDFromURL
(
"corpora"
)
// var had_page = localStorage[corpusId+'/terms/page']
var
had_type
=
localStorage
[
corpusId
+
'/terms/type'
]
var
had_state
=
localStorage
[
corpusId
+
'/terms/state'
]
var
had_search
=
localStorage
[
corpusId
+
'/terms/search'
]
var
had_perPage
=
localStorage
[
corpusId
+
'/terms/perPage'
]
// if (had_page) {
// MyTable.data('dynatable').paginationPage.set(had_page);
// }
if
(
had_type
)
{
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'my_termtype_filter'
]
=
had_type
}
if
(
had_state
)
{
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'my_state_filter'
]
=
had_state
}
if
(
had_search
)
{
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'search'
]
=
had_search
}
if
(
had_perPage
)
{
MyTable
.
data
(
'dynatable'
).
paginationPerPage
.
set
(
had_perPage
)
}
// re-process to makes the changes visible
MyTable
.
data
(
'dynatable'
).
process
()
return
null
;
}
// =============================================================================
// ELEMENT CONTROLLERS AND ROW PROCESSORS
// =============================================================================
...
...
@@ -1816,6 +1908,10 @@ function GROUPCRUDS( groupnode_id , send_data, http_method , callback) {
* @param ngdata: OriginalNG['records']
* @param initial: initial score type "occs" or "tfidf"
* @param search_filter: value among {0,1,2,'reset'} (see #picklistmenu options)
*
* TODO replace by new @param filters (multiple) for all cached values
* (would allow us to use them directly in settings instead of a posteriori
* with restoreSettingsFromCache)
*/
function
MainTableAndCharts
(
ngdata
,
initial
,
search_filter
)
{
...
...
@@ -2130,8 +2226,7 @@ function MainTableAndCharts( ngdata , initial , search_filter) {
// _cellWriter: customCellWriter
},
inputs
:
{
queries
:
$
(
'select#testquery'
),
queries
:
$
(
'select#picklistmenu'
),
queries
:
$
(
'select#picklistmenu, select#picktermtype'
),
}
})
...
...
@@ -2193,30 +2288,36 @@ function MainTableAndCharts( ngdata , initial , search_filter) {
return
true
}
// for states, possible value are in {0,1,2}
else
if
(
selectedValue
<=
2
)
{
else
{
// return true or false
return
(
AjaxRecords
[
record
.
id
].
state
==
selectedValue
)
}
// for values > max_state we can also select mono/multi
else
if
(
selectedValue
==
3
)
{
}
// second filter named 'my_termtype_filter'
MyTable
.
data
(
'dynatable'
).
queries
.
functions
[
'my_termtype_filter'
]
=
function
(
record
,
selectedValue
)
{
if
(
selectedValue
==
'reset'
)
{
return
true
}
else
if
(
selectedValue
==
'mono'
)
{
// one-word terms aka monograms aka monolexical terms
return
(
AjaxRecords
[
record
.
id
][
'name'
].
indexOf
(
" "
)
==
-
1
)
}
else
if
(
selectedValue
==
4
)
{
else
if
(
selectedValue
==
'multi'
)
{
// MWE aka multigrams aka polylexical terms
return
(
AjaxRecords
[
record
.
id
][
'name'
].
indexOf
(
" "
)
!=
-
1
)
}
else
{
console
.
error
(
"unknown value in #picklistmenu :"
,
selectedValue
)
return
true
}
}
// and set this filter's initial status to 'maplist' (aka state == 1)
// MyTable.data('dynatable').settings.dataset.queries['my_state_filter'] = 1 ;
// and set these filters' initial status
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'my_state_filter'
]
=
search_filter
;
MyTable
.
data
(
'dynatable'
).
settings
.
dataset
.
queries
[
'my_termtype_filter'
]
=
'reset'
;
MyTable
.
data
(
'dynatable'
).
process
();
// £todo factorize with previous with a param search_filters
restoreSettingsFromCache
(
localStorage
)
// moves pagination over table
if
(
$
(
".imadiv"
).
length
>
0
)
return
1
;
$
(
'<br><br><div class="imadiv"></div>'
).
insertAfter
(
".dynatable-per-page"
)
...
...
templates/pages/corpora/terms.html
View file @
84ddd28b
...
...
@@ -137,15 +137,17 @@ em {
</div>
<!-- see in javascript function queries.functions['my_state_filter'] -->
<div
class=
"pull-right"
style=
"margin-top:2.1em;padding-left:1em;"
>
Filter:
<select
id=
"picklistmenu"
name=
"my_state_filter"
>
<option
value=
'reset'
>
All
term
s
</option>
<option
value=
'reset'
>
All
list
s
</option>
<option
value=
'0'
>
Candidates only
</option>
<!-- <option value='1' selected="selected">Map terms only</option> -->
<option
value=
'1'
>
Map terms only
</option>
<option
value=
'2'
>
Stopwords only
</option>
<option
value=
'3'
>
One word terms only
</option>
<option
value=
'4'
>
Multiword terms only
</option>
</select>
<select
id=
"picktermtype"
name=
"my_termtype_filter"
style=
"margin-left:1em;"
>
<option
value=
'reset'
>
All types
</option>
<option
value=
'mono'
>
One word terms only
</option>
<option
value=
'multi'
>
Multiword terms only
</option>
</select>
</div>
</h4>
...
...
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