@@ -5,90 +5,88 @@ import React, { Component } from 'react';
55import Annotation from '@/src/annotations/components/Annotation' ;
66
77interface IAnnotationPanelProps {
8- annotationModel : IAnnotationModel ;
9- rightPanelModel : IJupyterGISModel ;
8+ annotationModel : IAnnotationModel ;
9+ rightPanelModel : IJupyterGISModel ;
1010}
1111
1212export class AnnotationsPanel extends Component < IAnnotationPanelProps > {
13- constructor ( props : IAnnotationPanelProps ) {
14- super ( props ) ;
15-
16- const updateCallback = ( ) => {
17- this . forceUpdate ( ) ;
18- } ;
19-
20- this . _annotationModel = props . annotationModel ;
21- this . _rightPanelModel = props . rightPanelModel ;
22-
23- this . _annotationModel . modelChanged . connect ( async ( ) => {
24- // await this._annotationModel?.context?.ready;
25-
26- this . _annotationModel ?. model ?. sharedMetadataChanged . disconnect (
27- updateCallback ,
28- ) ;
29- this . _annotationModel = props . annotationModel ;
30- this . _annotationModel ?. model ?. sharedMetadataChanged . connect (
31- updateCallback ,
32- ) ;
33- this . forceUpdate ( ) ;
34- } ) ;
35- }
36-
37- render ( ) : JSX . Element {
38- const annotationIds = this . _annotationModel ?. getAnnotationIds ( ) ;
39-
40- if ( ! annotationIds || ! this . _annotationModel ) {
41- return < div > </ div > ;
42- }
43-
44- const annotations = annotationIds . map ( ( id : string ) => {
45- return (
46- < div >
47- < Annotation
48- rightPanelModel = { this . _rightPanelModel }
49- annotationModel = { this . _annotationModel }
50- itemId = { id }
51- />
52- < hr className = "jGIS-Annotations-Separator" > </ hr >
53- </ div >
54- ) ;
55- } ) ;
56-
57- return < div className = "jgis-scrollable" > { annotations } </ div > ;
58- }
59-
60- private _annotationModel : IAnnotationModel ;
61- private _rightPanelModel : IJupyterGISModel ;
13+ constructor ( props : IAnnotationPanelProps ) {
14+ super ( props ) ;
15+
16+ console . log ( props . annotationModel ) ;
17+
18+ const updateCallback = ( ) => {
19+ this . forceUpdate ( ) ;
20+ } ;
21+
22+ this . _annotationModel = props . annotationModel ;
23+ this . _rightPanelModel = props . rightPanelModel ;
24+
25+ this . _annotationModel ?. model ?. sharedMetadataChanged . connect (
26+ updateCallback ,
27+ ) ;
28+ this . forceUpdate ( ) ;
29+ }
30+
31+ render ( ) : JSX . Element {
32+ const annotationIds = this . _annotationModel ?. getAnnotationIds ( ) ;
33+
34+ if ( ! annotationIds || ! this . _annotationModel ) {
35+ return < div > </ div > ;
36+ }
37+
38+ const annotations = annotationIds . map ( ( id : string ) => {
39+ return (
40+ < div >
41+ < Annotation
42+ rightPanelModel = {
43+ this . _rightPanelModel
44+ }
45+ annotationModel = {
46+ this . _annotationModel
47+ }
48+ itemId = { id }
49+ />
50+ < hr className = "jGIS-Annotations-Separator" > </ hr >
51+ </ div >
52+ ) ;
53+ } ) ;
54+
55+ return < div className = "jgis-scrollable" > { annotations } </ div > ;
56+ }
57+
58+ private _annotationModel : IAnnotationModel ;
59+ private _rightPanelModel : IJupyterGISModel ;
6260}
6361
6462export class Annotations extends PanelWithToolbar {
65- constructor ( options : Annotations . IOptions ) {
66- super ( { } ) ;
63+ constructor ( options : Annotations . IOptions ) {
64+ super ( { } ) ;
6765
68- this . title . label = 'Annotations' ;
69- this . addClass ( 'jgis-scrollable' ) ;
66+ this . title . label = 'Annotations' ;
67+ this . addClass ( 'jgis-scrollable' ) ;
7068
71- this . _annotationModel = options . annotationModel ;
72- this . _rightPanelModel = options . rightPanelModel ;
69+ this . _annotationModel = options . annotationModel ;
70+ this . _rightPanelModel = options . rightPanelModel ;
7371
74- this . _widget = ReactWidget . create (
75- < AnnotationsPanel
76- rightPanelModel = { this . _rightPanelModel }
77- annotationModel = { this . _annotationModel }
78- /> ,
79- ) ;
72+ this . _widget = ReactWidget . create (
73+ < AnnotationsPanel
74+ rightPanelModel = { this . _rightPanelModel }
75+ annotationModel = { this . _annotationModel }
76+ /> ,
77+ ) ;
8078
81- this . addWidget ( this . _widget ) ;
82- }
79+ this . addWidget ( this . _widget ) ;
80+ }
8381
84- private _widget : ReactWidget ;
85- private _annotationModel : IAnnotationModel ;
86- private _rightPanelModel : IJupyterGISModel ;
82+ private _widget : ReactWidget ;
83+ private _annotationModel : IAnnotationModel ;
84+ private _rightPanelModel : IJupyterGISModel ;
8785}
8886
8987export namespace Annotations {
90- export interface IOptions {
91- annotationModel : IAnnotationModel ;
92- rightPanelModel : IJupyterGISModel ;
93- }
88+ export interface IOptions {
89+ annotationModel : IAnnotationModel ;
90+ rightPanelModel : IJupyterGISModel ;
91+ }
9492}
0 commit comments