diff --git a/src/app/core/mock-data/recently-used.data.ts b/src/app/core/mock-data/recently-used.data.ts index 680adf7925..e2dc285f5e 100644 --- a/src/app/core/mock-data/recently-used.data.ts +++ b/src/app/core/mock-data/recently-used.data.ts @@ -1,5 +1,5 @@ import { RecentlyUsed } from '../models/v1/recently_used.model'; -import { ExtendedProject } from '../models/v2/extended-project.model'; +import { ProjectV2 } from '../models/v2/project-v2.model'; import { Currency, CurrencyName } from '../models/currency.model'; import { CostCenter } from '../models/v1/cost-center.model'; @@ -26,7 +26,7 @@ export const recentlyUsedRes: RecentlyUsed = { ], }; -export const recentlyUsedProjectRes: ExtendedProject[] = [ +export const recentlyUsedProjectRes: ProjectV2[] = [ { ap1_email: 'john.d@fyle.in', ap1_full_name: 'John Doe', diff --git a/src/app/core/models/add-edit-advance-request-form-value.model.ts b/src/app/core/models/add-edit-advance-request-form-value.model.ts index 7965c18cb4..b753655718 100644 --- a/src/app/core/models/add-edit-advance-request-form-value.model.ts +++ b/src/app/core/models/add-edit-advance-request-form-value.model.ts @@ -1,11 +1,11 @@ import { AdvanceRequestCustomFieldValues } from './advance-request-custom-field-values.model'; import { CurrencyObj } from './currency-obj.model'; -import { ExtendedProject } from './v2/extended-project.model'; +import { ProjectV2 } from './v2/project-v2.model'; export interface AddEditAdvanceRequestFormValue { currencyObj: CurrencyObj; purpose: string; notes: string; - project: ExtendedProject; + project: ProjectV2; customFieldValues: AdvanceRequestCustomFieldValues[]; } diff --git a/src/app/core/models/mileage-form-value.model.ts b/src/app/core/models/mileage-form-value.model.ts index 051648b3f8..012fece259 100644 --- a/src/app/core/models/mileage-form-value.model.ts +++ b/src/app/core/models/mileage-form-value.model.ts @@ -5,7 +5,7 @@ import { PlatformMileageRates } from './platform/platform-mileage-rates.model'; import { TxnCustomProperties } from './txn-custom-properties.model'; import { CostCenter } from './v1/cost-center.model'; import { OrgCategory } from './v1/org-category.model'; -import { ExtendedProject } from './v2/extended-project.model'; +import { ProjectV2 } from './v2/project-v2.model'; import { Report } from '../models/platform/v1/report.model'; export interface MileageFormValue { @@ -22,7 +22,7 @@ export interface MileageFormValue { mileage_rate_name: PlatformMileageRates; vehicle_type: string; dateOfSpend: Date; - project: ExtendedProject; + project: ProjectV2; costCenter: CostCenter; billable: boolean; purpose: string; diff --git a/src/app/core/models/per-diem-form-value.model.ts b/src/app/core/models/per-diem-form-value.model.ts index 7a259de850..e5237df121 100644 --- a/src/app/core/models/per-diem-form-value.model.ts +++ b/src/app/core/models/per-diem-form-value.model.ts @@ -5,7 +5,7 @@ import { TxnCustomProperties } from './txn-custom-properties.model'; import { CostCenter } from './v1/cost-center.model'; import { OrgCategory } from './v1/org-category.model'; import { PerDiemRates } from './v1/per-diem-rates.model'; -import { ExtendedProject } from './v2/extended-project.model'; +import { ProjectV2 } from './v2/project-v2.model'; export interface PerDiemFormValue { currencyObj: { @@ -15,7 +15,7 @@ export interface PerDiemFormValue { orig_amount: number; }; paymentMode: ExtendedAccount; - project: ExtendedProject; + project: ProjectV2; sub_category: OrgCategory; purpose: string; num_days: number; diff --git a/src/app/core/models/project-options.model.ts b/src/app/core/models/project-options.model.ts index 9454456cf7..482061a07f 100644 --- a/src/app/core/models/project-options.model.ts +++ b/src/app/core/models/project-options.model.ts @@ -1,7 +1,7 @@ -import { ExtendedProject } from './v2/extended-project.model'; +import { ProjectV2 } from './v2/project-v2.model'; export interface ProjectOption { label: string; - value: ExtendedProject; + value: ProjectV2; selected?: boolean; } diff --git a/src/app/core/models/split-expense.model.ts b/src/app/core/models/split-expense.model.ts index 8506633b59..4d4a3a624d 100644 --- a/src/app/core/models/split-expense.model.ts +++ b/src/app/core/models/split-expense.model.ts @@ -1,4 +1,4 @@ -import { ExtendedProject } from './v2/extended-project.model'; +import { ProjectV2 } from './v2/project-v2.model'; export interface SplitExpense { amount: number; @@ -17,7 +17,7 @@ export interface SplitExpense { sub_category: string; updated_at: string; }; - project?: ExtendedProject; + project?: ProjectV2; cost_center?: { id: number; created_at: string; diff --git a/src/app/core/models/v2/extended-project.model.ts b/src/app/core/models/v2/project-v2.model.ts similarity index 93% rename from src/app/core/models/v2/extended-project.model.ts rename to src/app/core/models/v2/project-v2.model.ts index 7699011f81..59edb030b5 100644 --- a/src/app/core/models/v2/extended-project.model.ts +++ b/src/app/core/models/v2/project-v2.model.ts @@ -1,4 +1,4 @@ -export interface ExtendedProject { +export interface ProjectV2 { ap1_email: string; ap1_full_name: string; ap2_email: string; diff --git a/src/app/core/services/projects.service.ts b/src/app/core/services/projects.service.ts index 50bcb6c35d..7b4b8d7081 100644 --- a/src/app/core/services/projects.service.ts +++ b/src/app/core/services/projects.service.ts @@ -4,7 +4,7 @@ import { ApiV2Service } from './api-v2.service'; import { map } from 'rxjs/operators'; import { Cacheable } from 'ts-cacheable'; import { Observable } from 'rxjs'; -import { ExtendedProject } from '../models/v2/extended-project.model'; +import { ProjectV2 } from '../models/v2/project-v2.model'; import { ProjectV1 } from '../models/v1/extended-project.model'; import { ProjectParams } from '../models/project-params.model'; import { intersection } from 'lodash'; @@ -14,10 +14,7 @@ import { OrgCategory } from '../models/v1/org-category.model'; providedIn: 'root', }) export class ProjectsService { - constructor( - private apiService: ApiService, - private apiV2Service: ApiV2Service, - ) {} + constructor(private apiService: ApiService, private apiV2Service: ApiV2Service) {} @Cacheable() getByParamsUnformatted( @@ -31,8 +28,8 @@ export class ProjectsService { sortOrder: string; sortDirection: string; projectIds: number[]; - }>, - ): Observable { + }> + ): Observable { // eslint-disable-next-line prefer-const let { orgId, active, orgCategoryIds, searchNameText, limit, offset, sortOrder, sortDirection, projectIds } = projectParams; @@ -59,7 +56,7 @@ export class ProjectsService { this.addNameSearchFilter(searchNameText, params); return this.apiV2Service - .get('/projects', { + .get('/projects', { params, }) .pipe( @@ -68,8 +65,8 @@ export class ProjectsService { ...datum, project_created_at: new Date(datum.project_created_at), project_updated_at: new Date(datum.project_updated_at), - })), - ), + })) + ) ); } @@ -86,7 +83,7 @@ export class ProjectsService { } }); return filterdProjects.length; - }), + }) ); } @@ -114,7 +111,7 @@ export class ProjectsService { } } - getAllowedOrgCategoryIds(project: ProjectParams | ExtendedProject, activeCategoryList: OrgCategory[]): OrgCategory[] { + getAllowedOrgCategoryIds(project: ProjectParams | ProjectV2, activeCategoryList: OrgCategory[]): OrgCategory[] { let categoryList: OrgCategory[] = []; if (project) { categoryList = activeCategoryList.filter((category: OrgCategory) => { @@ -142,14 +139,14 @@ export class ProjectsService { ...datum, created_at: new Date(datum.created_at), updated_at: new Date(datum.updated_at), - })), - ), + })) + ) ); } - getbyId(projectId: number | string): Observable { + getbyId(projectId: number | string): Observable { return this.apiV2Service - .get('/projects', { + .get('/projects', { params: { project_id: `eq.${projectId}`, }, @@ -161,8 +158,8 @@ export class ProjectsService { ...datum, project_created_at: new Date(datum.project_created_at), project_updated_at: new Date(datum.project_updated_at), - }))[0], - ), + }))[0] + ) ); } } diff --git a/src/app/core/services/recently-used-items.service.ts b/src/app/core/services/recently-used-items.service.ts index cba229ee82..31521d1ac5 100644 --- a/src/app/core/services/recently-used-items.service.ts +++ b/src/app/core/services/recently-used-items.service.ts @@ -5,7 +5,7 @@ import { RecentlyUsed } from '../models/v1/recently_used.model'; import { ApiService } from './api.service'; import { ProjectsService } from 'src/app/core/services/projects.service'; import { map } from 'rxjs/operators'; -import { ExtendedProject } from '../models/v2/extended-project.model'; +import { ProjectV2 } from '../models/v2/project-v2.model'; import { ExtendedOrgUser } from '../models/extended-org-user.model'; import { OrgCategoryListItem } from '../models/v1/org-category.model'; import { Currency, CurrencyName } from '../models/currency.model'; @@ -13,10 +13,7 @@ import { Currency, CurrencyName } from '../models/currency.model'; providedIn: 'root', }) export class RecentlyUsedItemsService { - constructor( - private apiService: ApiService, - private projectService: ProjectsService, - ) {} + constructor(private apiService: ApiService, private projectService: ProjectsService) {} getRecentlyUsed(): Observable { return this.apiService.get('/recently_used'); @@ -26,7 +23,7 @@ export class RecentlyUsedItemsService { recentValues: RecentlyUsed; eou: ExtendedOrgUser; categoryIds: string[]; - }): Observable { + }): Observable { if ( config.recentValues && config.recentValues.recent_project_ids && @@ -46,12 +43,12 @@ export class RecentlyUsedItemsService { }) .pipe( map((project) => { - const projectsMap: { [key: string]: ExtendedProject } = {}; + const projectsMap: { [key: string]: ProjectV2 } = {}; project.forEach((item) => { projectsMap[item.project_id] = item; }); return config.recentValues.recent_project_ids.map((id) => projectsMap[id]).filter((id) => id); - }), + }) ); } else { return of(null); @@ -60,7 +57,7 @@ export class RecentlyUsedItemsService { getRecentCostCenters( costCenters: CostCenters[], - recentValue: RecentlyUsed, + recentValue: RecentlyUsed ): Observable<{ label: string; value: CostCenter; selected?: boolean }[]> { if ( costCenters && @@ -78,7 +75,7 @@ export class RecentlyUsedItemsService { .filter((id) => id); if (recentCostCenterList.length > 0) { return of( - recentCostCenterList.map((costCenter) => ({ label: costCenter.value.name, value: costCenter.value })), + recentCostCenterList.map((costCenter) => ({ label: costCenter.value.name, value: costCenter.value })) ); } else { return of(null); @@ -90,7 +87,7 @@ export class RecentlyUsedItemsService { getRecentCategories( filteredCategories: OrgCategoryListItem[], - recentValues: RecentlyUsed, + recentValues: RecentlyUsed ): Observable { if ( filteredCategories && diff --git a/src/app/core/test-data/projects.spec.data.ts b/src/app/core/test-data/projects.spec.data.ts index 83c9fd8f96..9237864820 100644 --- a/src/app/core/test-data/projects.spec.data.ts +++ b/src/app/core/test-data/projects.spec.data.ts @@ -1,7 +1,7 @@ import { ProjectParams } from '../models/project-params.model'; import { ProjectV1 } from '../models/v1/extended-project.model'; import { OrgCategory, OrgCategoryListItem } from '../models/v1/org-category.model'; -import { ExtendedProject } from '../models/v2/extended-project.model'; +import { ProjectV2 } from '../models/v2/project-v2.model'; export const apiResponseActiveOnly = [ { @@ -315,7 +315,7 @@ export const allowedActiveCategoriesListOptions: OrgCategoryListItem[] = [ }, ]; -export const expectedProjectsResponse: ExtendedProject[] = [ +export const expectedProjectsResponse: ProjectV2[] = [ { ap1_email: null, ap1_full_name: null, @@ -368,7 +368,7 @@ export const testProjectParams: ProjectParams = { searchNameText: 'search', }; -export const testProjectV2: ExtendedProject = { +export const testProjectV2: ProjectV2 = { ap1_email: null, ap1_full_name: null, ap2_email: null, diff --git a/src/app/fyle/add-edit-expense/add-edit-expense.page.ts b/src/app/fyle/add-edit-expense/add-edit-expense.page.ts index 5e66d78403..fd482e4429 100644 --- a/src/app/fyle/add-edit-expense/add-edit-expense.page.ts +++ b/src/app/fyle/add-edit-expense/add-edit-expense.page.ts @@ -83,7 +83,7 @@ import { OrgCategory, OrgCategoryListItem } from 'src/app/core/models/v1/org-cat import { RecentlyUsed } from 'src/app/core/models/v1/recently_used.model'; import { Transaction } from 'src/app/core/models/v1/transaction.model'; import { DuplicateSet } from 'src/app/core/models/v2/duplicate-sets.model'; -import { ExtendedProject } from 'src/app/core/models/v2/extended-project.model'; +import { ProjectV2 } from 'src/app/core/models/v2/project-v2.model'; import { AccountsService } from 'src/app/core/services/accounts.service'; import { AuthService } from 'src/app/core/services/auth.service'; import { CategoriesService } from 'src/app/core/services/categories.service'; @@ -144,7 +144,7 @@ type FormValue = { orig_amount: number; }; paymentMode: ExtendedAccount; - project: ExtendedProject; + project: ProjectV2; category: OrgCategory; dateOfSpend: Date; vendor_id: { @@ -333,13 +333,13 @@ export class AddEditExpensePage implements OnInit { orgUserSettings$: Observable; - recentProjects: { label: string; value: ExtendedProject; selected?: boolean }[]; + recentProjects: { label: string; value: ProjectV2; selected?: boolean }[]; recentCurrencies: Currency[]; presetProjectId: number | string; - recentlyUsedProjects$: Observable; + recentlyUsedProjects$: Observable; recentlyUsedCurrencies$: Observable; @@ -411,7 +411,7 @@ export class AddEditExpensePage implements OnInit { dependentFields$: Observable; - selectedProject$: BehaviorSubject; + selectedProject$: BehaviorSubject; selectedCostCenter$: BehaviorSubject; @@ -1441,7 +1441,7 @@ export class AddEditExpensePage implements OnInit { ); } - getSelectedProjects(): Observable { + getSelectedProjects(): Observable { return this.etxn$.pipe( switchMap((etxn) => { if (etxn.tx.project_id) { @@ -1544,7 +1544,7 @@ export class AddEditExpensePage implements OnInit { ); } - getRecentProjects(): Observable { + getRecentProjects(): Observable { return forkJoin({ recentValues: this.recentlyUsedValues$, eou: this.authService.getEou(), @@ -2546,7 +2546,7 @@ export class AddEditExpensePage implements OnInit { } }), startWith(initialProject), - concatMap((project: ExtendedProject) => + concatMap((project: ProjectV2) => activeCategories$.pipe( map((activeCategories) => this.projectsService.getAllowedOrgCategoryIds(project, activeCategories)) ) @@ -2715,7 +2715,7 @@ export class AddEditExpensePage implements OnInit { this.onPageExit$ = new Subject(); this.projectDependentFieldsRef?.ngOnInit(); this.costCenterDependentFieldsRef?.ngOnInit(); - this.selectedProject$ = new BehaviorSubject(null); + this.selectedProject$ = new BehaviorSubject(null); this.selectedCostCenter$ = new BehaviorSubject(null); const fn = (): void => { this.showClosePopup(); @@ -2727,7 +2727,7 @@ export class AddEditExpensePage implements OnInit { setupSelectedProjectObservable(): void { this.fg.controls.project.valueChanges .pipe(takeUntil(this.onPageExit$)) - .subscribe((project: ExtendedProject) => this.selectedProject$.next(project)); + .subscribe((project: ProjectV2) => this.selectedProject$.next(project)); } setupSelectedCostCenterObservable(): void { diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts index abede06024..4c5f937feb 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts @@ -63,7 +63,7 @@ import { ExpenseFieldsObj } from 'src/app/core/models/v1/expense-fields-obj.mode import { OrgCategory, OrgCategoryListItem } from 'src/app/core/models/v1/org-category.model'; import { RecentlyUsed } from 'src/app/core/models/v1/recently_used.model'; import { Transaction } from 'src/app/core/models/v1/transaction.model'; -import { ExtendedProject } from 'src/app/core/models/v2/extended-project.model'; +import { ProjectV2 } from 'src/app/core/models/v2/project-v2.model'; import { AccountsService } from 'src/app/core/services/accounts.service'; import { AuthService } from 'src/app/core/services/auth.service'; import { CategoriesService } from 'src/app/core/services/categories.service'; @@ -222,11 +222,11 @@ export class AddEditMileagePage implements OnInit { recent_locations?: string[]; }>; - recentProjects: { label: string; value: ExtendedProject; selected?: boolean }[]; + recentProjects: { label: string; value: ProjectV2; selected?: boolean }[]; presetProjectId: number; - recentlyUsedProjects$: Observable; + recentlyUsedProjects$: Observable; recentCostCenters: { label: string; value: CostCenter; selected?: boolean }[]; @@ -262,7 +262,7 @@ export class AddEditMileagePage implements OnInit { dependentFields$: Observable; - selectedProject$: BehaviorSubject; + selectedProject$: BehaviorSubject; selectedCostCenter$: BehaviorSubject; @@ -464,7 +464,7 @@ export class AddEditMileagePage implements OnInit { } }), startWith(this.fg.controls.project.value), - concatMap((project: ExtendedProject) => + concatMap((project: ProjectV2) => activeCategories$.pipe( map((activeCategories: OrgCategory[]) => this.projectService.getAllowedOrgCategoryIds(project, activeCategories) @@ -968,7 +968,7 @@ export class AddEditMileagePage implements OnInit { this.onPageExit$ = new Subject(); this.projectDependentFieldsRef?.ngOnInit(); this.costCenterDependentFieldsRef?.ngOnInit(); - this.selectedProject$ = new BehaviorSubject(null); + this.selectedProject$ = new BehaviorSubject(null); this.selectedCostCenter$ = new BehaviorSubject(null); const fn = (): void => { this.showClosePopup(); @@ -1064,7 +1064,7 @@ export class AddEditMileagePage implements OnInit { setupSelectedProjects(): void { this.fg.controls.project.valueChanges .pipe(takeUntil(this.onPageExit$)) - .subscribe((project: ExtendedProject) => this.selectedProject$.next(project)); + .subscribe((project: ProjectV2) => this.selectedProject$.next(project)); } setupSelectedCostCenters(): void { @@ -1140,7 +1140,7 @@ export class AddEditMileagePage implements OnInit { ); } - getProjects(): Observable { + getProjects(): Observable { return this.etxn$.pipe( switchMap((etxn) => { if (etxn.tx.project_id) { diff --git a/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts b/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts index 5187cacba4..5e8d6b7e69 100644 --- a/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts +++ b/src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts @@ -62,7 +62,7 @@ import { TrackingService } from '../../core/services/tracking.service'; import { TokenService } from 'src/app/core/services/token.service'; import { RecentlyUsedItemsService } from 'src/app/core/services/recently-used-items.service'; import { RecentlyUsed } from 'src/app/core/models/v1/recently_used.model'; -import { ExtendedProject } from 'src/app/core/models/v2/extended-project.model'; +import { ProjectV2 } from 'src/app/core/models/v2/project-v2.model'; import { CostCenter, CostCenters } from 'src/app/core/models/v1/cost-center.model'; import { ExpenseFieldsService } from 'src/app/core/services/expense-fields.service'; import { ModalPropertiesService } from 'src/app/core/services/modal-properties.service'; @@ -213,9 +213,9 @@ export class AddEditPerDiemPage implements OnInit { recentlyUsedValues$: Observable; - recentProjects: { label: string; value: ExtendedProject; selected?: boolean }[]; + recentProjects: { label: string; value: ProjectV2; selected?: boolean }[]; - recentlyUsedProjects$: Observable; + recentlyUsedProjects$: Observable; presetProjectId: number; @@ -243,7 +243,7 @@ export class AddEditPerDiemPage implements OnInit { dependentFields$: Observable; - selectedProject$: BehaviorSubject; + selectedProject$: BehaviorSubject; selectedCostCenter$: BehaviorSubject; @@ -687,7 +687,7 @@ export class AddEditPerDiemPage implements OnInit { } }), startWith(this.fg.controls.project.value), - concatMap((project: ExtendedProject) => + concatMap((project: ProjectV2) => activeCategories$.pipe( map((activeCategories) => this.projectService.getAllowedOrgCategoryIds(project, activeCategories)) ) @@ -846,7 +846,7 @@ export class AddEditPerDiemPage implements OnInit { this.onPageExit$ = new Subject(); this.projectDependentFieldsRef?.ngOnInit(); this.costCenterDependentFieldsRef?.ngOnInit(); - this.selectedProject$ = new BehaviorSubject(null); + this.selectedProject$ = new BehaviorSubject(null); this.selectedCostCenter$ = new BehaviorSubject(null); this.hardwareBackButtonAction = this.platform.backButton.subscribeWithPriority( @@ -902,7 +902,7 @@ export class AddEditPerDiemPage implements OnInit { this.fg.controls.project.valueChanges .pipe(takeUntil(this.onPageExit$)) - .subscribe((project: ExtendedProject) => this.selectedProject$.next(project)); + .subscribe((project: ProjectV2) => this.selectedProject$.next(project)); this.fg.controls.costCenter.valueChanges .pipe(takeUntil(this.onPageExit$)) diff --git a/src/app/fyle/split-expense/split-expense.page.ts b/src/app/fyle/split-expense/split-expense.page.ts index b8eae52ece..c06e585050 100644 --- a/src/app/fyle/split-expense/split-expense.page.ts +++ b/src/app/fyle/split-expense/split-expense.page.ts @@ -38,7 +38,7 @@ import { SplitExpense } from 'src/app/core/models/split-expense.model'; import { CurrencyObj } from 'src/app/core/models/currency-obj.model'; import { SplitExpenseForm } from 'src/app/core/models/split-expense-form.model'; import { ToastType } from 'src/app/core/enums/toast-type.enum'; -import { ExtendedProject } from 'src/app/core/models/v2/extended-project.model'; +import { ProjectV2 } from 'src/app/core/models/v2/project-v2.model'; import { ExpenseField } from 'src/app/core/models/v1/expense-field.model'; import { SplitExpensePolicy } from 'src/app/core/models/platform/v1/split-expense-policy.model'; import { SplitExpenseMissingFields } from 'src/app/core/models/platform/v1/split-expense-missing-fields.model'; @@ -105,7 +105,7 @@ export class SplitExpensePage { dependentCustomProperties$: Observable[]>; - selectedProject: ExtendedProject; + selectedProject: ProjectV2; expenseFields: ExpenseField[]; @@ -373,7 +373,7 @@ export class SplitExpensePage { setSplitExpenseProjectHelper( splitFormValue: SplitExpense, splitTxn: Transaction, - project: ExtendedProject, + project: ProjectV2, costCenter: ExpenseField ): void { if (splitFormValue.project?.project_id) { @@ -410,7 +410,7 @@ export class SplitExpensePage { setCategoryAndProjectHelper( splitFormValue: SplitExpense, splitTxn: Transaction, - project: ExtendedProject, + project: ProjectV2, costCenter: ExpenseField ): void { splitTxn.cost_center_id = splitFormValue.cost_center?.id || this.transaction.cost_center_id; @@ -437,7 +437,7 @@ export class SplitExpensePage { this.transaction.project_id ) { //if split_expense or source txn has projectIds, call the method to get project and push to promises - let project: ExtendedProject; + let project: ProjectV2; if (splitFormValue.project) { project = splitFormValue.project; } else { @@ -831,7 +831,7 @@ export class SplitExpensePage { ) as MatchedCCCTransaction; this.reportId = JSON.parse(this.activatedRoute.snapshot.params.selectedReportId as string) as string; this.transaction = JSON.parse(this.activatedRoute.snapshot.params.txn as string) as Transaction; - this.selectedProject = JSON.parse(this.activatedRoute.snapshot.params.selectedProject as string) as ExtendedProject; + this.selectedProject = JSON.parse(this.activatedRoute.snapshot.params.selectedProject as string) as ProjectV2; this.expenseFields = JSON.parse(this.activatedRoute.snapshot.params.expenseFields as string) as ExpenseField[]; // Set max and min date for form diff --git a/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.ts b/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.ts index 09453e47bb..857130e502 100644 --- a/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.ts +++ b/src/app/shared/components/fy-select-project/fy-select-modal/fy-select-project-modal.component.ts @@ -6,7 +6,7 @@ import { isEqual } from 'lodash'; import { ProjectsService } from 'src/app/core/services/projects.service'; import { AuthService } from 'src/app/core/services/auth.service'; import { RecentLocalStorageItemsService } from 'src/app/core/services/recent-local-storage-items.service'; -import { ExtendedProject } from 'src/app/core/models/v2/extended-project.model'; +import { ProjectV2 } from 'src/app/core/models/v2/project-v2.model'; import { UtilityService } from 'src/app/core/services/utility.service'; import { OrgSettingsService } from 'src/app/core/services/org-settings.service'; import { OrgUserSettingsService } from 'src/app/core/services/org-user-settings.service'; @@ -21,7 +21,7 @@ import { ProjectOption } from 'src/app/core/models/project-options.model'; export class FyProjectSelectModalComponent implements AfterViewInit { @ViewChild('searchBar') searchBarRef: ElementRef; - @Input() currentSelection: ExtendedProject; + @Input() currentSelection: ProjectV2; @Input() filteredOptions$: Observable; @@ -145,7 +145,7 @@ export class FyProjectSelectModalComponent implements AfterViewInit { searchInput.dispatchEvent(new Event('keyup')); } - getRecentlyUsedItems(): Observable { + getRecentlyUsedItems(): Observable { if (this.recentlyUsed) { return of(this.recentlyUsed); } else { @@ -167,7 +167,7 @@ export class FyProjectSelectModalComponent implements AfterViewInit { distinctUntilChanged(), switchMap((searchText: string) => this.getProjects(searchText)), map((projects) => - projects.map((project: { label: string; value: ExtendedProject; selected?: boolean }) => { + projects.map((project: { label: string; value: ProjectV2; selected?: boolean }) => { if (isEqual(project.value, this.currentSelection)) { project.selected = true; } diff --git a/src/app/shared/components/fy-select-project/fy-select-project.component.ts b/src/app/shared/components/fy-select-project/fy-select-project.component.ts index 89995e3306..c9f16d19e2 100644 --- a/src/app/shared/components/fy-select-project/fy-select-project.component.ts +++ b/src/app/shared/components/fy-select-project/fy-select-project.component.ts @@ -3,7 +3,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { noop } from 'rxjs'; import { ModalController } from '@ionic/angular'; import { FyProjectSelectModalComponent } from './fy-select-modal/fy-select-project-modal.component'; -import { ExtendedProject } from 'src/app/core/models/v2/extended-project.model'; +import { ProjectV2 } from 'src/app/core/models/v2/project-v2.model'; import { ModalPropertiesService } from 'src/app/core/services/modal-properties.service'; import { ProjectOption } from 'src/app/core/models/project-options.model'; @@ -42,11 +42,11 @@ export class FySelectProjectComponent implements ControlValueAccessor, OnDestroy displayValue: string; - innerValue: ExtendedProject; + innerValue: ProjectV2; onTouchedCallback: () => void = noop; - onChangeCallback: (value: ExtendedProject) => void = noop; + onChangeCallback: (value: ProjectV2) => void = noop; constructor(private modalController: ModalController, private modalProperties: ModalPropertiesService) {} @@ -58,11 +58,11 @@ export class FySelectProjectComponent implements ControlValueAccessor, OnDestroy } } - get value(): ExtendedProject { + get value(): ProjectV2 { return this.innerValue; } - set value(v: ExtendedProject) { + set value(v: ProjectV2) { if (v !== this.innerValue) { this.innerValue = v; const selectedOption = this.innerValue; @@ -109,7 +109,7 @@ export class FySelectProjectComponent implements ControlValueAccessor, OnDestroy this.onTouchedCallback(); } - writeValue(value: ExtendedProject): void { + writeValue(value: ProjectV2): void { if (value !== this.innerValue) { this.innerValue = value; const selectedOption = this.innerValue; @@ -121,7 +121,7 @@ export class FySelectProjectComponent implements ControlValueAccessor, OnDestroy } } - registerOnChange(fn: (newValue: ExtendedProject) => void): void { + registerOnChange(fn: (newValue: ProjectV2) => void): void { this.onChangeCallback = fn; }