Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion default/methods/attribute/attribute_template_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def api_attribute_template_list(project_string_id):
session = session,
group_id = input['group_id'],
project_id = project.id,
return_kind = "objects"
return_kind = "objects",
limit = None
)

group_list_serialized = []
Expand Down
21 changes: 8 additions & 13 deletions frontend/src/helpers/tree_view/construct_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,40 +42,35 @@ export const build_path = (array: Array<any>, parent_id, path) => {
}

export const construct_tree = (node_list: Array<Node>): Array<any> => {
root_path = [];
root_path = []
const node_list_working_copy = [...node_list]
const node_wait_list = []
const tree = [];
const check_list = [];

node_list_working_copy.map(item => {
const render_item = item.get_render_data()
if (!render_item.parent) {
tree.push(render_item)
} else {
const returned_path = build_path(tree, render_item.parent, [])
let track_item: any = tree
returned_path.map(q_item => {
track_item = track_item[q_item]
})
if (returned_path && returned_path.length !== 0 && track_item) {
track_item.children.push(render_item)
} else {
node_wait_list.push(render_item)
}
node_wait_list.push(render_item)
}
})

while (node_wait_list.length !== 0) {
root_path = []
const render_item = node_wait_list.shift()
const returned_path = build_path(tree, render_item.parent, [])
let track_item: any = tree
returned_path.map(q_item => {
root_path.map(q_item => {
track_item = track_item[q_item]
})
if (returned_path && returned_path.length !== 0 && track_item) {
track_item.children.push(render_item)
} else {
} else if (node_wait_list.find(item => item.id === render_item.parent)) {
node_wait_list.push(render_item)
} else {
check_list.push(render_item)
}
}

Expand Down
10 changes: 7 additions & 3 deletions shared/database/attribute/attribute_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def list(session,
group_id,
mode = "from_group",
archived = False,
limit = 100,
limit = None,
return_kind = "objects"
):
"""
Expand All @@ -126,10 +126,14 @@ def list(session,
# query = query.order_by(Attribute_Template.display_order)

if return_kind == "count":
return query.limit(limit).count()
if limit:
query = query.limit(limit)
return query.count()

if return_kind == "objects":
return query.limit(limit).all()
if limit:
query = query.limit(limit)
return query.all()

def serialize(self):
"""
Expand Down
13 changes: 8 additions & 5 deletions shared/database/attribute/attribute_template_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def list(session,
project_id,
archived = False,
recursive = False,
limit = 100,
limit = None,
return_kind = "objects",
is_root = None,
is_global = None
Expand All @@ -251,8 +251,10 @@ def list(session,

# Future
if recursive == True:
if limit:
query = query.limit(limit)

root_group_list = query.limit(limit).all()
root_group_list = query.all()

for group in root_group_list:
# Caching / have_children? flag on attribute group?
Expand All @@ -273,12 +275,13 @@ def list(session,

return serialized
## end future

if limit:
query = query.limit(limit)
if return_kind == "count":
return query.limit(limit).count()
return query.count()

if return_kind == "objects":
return query.limit(limit).all()
return query.all()

def generate_unselected_attribute_answer(self, nested_data = None, nested_result = None):
if not self.tree_data:
Expand Down