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

ref: separate ui and business logic #3

Merged
merged 2 commits into from
Sep 25, 2023

Conversation

trusz
Copy link

@trusz trusz commented Sep 6, 2023

No description provided.

Comment on lines +135 to +147
private calcSelectedLNClasses(): string[] {
const somethingSelected = this.selectedLNClasses.length > 0;
const lnClasses = this.lnClassList.map( lnClassInfo => lnClassInfo[0] );

let selectedLNClasses = lnClasses;

if(somethingSelected){
selectedLNClasses = lnClasses.filter( lnClass => this.selectedLNClasses.includes(lnClass));
}

return selectedLNClasses;
}

Copy link
Author

Choose a reason for hiding this comment

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

This is the main logic.
I've went for readability. You could argue, that we could wait with the mapping until nothing is selected, but I don't think this so such a big performance problem and it would be the code less readable.

Copy link
Owner

Choose a reason for hiding this comment

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

I like it!


this.selectedLNClasses = selectedItems;
this.selectedLNClasses = e.detail.selectedItems;
Copy link
Author

Choose a reason for hiding this comment

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

basically reverting as it was

@@ -214,8 +216,7 @@ export default class IedPlugin extends LitElement {
const label = lnClassInfo[1];
return html`<mwc-check-list-item
value="${value}"
?selected="${this.lNClassListOpenedOnce &&
this.selectedLNClasses.includes(value)}"
?selected="${this.selectedLNClasses.includes(value)}"
Copy link
Author

Choose a reason for hiding this comment

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

reverting this too

Copy link
Owner

Choose a reason for hiding this comment

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

Less sure about reverting the "opened once" logic.

Copy link
Owner

Choose a reason for hiding this comment

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

I really like the improvement and I checked this out and had a look.

However when I select a new IED then all LNs are selected again.

  1. Open file.
  2. Open LN class filter. Looks good.
  3. Close LN filter.
  4. Open IED filter.
  5. Select new IED
  6. Open LN filter.
  7. Alas, all LNs are selected

Also, there is another issue alas which is quite visible when I merge this PR which is that

  1. Select some LNs in the LN class filter.
  2. Change the IED using the IED filter.
  3. Open the LN class filter -- the same LNs are selected.
  4. However the selection is not correctly being applied.

Copy link
Author

Choose a reason for hiding this comment

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

How about like this? (PR has been updated)
20230908033556_ied_ln_class

@danyill
Copy link
Owner

danyill commented Sep 8, 2023

Thanks @trusz for looking at this for me -- would you like to make further improvements or I can try to adapt for the two scenarios which still appear to give unexpected results. Sorry, this seems quite fiddly and not well wrapped in test coverage either.

@danyill
Copy link
Owner

danyill commented Sep 16, 2023

Thanks @trusz it is better. and a better way of structuring this.

Alas it is still not right for the behaviour you were looking for... I can get a situation where I select all all LNs and I am expecting to see none selected when I open the LN filter which was (I thought) the most difficult problem....

still_not_right.mp4

I had another play to try and resolve this but was not successful.

@danyill
Copy link
Owner

danyill commented Sep 25, 2023

Small ping @trusz ! 😉

@trusz
Copy link
Author

trusz commented Sep 25, 2023

It looks good to me. This would have been my expectation. The UI stays es the user left it. It should not change its state because of a single case. Two states has the same effect, which you would not want normally but I think this is an exception.
I interpret the intention like this:

  • if the user does not selects anything, he/she does not care for filtering, so he/she does not want to filter, because what would be the use case of that?
  • if the user selects something, he/she only wants to see those things
  • if the user selects everything, he/she wants to see everything

@danyill
Copy link
Owner

danyill commented Sep 25, 2023

Hmmm, I thought you wanted if the user selects everything for there to be nothing selected based on your previous comment but I am happy with it as it is, so let's leave further improvements for another time.

@danyill danyill merged commit f3fb3b1 into danyill:issue-1287-ied-editor-ui Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants