@@ -247,6 +247,7 @@ export class EditingModeExtension implements DocumentRegistry.IWidgetExtension<N
247
247
const suggestionMenu = new Menu ( { commands : suggestionCommands } ) ;
248
248
const reviewMenu = new Menu ( { commands : reviewCommands } ) ;
249
249
250
+ const sharedModel = context . model . sharedModel ;
250
251
var myForkId = '' ; // curently allows only one suggestion per user
251
252
252
253
editingMenu . title . label = 'Editing' ;
@@ -263,6 +264,7 @@ export class EditingModeExtension implements DocumentRegistry.IWidgetExtension<N
263
264
execute : ( ) => {
264
265
editingMenu . title . label = 'Editing' ;
265
266
suggestionMenu . title . label = 'Root' ;
267
+ open_dialog ( 'Editing' , this . _trans ) ;
266
268
}
267
269
} ) ;
268
270
editingCommands . addCommand ( 'suggesting' , {
@@ -272,17 +274,17 @@ export class EditingModeExtension implements DocumentRegistry.IWidgetExtension<N
272
274
reviewMenu . clearItems ( ) ;
273
275
if ( myForkId === '' ) {
274
276
myForkId = 'pending' ;
275
- const provider = context . model . sharedModel . provider ;
276
- provider . fork ( ) . then ( newForkId => {
277
+ sharedModel . provider . fork ( ) . then ( newForkId => {
277
278
myForkId = newForkId ;
278
- provider . connectFork ( newForkId ) ;
279
+ sharedModel . provider . connectFork ( newForkId ) ;
279
280
suggestionMenu . title . label = newForkId ;
280
281
} ) ;
281
282
}
282
283
else {
283
284
suggestionMenu . title . label = myForkId ;
284
- context . model . sharedModel . provider . connectFork ( myForkId ) ;
285
+ sharedModel . provider . connectFork ( myForkId ) ;
285
286
}
287
+ open_dialog ( 'Suggesting' , this . _trans ) ;
286
288
}
287
289
} ) ;
288
290
@@ -293,14 +295,15 @@ export class EditingModeExtension implements DocumentRegistry.IWidgetExtension<N
293
295
reviewMenu . clearItems ( ) ;
294
296
suggestionMenu . title . label = 'Root' ;
295
297
editingMenu . title . label = 'Editing' ;
296
- context . model . sharedModel . provider . connectFork ( context . model . sharedModel . rootRoomId ) ;
298
+ sharedModel . provider . connectFork ( sharedModel . rootRoomId ) ;
299
+ open_dialog ( 'Editing' , this . _trans ) ;
297
300
}
298
301
} ) ;
299
302
300
303
reviewCommands . addCommand ( 'merge' , {
301
304
label : 'Merge' ,
302
305
execute : ( ) => {
303
- requestDocMerge ( context . model . sharedModel . currentRoomId , context . model . sharedModel . rootRoomId ) ;
306
+ requestDocMerge ( sharedModel . currentRoomId , sharedModel . rootRoomId ) ;
304
307
}
305
308
} ) ;
306
309
reviewCommands . addCommand ( 'discard' , {
@@ -336,29 +339,24 @@ export class EditingModeExtension implements DocumentRegistry.IWidgetExtension<N
336
339
reviewMenu . addItem ( { type : 'command' , command : 'discard' } ) ;
337
340
}
338
341
suggestionMenu . title . label = newForkId ;
339
- context . model . sharedModel . provider . connectFork ( newForkId ) ;
340
- const dialog = new Dialog ( {
341
- title : this . _trans . __ ( 'Suggestion' ) ,
342
- body : this . _trans . __ ( 'Your are now viewing the suggestion.' ) ,
343
- buttons : [ Dialog . okButton ( { label : 'OK' } ) ] ,
344
- } ) ;
345
- dialog . launch ( ) . then ( resp => { dialog . close ( ) ; } ) ;
342
+ sharedModel . provider . connectFork ( newForkId ) ;
343
+ open_dialog ( 'Suggesting' , this . _trans ) ;
346
344
}
347
345
} ) ;
348
346
suggestionMenu . addItem ( { type : 'command' , command : newForkId } ) ;
349
347
if ( ( myForkId !== 'pending' ) && ( myForkId !== newForkId ) ) {
350
348
const dialog = new Dialog ( {
351
349
title : this . _trans . __ ( 'New suggestion' ) ,
352
- body : this . _trans . __ ( 'Open notebook for suggestion?' ) ,
350
+ body : this . _trans . __ ( 'View suggestion?' ) ,
353
351
buttons : [
354
- Dialog . okButton ( { label : 'Open ' } ) ,
352
+ Dialog . okButton ( { label : 'View ' } ) ,
355
353
Dialog . cancelButton ( { label : 'Discard' } ) ,
356
354
] ,
357
355
} ) ;
358
356
dialog . launch ( ) . then ( resp => {
359
357
dialog . close ( ) ;
360
- if ( resp . button . label === 'Open ' ) {
361
- context . model . sharedModel . provider . connectFork ( newForkId ) ;
358
+ if ( resp . button . label === 'View ' ) {
359
+ sharedModel . provider . connectFork ( newForkId ) ;
362
360
suggestionMenu . title . label = newForkId ;
363
361
editingMenu . title . label = 'Editing' ;
364
362
reviewMenu . clearItems ( ) ;
@@ -372,7 +370,7 @@ export class EditingModeExtension implements DocumentRegistry.IWidgetExtension<N
372
370
}
373
371
} ;
374
372
375
- context . model . sharedModel . changed . connect ( _onStateChanged , this ) ;
373
+ sharedModel . changed . connect ( _onStateChanged , this ) ;
376
374
377
375
editingMenubar . addMenu ( editingMenu ) ;
378
376
suggestionMenubar . addMenu ( suggestionMenu ) ;
@@ -388,3 +386,20 @@ export class EditingModeExtension implements DocumentRegistry.IWidgetExtension<N
388
386
} ) ;
389
387
}
390
388
}
389
+
390
+
391
+ function open_dialog ( title : string , trans : TranslationBundle ) {
392
+ var body : string ;
393
+ if ( title === 'Editing' ) {
394
+ body = 'You are now directly editing the document.'
395
+ }
396
+ else {
397
+ body = 'Your edits now become suggestions to the document.'
398
+ }
399
+ const dialog = new Dialog ( {
400
+ title : trans . __ ( title ) ,
401
+ body : trans . __ ( body ) ,
402
+ buttons : [ Dialog . okButton ( { label : 'OK' } ) ] ,
403
+ } ) ;
404
+ dialog . launch ( ) . then ( resp => { dialog . close ( ) ; } ) ;
405
+ }
0 commit comments