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(editors/ied): Improve IED editor UI for IED and LN selection #1288

Merged
merged 13 commits into from
Sep 25, 2023

Conversation

danyill
Copy link
Collaborator

@danyill danyill commented Aug 4, 2023

Closes #1287

This PR does three things to improve usability of the editing and selection interface in the IED editor:

  • If you select an IED and open the IED selection and select the same IED, nothing changes (previously it would reset the selections)
  • If you edit a DAI value, the selected IED is not reset
  • Sorts the logical node classes in the class filter
  • Defaults to showing no logical node classes selected on first opening of logical node classes filter

Copy link
Member

@trusz trusz left a comment

Choose a reason for hiding this comment

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

I just only have a few nitpicks (tagged with Nit:) and a question (tagged with Q:)
They are not critical so you can ignore some or all if you'd like 😄

src/editors/IED.ts Outdated Show resolved Hide resolved
src/editors/IED.ts Outdated Show resolved Hide resolved
src/editors/IED.ts Outdated Show resolved Hide resolved
src/editors/IED.ts Outdated Show resolved Hide resolved
src/editors/IED.ts Outdated Show resolved Hide resolved
@trusz
Copy link
Member

trusz commented Aug 22, 2023

I am testing the fix and would like to get your feedback if I understood the bugs correctly.

  • If you select an IED and open the IED selection and select the same IED, nothing changes (previously it would reset the selections)

    I was not able to reproduce this one

  • If you edit a DAI value, the selected IED is not reset

    Before:
    20230822094027_bug_ied_reset

    After:
    20230822094027_bug_ied_reset_fixed

  • Sorts the logical node classes in the class filter
    &
    Defaults to showing no logical node classes selected on first opening of logical node classes filter

    Before After
    20230822094027_bug_ied_reset_fixed 20230822094027_bug_ied_reset_fixed

@trusz
Copy link
Member

trusz commented Aug 22, 2023

  • Defaults to showing no logical node classes selected on first opening of logical node classes filter

    When I open the LN class filter, nothing is selected. If I close without making any selection, the filter will hide everything. Was this intended?

    20230822100224_ied_maybe_bug

@trusz trusz self-assigned this Aug 22, 2023
@danyill
Copy link
Collaborator Author

danyill commented Aug 22, 2023 via email

@trusz
Copy link
Member

trusz commented Aug 22, 2023

We usually handle the "nothing-is-selected" case as if everything would be selected. Would that work for you here?

@danyill
Copy link
Collaborator Author

danyill commented Aug 22, 2023 via email

@danyill
Copy link
Collaborator Author

danyill commented Aug 24, 2023

If you select an IED and open the IED selection and select the same IED, nothing changes (previously it would reset the selections)

I was not able to reproduce this one

Since video-chat is our new paradigm, here we are 😉

reset-selection.mp4

@trusz
Copy link
Member

trusz commented Aug 24, 2023

If you select an IED and open the IED selection and select the same IED, nothing changes (previously it would reset the selections)

I was not able to reproduce this one

Since video-chat is our new paradigm, here we are 😉
reset-selection.mp4

I see, thank you for the clarification!
The description did not mention that it resets the LN filter. I thought it would reset the IED selection.

Now I could replicate it and can confirm that the PR fixed it 😄

@danyill
Copy link
Collaborator Author

danyill commented Aug 24, 2023

We usually handle the "nothing-is-selected" case as if everything would be selected. Would that work for you here?

That is what we must have. I have updated and added a test for it.

src/editors/IED.ts Outdated Show resolved Hide resolved
@trusz
Copy link
Member

trusz commented Sep 4, 2023

I find a behavior a bit surprising. It selects everything if I don't have anything selected and not just behaves as-if.

See screen recording

However, I think the PR is at an acceptable place and If you do not want to change this anymore you are welcome to merge it. 👍

trusz
trusz previously approved these changes Sep 4, 2023
@danyill
Copy link
Collaborator Author

danyill commented Sep 6, 2023

There is a few odd things with this code:

I'm surprised there is a this.requestUpdate('selectedIed'); in the LN class filtering. Perhaps it should be:

this.requestUpdate('selectedLNClasses');

But it should be unnecessary anyway (it's a property).

I had thought I would be able to do something like:

<oscd-filter-button
            id="lnClassesFilter"
            multi="true"
            .header="${translate('iededitor.lnFilter')}"
            @selected-items-changed="${(e: SelectedItemsChangedEvent) => {
              let selectedItems = e.detail.selectedItems;
              const nothingSelected = selectedItems.length === 0;
              if (nothingSelected) {
                selectedItems = this.lnClassList.map(
                  lnClassInfo => lnClassInfo[0]
                );
              }

              this.selectedLNClasses = selectedItems;
              this.requestUpdate('selectedIed');
              this.lNClassListOpenedOnce = true;
            }}"
          >
            <span slot="icon">${getIcon('lNIcon')}</span>
            ${this.lnClassList.map(lnClassInfo => {
              const value = lnClassInfo[0];
              const label = lnClassInfo[1];
              return html`<mwc-check-list-item
                value="${value}"
                ?selected=${this.lNClassListOpenedOnce &&
                this.selectedLNClasses.includes(value) &&
                this.selectedLNClasses.length !== this.lnClassList.length}
              >
                ${label}
              </mwc-check-list-item>`;
            })}
          </oscd-filter-button>

Where this.selectedLNClasses.length !== this.lnClassList.length provides the behaviour you are looking for however for reasons unclear to me there is no reactive update when I add this.

The easiest way I can get this behaviour is by doing the following within oscd-filter-button.ts and it seems if that is the behaviour we are looking for then it would apply across all usages of these elements.

  private onClosing(): void {
    const selectedItems: string[] = [];
    if (this.selected) {
      if (this.selected instanceof Array) {
        this.selected.forEach(item => selectedItems.push(item.value));
      } else {
        selectedItems.push(this.selected.value);
      }
      if (this.items.length === selectedItems.length) {
        this.items.forEach(item => (item.selected = false));
        return;
      }
      this.dispatchEvent(newSelectedItemsChangedEvent(selectedItems));
    }
  }

However there may be use cases for selecting nothing and being able to see that (in the IED editor this shows the IED structures without any of the LNs for instance which may be a feature worth having -- ??) so it's not obvious that this is generic (although with this change all tests would currently pass for open-scd but that may say more about the adequacy of our tests for these kind of changes than anything else).

I suggest we merge as is as the behaviour is a significant improvement on what it was before and it's not clear to me how to implement that functionality you've requested for just this usage of the oscd-filter-button. However happy to be mentored in this regard 😉

@trusz
Copy link
Member

trusz commented Sep 7, 2023

There is a PR for PR to be checked out first:

ref: separate ui and business logic
@trusz
Copy link
Member

trusz commented Sep 25, 2023

OpenSCD is now in packages/open-scd
Need help with the changes?

@danyill
Copy link
Collaborator Author

danyill commented Sep 25, 2023

Thank you for your patience and for showing me a better way to do this.

OpenSCD is now in packages/open-scd Need help with the changes?

Surprisingly, achieved with no conflicts or test failures!

@danyill danyill requested a review from trusz September 25, 2023 15:33
@danyill danyill merged commit e5bc0b8 into openscd:main Sep 25, 2023
1 check passed
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.

IED Editor - improved UI when editing DAIs
2 participants