@@ -9,14 +9,20 @@ import '@material/mwc-list/mwc-list-item';
9
9
import '@material/mwc-list/mwc-check-list-item' ;
10
10
11
11
import { newLogEvent , newWizardEvent , Wizard } from "../foundation.js" ;
12
+ import { MultiSelectedEvent } from "@material/mwc-list/mwc-list-foundation" ;
12
13
13
14
import { CompasSclDataService , SDS_NAMESPACE } from "../compas-services/CompasSclDataService.js" ;
14
15
import { createLogEvent } from "../compas-services/foundation.js" ;
15
- import { getTypeFromDocName , updateDocumentInOpenSCD } from "../compas/foundation.js" ;
16
- import { getElementByName , getOpenScdElement , styles } from './foundation.js' ;
16
+ import {
17
+ dispatchEventOnOpenScd ,
18
+ getOpenScdElement ,
19
+ getTypeFromDocName ,
20
+ setDocIdOnOpenScd ,
21
+ updateDocumentInOpenSCD
22
+ } from "../compas/foundation.js" ;
17
23
import { addVersionToCompasWizard } from "../compas/CompasUploadVersion.js" ;
18
24
import { compareWizard } from "../compas/CompasCompareDialog.js" ;
19
- import { MultiSelectedEvent } from "@material/mwc-list/mwc-list- foundation" ;
25
+ import { getElementByName , styles } from './ foundation.js' ;
20
26
21
27
// Save the selection for the current document.
22
28
let selectedVersionsOnCompasVersionsEditor : Set < number > = new Set ( ) ;
@@ -38,7 +44,7 @@ export default class CompasVersionsPlugin extends LitElement {
38
44
39
45
// Add event to get a notification when a new document is opened.
40
46
const openSCD = getOpenScdElement ( ) ;
41
- if ( openSCD ) {
47
+ if ( openSCD !== null ) {
42
48
openSCD . addEventListener ( 'open-doc' , this . resetSelection ) ;
43
49
}
44
50
}
@@ -273,14 +279,13 @@ export default class CompasVersionsPlugin extends LitElement {
273
279
function confirmDeleteCompasWizard ( docName : string , docId : string ) : Wizard {
274
280
function deleteScl ( docName : string , docId : string ) {
275
281
return function ( ) {
276
- const openScd = getOpenScdElement ( ) ;
277
282
const type = getTypeFromDocName ( docName ) ;
278
283
279
284
CompasSclDataService ( )
280
285
. deleteSclDocument ( type , docId )
281
286
. then ( ( ) => {
282
- openScd . docId = '' ;
283
- openScd . dispatchEvent (
287
+ setDocIdOnOpenScd ( '' ) ;
288
+ dispatchEventOnOpenScd (
284
289
newLogEvent ( {
285
290
kind : 'info' ,
286
291
title : get ( 'compas.versions.deleteSuccess' )
@@ -289,7 +294,7 @@ function confirmDeleteCompasWizard(docName: string, docId: string): Wizard {
289
294
. catch ( createLogEvent ) ;
290
295
291
296
// Close the Restore Dialog.
292
- openScd . dispatchEvent ( newWizardEvent ( ) ) ;
297
+ dispatchEventOnOpenScd ( newWizardEvent ( ) ) ;
293
298
294
299
return [ ] ;
295
300
}
@@ -313,14 +318,13 @@ function confirmDeleteCompasWizard(docName: string, docId: string): Wizard {
313
318
function confirmRestoreVersionCompasWizard ( docName : string , docId : string , version : string ) : Wizard {
314
319
function openScl ( docName : string , docId : string , version : string ) {
315
320
return function ( ) {
316
- const openScd = getOpenScdElement ( ) ;
317
321
const type = getTypeFromDocName ( docName ) ;
318
322
319
323
CompasSclDataService ( ) . getSclDocumentVersion ( type , docId , version )
320
324
. then ( sclDocument => {
321
325
updateDocumentInOpenSCD ( sclDocument ) ;
322
326
323
- openScd . dispatchEvent (
327
+ dispatchEventOnOpenScd (
324
328
newLogEvent ( {
325
329
kind : 'info' ,
326
330
title : get ( 'compas.versions.restoreVersionSuccess' , { version : version } )
@@ -329,7 +333,7 @@ function confirmRestoreVersionCompasWizard(docName: string, docId: string, versi
329
333
. catch ( createLogEvent ) ;
330
334
331
335
// Close the Restore Dialog.
332
- openScd . dispatchEvent ( newWizardEvent ( ) ) ;
336
+ dispatchEventOnOpenScd ( newWizardEvent ( ) ) ;
333
337
334
338
return [ ] ;
335
339
}
@@ -353,13 +357,12 @@ function confirmRestoreVersionCompasWizard(docName: string, docId: string, versi
353
357
function confirmDeleteVersionCompasWizard ( docName : string , docId : string , version : string ) : Wizard {
354
358
function deleteSclVersion ( docName : string , docId : string , version : string ) {
355
359
return function ( ) {
356
- const openScd = getOpenScdElement ( ) ;
357
360
const type = getTypeFromDocName ( docName ) ;
358
361
359
362
CompasSclDataService ( )
360
363
. deleteSclDocumentVersion ( type , docId , version )
361
364
. then ( ( ) => {
362
- openScd . dispatchEvent (
365
+ dispatchEventOnOpenScd (
363
366
newLogEvent ( {
364
367
kind : 'info' ,
365
368
title : get ( 'compas.versions.deleteVersionSuccess' , { version : version } )
@@ -368,7 +371,7 @@ function confirmDeleteVersionCompasWizard(docName: string, docId: string, versio
368
371
. catch ( createLogEvent ) ;
369
372
370
373
// Close the Restore Dialog.
371
- openScd . dispatchEvent ( newWizardEvent ( ) ) ;
374
+ dispatchEventOnOpenScd ( newWizardEvent ( ) ) ;
372
375
373
376
return [ ] ;
374
377
}
0 commit comments