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

Feat/select bays in sidebar #253

Merged
merged 11 commits into from
Feb 13, 2025
Merged

Feat/select bays in sidebar #253

merged 11 commits into from
Feb 13, 2025

Conversation

pwinkelholzS1
Copy link
Collaborator

@pwinkelholzS1 pwinkelholzS1 commented Jan 17, 2025

🗒 Description

reworked the communication explorer sidebar selection menu.
Now both IEDs and bays can be selected. Selecting a bay will select all contained IEDs

📷 Demo screen recording or Screenshots

OpenSCD.Mozilla.Firefox.2025-01-17.17-07-15.mp4

📋 Checklist

You may remove tasks that do not make sense in this PR.

  • Ticket-ACs are checked and met
  • GitHub labels are assigned
  • Git Ticket / issue is linked with PR
  • Designated PR Reviewers are set
  • Tested by another developer
  • Changelog updated
  • Documentation updated (check Documentation guidelines for further reading )
  • All comments in the PR are resolved / answered

🔦 Useful commits

You can add specific commits which are worth taking a look into

@pwinkelholzS1 pwinkelholzS1 linked an issue Jan 22, 2025 that may be closed by this pull request
2 tasks
@pwinkelholzS1 pwinkelholzS1 mentioned this pull request Jan 22, 2025
2 tasks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could. It was meant as an abstraction layer if any changes comes from the api or if you need to consolidate data before sending it to you plugin. It's part of good practices to have those kind of layers (maybe it feel a bit overengineering here with our API, but it's a good habit to have ;) )

Comment on lines 57 to 60
function handleSearch() {
filteredIEDs = IEDs.filter(ied => ied.label.toLowerCase().includes(searchQuery.toLowerCase()))
filteredBays = bays.filter(bay => bay.toLowerCase().includes(searchQuery.toLowerCase()))
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should avoid mutating variable available in the global scope like that. If you are changing the values elsewhere, you will have some strange side effect.
You could wrap the whole in a new object that you will return or make filteredIEDs & filteredBays directly reactive. Something like (not tested) :

$: filteredIEDs: (searchQuery && IEDs?.filter(ied => ied.label.toLowerCase().includes(searchQuery.toLowerCase()))) || IEDs

Comment on lines 113 to 115
on:input={handleSearch}
on:focus={handleSearchFocus}
on:blur={handleSearchBlur}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making filteredIEDs & filteredBays reactive will make these function irrelevant I think.

Comment on lines 117 to 130
{#if searchFocus}
<div class="dropdown">
{#if filteredIEDs.length > 0}
<div class="dropdown_label">
IEDs ({filteredIEDs.length})
</div>
{#each filteredIEDs as ied}
<div class="dropdown_content" role="button" tabindex="0" on:mousedown={handleDropdownSelect}>
{ied.label}
</div>
{/each}
{#if filteredBays.length > 0}
<hr>
{/if}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha I see that you still need the focus variable. To make it less verbose you can write this like that :

<script>
let isIEDSearchInputFocused = false
</script>
<input
    type="text"
    placeholder="Filter IED or bay"
    bind:value={searchQuery}
    on:focus={() => isIEDSearchInputFocused = true}
    on:blur={() => isIEDSearchInputFocused = false}
</input>

Making the variable name very specific, will also lower the risks to reuse the variables for another input and have weird side effects.

@pwinkelholzS1 pwinkelholzS1 merged commit 44002ae into main Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Select Bays in sidebar
2 participants