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

wfprev-143 Edit project: UI #359

Merged
merged 8 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class AppComponent {
) {
}


setActive(menuItem: string): void {
this.activeRoute = menuItem;
switch (menuItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('App Routing Module', () => {

it('should have correct routes defined', () => {
const routes = router.config;
expect(routes.length).toBe(4);
expect(routes.length).toBe(6);
});

it('should define route for LIST path', () => {
Expand Down
6 changes: 6 additions & 0 deletions client/wfprev-war/src/main/angular/src/app/app.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ const PANEL_ROUTES: Routes = [
component: ErrorPageComponent,
pathMatch: 'full',
},
{
path: ResourcesRoutes.EDIT_PROJECT,
loadChildren: () =>
yzlucas marked this conversation as resolved.
Show resolved Hide resolved
import('src/app/components/edit-project.module').then(m => m.EditProjectModule),
},
{ path: '', redirectTo: ResourcesRoutes.MAP, pathMatch: 'full' }, // Default route to map
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the authentication check canActivate: [PrevAuthGuard] like the list and map pages above


{ path: '',
redirectTo: ResourcesRoutes.MAP,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { EditProjectComponent } from 'src/app/components/edit-project/edit-project.component';


const routes: Routes = [
{ path: '', component: EditProjectComponent }
];

@NgModule({
imports: [RouterModule.forChild(routes), EditProjectComponent]
})
export class EditProjectModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div>
<div class="project-title">
<span>{{projectName}}</span>
</div>
<mat-tab-group class="custom-tab-group">
<!-- Details Tab -->
<mat-tab label="Details">
<div class="details-tab">
<app-project-details></app-project-details>
</div>
</mat-tab>

<!-- Fiscals Tab -->
<mat-tab label="Fiscals">
<div class="fiscals-tab">
<p>Fiscals Section</p>
</div>
</mat-tab>

<!-- Documents Tab -->
<mat-tab label="Documents">
<div class="documents-tab">
<p>Documents Section</p>
</div>
</mat-tab>

<!-- History Tab -->
<mat-tab label="History">
<div class="history-tab">
<p>History Section</p>
</div>
</mat-tab>
</mat-tab-group>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.project-title {
color: #000;
font-size: 34px;
font-style: normal;
font-weight: 400;
line-height: normal;
padding: 12px 24px;
}

.custom-tab-group {
display: flex;
justify-content: flex-start;

// Angular Material tab header overrides
::ng-deep {
.mat-mdc-tab-header {
width: 50%;
padding-left: 30px;
}

.mat-mdc-tab {
font-size: 22px;
color: #000;
font-style: normal;
font-weight: 400;
}

.mat-mdc-tab-indicator {
background-color: black !important; /* Change the underline color to black */
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { EditProjectComponent } from './edit-project.component';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { of } from 'rxjs';
import { By } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ProjectDetailsComponent } from 'src/app/components/edit-project/project-details/project-details.component';

describe('EditProjectComponent', () => {
let component: EditProjectComponent;
let fixture: ComponentFixture<EditProjectComponent>;
let mockActivatedRoute: Partial<ActivatedRoute>;

beforeEach(async () => {
const mockParamMap: ParamMap = {
has: (key: string) => key === 'name',
get: (key: string) => (key === 'name' ? 'Test Project' : null),
getAll: () => [],
keys: [],
};

mockActivatedRoute = {
queryParamMap: of(mockParamMap),
};

await TestBed.configureTestingModule({
imports: [EditProjectComponent, BrowserAnimationsModule],
providers: [{ provide: ActivatedRoute, useValue: mockActivatedRoute }],
}).compileComponents();

fixture = TestBed.createComponent(EditProjectComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});

it('should set the projectName from query parameters', () => {
expect(component.projectName).toBe('Test Project');
});

it('should display the project name in the title', () => {
const projectTitleElement = fixture.debugElement.query(By.css('.project-title span')).nativeElement;
expect(projectTitleElement.textContent).toContain('Test Project');
});

it('should render the Details tab', () => {
const detailsTab = fixture.debugElement.query(By.css('.details-tab'));
expect(detailsTab).toBeTruthy();
});

it('should display ProjectDetailsComponent inside the Details tab', () => {
const projectDetailsComponent = fixture.debugElement.query(By.directive(ProjectDetailsComponent));
expect(projectDetailsComponent).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { moduleMetadata, type Meta, type StoryObj } from '@storybook/angular';
import { EditProjectComponent } from './edit-project.component';
import { MatTabsModule } from '@angular/material/tabs';
import { ProjectDetailsComponent } from 'src/app/components/edit-project/project-details/project-details.component';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

const meta: Meta<EditProjectComponent> = {
title: 'EditProjectComponent',
component: EditProjectComponent,
tags: ['autodocs'],
decorators: [
moduleMetadata({
imports: [EditProjectComponent, MatTabsModule, ProjectDetailsComponent,BrowserAnimationsModule ],
providers: [
{
provide: ActivatedRoute,
useValue: {
queryParamMap: of({
get: (key: string) => (key === 'name' ? 'Sample Project' : null),
}),
},
},
],
}),
],
};

export default meta;
type Story = StoryObj<EditProjectComponent>;

export const Default: Story = {
args: {},
};

export const WithCustomProjectName: Story = {
decorators: [
moduleMetadata({
providers: [
{
provide: ActivatedRoute,
useValue: {
queryParamMap: of({
get: (key: string) => (key === 'name' ? 'Custom Project' : null),
}),
},
},
],
}),
],
args: {},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Component, OnInit } from '@angular/core';
import { MatTabsModule } from '@angular/material/tabs';
import { ActivatedRoute } from '@angular/router';
import { ProjectDetailsComponent } from 'src/app/components/edit-project/project-details/project-details.component';

@Component({
selector: 'app-edit-project',
standalone: true,
imports: [MatTabsModule, ProjectDetailsComponent],
templateUrl: './edit-project.component.html',
styleUrl: './edit-project.component.scss'
})
export class EditProjectComponent implements OnInit {
projectName: string | null = null;

constructor(private route: ActivatedRoute) {}
ngOnInit(): void {
this.route.queryParamMap.subscribe((params) => {
this.projectName = params.get('name');
});
}

}
Loading
Loading