@@ -5,6 +5,7 @@ import { OneNotePicker } from '../src/oneNotePicker';
5
5
import { GlobalProps } from '../src/props/globalProps' ;
6
6
import { OneNoteDataProvider } from '../src/providers/oneNoteDataProvider' ;
7
7
import { Notebook } from '../src/oneNoteDataStructures/notebook' ;
8
+ import { Section } from '../src/oneNoteDataStructures/section' ;
8
9
import { OneNoteItemUtils } from '../src/oneNoteDataStructures/oneNoteItemUtils' ;
9
10
import { NotebookListUpdater } from '../src/oneNoteDataStructures/notebookListUpdater' ;
10
11
import { SampleOneNoteDataProvider } from './sampleOneNoteDataProvider' ;
@@ -73,11 +74,37 @@ oneNoteDataProvider.getNotebooks().then((notebooks) => {
73
74
onAccessibleSelection : ( selectedItemId : string ) => {
74
75
globalProps . globals . ariaSelectedId = selectedItemId ;
75
76
let notebookName = findNotebook ( notebooks , selectedItemId ) ;
76
- if ( defaultDropdownLabel === "" )
77
- defaultDropdownLabel = notebookName ;
77
+ if ( defaultDropdownLabel === "" )
78
+ defaultDropdownLabel = notebookName ;
78
79
// todo this changes the label but you can't click to make a selection?
79
80
render ( globalProps , globalProps . globals . notebookListUpdater ! . get ( ) ) ;
80
81
renderDropdown ( globalProps , globalProps . globals . notebookListUpdater ! . get ( ) , defaultDropdownLabel , true ) ;
82
+ } ,
83
+ onNotebookCreated : ( notebook : Notebook ) => {
84
+ // Allow max one creation
85
+ globalProps . globals . callbacks . onNotebookCreated = undefined ;
86
+
87
+ if ( globalProps . globals . notebookListUpdater ) {
88
+ globalProps . globals . notebookListUpdater . addNotebook ( notebook ) ;
89
+ globalProps . globals . selectedId = notebook . id ;
90
+ }
91
+
92
+ // tslint:disable-next-line:no-console
93
+ console . log ( `Notebook created: ${ notebook . name } ` ) ;
94
+
95
+ render ( globalProps , globalProps . globals . notebookListUpdater ! . get ( ) ) ;
96
+ } ,
97
+ onSectionCreated : ( section : Section ) => {
98
+ // TODO (machiam) Introduce a way of only allowing max one section creation per parent
99
+ // tslint:disable-next-line:no-console
100
+ console . log ( `Section created: ${ section . name } ` ) ;
101
+
102
+ if ( globalProps . globals . notebookListUpdater ) {
103
+ globalProps . globals . notebookListUpdater ! . addSection ( section ) ;
104
+ globalProps . globals . selectedId = section . id ;
105
+ }
106
+
107
+ render ( globalProps , globalProps . globals . notebookListUpdater ! . get ( ) ) ;
81
108
}
82
109
} ,
83
110
selectedId : initialSelectedId ,
0 commit comments