Skip to content

Commit

Permalink
feat(editors/templates): add read-only DOType section (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobVogelsang committed Jun 7, 2021
1 parent 3c3e084 commit 75cfbdf
Show file tree
Hide file tree
Showing 8 changed files with 299 additions and 17 deletions.
235 changes: 227 additions & 8 deletions __snapshots__/Templates Plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,267 @@
<div id="containerTemplates">
<section tabindex="0">
<h1>
[scl.DAType]
[scl.DOType]
<nav>
<abbr title="[add]">
<mwc-icon-button icon="playlist_add">
</mwc-icon-button>
</abbr>
</nav>
</h1>
<filtered-list id="datypelist">
<filtered-list id="dotypelist">
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="0"
value="#AnalogueValue_i"
twoline=""
value="#Dummy.LLN0.Mod"
>
<span>
AnalogueValue_i
Dummy.LLN0.Mod
</span>
<span slot="secondary">
ENC
</span>
<span slot="meta">
1
14
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
value="#ScaledValueConfig"
twoline=""
value="#Dummy.LLN0.Beh"
>
<span>
ScaledValueConfig
Dummy.LLN0.Beh
</span>
<span slot="secondary">
ENS
</span>
<span slot="meta">
2
3
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
twoline=""
value="#Dummy.LLN0.Health"
>
<span>
Dummy.LLN0.Health
</span>
<span slot="secondary">
ENS
</span>
<span slot="meta">
3
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
twoline=""
value="#Dummy.LLN0.NamPlt"
>
<span>
Dummy.LLN0.NamPlt
</span>
<span slot="secondary">
LPL
</span>
<span slot="meta">
5
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
twoline=""
value="#Dummy.LPHD1.PhyNam"
>
<span>
Dummy.LPHD1.PhyNam
</span>
<span slot="secondary">
DPL
</span>
<span slot="meta">
5
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
twoline=""
value="#Dummy.LPHD1.Sim"
>
<span>
Dummy.LPHD1.Sim
</span>
<span slot="secondary">
SPC
</span>
<span slot="meta">
15
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
twoline=""
value="#Dummy.XCBR1.Pos"
>
<span>
Dummy.XCBR1.Pos
</span>
<span slot="secondary">
DPC
</span>
<span slot="meta">
5
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
twoline=""
value="#Dummy.CSWI.Pos1"
>
<span>
Dummy.CSWI.Pos1
</span>
<span slot="secondary">
DPC
</span>
<span slot="meta">
5
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
twoline=""
value="#Dummy.CSWI.Pos2"
>
<span>
Dummy.CSWI.Pos2
</span>
<span slot="secondary">
DPC
</span>
<span slot="meta">
5
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
twoline=""
value="#Dummy.XCBR1.OpCnt"
>
<span>
Dummy.XCBR1.OpCnt
</span>
<span slot="secondary">
INS
</span>
<span slot="meta">
3
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
twoline=""
value="#Dummy.XCBR1.NamPlt"
>
<span>
Dummy.XCBR1.NamPlt
</span>
<span slot="secondary">
LPL
</span>
<span slot="meta">
3
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
twoline=""
value="#Dummy.XCBR1.BlkOpn"
>
<span>
Dummy.XCBR1.BlkOpn
</span>
<span slot="secondary">
SPC
</span>
<span slot="meta">
5
</span>
</mwc-list-item>
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="-1"
twoline=""
value="#Dummy.SPS"
>
<span>
Dummy.SPS
</span>
<span slot="secondary">
SPS
</span>
<span slot="meta">
3
</span>
</mwc-list-item>
</filtered-list>
</section>
<section tabindex="0">
<h1>
[scl.DAType]
<nav>
<abbr title="[add]">
<mwc-icon-button icon="playlist_add">
</mwc-icon-button>
</abbr>
</nav>
</h1>
<filtered-list id="datypelist">
<mwc-list-item
aria-disabled="false"
hasmeta=""
mwc-list-item=""
tabindex="0"
value="#Dummy_origin"
>
<span>
Expand Down
30 changes: 30 additions & 0 deletions src/editors/Templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,36 @@ export default class TemplatesPlugin extends LitElement {
</h1>`;
return html`
<div id="containerTemplates">
<section tabindex="0">
<h1>
${translate('scl.DOType')}
<nav>
<abbr title="${translate('add')}">
<mwc-icon-button icon="playlist_add"></mwc-icon-button>
</abbr>
</nav>
</h1>
<filtered-list id="dotypelist">
${Array.from(
this.doc.querySelectorAll(':root > DataTypeTemplates > DOType') ??
[]
).map(
dotype =>
html`<mwc-list-item
twoline
value="${identity(dotype)}"
tabindex="0"
hasMeta
><span>${dotype.getAttribute('id')}</span
><span slot="secondary">${dotype.getAttribute(
'cdc'
)}</span></span><span slot="meta"
>${dotype.querySelectorAll('SDO, DA').length}</span
></mwc-list-item
>`
)}
</filtered-list>
</section>
<section tabindex="0">
<h1>
${translate('scl.DAType')}
Expand Down
1 change: 1 addition & 0 deletions src/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const de: Translations = {
EnumVal: 'Enum Wert',
EnumType: 'Enum Typ',
DAType: 'Datenattribut Typ',
DOType: 'Datenobjekt Typ',
Report: 'Report',
LN: 'Logischer Knoten',
},
Expand Down
1 change: 1 addition & 0 deletions src/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const en = {
EnumVal: 'Enum Value',
EnumType: 'Enum Type',
DAType: 'Data Attribute Type',
DOType: 'Data Object Type',
Report: 'Report',
LN: 'Logical Node',
},
Expand Down
23 changes: 17 additions & 6 deletions test/integration/editors/templates/Templates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import TemplatesPlugin from '../../../../src/editors/Templates.js';
import { Editing, EditingElement } from '../../../../src/Editing.js';
import { Wizarding, WizardingElement } from '../../../../src/Wizarding.js';

import { getDocument } from '../../../data.js';

describe('Templates Plugin', () => {
customElements.define(
'templates-plugin',
Expand All @@ -23,8 +21,12 @@ describe('Templates Plugin', () => {
});

describe('with a doc loaded', () => {
let doc: XMLDocument;
beforeEach(async () => {
element.doc = getDocument();
doc = await fetch('/base/test/testfiles/templates/datypes.scd')
.then(response => response.text())
.then(str => new DOMParser().parseFromString(str, 'application/xml'));
element.doc = doc;
await element.updateComplete;
});
it('looks like the latest snapshot', () => {
Expand All @@ -33,10 +35,14 @@ describe('Templates Plugin', () => {
});

describe('with a doc loaded missing a datatypetemplates section', () => {
const doc = getDocument(false);
let doc: XMLDocument;
let parent: WizardingElement & EditingElement;

beforeEach(async () => {
doc = await fetch('/base/test/testfiles/templates/missingdatatypes.scd')
.then(response => response.text())
.then(str => new DOMParser().parseFromString(str, 'application/xml'));

parent = <WizardingElement & EditingElement>(
await fixture(
html`<mock-wizard-editor
Expand All @@ -61,10 +67,13 @@ describe('Templates Plugin', () => {
});
});
describe('with a doc loaded having a datatypetemplates section', () => {
const doc = getDocument();
let doc: XMLDocument;
let parent: WizardingElement & EditingElement;

beforeEach(async () => {
doc = await fetch('/base/test/testfiles/templates/datypes.scd')
.then(response => response.text())
.then(str => new DOMParser().parseFromString(str, 'application/xml'));
parent = <WizardingElement & EditingElement>(
await fixture(
html`<mock-wizard-editor
Expand All @@ -79,7 +88,9 @@ describe('Templates Plugin', () => {
(<HTMLElement>(
parent
?.querySelector('templates-plugin')
?.shadowRoot?.querySelector('mwc-icon-button[icon="playlist_add"]')
?.shadowRoot?.querySelectorAll(
'mwc-icon-button[icon="playlist_add"]'
)[2]
)).click();
await parent.updateComplete;
await new Promise(resolve => setTimeout(resolve, 100)); // await animation
Expand Down
Loading

0 comments on commit 75cfbdf

Please sign in to comment.