@@ -21,7 +21,7 @@ import { Toolbar } from '@jupyterlab/apputils';
2121import { DocumentRegistry } from '@jupyterlab/docregistry' ;
2222import { PathExt } from '@jupyterlab/coreutils' ;
2323
24- import { AngularWidget } from './phosphor-angular-loader' ;
24+ import { AngularWidget , AngularLoader } from './phosphor-angular-loader' ;
2525import { AppComponent } from './app.component' ;
2626import { AppModule } from './app.module' ;
2727
@@ -43,6 +43,7 @@ export namespace IScriptedFormsWidget {
4343 export interface IOptions {
4444 serviceManager : ServiceManager ;
4545 contentsManager : ContentsManager ;
46+ angularLoader : AngularLoader < AppModule > ;
4647 context ?: DocumentRegistry . Context ;
4748 }
4849}
@@ -52,6 +53,7 @@ export namespace IAngularWrapperWidget {
5253 toolbar : Toolbar < Widget > ;
5354 serviceManager : ServiceManager ;
5455 contentsManager : ContentsManager ;
56+ angularLoader : AngularLoader < AppModule > ;
5557 context ?: DocumentRegistry . Context ;
5658 }
5759}
@@ -64,7 +66,8 @@ export class AngularWrapperWidget extends AngularWidget<
6466 scriptedFormsOptions : IScriptedForms . IOptions ;
6567
6668 constructor ( options : IAngularWrapperWidget . IOptions ) {
67- super ( AppComponent , AppModule ) ;
69+
70+ super ( AppComponent , options . angularLoader ) ;
6871
6972 this . scriptedFormsOptions = Object . assign (
7073 {
@@ -95,8 +98,8 @@ export class AngularWrapperWidget extends AngularWidget<
9598
9699export class ScriptedFormsWidget extends Widget {
97100 _context : DocumentRegistry . Context ;
98- content : AngularWrapperWidget ;
99- toolbar : Toolbar
101+ private _content : AngularWrapperWidget ;
102+ toolbar = new Toolbar ( ) ;
100103 id : 'ScriptedForms' ;
101104
102105 constructor ( options : IScriptedFormsWidget . IOptions ) {
@@ -109,20 +112,24 @@ export class ScriptedFormsWidget extends Widget {
109112 this . addClass ( 'scripted-form-widget' ) ;
110113
111114 const layout = ( this . layout = new BoxLayout ( ) ) ;
112- const toolbar = new Toolbar ( ) ;
113- this . toolbar = toolbar ;
114- toolbar . addClass ( 'jp-NotebookPanel-toolbar' ) ;
115- toolbar . addClass ( 'custom-toolbar' ) ;
116- layout . addWidget ( toolbar ) ;
117- BoxLayout . setStretch ( toolbar , 0 ) ;
115+ this . toolbar . addClass ( 'jp-NotebookPanel-toolbar' ) ;
116+ this . toolbar . addClass ( 'custom-toolbar' ) ;
117+ layout . addWidget ( this . toolbar ) ;
118+ BoxLayout . setStretch ( this . toolbar , 0 ) ;
119+
120+ const angularWrapperWidgetOptions = Object . assign ( { toolbar : this . toolbar } , options ) ;
121+
122+ this . _content = new AngularWrapperWidget ( angularWrapperWidgetOptions ) ;
123+ this . _content . addClass ( 'form-container' ) ;
118124
119- const angularWrapperWidgetOptions = Object . assign ( { toolbar } , options ) ;
125+ layout . addWidget ( this . _content ) ;
126+ BoxLayout . setStretch ( this . _content , 1 ) ;
120127
121- this . content = new AngularWrapperWidget ( angularWrapperWidgetOptions ) ;
122- this . content . addClass ( 'form-container' ) ;
128+ this . _content . initiliseScriptedForms ( ) ;
129+ }
123130
124- layout . addWidget ( this . content ) ;
125- BoxLayout . setStretch ( this . content , 1 ) ;
131+ get content ( ) {
132+ return this . _content ;
126133 }
127134
128135 get revealed ( ) {
@@ -136,9 +143,4 @@ export class ScriptedFormsWidget extends Widget {
136143 onPathChanged ( ) : void {
137144 this . title . label = PathExt . basename ( this . _context . path ) ;
138145 }
139-
140- dispose ( ) {
141- this . content . dispose ( ) ;
142- super . dispose ( ) ;
143- }
144146}
0 commit comments