Skip to content

Commit

Permalink
Merge branch 'develop' into issue-317
Browse files Browse the repository at this point in the history
  • Loading branch information
rmroot committed Nov 19, 2024
2 parents e80dace + b101f38 commit b3f5714
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class CompanyContactsSetupComponent implements OnInit, OnDestroy {

canDeactivate(): Observable<boolean> {
if (this.hasInvalidContacts) {
this.dislayWarningModal();
this.displayWarningModal();
return of(false);
}
return of(true);
Expand Down Expand Up @@ -99,7 +99,7 @@ export class CompanyContactsSetupComponent implements OnInit, OnDestroy {
this.hasInvalidContacts = hasInvalidContacts;
}
}
dislayWarningModal() {
displayWarningModal() {
this.routeGuardWarningModal = true;
}
closeWarningModal() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ <h5>
Go Back
</button>
<button class="btn nav-btn btn-sm" (click)="goToKpiDetails()">
Detail KPIs
<ng-template [ngIf]="companyKpis.length > 0" [ngIfElse]="noKPIsBlock">
Detail KPIs
</ng-template>
<ng-template #noKPIsBlock>
Facility Details
</ng-template>
<fa-icon [icon]="faChevronRight"></fa-icon>
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { IdbOnSiteVisit } from 'src/app/models/onSiteVisit';
import { OnSiteVisitIdbService } from 'src/app/indexed-db/on-site-visit-idb.service';
import { KeyPerformanceIndicatorsIdbService } from 'src/app/indexed-db/key-performance-indicators-idb.service';
import { IdbKeyPerformanceIndicator } from 'src/app/models/keyPerformanceIndicator';
import { Subscription } from 'rxjs';

@Component({
selector: 'app-company-kpi-select',
Expand All @@ -15,12 +16,27 @@ export class CompanyKpiSelectComponent {
faChartBar: IconDefinition = faChartBar;
faChevronRight: IconDefinition = faChevronRight;
faChevronLeft: IconDefinition = faChevronLeft;

companyKpiSub: Subscription;
companyKpis: Array<IdbKeyPerformanceIndicator>;
onSiteVisit: IdbOnSiteVisit;
constructor(private router: Router,
private onSiteVisitIdbService: OnSiteVisitIdbService,
private keyPerformanceIndicatorIdbService: KeyPerformanceIndicatorsIdbService,
) { }

ngOnInit() {
this.onSiteVisit = this.onSiteVisitIdbService.selectedVisit.getValue();
this.companyKpiSub = this.keyPerformanceIndicatorIdbService.keyPerformanceIndicators.subscribe(kpis => {
let keyPerformanceIndicators: Array<IdbKeyPerformanceIndicator> = this.keyPerformanceIndicatorIdbService.keyPerformanceIndicators.getValue();
this.companyKpis = keyPerformanceIndicators.filter(kpi => {
return kpi.companyId == this.onSiteVisit.companyId
});
});
}

ngOnDestroy(){
this.companyKpiSub.unsubscribe();
}

goBack() {
Expand All @@ -29,15 +45,10 @@ export class CompanyKpiSelectComponent {
}

goToKpiDetails() {
let onSiteVisit: IdbOnSiteVisit = this.onSiteVisitIdbService.selectedVisit.getValue();
let keyPerformanceIndicators: Array<IdbKeyPerformanceIndicator> = this.keyPerformanceIndicatorIdbService.keyPerformanceIndicators.getValue();
let companyKpis: Array<IdbKeyPerformanceIndicator> = keyPerformanceIndicators.filter(kpi => {
return kpi.companyId == onSiteVisit.companyId
});
if (companyKpis.length > 0) {
this.router.navigateByUrl('setup-wizard/pre-visit/' + onSiteVisit.guid + '/company-kpi-detail/' + companyKpis[0].guid);
if (this.companyKpis.length > 0) {
this.router.navigateByUrl('setup-wizard/pre-visit/' + this.onSiteVisit.guid + '/company-kpi-detail/' + this.companyKpis[0].guid);
} else {
this.router.navigateByUrl('setup-wizard/pre-visit/' + onSiteVisit.guid + '/facility-setup');
this.router.navigateByUrl('setup-wizard/pre-visit/' + this.onSiteVisit.guid + '/facility-setup');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ export class FacilitySetupComponent implements OnInit {
canDeactivate(): Observable<boolean> {
if (this.name && this.name.getError('required')) {
this.name.markAsTouched();
this.dislayWarningModal();
this.displayWarningModal();
return of(false);
}
return of(true);
}

dislayWarningModal() {
displayWarningModal() {
this.routeGuardWarningModal = true;
}
closeWarningModal() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ export class CompanyContactsFormComponent {
this.contactForm.controls['lastname'].invalid
) {
this.contactForm.markAllAsTouched();
this.dislayWarningModal();
this.displayWarningModal();
return of(false);
}
return of(true);
}

dislayWarningModal() {
displayWarningModal() {
this.routeGuardWarningModal = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ export class FacilitySettingsComponent {

canDeactivate(): Observable<boolean> {
if (this.name && this.name.getError('required')) {
this.dislayWarningModal();
this.displayWarningModal();
return of(false);
}
return of(true);
}

dislayWarningModal() {
displayWarningModal() {
this.routeGuardWarningModal = true;
}
closeWarningModal() {
Expand Down

0 comments on commit b3f5714

Please sign in to comment.