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
1b0d84fd
Commit
1b0d84fd
authored
Jun 06, 2016
by
Romain Loth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: better group removal in table
parent
ba57e9ab
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
31 deletions
+82
-31
ngramlists.py
gargantext/views/api/ngramlists.py
+17
-0
NGrams_dyna_chart_and_table.js
static/lib/gargantext/NGrams_dyna_chart_and_table.js
+65
-31
No files found.
gargantext/views/api/ngramlists.py
View file @
1b0d84fd
...
...
@@ -206,6 +206,10 @@ class GroupChange(APIView):
# the others params are links to change
couples
=
self
.
links_to_couples
(
params
)
# £debug
print
(
"==couples from url =================================++++="
)
print
(
couples
)
# local version of "insert if not exists" -------------------->8--------
# (1) check already existing elements
check_query
=
(
session
.
query
(
NodeNgramNgram
)
...
...
@@ -220,11 +224,20 @@ class GroupChange(APIView):
for
synonyms
in
check_query
.
all
():
existing
[(
synonyms
.
ngram1_id
,
synonyms
.
ngram2_id
)]
=
True
# £debug
print
(
"==existing"
)
print
(
existing
)
# (2) compute difference locally
couples_to_add
=
[(
mform
,
sform
)
for
(
mform
,
sform
)
in
couples
if
(
mform
,
sform
)
not
in
existing
]
# £debug
print
(
"== couples_to_add =================================++++="
)
print
(
couples_to_add
)
# (3) add new groupings
bulk_insert
(
NodeNgramNgram
,
...
...
@@ -255,6 +268,10 @@ class GroupChange(APIView):
# the others params are links to change
couples_to_remove
=
self
.
links_to_couples
(
params
)
# £debug
print
(
"==couples_to_remove=================================dd="
)
print
(
couples_to_remove
)
# remove selectively group_couples
# using IN is correct in this case: list of ids is short and external
# see stackoverflow.com/questions/444475/
...
...
static/lib/gargantext/NGrams_dyna_chart_and_table.js
View file @
1b0d84fd
...
...
@@ -431,7 +431,9 @@ function saveActiveGroup() {
GroupsBuffer
.
_to_del
[
downgradedNgramId
]
=
CurrentGroups
[
"links"
][
downgradedNgramId
]
// locally
deleteInCurrentGroups
(
downgradedNgramId
,
false
)
// "false" <=> no need to change subform states
deleteInCurrentGroups
(
false
,
downgradedNgramId
)
// arg 1 "false" <=> no need to change subform states
// arg 3 no subforms <=> delete entire group
}
}
...
...
@@ -671,26 +673,24 @@ function removeSubform(ngramId) {
// in another group see comment at the top of script
// special case: if removed form already was a subform it becomes independant
//
// (because the old mainform may be remaining in the new group, we set a
// convention: entire previous group goes "to_delete" at 1st sub remove)
// (because the old mainform may be remaining in the new group)
//
if
(
CurrentGroups
[
"subs"
][
ngramId
])
{
var
oldMainFormId
=
CurrentGroups
[
"subs"
][
ngramId
]
// it must
break the old group, mark for deletion
// it must
remove the subform from old group
// TODO make temporary
// for DB
GroupsBuffer
.
_to_del
[
oldMainFormId
]
=
CurrentGroups
[
"links"
]
[
ngramId
]
GroupsBuffer
.
_to_del
[
oldMainFormId
]
=
[
ngramId
]
// local consequences:
deleteInCurrentGroups
(
oldMainFormId
,
true
)
// => they are all removed from CurrentGroups
//
=> the removed subform and all others
from the old group
//
get
a state (map/del/normal)
var
subformInheritsState
=
true
deleteInCurrentGroups
(
subformInheritsState
,
oldMainFormId
,
[
ngramId
])
//
arg1 true => the removed subform
from the old group
//
gets
a state (map/del/normal)
}
// ==========================================
...
...
@@ -723,24 +723,41 @@ function removeSubform(ngramId) {
/**
* Effects of deleting a mainform from the current groups
* Effects of deleting a mainform from the current groups
(client-side)
*
* => updates the global var CurrentGroups
* => optionally triggers assignment of a state to the ex-subforms
*
* @param ngramId of a mainform
* @param inheritState boolean => updates the AjaxRecords[subformId].state
* @param ngramId of a mainform
* @param (optional) subforms array of subNgramIds (removes individual links)
* if absent: removes the whole group
*/
function
deleteInCurrentGroups
(
ngramId
,
inheritState
)
{
function
deleteInCurrentGroups
(
inheritState
,
mainformId
,
subforms
)
{
var
wholeGroup
=
false
if
(
typeof
subforms
==
"undefined"
)
{
console
.
log
(
"deleteInCurrentGroups: no subforms specified: removing *entire* old group"
)
wholeGroup
=
true
}
if
(
inheritState
)
{
// ex-subforms can inherit state from their previous mainform
var
implicitState
=
AjaxRecords
[
ngramId
].
state
var
implicitState
=
AjaxRecords
[
mainformId
].
state
}
var
subsToDel
=
[]
if
(
wholeGroup
)
{
subsToDel
=
CurrentGroups
.
links
[
mainformId
]
}
else
{
subsToDel
=
subforms
}
if
(
CurrentGroups
.
links
[
ngramId
])
{
var
oldGroup
=
CurrentGroups
.
links
[
ngramId
]
// deleting in reverse index
for
(
var
i
in
oldGroup
)
{
var
subformId
=
oldGroup
[
i
]
for
(
var
i
in
subsToDel
)
{
var
subformId
=
subsToDel
[
i
]
// deleting in "subs"
delete
CurrentGroups
.
subs
[
subformId
]
if
(
inheritState
)
{
...
...
@@ -751,14 +768,31 @@ function deleteInCurrentGroups(ngramId, inheritState) {
// therefore the newly independant forms
// will be added to their new wordlist
}
}
// deleting in "links"
delete
CurrentGroups
.
links
[
ngramId
]
if
(
!
wholeGroup
)
{
// remove 1 from links array (indexOf is ok b/c length always small)
var
i
=
CurrentGroups
[
"links"
][
mainformId
].
indexOf
(
subformId
)
CurrentGroups
[
"links"
][
mainformId
].
splice
(
i
,
1
)
// if it was the last of this group
if
(
CurrentGroups
[
"links"
][
mainformId
].
length
==
0
)
{
delete
CurrentGroups
[
"links"
][
mainformId
]
}
}
}
// deleting in "links" is simpler in this case
if
(
wholeGroup
)
{
delete
CurrentGroups
[
"links"
][
mainformId
]
}
}
/**
* Adding links to the current groups
* Adding links to the current groups
(client-side)
*
* => updates the global var CurrentGroups
*
...
...
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