@@ -2,8 +2,9 @@ import { property, PropertyValues, state } from 'lit-element';
2
2
3
3
import { LitElementConstructor , Mixin } from '../foundation.js' ;
4
4
5
- import { CompasSclDataService } from '../compas-services/CompasSclDataService.js' ;
6
5
import { getTypeFromDocName } from './foundation.js' ;
6
+ import { CompasSclDataService } from '../compas-services/CompasSclDataService.js' ;
7
+ import { NOT_FOUND_ERROR } from '../compas-services/foundation.js' ;
7
8
8
9
export type CompasExistsInElement = Mixin < typeof CompasExistsIn > ;
9
10
@@ -32,7 +33,7 @@ export function CompasExistsIn<TBase extends LitElementConstructor>(
32
33
}
33
34
}
34
35
35
- callService ( docType : string , docId : string ) {
36
+ callService ( docType : string , docId : string ) : Promise < Document > {
36
37
// Use the versions call to check if any exist, because then the document also exists
37
38
// And it saves bandwidth not to retrieve the whole document.
38
39
return CompasSclDataService ( ) . listVersions ( docType , docId ) ;
@@ -43,8 +44,10 @@ export function CompasExistsIn<TBase extends LitElementConstructor>(
43
44
const docType = getTypeFromDocName ( this . docName ) ;
44
45
this . callService ( docType , this . docId )
45
46
. then ( ( ) => ( this . existInCompas = true ) )
46
- . catch ( ( ) => {
47
- this . existInCompas = false ;
47
+ . catch ( reason => {
48
+ if ( reason . type === NOT_FOUND_ERROR ) {
49
+ this . existInCompas = false ;
50
+ }
48
51
} ) ;
49
52
} else {
50
53
this . existInCompas = false ;
0 commit comments