-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,12 +129,22 @@ export default class IedPlugin extends LitElement { | |
this.selectedIEDs = [iedName]; | ||
} | ||
} | ||
this.selectedLNClasses = this.lnClassList.map( | ||
lnClassInfo => lnClassInfo[0] | ||
); | ||
} | ||
} | ||
|
||
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; | ||
} | ||
|
||
render(): TemplateResult { | ||
const iedList = this.iedList; | ||
if (iedList.length > 0) { | ||
|
@@ -165,9 +175,7 @@ export default class IedPlugin extends LitElement { | |
|
||
this.lNClassListOpenedOnce = false; | ||
this.selectedIEDs = e.detail.selectedItems; | ||
this.selectedLNClasses = this.lnClassList.map( | ||
lnClassInfo => lnClassInfo[0] | ||
); | ||
this.selectedLNClasses = []; | ||
this.requestUpdate('selectedIed'); | ||
}}" | ||
> | ||
|
@@ -195,17 +203,9 @@ export default class IedPlugin extends LitElement { | |
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.selectedLNClasses = e.detail.selectedItems; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. basically reverting as it was |
||
this.requestUpdate('selectedIed'); | ||
this.lNClassListOpenedOnce = true; | ||
}}" | ||
> | ||
<span slot="icon">${getIcon('lNIcon')}</span> | ||
|
@@ -214,8 +214,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)}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reverting this too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Less sure about reverting the "opened once" logic. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Also, there is another issue alas which is quite visible when I merge this PR which is that
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
> | ||
${label} | ||
</mwc-check-list-item>`; | ||
|
@@ -229,7 +228,7 @@ export default class IedPlugin extends LitElement { | |
.editCount=${this.editCount} | ||
.doc=${this.doc} | ||
.element=${this.selectedIed} | ||
.selectedLNClasses=${this.selectedLNClasses} | ||
.selectedLNClasses=${this.calcSelectedLNClasses()} | ||
.nsdoc=${this.nsdoc} | ||
></ied-container> | ||
</section>`; | ||
|
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.
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.
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.
I like it!