-
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
18 changed files
with
257 additions
and
10 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
20 changes: 20 additions & 0 deletions
20
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,20 @@ | ||
<div class="personEditRow" [formGroup]="form"> | ||
<div> | ||
<mat-form-field> | ||
<mat-label>Title</mat-label> | ||
<input matInput [formControlName]="person.title" /> | ||
</mat-form-field> | ||
</div> | ||
<div> | ||
<mat-form-field> | ||
<mat-label>Name</mat-label> | ||
<input matInput [formControlName]="person.name" /> | ||
</mat-form-field> | ||
</div> | ||
<div> | ||
<mat-form-field> | ||
<mat-label>Callsign</mat-label> | ||
<input matInput [formControlName]="person.callsign" /> | ||
</mat-form-field> | ||
</div> | ||
</div> |
4 changes: 4 additions & 0 deletions
4
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,4 @@ | ||
.personEditRow { | ||
display: flex; | ||
flex-direction: row; | ||
} |
23 changes: 23 additions & 0 deletions
23
...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,23 @@ | ||
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(); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
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,22 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { FormGroup, ReactiveFormsModule } from '@angular/forms'; | ||
import { Personnel } from '../../../datatypes/organization'; | ||
import { MatFormFieldModule } from '@angular/material/form-field'; | ||
import { MatInputModule } from '@angular/material/input'; | ||
|
||
@Component({ | ||
selector: 'app-personnel-edit-row', | ||
standalone: true, | ||
imports: [ | ||
MatFormFieldModule, | ||
MatInputModule, | ||
ReactiveFormsModule | ||
], | ||
templateUrl: './personnel-edit-row.component.html', | ||
styleUrl: './personnel-edit-row.component.scss' | ||
}) | ||
export class PersonnelEditRowComponent { | ||
@Input() person!: Personnel; | ||
@Input() index!: number; | ||
@Input() form!: FormGroup; | ||
} |
5 changes: 5 additions & 0 deletions
5
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,5 @@ | ||
<div [formGroup]="personnelForm"> | ||
<div *ngFor="let person of personnelArray.value; let i=index"> | ||
<app-personnel-edit-row [person]="person" [index]="i" [form]="personnelForm" /> | ||
</div> | ||
</div> |
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({ | ||
declarations: [PersonnelEditComponent] | ||
}); | ||
fixture = TestBed.createComponent(PersonnelEditComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
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,42 @@ | ||
import { Component, inject, Inject, Input } from '@angular/core'; | ||
|
||
import { Personnel } from '../../datatypes/organization'; | ||
import { FormArray, FormBuilder, FormGroup } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'app-personnel-edit', | ||
templateUrl: './personnel-edit.component.html', | ||
styleUrls: ['./personnel-edit.component.scss'] | ||
}) | ||
export class PersonnelEditComponent { | ||
private formBuilder = inject(FormBuilder); | ||
personnelArray = this.formBuilder.array([this.buildFormGroup({} as Personnel)]); | ||
personnelForm = this.formBuilder.group({ | ||
personnelArray: this.personnelArray | ||
}); | ||
|
||
@Input() set personnel(personnel: Personnel[]) { | ||
const personnelArray = this.personnelForm.get('personnelArray') as FormArray; | ||
personnelArray.clear(); | ||
personnel.forEach((p) => personnelArray.push(this.buildFormGroup(p))); | ||
personnelArray.push(this.buildFormGroup({} as Personnel)); | ||
} | ||
|
||
private buildFormGroup(person: Personnel): FormGroup { | ||
return this.formBuilder.group({ | ||
title: [person.title || ''], | ||
name: [person.name || ''], | ||
callsign: [person.callsign || ''] | ||
}); | ||
} | ||
|
||
validate(): boolean { | ||
return this.personnelForm.valid; | ||
} | ||
|
||
getFormData(): Personnel[] { | ||
const personnelArray = this.personnelForm.get('personnelArray') as FormArray; | ||
console.log('personnelArray', personnelArray); | ||
return personnelArray.value as Personnel[]; | ||
} | ||
} |
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
16 changes: 16 additions & 0 deletions
16
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,16 @@ | ||
<table> | ||
<tr *ngFor="let tac of _tacticalCallsigns"> | ||
<td> | ||
<mat-form-field> | ||
<mat-label>Title</mat-label> | ||
<input matInput [value]="tac.title ?? ''" /> | ||
</mat-form-field> | ||
</td> | ||
<td> | ||
<mat-form-field> | ||
<mat-label>Callsign</mat-label> | ||
<input matInput [value]="tac.callsign ?? ''" /> | ||
</mat-form-field> | ||
</td> | ||
</tr> | ||
</table> |
Empty file.
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({ | ||
declarations: [TacticalEditComponent] | ||
}); | ||
fixture = TestBed.createComponent(TacticalEditComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
web/src/app/org-detail/tactical-edit/tactical-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,25 @@ | ||
import { Component, Input } from '@angular/core'; | ||
|
||
import { TacticalCallsign } from '../../datatypes/organization'; | ||
|
||
@Component({ | ||
selector: 'app-tactical-edit', | ||
templateUrl: './tactical-edit.component.html', | ||
styleUrls: ['./tactical-edit.component.scss'], | ||
}) | ||
export class TacticalEditComponent { | ||
_tacticalCallsigns: Partial<TacticalCallsign>[] = []; | ||
@Input() set tacticalCallsigns(tacticalCallsigns: TacticalCallsign[]) { | ||
this._tacticalCallsigns = tacticalCallsigns.concat([ | ||
{} as TacticalCallsign, | ||
]); | ||
} | ||
|
||
validate(): boolean { | ||
return true; | ||
} | ||
|
||
getFormData(): TacticalCallsign[] { | ||
return []; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
web/src/app/org-detail/tactical-view/tactical-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