Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions editors/dataset/data-set-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,15 @@ describe('DataSet editor component', () => {
'DataSet'
);
});

it('sets searchValue on ActionList when passed as a prop', async () => {
const el = await fixture(
html`<data-set-editor .doc="${doc}" searchValue="IED1"></data-set-editor>`
);
await (el as DataSetEditor).updateComplete;

const actionList = (el as DataSetEditor).selectionList;
expect(actionList).to.exist;
expect(actionList.searchValue).to.equal('IED1');
});
});
9 changes: 9 additions & 0 deletions editors/dataset/data-set-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export class DataSetEditor extends ScopedElementsMixin(LitElement) {
@property({ type: Number })
editCount = 0;

@property({ type: String }) searchValue = '';

@state()
selectedDataSet?: Element;

Expand All @@ -61,6 +63,13 @@ export class DataSetEditor extends ScopedElementsMixin(LitElement) {
super.update(props);
} */

updated(changedProps: Map<string | number | symbol, unknown>) {
super.updated?.(changedProps);
if (changedProps.has('searchValue') && this.selectionList) {
this.selectionList.searchValue = this.searchValue;
}
}

private renderElementEditorContainer(): TemplateResult {
if (this.selectedDataSet)
return html`<div class="elementeditorcontainer">
Expand Down
21 changes: 16 additions & 5 deletions editors/gsecontrol/gse-control-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ function timeout(ms: number) {
});
}

const doc = new DOMParser().parseFromString(gseControlDoc, 'application/xml');

describe('GSEControl editor component', () => {
let editor: GseControlEditor;
let editEvent: SinonSpy;

beforeEach(async () => {
const doc = new DOMParser().parseFromString(
gseControlDoc,
'application/xml'
);

editor = await fixture(
html`<gse-control-editor .doc="${doc}"></gse-control-editor>`
);
Expand Down Expand Up @@ -91,4 +88,18 @@ describe('GSEControl editor component', () => {
'datSet2'
);
});

it('sets searchValue on ActionList when passed as a prop', async () => {
const el = await fixture(
html`<gse-control-editor
.doc="${doc}"
searchValue="GSE1"
></gse-control-editor>`
);
await (el as GseControlEditor).updateComplete;

const actionList = (el as GseControlEditor).selectionList;
expect(actionList).to.exist;
expect(actionList.searchValue).to.equal('GSE1');
});
});
11 changes: 10 additions & 1 deletion editors/gsecontrol/gse-control-editor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/no-extraneous-dependencies */
import { css, html, TemplateResult } from 'lit';
import { query } from 'lit/decorators.js';
import { query, property } from 'lit/decorators.js';

import {
ActionItem,
Expand Down Expand Up @@ -38,6 +38,8 @@ export class GseControlEditor extends BaseElementEditor {
'md-checkbox': MdCheckbox,
};

@property({ type: String }) searchValue = '';

@query('.selectionlist') selectionList!: ActionList;

@query('.change.scl.element') selectGSEControlButton!: MdOutlinedButton;
Expand Down Expand Up @@ -69,6 +71,13 @@ export class GseControlEditor extends BaseElementEditor {
}
} */

updated(changedProps: Map<string | number | symbol, unknown>) {
super.updated?.(changedProps);
if (changedProps.has('searchValue') && this.selectionList) {
this.selectionList.searchValue = this.searchValue;
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Do all editors have the same property and update code? If so we can move it into the baseclass BaseElementEditor

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea, fixed that

protected renderElementEditorContainer(): TemplateResult {
if (this.selectCtrlBlock !== undefined)
return html`<div class="elementeditorcontainer">
Expand Down
24 changes: 19 additions & 5 deletions editors/report/report-control-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ function timeout(ms: number) {
});
}

const doc = new DOMParser().parseFromString(
reportControlDoc,
'application/xml'
);

describe('ReportControl editor component', () => {
let editor: ReportControlEditor;
let editEvent: SinonSpy;

beforeEach(async () => {
const doc = new DOMParser().parseFromString(
reportControlDoc,
'application/xml'
);

editor = await fixture(
html`<report-control-editor .doc="${doc}"></report-control-editor>`
);
Expand Down Expand Up @@ -93,4 +93,18 @@ describe('ReportControl editor component', () => {
'datSet2'
);
});

it('sets searchValue on ActionList when passed as a prop', async () => {
const el = await fixture(
html`<report-control-editor
.doc="${doc}"
searchValue="Report1"
></report-control-editor>`
);
await (el as ReportControlEditor).updateComplete;

const actionList = (el as ReportControlEditor).selectionList;
expect(actionList).to.exist;
expect(actionList.searchValue).to.equal('Report1');
});
});
11 changes: 10 additions & 1 deletion editors/report/report-control-editor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/no-extraneous-dependencies */
import { css, html, TemplateResult } from 'lit';
import { query } from 'lit/decorators.js';
import { query, property } from 'lit/decorators.js';

import {
ActionItem,
Expand Down Expand Up @@ -51,6 +51,8 @@ export class ReportControlEditor extends BaseElementEditor {
@query('data-set-element-editor')
dataSetElementEditor!: DataSetElementEditor;

@property({ type: String }) searchValue = '';

/** Resets selected Report and its DataSet, if not existing in new doc
update(props: Map<string | number | symbol, unknown>): void {
super.update(props);
Expand All @@ -76,6 +78,13 @@ export class ReportControlEditor extends BaseElementEditor {
}
} */

updated(changedProps: Map<string | number | symbol, unknown>) {
super.updated?.(changedProps);
if (changedProps.has('searchValue') && this.selectionList) {
this.selectionList.searchValue = this.searchValue;
}
}

private renderElementEditorContainer(): TemplateResult {
if (this.selectCtrlBlock !== undefined)
return html`<div class="elementeditorcontainer">
Expand Down
21 changes: 16 additions & 5 deletions editors/sampledvalue/sampled-value-control-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@ function timeout(ms: number) {
});
}

const doc = new DOMParser().parseFromString(smvControlDoc, 'application/xml');

describe('SampledValueControl editor component', () => {
let editor: SampledValueControlEditor;
let editEvent: SinonSpy;

beforeEach(async () => {
const doc = new DOMParser().parseFromString(
smvControlDoc,
'application/xml'
);

editor = await fixture(
html`<sampled-value-control-editor
.doc="${doc}"
Expand Down Expand Up @@ -85,4 +82,18 @@ describe('SampledValueControl editor component', () => {
'datSet2'
);
});

it('sets searchValue on ActionList when passed as a prop', async () => {
const el = await fixture(
html`<sampled-value-control-editor
.doc="${doc}"
searchValue="SV1"
></sampled-value-control-editor>`
);
await (el as SampledValueControlEditor).updateComplete;

const actionList = (el as SampledValueControlEditor).selectionList;
expect(actionList).to.exist;
expect(actionList.searchValue).to.equal('SV1');
});
});
11 changes: 10 additions & 1 deletion editors/sampledvalue/sampled-value-control-editor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable import/no-extraneous-dependencies */
import { css, html, TemplateResult } from 'lit';
import { query } from 'lit/decorators.js';
import { query, property } from 'lit/decorators.js';

import {
ActionItem,
Expand Down Expand Up @@ -45,6 +45,8 @@ export class SampledValueControlEditor extends BaseElementEditor {
'md-checkbox': MdCheckbox,
};

@property({ type: String }) searchValue = '';

@query('.selectionlist') selectionList!: ActionList;

@query('.change.scl.element')
Expand Down Expand Up @@ -81,6 +83,13 @@ export class SampledValueControlEditor extends BaseElementEditor {
}
} */

updated(changedProps: Map<string | number | symbol, unknown>) {
super.updated?.(changedProps);
if (changedProps.has('searchValue') && this.selectionList) {
this.selectionList.searchValue = this.searchValue;
}
}

private renderElementEditorContainer(): TemplateResult {
if (this.selectCtrlBlock !== undefined)
return html`<div class="elementeditorcontainer">
Expand Down
Loading
Loading