Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fulltext-search): update projects list dropdown on new project creation (DEV-212) #586

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -37,5 +37,6 @@ export class EmitEvent {
// possible events that can be emitted.
export enum Events {
loginSuccess,
gravSearchExecuted
gravSearchExecuted,
projectCreated
}
Expand Up @@ -14,6 +14,7 @@ import { CacheService } from 'src/app/main/cache/cache.service';
import { DspApiConnectionToken } from 'src/app/main/declarations/dsp-api-tokens';
import { DialogComponent } from 'src/app/main/dialog/dialog.component';
import { ErrorHandlerService } from 'src/app/main/error/error-handler.service';
import { ComponentCommunicationEventService, EmitEvent, Events } from 'src/app/main/services/component-communication-event.service';
import { Session, SessionService } from 'src/app/main/services/session.service';
import { SortingService } from 'src/app/main/services/sorting.service';

Expand Down Expand Up @@ -84,7 +85,8 @@ export class ProjectsListComponent implements OnInit {
private _dialog: MatDialog,
private _router: Router,
private _session: SessionService,
private _sortingService: SortingService
private _sortingService: SortingService,
private _componentCommsService: ComponentCommunicationEventService
) { }

ngOnInit() {
Expand Down Expand Up @@ -165,6 +167,10 @@ export class ProjectsListComponent implements OnInit {
} else {
// update the view
this.refreshParent.emit();

if (mode === 'createProject') {
this._componentCommsService.emit(new EmitEvent(Events.projectCreated, true));
}
}
});
}
Expand Down
Expand Up @@ -108,7 +108,7 @@ export class FulltextSearchComponent implements OnInit, OnChanges, OnDestroy {

projectIri: string;

componentCommsSubscription: Subscription;
componentCommsSubscriptions: Subscription[]= [];

// in case of an (api) error
error: any;
Expand Down Expand Up @@ -169,10 +169,17 @@ export class FulltextSearchComponent implements OnInit, OnChanges, OnDestroy {
}

// in the event of a grav search (advanced or expert search), clear the input field
this.componentCommsSubscription = this._componentCommsService.on(
this.componentCommsSubscriptions.push(this._componentCommsService.on(
Events.gravSearchExecuted, () => {
this.searchQuery = null;
});
})
);

this.componentCommsSubscriptions.push(this._componentCommsService.on(
Events.projectCreated, () => {
this.getAllProjects();
}
));
}

ngOnChanges() {
Expand All @@ -190,9 +197,9 @@ export class FulltextSearchComponent implements OnInit, OnChanges, OnDestroy {
}

ngOnDestroy() {
// unsubscribe from the componentCommsSubscription when component is destroyed
if (this.componentCommsSubscription !== undefined) {
this.componentCommsSubscription.unsubscribe();
// unsubscribe from all subscriptions incomponentCommsSubscriptions when component is destroyed
if (this.componentCommsSubscriptions !== undefined) {
this.componentCommsSubscriptions.forEach(sub => sub.unsubscribe());
}
}

Expand Down