Skip to content
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

Merged

Conversation

khodgkinson-he
Copy link
Contributor

@khodgkinson-he khodgkinson-he commented Oct 31, 2023

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

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..

image

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.

@khodgkinson-he khodgkinson-he marked this pull request as ready for review October 31, 2023 12:04
@aj-he aj-he requested a review from chiatt October 31, 2023 13:00
@aj-he aj-he added the Type: Bug Something isn't working label Oct 31, 2023
@aj-he
Copy link
Contributor

aj-he commented Oct 31, 2023

@chiatt reassign as required

Comment on lines 96 to 109
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)
Copy link
Member

@chiatt chiatt Nov 9, 2023

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

Copy link
Contributor Author

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!

@chiatt chiatt merged commit c4e358f into archesproject:dev/6.2.x Nov 14, 2023
1 check passed
chiatt added a commit that referenced this pull request Nov 27, 2023
)

* Itterate through subcards to terminus.

* Amended to use inline fn.

Co-authored-by: Kingsley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants