Skip to content

Commit 58c62d5

Browse files
author
Dennis Labordus
committed
Fixed layout of Compas Versions Editor.
Signed-off-by: Dennis Labordus <[email protected]>
1 parent 559eb2c commit 58c62d5

File tree

5 files changed

+85
-53
lines changed

5 files changed

+85
-53
lines changed

__snapshots__/compas-versions-plugin.md

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -59,72 +59,88 @@
5959
#### `looks like the latest snapshot`
6060

6161
```html
62+
<h1>
63+
<nav>
64+
<abbr title="[compas.versions.addVersionButton]">
65+
<mwc-icon-button icon="playlist_add">
66+
</mwc-icon-button>
67+
</abbr>
68+
</nav>
69+
<nav>
70+
<abbr title="[compas.versions.deleteProjectButton]">
71+
<mwc-icon-button icon="delete_forever">
72+
</mwc-icon-button>
73+
</abbr>
74+
</nav>
75+
</h1>
6276
<div id="containerCompasVersions">
6377
<section tabindex="0">
6478
<h1>
6579
[compas.versions.title]
66-
<mwc-icon-button icon="note_add">
67-
</mwc-icon-button>
68-
<mwc-icon-button icon="delete_forever">
69-
</mwc-icon-button>
7080
</h1>
71-
<mwc-list>
72-
<mwc-list-item
81+
<mwc-list multi="">
82+
<mwc-check-list-item
7383
aria-disabled="false"
74-
graphic="control"
84+
graphic="icon"
7585
mwc-list-item=""
7686
tabindex="0"
87+
value="1.0.0"
7788
>
7889
demo_station1 (1.0.0)
79-
<span
80-
slot="graphic"
81-
style="width: 90px"
82-
>
90+
<span slot="graphic">
8391
<mwc-icon>
8492
restore
8593
</mwc-icon>
8694
<mwc-icon>
8795
delete
8896
</mwc-icon>
8997
</span>
90-
</mwc-list-item>
91-
<mwc-list-item
98+
</mwc-check-list-item>
99+
<mwc-check-list-item
92100
aria-disabled="false"
93-
graphic="control"
101+
graphic="icon"
94102
mwc-list-item=""
95103
tabindex="-1"
104+
value="2.0.0"
96105
>
97106
demo_station1 (2.0.0)
98-
<span
99-
slot="graphic"
100-
style="width: 90px"
101-
>
107+
<span slot="graphic">
102108
<mwc-icon>
103109
restore
104110
</mwc-icon>
105111
<mwc-icon>
106112
delete
107113
</mwc-icon>
108114
</span>
109-
</mwc-list-item>
110-
<mwc-list-item
115+
</mwc-check-list-item>
116+
<mwc-check-list-item
111117
aria-disabled="false"
112-
graphic="control"
118+
graphic="icon"
113119
mwc-list-item=""
114120
tabindex="-1"
121+
value="2.1.0"
115122
>
116123
3b572a56-51cc-479b-97fd-e404ebf9ae67 (2.1.0)
117-
<span
118-
slot="graphic"
119-
style="width: 90px"
120-
>
124+
<span slot="graphic">
121125
<mwc-icon>
122126
restore
123127
</mwc-icon>
124128
</span>
125-
</mwc-list-item>
129+
</mwc-check-list-item>
126130
</mwc-list>
127131
</section>
132+
<mwc-fab
133+
extended=""
134+
icon="compare"
135+
label="[compas.versions.compareButton]"
136+
>
137+
</mwc-fab>
138+
<mwc-fab
139+
extended=""
140+
icon="compare"
141+
label="[compas.versions.compareCurrentButton]"
142+
>
143+
</mwc-fab>
128144
</div>
129145
<wizard-dialog>
130146
</wizard-dialog>

public/md/CoMPAS-Versions-Editor.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
In the CoMPAS Editor the different versions of an SCL XML File are shown that are stored in CoMPAS.
2+
Different actions can be done in this screen.
23

34
- <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M13 3c-4.97 0-9 4.03-9 9H1l4 3.99L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.25 2.52.77-1.28-3.52-2.09V8z"/></svg>:
45
Restore a specific version from CoMPAS. <br/>
@@ -8,10 +9,16 @@ In the CoMPAS Editor the different versions of an SCL XML File are shown that ar
89
- <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"/></svg>:
910
Remove a specific version from CoMPAS.<br/>
1011
By pressing the icon and confirming the action that specific version will be removed from CoMPAS.
11-
- <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M13 11h-2v3H8v2h3v3h2v-3h3v-2h-3zm1-9H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z"/></svg>:
12+
- <svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M14,10H3v2h11V10z M14,6H3v2h11V6z M18,14v-4h-2v4h-4v2h4v4h2v-4h4v-2H18z M3,16h7v-2H3V16z"/></g></svg>:
1213
Add version from filesystem.<br/>
1314
By pressing the icon you can select an XML SCL File from your local system to become the latest version for current SCL XML File loaded from CoMPAS.<br/>
1415
Remark: The full XML will be replaced, including the history and CoMPAS Extensions, like filename.
1516
- <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M14.12 10.47L12 12.59l-2.13-2.12-1.41 1.41L10.59 14l-2.12 2.12 1.41 1.41L12 15.41l2.12 2.12 1.41-1.41L13.41 14l2.12-2.12zM15.5 4l-1-1h-5l-1 1H5v2h14V4zM6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM8 9h8v10H8V9z"/></svg>:
1617
Remove the SCL XML File completely from CoMPAS, all versions.<br/>
1718
By pressing the icon and confirming the action all versions will be removed from CoMPAS.
19+
20+
Beside these icons to execute actions, it's also possible to compare versions with each other.
21+
Select two versions by checking the checkbox and press the button "Compare versions" to see the differences between these two versions.
22+
23+
The current version opened (and changed) can also be compared to a specific version.
24+
Select one version by checking the checkbox and press the button "Compare versions (current)" to see the differences between current version and the selected version.

src/compas-editors/CompasVersions.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ export default class CompasVersionsPlugin extends LitElement {
5555

5656
private getSelectedVersions(): Array<string> {
5757
const selectedVersions: Array<string> = [];
58-
this.shadowRoot!.querySelectorAll('mwc-checkbox')
59-
.forEach(checkbox => {
60-
if (checkbox.checked) {
61-
selectedVersions.push(checkbox.value);
58+
this.shadowRoot!.querySelectorAll('mwc-check-list-item')
59+
.forEach(checkListItem => {
60+
if (checkListItem.selected) {
61+
selectedVersions.push(checkListItem.value);
6262
}
6363
});
6464
return selectedVersions;
@@ -148,7 +148,7 @@ export default class CompasVersionsPlugin extends LitElement {
148148
<div id="containerCompasVersions">
149149
<section tabindex="0">
150150
<h1>${translate('compas.versions.title')}</h1>
151-
<mwc-list>
151+
<mwc-list multi>
152152
${this.scls.map( (item, index, items) => {
153153
let element = getElementByName(item, SDS_NAMESPACE, "Name");
154154
if (element === null) {
@@ -157,30 +157,30 @@ export default class CompasVersionsPlugin extends LitElement {
157157
const name = element!.textContent ?? '';
158158
const version = getElementByName(item, SDS_NAMESPACE, "Version")!.textContent ?? '';
159159
if (items.length - 1 === index) {
160-
return html`<mwc-list-item tabindex="0"
161-
graphic="control">
160+
return html`<mwc-check-list-item value="${version}"
161+
tabindex="0"
162+
graphic="icon">
162163
${name} (${version})
163164
<span slot="graphic">
164-
<mwc-checkbox value="${version}"></mwc-checkbox>
165165
<mwc-icon @click=${() => {
166166
this.confirmRestoreVersionCompas(version);
167167
}}>restore</mwc-icon>
168168
</span>
169-
</mwc-list-item>`
169+
</mwc-check-list-item>`
170170
}
171-
return html`<mwc-list-item tabindex="0"
172-
graphic="control">
171+
return html`<mwc-check-list-item value="${version}"
172+
tabindex="0"
173+
graphic="icon">
173174
${name} (${version})
174175
<span slot="graphic">
175-
<mwc-checkbox value="${version}"></mwc-checkbox>
176176
<mwc-icon @click=${() => {
177177
this.confirmRestoreVersionCompas(version);
178178
}}>restore</mwc-icon>
179179
<mwc-icon @click=${() => {
180180
this.confirmDeleteVersionCompas(version);
181181
}}>delete</mwc-icon>
182182
</span>
183-
</mwc-list-item>`
183+
</mwc-check-list-item>`
184184
})}
185185
</mwc-list>
186186
</section>
@@ -212,22 +212,31 @@ export default class CompasVersionsPlugin extends LitElement {
212212
border-bottom: none;
213213
}
214214
215-
[mwc-list-item] {
216-
--mdc-list-item-graphic-size: 60px;
217-
--mdc-list-item-graphic-margin: 40px;
218-
}
219-
220215
#containerCompasVersions {
221216
padding: 8px 12px 16px;
222217
box-sizing: border-box;
223-
grid-template-columns: repeat(auto-fit, minmax(400px, auto));
218+
grid-template-columns: repeat(auto-fit, minmax(316px, auto));
224219
}
225220
226221
@media (max-width: 387px) {
227222
#containerCompasVersions {
228223
grid-template-columns: repeat(auto-fit, minmax(196px, auto));
229224
}
230225
}
226+
227+
mwc-check-list-item {
228+
padding-left: 60px;
229+
}
230+
231+
mwc-check-list-item > span {
232+
width: 90px;
233+
text-align: left;
234+
}
235+
236+
mwc-fab {
237+
float: right;
238+
margin: 5px 5px 5px 5px
239+
}
231240
`;
232241
}
233242

src/translations/en.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,10 @@ export const en = {
429429
confirmButton: 'Confirm',
430430
compareButton: 'Compare versions',
431431
selectTwoVersionsTitle: 'Select two versions?',
432-
selectTwoVersionsMessage: 'Select maximum two versions to compare with each other. Currently {{size}} versions is/are selected.',
432+
selectTwoVersionsMessage: 'Select maximum two versions to compare with each other. Currently selected: {{size}}.',
433433
compareCurrentButton: 'Compare version (current)',
434434
selectOneVersionsTitle: 'Select one version?',
435-
selectOneVersionsMessage: 'Select maximum one version to compare the current project against. Currently {{size}} versions is/are selected.',
435+
selectOneVersionsMessage: 'Select maximum one version to compare the current project against. Currently selected: {{size}}.',
436436
},
437437
compare: {
438438
title: 'Compare version {{leftVersion}} with version {{rightVersion}}',

test/integration/compas-editors/CompasVersions.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,26 @@ describe('compas-versions-plugin', () => {
117117
});
118118

119119
it('has 3 item entries', () => {
120-
expect(element.shadowRoot!.querySelectorAll('mwc-list > mwc-list-item'))
120+
expect(element.shadowRoot!.querySelectorAll('mwc-list > mwc-check-list-item'))
121121
.to.have.length(3);
122122
});
123123

124124
it('first entry has correct buttons', () => {
125-
expect(element.shadowRoot!.querySelectorAll('mwc-list > mwc-list-item').length)
125+
expect(element.shadowRoot!.querySelectorAll('mwc-list > mwc-check-list-item').length)
126126
.to.be.greaterThan(1);
127127
// Retrieve the first item after checking that there are items.
128-
const item = element.shadowRoot!.querySelectorAll('mwc-list > mwc-list-item')[0];
128+
const item = element.shadowRoot!.querySelectorAll('mwc-list > mwc-check-list-item')[0];
129129
// There should be 2 buttons, first the restore, second the delete.
130130
expect(item.querySelectorAll('span > mwc-icon')).to.have.length(2);
131131
expect(item.querySelectorAll('span > mwc-icon')[0].textContent).to.be.equal('restore');
132132
expect(item.querySelectorAll('span > mwc-icon')[1].textContent).to.be.equal('delete');
133133
});
134134

135135
it('last entry has one buttons', () => {
136-
expect(element.shadowRoot!.querySelectorAll('mwc-list > mwc-list-item'))
136+
expect(element.shadowRoot!.querySelectorAll('mwc-list > mwc-check-list-item'))
137137
.to.have.length(3);
138138
// Retrieve the last item after checking that there are 3 items.
139-
const item = element.shadowRoot!.querySelectorAll('mwc-list > mwc-list-item')[2];
139+
const item = element.shadowRoot!.querySelectorAll('mwc-list > mwc-check-list-item')[2];
140140
// There should be 1 buttons, the restore button.
141141
expect(item.querySelectorAll('span > mwc-icon')).to.have.length(1);
142142
expect(item.querySelectorAll('span > mwc-icon')[0].textContent).to.be.equal('restore');

0 commit comments

Comments
 (0)