@@ -10,7 +10,7 @@ import { SelectionModel } from '@angular/cdk/collections';
1010import { Router , ActivatedRoute , RouterLink } from '@angular/router' ;
1111import { FormControl , FormsModule , ReactiveFormsModule } from '@angular/forms' ;
1212import { Subject , of } from 'rxjs' ;
13- import { switchMap , takeUntil } from 'rxjs/operators' ;
13+ import { map , switchMap , takeUntil } from 'rxjs/operators' ;
1414import { FuzzySearchService } from '../shared/fuzzy-search.service' ;
1515import {
1616 filterSpecificFields , composeFilterFunctions , createDeleteArray , filterTags ,
@@ -29,6 +29,7 @@ import { CoursesService } from './courses.service';
2929import { dedupeShelfReduce , doesMarkdownPreviewTruncate , findByIdInArray , hasMarkdownImages , itemsShown } from '../shared/utils' ;
3030import { StateService } from '../shared/state.service' ;
3131import { DialogsLoadingService } from '../shared/dialogs/dialogs-loading.service' ;
32+ import { DialogGuardService } from '../shared/dialogs/dialog-guard.service' ;
3233import { TagsService } from '../shared/forms/tags.service' ;
3334import { PlanetTagInputComponent } from '../shared/forms/planet-tag-input.component' ;
3435import { SearchService } from '../shared/forms/search.service' ;
@@ -95,7 +96,7 @@ export class CoursesComponent implements OnInit, OnChanges, AfterViewInit, OnDes
9596 @Input ( ) displayedColumns = [ 'select' , 'courseTitle' , 'info' , 'createdDate' , 'rating' ] ;
9697 @Input ( ) excludeIds = [ ] ;
9798 @Input ( ) includeIds : string [ ] = [ ] ;
98- dialogRef : MatDialogRef < DialogsListComponent > ;
99+ dialogRef : MatDialogRef < DialogsListComponent > | null = null ;
99100 message = '' ;
100101 deleteDialog : any ;
101102 readonly dbName = 'courses' ;
@@ -163,6 +164,7 @@ export class CoursesComponent implements OnInit, OnChanges, AfterViewInit, OnDes
163164 private syncService : SyncService ,
164165 private stateService : StateService ,
165166 private dialogsLoadingService : DialogsLoadingService ,
167+ public dialogGuard : DialogGuardService ,
166168 private tagsService : TagsService ,
167169 private searchService : SearchService ,
168170 private deviceInfoService : DeviceInfoService ,
@@ -470,17 +472,19 @@ export class CoursesComponent implements OnInit, OnChanges, AfterViewInit, OnDes
470472 }
471473
472474 openSendCourseDialog ( ) {
473- this . dialogsListService . getListAndColumns ( 'communityregistrationrequests' , { 'registrationRequest' : 'accepted' } ) . pipe (
474- takeUntil ( this . onDestroy$ )
475- ) . subscribe ( ( planet ) => {
476- const data = { okClick : this . sendCourse ( ) . bind ( this ) ,
477- filterPredicate : filterSpecificFields ( [ 'name' ] ) ,
478- allowMulti : true ,
479- ...planet } ;
480- this . dialogRef = this . dialog . open ( DialogsListComponent , {
481- data, maxHeight : '500px' , width : '600px' , autoFocus : false
482- } ) ;
483- } ) ;
475+ this . dialogGuard . open ( 'send-course' , ( ) =>
476+ this . dialogsListService . getListAndColumns ( 'communityregistrationrequests' , { 'registrationRequest' : 'accepted' } ) . pipe (
477+ map ( planet => this . dialog . open ( DialogsListComponent , {
478+ data : {
479+ okClick : this . sendCourse ( ) . bind ( this ) ,
480+ filterPredicate : filterSpecificFields ( [ 'name' ] ) ,
481+ allowMulti : true ,
482+ ...planet
483+ } ,
484+ maxHeight : '500px' , width : '600px' , autoFocus : false
485+ } ) )
486+ )
487+ ) . pipe ( takeUntil ( this . onDestroy$ ) ) . subscribe ( ref => this . dialogRef = ref ) ;
484488 }
485489
486490 sendCourse ( ) {
0 commit comments