@@ -10,7 +10,7 @@ import {CompasSclTypeRadiogroup} from "./CompasSclTypeRadiogroup.js";
10
10
import { CompasCommentElement } from "./CompasComment.js" ;
11
11
import { CompasSclDataService } from "../compas-services/CompasSclDataService.js" ;
12
12
import { createLogEvent } from "../compas-services/foundation.js" ;
13
- import { getOpenScdElement , getTypeFromDocName , reloadSclDocument , stripExtensionFromName } from "./foundation.js" ;
13
+ import { getOpenScdElement , getTypeFromDocName , stripExtensionFromName , updateDocumentInOpenSCD } from "./foundation.js" ;
14
14
import './CompasSclTypeRadiogroup.js' ;
15
15
16
16
@customElement ( 'compas-save-to' )
@@ -47,11 +47,11 @@ export class CompasSaveTo extends CompasExistsIn(LitElement) {
47
47
const docType = this . getSclTypeRadioGroup ( ) . getSelectedValue ( ) ?? '' ;
48
48
49
49
await CompasSclDataService ( ) . addSclDocument ( docType , { sclName : name , comment : comment , doc : doc } )
50
- . then ( async xmlResponse => {
51
- const id = Array . from ( xmlResponse . querySelectorAll ( '*|Id' ) ?? [ ] ) [ 0 ]
50
+ . then ( response => {
51
+ const sclData = response . querySelectorAll ( "SclData" ) . item ( 0 ) . textContent ;
52
+ const sclDocument = new DOMParser ( ) . parseFromString ( sclData ?? '' , 'application/xml' ) ;
52
53
53
- // Retrieve the document to fetch server-side updates.
54
- await reloadSclDocument ( docType , id . textContent ?? '' ) ;
54
+ updateDocumentInOpenSCD ( sclDocument ) ;
55
55
56
56
const openScd = getOpenScdElement ( ) ;
57
57
openScd . dispatchEvent (
@@ -72,9 +72,10 @@ export class CompasSaveTo extends CompasExistsIn(LitElement) {
72
72
const docType = getTypeFromDocName ( docName ) ;
73
73
74
74
await CompasSclDataService ( ) . updateSclDocument ( docType . toUpperCase ( ) , docId , { changeSet : changeSet ! , comment : comment , doc : doc } )
75
- . then ( async ( ) => {
76
- // Retrieve the document to fetch server-side updates.
77
- await reloadSclDocument ( docType , docId ) ;
75
+ . then ( response => {
76
+ const sclData = response . querySelectorAll ( "SclData" ) . item ( 0 ) . textContent ;
77
+ const sclDocument = new DOMParser ( ) . parseFromString ( sclData ?? '' , 'application/xml' ) ;
78
+ updateDocumentInOpenSCD ( sclDocument ) ;
78
79
79
80
const openScd = getOpenScdElement ( ) ;
80
81
openScd . dispatchEvent (
0 commit comments