Skip to content

Commit

Permalink
Use card-tree as node selector label, #10186
Browse files Browse the repository at this point in the history
  • Loading branch information
njkim committed Oct 27, 2023
1 parent 70562ee commit f77bc57
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
24 changes: 16 additions & 8 deletions arches/app/etl_modules/base_data_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,23 @@ def get_nodegroups(self, request):

with connection.cursor() as cursor:
cursor.execute("""
SELECT ng.nodegroupid, c.name ->> %s card_name, n.name node_name
FROM node_groups ng, cards c, nodes n
WHERE c.nodegroupid = ng.nodegroupid
AND ng.nodegroupid = n.nodeid
AND c.graphid = %s
AND c.visible = true
ORDER BY c.name;
WITH RECURSIVE card_tree(nodegroupid, parentnodegroupid, name) AS (
SELECT ng.nodegroupid, ng.parentnodegroupid, c.name ->> %s name
FROM node_groups ng, cards c
WHERE c.nodegroupid = ng.nodegroupid
AND c.graphid = %s
AND ng.parentnodegroupid IS null
AND c.visible = true
UNION
SELECT ng.nodegroupid, ng.parentnodegroupid, (ct.name || ' - ' || (c.name ->> %s)) name
FROM node_groups ng, cards c, card_tree ct
WHERE ng.parentnodegroupid = ct.nodegroupid
AND c.nodegroupid = ng.nodegroupid
AND c.visible = true
)
SELECT nodegroupid, name FROM card_tree ORDER BY name
""",
[settings.LANGUAGE_CODE, graphid],
[settings.LANGUAGE_CODE, graphid, settings.LANGUAGE_CODE],
)
nodegroups = dictfetchall(cursor)
return {"success": True, "data": nodegroups}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ define([
self.loading(true);
self.formData.append('graphid', graph);
self.submit('get_nodegroups').then(function(response){
const nodegroups = response.result.map(nodegroup => (
{ ...nodegroup,
label: `${nodegroup.card_name} (${nodegroup.node_name})`
}));
const nodegroups = response.result;
self.selectedNodegroup(null);
self.nodegroups(nodegroups);
self.loading(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h3>
<select id="nodegroup-select" data-bind="
value: selectedNodegroup,
options: nodegroups,
optionsText: 'label',
optionsText: 'name',
optionsCaption: $root.translations.select + '...',
optionsValue: 'nodegroupid',
valueAllowUnset: true,
Expand Down

0 comments on commit f77bc57

Please sign in to comment.