-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: edit org personnel and tacticals
- Loading branch information
Showing
22 changed files
with
335 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,3 @@ button[mat-mini-fab] { | |
mat-card { | ||
max-width: 500px; | ||
} | ||
|
||
table.personnel { | ||
margin-bottom: 2em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
web/src/app/org-detail/personnel-edit/personnel-edit-row/personnel-edit-row.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div class="personEditRow" [formGroup]="form"> | ||
<mat-form-field> | ||
<mat-label>Title</mat-label> | ||
<input matInput formControlName="title" /> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Name</mat-label> | ||
<input matInput formControlName="name" /> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Callsign</mat-label> | ||
<input matInput formControlName="callsign" /> | ||
</mat-form-field> | ||
<button mat-icon-button (click)="delete.emit(index)"> | ||
<mat-icon>delete</mat-icon> | ||
</button> | ||
</div> |
7 changes: 7 additions & 0 deletions
7
web/src/app/org-detail/personnel-edit/personnel-edit-row/personnel-edit-row.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.personEditRow { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
mat-form-field { | ||
margin-right: 5px; | ||
} |
22 changes: 22 additions & 0 deletions
22
...src/app/org-detail/personnel-edit/personnel-edit-row/personnel-edit-row.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PersonnelEditRowComponent } from './personnel-edit-row.component'; | ||
|
||
describe('PersonnelEditRowComponent', () => { | ||
let component: PersonnelEditRowComponent; | ||
let fixture: ComponentFixture<PersonnelEditRowComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [PersonnelEditRowComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PersonnelEditRowComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
web/src/app/org-detail/personnel-edit/personnel-edit-row/personnel-edit-row.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { FormGroup, ReactiveFormsModule } from '@angular/forms'; | ||
import { MatFormFieldModule } from '@angular/material/form-field'; | ||
import { MatIcon } from '@angular/material/icon'; | ||
import { MatInputModule } from '@angular/material/input'; | ||
|
||
import { Personnel } from '../../../datatypes/organization'; | ||
|
||
@Component({ | ||
selector: 'app-personnel-edit-row', | ||
standalone: true, | ||
imports: [MatFormFieldModule, MatInputModule, ReactiveFormsModule, MatIcon], | ||
templateUrl: './personnel-edit-row.component.html', | ||
styleUrl: './personnel-edit-row.component.scss', | ||
}) | ||
export class PersonnelEditRowComponent { | ||
@Input({ required: true }) form!: FormGroup; | ||
@Input({ required: true }) index!: number; | ||
@Output() delete = new EventEmitter<number>(); | ||
} |
10 changes: 10 additions & 0 deletions
10
web/src/app/org-detail/personnel-edit/personnel-edit.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@for (form of formArray.controls; track form; let i = $index) { | ||
<app-personnel-edit-row | ||
[form]="form" | ||
[index]="i" | ||
(delete)="deleteRow($event)" | ||
/> | ||
} | ||
<button mat-icon-button (click)="addRow()"> | ||
<mat-icon>add</mat-icon> | ||
</button> |
Empty file.
21 changes: 21 additions & 0 deletions
21
web/src/app/org-detail/personnel-edit/personnel-edit.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PersonnelEditComponent } from './personnel-edit.component'; | ||
|
||
describe('PersonnelEditComponent', () => { | ||
let component: PersonnelEditComponent; | ||
let fixture: ComponentFixture<PersonnelEditComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [PersonnelEditComponent], | ||
}); | ||
fixture = TestBed.createComponent(PersonnelEditComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
46 changes: 46 additions & 0 deletions
46
web/src/app/org-detail/personnel-edit/personnel-edit.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Component, Input, inject } from '@angular/core'; | ||
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms'; | ||
import { MatIcon } from '@angular/material/icon'; | ||
|
||
import { Personnel } from '../../datatypes/organization'; | ||
import { PersonnelEditRowComponent } from './personnel-edit-row/personnel-edit-row.component'; | ||
|
||
@Component({ | ||
selector: 'app-personnel-edit', | ||
templateUrl: './personnel-edit.component.html', | ||
styleUrls: ['./personnel-edit.component.scss'], | ||
standalone: true, | ||
imports: [ReactiveFormsModule, PersonnelEditRowComponent, MatIcon], | ||
}) | ||
export class PersonnelEditComponent { | ||
private formBuilder = inject(FormBuilder); | ||
formArray = this.formBuilder.array([ | ||
// Add an empty row at the end | ||
this.buildFormGroup({} as Personnel), | ||
]); | ||
|
||
@Input() set personnel(personnel: Personnel[]) { | ||
this.formArray.clear(); | ||
personnel.forEach((p) => this.formArray.push(this.buildFormGroup(p))); | ||
} | ||
|
||
private buildFormGroup(person: Personnel): FormGroup { | ||
return this.formBuilder.group({ | ||
title: [person.title || ''], | ||
name: [person.name || ''], | ||
callsign: [person.callsign || ''], | ||
}); | ||
} | ||
|
||
addRow() { | ||
this.formArray.push(this.buildFormGroup({} as Personnel)); | ||
} | ||
|
||
deleteRow(index: number) { | ||
this.formArray.removeAt(index); | ||
} | ||
|
||
getFormValues(): Personnel[] { | ||
return this.formArray.value; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
web/src/app/org-detail/personnel-view/personnel-view.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
web/src/app/org-detail/tactical-edit/tactical-edit-row/tactical-edit-row.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<div class="tacticalEditRow" [formGroup]="form"> | ||
<mat-form-field> | ||
<mat-label>Title</mat-label> | ||
<input matInput formControlName="title" /> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Callsign</mat-label> | ||
<input matInput formControlName="callsign" /> | ||
</mat-form-field> | ||
<button mat-icon-button (click)="delete.emit(index)"> | ||
<mat-icon>delete</mat-icon> | ||
</button> | ||
</div> |
7 changes: 7 additions & 0 deletions
7
web/src/app/org-detail/tactical-edit/tactical-edit-row/tactical-edit-row.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.tacticalEditRow { | ||
display: flex; | ||
flex-direction: row; | ||
} | ||
mat-form-field { | ||
margin-right: 5px; | ||
} |
23 changes: 23 additions & 0 deletions
23
web/src/app/org-detail/tactical-edit/tactical-edit-row/tactical-edit-row.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TacticalEditRowComponent } from './tactical-edit-row.component'; | ||
|
||
describe('TacticalEditRowComponent', () => { | ||
let component: TacticalEditRowComponent; | ||
let fixture: ComponentFixture<TacticalEditRowComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [TacticalEditRowComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(TacticalEditRowComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
web/src/app/org-detail/tactical-edit/tactical-edit-row/tactical-edit-row.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Component, EventEmitter, Input, Output } from '@angular/core'; | ||
import { FormGroup, ReactiveFormsModule } from '@angular/forms'; | ||
import { MatFormFieldModule } from '@angular/material/form-field'; | ||
import { MatIcon } from '@angular/material/icon'; | ||
import { MatInputModule } from '@angular/material/input'; | ||
|
||
@Component({ | ||
selector: 'app-tactical-edit-row', | ||
standalone: true, | ||
imports: [MatFormFieldModule, MatInputModule, ReactiveFormsModule, MatIcon], | ||
templateUrl: './tactical-edit-row.component.html', | ||
styleUrl: './tactical-edit-row.component.scss', | ||
}) | ||
export class TacticalEditRowComponent { | ||
@Input({ required: true }) form!: FormGroup; | ||
@Input({ required: true }) index!: number; | ||
@Output() delete = new EventEmitter<number>(); | ||
} |
10 changes: 10 additions & 0 deletions
10
web/src/app/org-detail/tactical-edit/tactical-edit.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@for (form of formArray.controls; track form; let i = $index) { | ||
<app-personnel-edit-row | ||
[form]="form" | ||
[index]="i" | ||
(delete)="deleteRow($event)" | ||
/> | ||
} | ||
<button mat-icon-button (click)="addRow()"> | ||
<mat-icon>add</mat-icon> | ||
</button> |
3 changes: 3 additions & 0 deletions
3
web/src/app/org-detail/tactical-edit/tactical-edit.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mat-form-field { | ||
margin-right: 5px; | ||
} |
21 changes: 21 additions & 0 deletions
21
web/src/app/org-detail/tactical-edit/tactical-edit.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { TacticalEditComponent } from './tactical-edit.component'; | ||
|
||
describe('TacticalEditComponent', () => { | ||
let component: TacticalEditComponent; | ||
let fixture: ComponentFixture<TacticalEditComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [TacticalEditComponent], | ||
}); | ||
fixture = TestBed.createComponent(TacticalEditComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.