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
3b46af20
Commit
3b46af20
authored
Jun 28, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documents view: faster trashAll
parent
29146ec5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
15 deletions
+31
-15
Docs_dyna_chart_and_table.js
static/lib/gargantext/Docs_dyna_chart_and_table.js
+30
-14
titles.html
templates/pages/corpora/titles.html
+1
-1
No files found.
static/lib/gargantext/Docs_dyna_chart_and_table.js
View file @
3b46af20
...
@@ -202,7 +202,7 @@ function transformContent2(rec_id, trClass) {
...
@@ -202,7 +202,7 @@ function transformContent2(rec_id, trClass) {
result
[
"isFavorite"
]
=
favstatusToStar
(
rec_id
,
elem
[
"isFavorite"
],
boolStrike
=
true
)
result
[
"isFavorite"
]
=
favstatusToStar
(
rec_id
,
elem
[
"isFavorite"
],
boolStrike
=
true
)
result
[
"rawtitle"
]
=
elem
[
"rawtitle"
]
result
[
"rawtitle"
]
=
elem
[
"rawtitle"
]
if
(
trClass
==
"normalrow"
||
trClass
==
"duplrowdel"
)
{
if
(
trClass
==
"normalrow"
||
trClass
==
"duplrowdel"
)
{
result
[
"del"
]
=
'<input id='
+
rec_id
+
' class="trash1" onclick="toggleTrashIt(this)" type="checkbox" checked
/
>'
result
[
"del"
]
=
'<input id='
+
rec_id
+
' class="trash1" onclick="toggleTrashIt(this)" type="checkbox" checked
></input
>'
}
}
else
if
(
trClass
==
"duplrowkeep"
)
{
else
if
(
trClass
==
"duplrowkeep"
)
{
// forbid deletion for one of the duplicates
// forbid deletion for one of the duplicates
...
@@ -216,7 +216,7 @@ function transformContent2(rec_id, trClass) {
...
@@ -216,7 +216,7 @@ function transformContent2(rec_id, trClass) {
result
[
"isFavorite"
]
=
favstatusToStar
(
rec_id
,
elem
[
"isFavorite"
])
result
[
"isFavorite"
]
=
favstatusToStar
(
rec_id
,
elem
[
"isFavorite"
])
result
[
"rawtitle"
]
=
elem
[
"rawtitle"
]
result
[
"rawtitle"
]
=
elem
[
"rawtitle"
]
if
(
trClass
==
"normalrow"
||
trClass
==
"duplrowdel"
)
{
if
(
trClass
==
"normalrow"
||
trClass
==
"duplrowdel"
)
{
result
[
"del"
]
=
'<input id='
+
rec_id
+
' class="trash1" onclick="toggleTrashIt(this)" type="checkbox"
/
>'
result
[
"del"
]
=
'<input id='
+
rec_id
+
' class="trash1" onclick="toggleTrashIt(this)" type="checkbox"
></input
>'
}
}
else
if
(
trClass
==
"duplrowkeep"
)
{
else
if
(
trClass
==
"duplrowkeep"
)
{
result
[
"del"
]
=
''
result
[
"del"
]
=
''
...
@@ -225,21 +225,37 @@ function transformContent2(rec_id, trClass) {
...
@@ -225,21 +225,37 @@ function transformContent2(rec_id, trClass) {
return
result
;
return
result
;
}
}
function
toggleTrashIt
(
boxElem
)
{
/* Trash one element
* -> strike it
* -> move it to Garbage global var
*
* @param boxElem the html checkbox element that was just (un)checked
* <input id="185" class="trash1" onclick="toggleTrashIt(this)" type="checkbox">
*
* @param doUpdate optional boolean (default: true)
* possibility to control the dynatable update after trashing
* (set it to false if several operations are done at once)
*/
function
toggleTrashIt
(
boxElem
,
doUpdate
)
{
var
id
=
boxElem
.
id
// row_id in the table (not ngram_id)
var
id
=
boxElem
.
id
// row_id in the table (not ngram_id)
var
val
=
boxElem
.
checked
var
val
=
boxElem
.
checked
if
(
typeof
doUpdate
==
'undefined'
)
{
doUpdate
=
true
;
}
// console.log("striking =>", val)
// console.log("striking =>", val)
// console.log("record", AjaxRecords[id])
// console.log("record", AjaxRecords[id])
// MyTable.data('dynatable').settings.dataset.originalRecords[id]["del"] = val;
AjaxRecords
[
id
][
"del"
]
=
val
;
AjaxRecords
[
id
][
"del"
]
=
val
;
if
(
val
)
Garbage
[
id
]
=
true
;
if
(
val
)
Garbage
[
id
]
=
true
;
else
delete
Garbage
[
id
];
else
delete
Garbage
[
id
];
if
(
Object
.
keys
(
Garbage
).
length
>
0
)
$
(
"#move2trash"
).
show
();
if
(
Object
.
keys
(
Garbage
).
length
>
0
)
$
(
"#empty-trash"
).
show
();
else
$
(
"#move2trash"
).
hide
();
else
$
(
"#empty-trash"
).
hide
();
// console.log(MyTable.data('dynatable').settings.dataset.originalRecords[id])
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
if
(
doUpdate
)
{
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
}
}
}
// function transformContent(rec_id , header , content) {
// function transformContent(rec_id , header , content) {
...
@@ -253,7 +269,7 @@ function toggleTrashIt(boxElem) {
...
@@ -253,7 +269,7 @@ function toggleTrashIt(boxElem) {
// }
// }
$
(
"#
move2
trash"
)
$
(
"#
empty-
trash"
)
.
click
(
function
(){
.
click
(
function
(){
var
ids2trash
=
[]
var
ids2trash
=
[]
...
@@ -272,12 +288,12 @@ $("#move2trash")
...
@@ -272,12 +288,12 @@ $("#move2trash")
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
getCookie
(
"csrftoken"
));
},
},
success
:
function
(
data
)
{
success
:
function
(
data
)
{
console
.
log
(
"in #
move2
trash"
)
console
.
log
(
"in #
empty-
trash"
)
console
.
log
(
data
)
console
.
log
(
data
)
location
.
reload
();
location
.
reload
();
},
},
error
:
function
(
result
)
{
error
:
function
(
result
)
{
console
.
log
(
"Data not found in #
move2
trash"
);
console
.
log
(
"Data not found in #
empty-
trash"
);
console
.
log
(
result
)
console
.
log
(
result
)
}
}
});
});
...
@@ -657,7 +673,6 @@ function Main_test(Data) {
...
@@ -657,7 +673,6 @@ function Main_test(Data) {
function
trashAll
()
{
function
trashAll
()
{
var
newColumnState
=
$
(
"#trashAll"
).
prop
(
'checked'
)
var
newColumnState
=
$
(
"#trashAll"
).
prop
(
'checked'
)
// propagate changes to all rows
// propagate changes to all rows
$
(
"tbody tr"
).
each
(
function
(
i
,
row
)
{
$
(
"tbody tr"
).
each
(
function
(
i
,
row
)
{
// var nodeId = $(row).attr("node-id") ;
// var nodeId = $(row).attr("node-id") ;
...
@@ -671,12 +686,13 @@ function trashAll() {
...
@@ -671,12 +686,13 @@ function trashAll() {
// toggle all these rows' boxes
// toggle all these rows' boxes
boxElem
.
checked
=
newColumnState
boxElem
.
checked
=
newColumnState
// and trigger the corresponding action manually
// and trigger the corresponding action manually
toggleTrashIt
(
boxElem
)
toggleTrashIt
(
boxElem
,
false
)
// false <=> don't update the table each time
}
}
}
}
});
});
// OK update this table page
// OK
now
update this table page
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
MyTable
.
data
(
'dynatable'
).
dom
.
update
();
}
}
...
...
templates/pages/corpora/titles.html
View file @
3b46af20
...
@@ -83,7 +83,7 @@
...
@@ -83,7 +83,7 @@
<div
class=
"panel-body"
>
<div
class=
"panel-body"
>
<div
id=
"div-table"
></div>
<div
id=
"div-table"
></div>
<p
align=
"right"
>
<p
align=
"right"
>
<button
id=
"
move2
trash"
class=
"btn btn-primary btn-lg"
>
<button
id=
"
empty-
trash"
class=
"btn btn-primary btn-lg"
>
<span
class=
"glyphicon glyphicon-trash"
aria-hidden=
"true"
></span>
<span
class=
"glyphicon glyphicon-trash"
aria-hidden=
"true"
></span>
Trash It!
Trash It!
</button>
</button>
...
...
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