-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle multiple Subcard levels in Search Export. #10199 #10214
Handle multiple Subcard levels in Search Export. #10199 #10214
Conversation
@chiatt reassign as required |
arches/app/search/search_export.py
Outdated
self.insert_subcard_below_parent_card(sorted_card_list, card_list_no_sort) | ||
# Loop down through the levels of subcards, 'till no more sub-levels may be added. | ||
subcards_added = [True] | ||
while subcards_added[0]: | ||
subcards_added = [False] | ||
self.insert_subcard_below_parent_card(sorted_card_list, card_list_no_sort, subcards_added) | ||
|
||
# Cards in subcard_list_with_sort are added after cards with no sort | ||
# Cards in subcard_list_with_sort are added after cards with no sort | ||
|
||
self.insert_subcard_below_parent_card(sorted_card_list, subcard_list_with_sort) | ||
self.insert_subcard_below_parent_card(sorted_card_list, subcard_list_with_sort, subcards_added) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@khodgkinson-he This works like a charm, but just be consistent with other parts of Arches, could you change this to use recursion rather than a while loop? Something like this should work:
def order_cards(subcards_added=True):
if subcards_added == True:
subcards_added = False
unsorted_subcards_added = self.insert_subcard_below_parent_card(sorted_card_list, card_list_no_sort, subcards_added)
sorted_subcards_added = self.insert_subcard_below_parent_card(sorted_card_list, subcard_list_with_sort, unsorted_subcards_added)
order_cards(sorted_subcards_added)
order_cards()
With that change you would need to change line 71 to subcards_added = True
and then add a return statement to line 74, return subcards_added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chiatt Glad you like.. ^_^
I've refactored that as an inline function as recommended, any issues please let me know!
) * Itterate through subcards to terminus. * Amended to use inline fn. Co-authored-by: Kingsley <[email protected]>
Types of changes
Description of Change
In the example below, I am attempting to nest:
Discovery
└─> Location Data
____└─>Geometry
However as Geometry Card is processed before it's parent Location Data Card is added, it can never be appended..
To address this I have introduced a loop whilst sub-cards have been added to the main card list, to check if they have sub-cards in turn.
Issues Solved
#10199
Further comments
This is likely an historical remnant of when Arches only allowed sub-cards nested two levels deep.