blob: 143d6816b9bc616d0b8d4cab6f56bb8942ddd1df [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import { CompanyDetailsSandBox } from '@pages/company/company-details/company-details.sandbox';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { Injectable } from '@angular/core';
import { CommunicationTypesSandbox } from '@pages/admin/communication-types/communication-types.sandbox';
@Injectable()
export class CompanyDetailsResolver implements Resolve<any>{
constructor(
private companySandbox: CompanyDetailsSandBox,
private communicationTypesSandbox: CommunicationTypesSandbox
) { }
/**
* @param route
*/
public resolve(route: ActivatedRouteSnapshot): void {
const contactId: string = route.params['contactId'];
if (contactId && (contactId !== 'new')) {
this.companySandbox.loadCompany(contactId);
this.companySandbox.loadCommunicationsData(contactId);
this.companySandbox.loadCompanyAddresses(contactId);
} else {
this.companySandbox.clearCompany();
}
this.communicationTypesSandbox.loadCommunicationTypes();
this.companySandbox.isCommunicationsDataDetailViewVisible = false;
}
}