Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/api/shared/feature-auth/src/lib/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class AuthService {
const tokens = await this.createTokens(user);
await this.updateRefreshTokenHash(user, tokens.refreshToken);
const partialUser: UserEntity = { ...user };
partialUser.id = null;
partialUser.password = null;
partialUser.refreshToken = null;
const result = new AuthDto(partialUser, tokens.accessToken, tokens.refreshToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import {
selectProjStatusUpdated,
updateProjStatus,
} from '@tempus/client/onboarding-client/business-owner/data-access';
import { Column, ViewProjects, ButtonType } from '@tempus/client/shared/ui-components/presentational';
import { take, Subject, takeUntil, finalize, skip } from 'rxjs';
import { CustomModalType, ModalService, ModalType } from '@tempus/client/shared/ui-components/modal';
import { FormBuilder, Validators } from '@angular/forms';
import { ErorType, ProjectStatus, RoleType } from '@tempus/shared-domain';
import {
AsyncRequestState,
OnboardingClientState,
selectLoggedInUserNameEmail,
} from '@tempus/client/onboarding-client/shared/data-access';
import { Column, ViewProjects, ButtonType } from '@tempus/client/shared/ui-components/presentational';
import { take, Subject, takeUntil, finalize, skip } from 'rxjs';
import { CustomModalType, ModalService, ModalType } from '@tempus/client/shared/ui-components/modal';
import { FormBuilder, Validators } from '@angular/forms';
import { ErorType, ProjectStatus, RoleType } from '@tempus/shared-domain';
import { isValidRole } from '@tempus/client/shared/util';

@Component({
Expand Down Expand Up @@ -192,6 +192,7 @@ export class ViewProjectsComponent implements OnInit {
});
}

// eslint-disable-next-line @typescript-eslint/member-ordering
isValidRole = isValidRole;

openErrorModal = (errorMessage: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { TranslateService } from '@ngx-translate/core';
import { OnboardingClientResourceService } from '@tempus/client/onboarding-client/shared/data-access';
import {
createResourceView,
getAllViewsByResourceId,
OnboardingClientResourceService,
OnboardingClientState,
selectResourceViews,
selectView,
} from '@tempus/client/onboarding-client/shared/data-access';
import { EditViewFormComponent } from '@tempus/onboarding-client/shared/feature-edit-view-form';
import { RevisionType, ViewType } from '@tempus/shared-domain';
import { take } from 'rxjs';
import { Subject, takeUntil } from 'rxjs';

@Component({
selector: 'tempus-business-owner-create-new-view',
Expand All @@ -17,6 +25,7 @@ export class BusinessOwnerCreateNewViewComponent implements OnInit {
private router: Router,
private route: ActivatedRoute,
private resourceService: OnboardingClientResourceService,
private sharedStore: Store<OnboardingClientState>,
private translateService: TranslateService,
) {
const { currentLang } = translateService;
Expand All @@ -29,17 +38,30 @@ export class BusinessOwnerCreateNewViewComponent implements OnInit {

resourceId = 0;

destroyed$ = new Subject<void>();

ngOnInit(): void {
this.resourceId = parseInt(this.route.snapshot.paramMap.get('id') || '0', 10);

// New view form loaded with latest approved Primary view
this.resourceService.getResourceProfileViews(this.resourceId).subscribe(data => {
const filteredViews = data.views.filter(
view => view.viewType === ViewType.PRIMARY && view.revisionType === RevisionType.APPROVED,
);
this.newViewForm.setFormDataFromView(filteredViews[0]);
this.newViewForm.enableViewNameField();
});
this.sharedStore.dispatch(getAllViewsByResourceId({ resourceId: this.resourceId, pageNum: 0, pageSize: 1000 }));
this.sharedStore
.select(selectResourceViews)
.pipe(takeUntil(this.destroyed$))
.subscribe(data => {
const filteredViews = data.views.filter(
view => view.viewType === ViewType.PRIMARY && view.revisionType === RevisionType.APPROVED,
);
this.newViewForm.setFormDataFromView(filteredViews[0]);
this.newViewForm.enableViewNameField();
});
// this.resourceService.getResourceProfileViews(this.resourceId).subscribe(data => {
// const filteredViews = data.views.filter(
// view => view.viewType === ViewType.PRIMARY && view.revisionType === RevisionType.APPROVED,
// );
// this.newViewForm.setFormDataFromView(filteredViews[0]);
// this.newViewForm.enableViewNameField();
// });
}

submitChanges() {
Expand All @@ -50,15 +72,25 @@ export class BusinessOwnerCreateNewViewComponent implements OnInit {

createNewView() {
const newView = this.newViewForm.generateNewView();
this.resourceService
.createSecondaryView(this.resourceId, newView)
.pipe(take(1))
.subscribe(view => {
this.sharedStore.dispatch(createResourceView({ resourceId: this.resourceId, newView }));
this.sharedStore
.select(selectView)
.pipe(takeUntil(this.destroyed$))
.subscribe(resourceView => {
this.router.navigate(['../'], {
queryParams: { viewId: view.id },
queryParams: { viewId: resourceView?.id },
relativeTo: this.route,
});
});
// this.resourceService
// .createSecondaryView(this.resourceId, newView)
// .pipe(take(1))
// .subscribe(view => {
// this.router.navigate(['../'], {
// queryParams: { viewId: view.id },
// relativeTo: this.route,
// });
// });
}

closeForm() {
Expand Down
Loading