Commit badb52e4 authored by hasan khaddour's avatar hasan khaddour

add the main domains for traks

parent 3f48d457
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<div class="col-auto"> <div class="col-auto">
<button type="button" class="btn m-2 btn-sm btn-primary">استعراض تارخ متابعتها </button> <button type="button" class="btn m-2 btn-sm btn-primary">استعراض تارخ متابعتها </button>
<button type="button" class="btn m-2 btn-sm btn-secondary">تعديل المعلومات</button> <button type="button" class="btn m-2 btn-sm btn-secondary">تعديل المعلومات</button>
<button type="button" class="btn m-2 btn-sm btn-danger">إزالة</button> <button type="button" (click)="onDelete()" class="btn m-2 btn-sm btn-danger">إزالة</button>
</div> </div>
</div> </div>
......
import { Component, Input } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Step } from '../../models/responses/Step'; import { Step } from '../../models/responses/Step';
@Component({ @Component({
...@@ -9,4 +9,9 @@ import { Step } from '../../models/responses/Step'; ...@@ -9,4 +9,9 @@ import { Step } from '../../models/responses/Step';
export class StepRowItemComponent { export class StepRowItemComponent {
@Input() step :Step @Input() step :Step
@Output() delete = new EventEmitter<void>();
onDelete() {
this.delete.emit();
}
} }
...@@ -12,11 +12,85 @@ ...@@ -12,11 +12,85 @@
<hr> <hr>
<step-row-item class=" offset-2" *ngFor="let step of steps" [step]="step"></step-row-item> <step-row-item
class=" offset-2"
*ngFor="let step of steps"
[step]="step"
(delete)="openModal('delete', step)"
></step-row-item>
<div *ngIf="steps.length==0"> <div *ngIf="steps.length==0">
للأسف هذا المروع لايحوي على أية مراحل للأسف هذا المروع لايحوي على أية مراحل
</div> </div>
</div> </div>
</div> </div>
</section> </section>
\ No newline at end of file
<div class="modal fade" id="stepModal" tabindex="-1" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<h5 class="modal-title" id="modalLabel">{{ modalTitle }}</h5>
</div>
<div class="modal-body">
<!-- Edit Form -->
<!-- <div *ngIf="modalMode === 'edit'">
<form (ngSubmit)="saveProject()">
<div class="row">
<div class="mb-3 col-5 offset-1">
<label for="stepName" class="form-label">نوع الكلفة</label>
<input type="text" name="stepName" id="stepName" class="form-control" [(ngModel)]="selectedItem.costType" required>
</div>
<div class="mb-3 col-5">
<label for="expectedSpendingDate" class="form-label">تاريخ الانفاق المتوقع</label>
<input type="date" id="expectedSpendingDate" class="form-control" [(ngModel)]="selectedItem.expectedSpendingDate" name="expectedSpendingDate" required>
</div>
<div class="mb-3 col-4 offset-1">
<label for="local" class="form-label">الشراء المحلي</label>
<input id="local" class="form-control" [(ngModel)]="selectedItem.localPurchase" name="local" required>
</div>
<div class="mb-3 col-4 ">
<label for="completion" class="form-label">الشراء الخارجي </label>
<input id="completion" class="form-control" [(ngModel)]="selectedItem.externalPurchase.ammount" name="completion" required>
</div>
<div class="mb-3 col-2">
<label for="duration" class="form-label">نوغ القطع</label>
<select id="duration" class="form-control select " [(ngModel)]="selectedItem.externalPurchase.currency" name="duration" required>
<option value="USA">USA</option>
<option value="EUR">EUR</option>
</select>
</div>
</div>
<div class="row">
<div class="mb-3 col-10 offset-1 " >
<label for="decription" class="form-label">البيان</label>
<textarea col="3" name="worker" id="decription" class="form-control" [(ngModel)]="selectedItem.description" required>
</textarea>
</div>
</div>
<div class="row">
</div>
<button type="submit" class="btn btn-success">حفظ</button>
</form>
</div> -->
<!-- Delete Confirmation -->
<div *ngIf="modalMode === 'delete'">
<p>هل أنت متأكد من أنك تريد حذف المرحلة {{ selectedItem.stepInfo.stepName }}?</p>
<button type="button" class="btn m-4 btn-danger" (click)="delete()">حذف</button>
<button type="button" class="btn m-4 btn-secondary" (click)="closeModal()">إلغاء</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -6,6 +6,7 @@ import { ActivatedRoute, Route, Router } from '@angular/router'; ...@@ -6,6 +6,7 @@ import { ActivatedRoute, Route, Router } from '@angular/router';
import { StepService } from '../../services/step.service'; import { StepService } from '../../services/step.service';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { AddStepModalComponent } from '../../components/modals/add-step-modal/add-step-modal.component'; import { AddStepModalComponent } from '../../components/modals/add-step-modal/add-step-modal.component';
import { Modal } from 'bootstrap';
@Component({ @Component({
selector: 'step-list', selector: 'step-list',
templateUrl: './step-list.component.html', templateUrl: './step-list.component.html',
...@@ -13,7 +14,9 @@ import { AddStepModalComponent } from '../../components/modals/add-step-modal/ad ...@@ -13,7 +14,9 @@ import { AddStepModalComponent } from '../../components/modals/add-step-modal/ad
}) })
export class StepListComponent { export class StepListComponent {
steps : Step[] steps : Step[]
modalMode: 'edit' | 'delete' = 'edit';
modalTitle: string = '';
selectedItem : Step;
projectId = Number(this.route.snapshot.paramMap.get('id')); projectId = Number(this.route.snapshot.paramMap.get('id'));
constructor( constructor(
...@@ -63,4 +66,55 @@ export class StepListComponent { ...@@ -63,4 +66,55 @@ export class StepListComponent {
}); });
} }
openModal(mode: 'edit' | 'delete', item: Step): void {
this.modalMode = mode;
this.selectedItem = { ...item }; // Clone project to prevent direct mutation
console.log(this.selectedItem)
if (mode === 'edit') {
this.modalTitle = 'تعديل عنصر ';
} else if (mode === 'delete') {
this.modalTitle = 'حذف عنصر';
}
const modalElement = document.getElementById('stepModal');
if (modalElement) {
new Modal(modalElement).show(); // Open the modal
}
}
delete(): void {
this.stepService.deleteSep(this.selectedItem.id).subscribe({
next :()=>{
this.steps = this.steps.filter(p => p.id !== this.selectedItem.id);
this.toastr.success("تم الحذف بنجاح")
this.closeModal();
}
,
error:(err)=>{
this.toastr.error("لقد حدث خطاء ما ")
this.closeModal();
}
}
);
}
closeModal(): void {
const modalElement = document.getElementById('stepModal');
if (modalElement) {
new Modal(modalElement).hide(); // Close the modal
}
}
} }
<p>add-employee-track-modal works!</p> <div class="modal modal-md fade" id="addEmployeeTrackModal" tabindex="-1" aria-labelledby="addEmployeeTrackModalLable" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addEmployeeTrackModalLable">إضافة متابعة مشارك</h5>
<button type="button" class="mr-4 ml-4 btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form [formGroup]="stepTrackForm" (ngSubmit)="onSubmit()">
<div class="row ">
<div class="mb-3 col-4">
<label for="hiastId" class="form-label">الرقم الذاتي لمشارك</label>
<input type="text" id="hiastId" formControlName="hiastId" class="form-control" [ngbTypeahead]="search" (selectItem)="onStepSelected($event.item)">
</div>
<input type="number" hidden id="id" formControlName="id" class="form-control" >
<div class="mb-3 col-6">
<label for="notes" class="form-label">الملاحظات</label>
<input type="text" id="notes" formControlName="notes" class="form-control">
</div>
</div>
<div class="row">
<div class="mb-3 col-4">
<label for="assignedWork" class="form-label">العمل المسند</label>
<input id="assignedWork" formControlName="assignedWork" class="form-control" >
</div>
<div class="mb-3 col-4">
<label for="performedWork" class="form-label">العمل المنجز</label>
<input id="performedWork" formControlName="performedWork" class="form-control" >
</div>
<div class="mb-3 col-4">
<label for="assignedWorkEnd" class="form-label">تاريخ تنفيذ العمل المسند</label>
<input type="date" id="assignedWorkEnd" formControlName="assignedWorkEnd" class="form-control" >
</div>
</div>
<div class="row">
<div class="mb-3 col-4">
<label for="assignedWorkingHours" class="form-label">ساعات العمل المسندة </label>
<input type="number" id="assignedWorkingHours" formControlName="assignedWorkingHours" class="form-control" >
</div>
<div class="mb-3 col-4">
<label for="workedHours" class="form-label">ساعات العمل الفعلية</label>
<input type="number" id="workedHours" formControlName="workedHours" class="form-control" >
</div>
<div class="mb-3 col-4">
<label for="contributingRatio" class="form-label">نسبة المساهمة في العمل</label>
<input type="number" id="contributingRatio" formControlName="contributingRatio" class="form-control" >
</div>
</div>
<button type="submit" class="btn mr-4 ml-4 btn-primary" [disabled]="!stepTrackForm.valid">إضافة</button>
<button data-bs-dismiss="modal" aria-label="Close" class=" mr-4 ml-4 btn btn-primary" >إلغاء</button>
</form>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { Component } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Modal } from 'bootstrap';
import { Observable, map } from 'rxjs';
import { Step } from '../../../../projects/models/responses/Step';
import { StepService } from '../../../../projects/services/step.service';
import { AddStepTrackRequest } from '../../../models/requests/AddStepTrackRequest';
import { Employee } from '../../../../employees/models/responses/employee';
import { AddEmployeeTrackRequest } from '../../../models/requests/AddEmployeeTrackRequest';
import { ProjectService } from '../../../../projects/services/project.service';
import { EmployeeParticipate } from '../../../../employees/models/responses/employeeParticipate';
import { EmployeeTrack } from '../../../models/responses/employeeTrack';
import { FullnamePipe } from '../../../../shared/pipes/fullName/fullname.pipe';
@Component({ @Component({
selector: 'add-employee-track-modal', selector: 'add-employee-track-modal',
...@@ -6,5 +18,110 @@ import { Component } from '@angular/core'; ...@@ -6,5 +18,110 @@ import { Component } from '@angular/core';
styleUrl: './add-employee-track-modal.component.css' styleUrl: './add-employee-track-modal.component.css'
}) })
export class AddEmployeeTrackModalComponent { export class AddEmployeeTrackModalComponent {
@Input() isVisible = false;
participants: EmployeeParticipate[] = []; // All steps available for the project
@Input() trackedParticipants: EmployeeTrack[] = []; // Steps that are already tracked
@Input() projectId :number
@Input() trackId :number
@Output() addEmployeeTrack = new EventEmitter<AddEmployeeTrackRequest>();
stepTrackForm: FormGroup;
filteredParticipants: Employee[] = [];
constructor(private fb: FormBuilder,
private projectService : ProjectService
) {
this.stepTrackForm = this.fb.group({
id: [],
hiastId: ['', Validators.required],
notes: ['', Validators.required],
assignedWork: ['', Validators.required],
performedWork: ['', Validators.required],
assignedWorkEnd: [new Date(), Validators.required],
assignedWorkingHours: [0,[ Validators.required,,Validators.min(0)]],
workedHours: [0, [Validators.required,,Validators.min(0)]],
contributingRatio: [0, [Validators.required,Validators.min(0),,Validators.max(100)]]
}
);
}
ngOnInit(): void {
this.projectService.getParticipants(this.projectId)
.subscribe({
next: (data)=> {
console.log(data)
this.participants=data
this.filteredParticipants = this.participants.filter(track=>
!this.trackedParticipants.some(participate => participate.emloyeeId ===track.employeeId )
).map(e => e.employee);
}
})
}
search = (text$: Observable<string>) =>
text$.pipe(
map(term => term.length < 1 ? [] :
this.filteredParticipants.filter(v => v.hiastId.toString().includes(term.toLowerCase())).slice(0, 10).map( e => e.personalInfo.firstName + " " + e.personalInfo.lastName))
);
onStepSelected(step: Employee): void {
debugger
this.stepTrackForm.patchValue({ hiastId: step.hiastId });
//this.stepTrackForm.patchValue({id: step.id});
}
onSubmit(): void {
if (this.stepTrackForm.valid) {
debugger
const selectedStep = this.filteredParticipants.find(emp => emp.hiastId == this.stepTrackForm.value.hiastId);
if (selectedStep) {
const newEmployeeTrack: AddEmployeeTrackRequest = {
employeeId: selectedStep.id,
trackId: this.trackId,
employeeWork: {
workedHours: this.stepTrackForm.value.workedHours,
assignedWorkingHours: this.stepTrackForm.value.assignedWork,
contributingRatio:this.stepTrackForm.value.contributingRatio
},
employeeWorkInfo:{
assignedWork: this.stepTrackForm.value.assignedWork,
performedWork:this.stepTrackForm.value.performedWork ,
assignedWorkEnd: this.stepTrackForm.value.assignedWorkEnd
},
notes:this.stepTrackForm.value.notes,
projectId:this.projectId
};
this.closeModal();
this.addEmployeeTrack.emit(newEmployeeTrack);
}
}
}
closeModal(): void {
const modal = document.getElementById('addEmployeeTrackModal');
if (modal) {
const bootstrapModal = new Modal(modal);
bootstrapModal.hide();
}
}
} }
...@@ -2,25 +2,29 @@ ...@@ -2,25 +2,29 @@
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="addStepTrackModalLabel">Add Step Track</h5> <h5 class="modal-title" id="addStepTrackModalLabel">إضافة متابعة مرحلة</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> <button type="button" class=" mr-4 ml-4 btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form [formGroup]="stepTrackForm" (ngSubmit)="onSubmit()"> <form [formGroup]="stepTrackForm" (ngSubmit)="onSubmit()">
<div class="mb-3"> <div class="mb-3">
<label for="stepName" class="form-label">Step Name</label> <label for="stepName" class="form-label">اسم المرحلة</label>
<input type="text" id="stepName" formControlName="stepName" class="form-control" [ngbTypeahead]="search" (selectItem)="onStepSelected($event.item)"> <input type="text" id="stepName" formControlName="stepName" class="form-control" [ngbTypeahead]="search" (selectItem)="onStepSelected($event.item)">
</div> </div>
<input type="number" hidden id="id" formControlName="id" class="form-control" >
<div class="mb-3"> <div class="mb-3">
<label for="executionState" class="form-label">Execution State</label> <label for="executionState" class="form-label">طبيعية التنفيذ</label>
<input type="text" id="executionState" formControlName="executionState" class="form-control"> <input type="text" id="executionState" formControlName="executionState" class="form-control">
</div> </div>
<div class="mb-3"> <div class="mb-3">
<label for="trackExecutionRatio" class="form-label">Track Execution Ratio</label> <label for="trackExecutionRatio" class="form-label">نسبة التنفيذ خلال المتابعة</label>
<input type="number" id="trackExecutionRatio" formControlName="trackExecutionRatio" class="form-control" min="0" max="100"> <input type="number" id="trackExecutionRatio" formControlName="trackExecutionRatio" class="form-control" min="0" max="100">
</div> </div>
<button type="submit" class="btn btn-primary" [disabled]="!stepTrackForm.valid">Add Step Track</button> <button type="submit" class="btn mr-4 ml-4 btn-primary" [disabled]="!stepTrackForm.valid">إضافة</button>
<button data-bs-dismiss="modal" aria-label="Close" class="btn mr-4 ml-4 btn-primary" >إلغاء</button>
</form> </form>
</div> </div>
</div> </div>
......
...@@ -19,8 +19,9 @@ import { StepService } from '../../../../projects/services/step.service'; ...@@ -19,8 +19,9 @@ import { StepService } from '../../../../projects/services/step.service';
}) })
export class AddStepTrackModalComponent { export class AddStepTrackModalComponent {
@Input() isVisible = false; @Input() isVisible = false;
@Input() steps: Step[] = []; // All steps available for the project steps: Step[] = []; // All steps available for the project
@Input() trackedSteps: Step[] = []; // Steps that are already tracked @Input() trackedSteps: Step[] = []; // Steps that are already tracked
@Input() projectId :number
@Input() trackId :number @Input() trackId :number
@Output() addStepTrack = new EventEmitter<AddStepTrackRequest>(); @Output() addStepTrack = new EventEmitter<AddStepTrackRequest>();
...@@ -31,6 +32,7 @@ export class AddStepTrackModalComponent { ...@@ -31,6 +32,7 @@ export class AddStepTrackModalComponent {
private stepService : StepService private stepService : StepService
) { ) {
this.stepTrackForm = this.fb.group({ this.stepTrackForm = this.fb.group({
id: [],
stepName: ['', Validators.required], stepName: ['', Validators.required],
executionState: ['', Validators.required], executionState: ['', Validators.required],
trackExecutionRatio: [0, [Validators.required, Validators.min(0), Validators.max(100)]], trackExecutionRatio: [0, [Validators.required, Validators.min(0), Validators.max(100)]],
...@@ -38,36 +40,54 @@ export class AddStepTrackModalComponent { ...@@ -38,36 +40,54 @@ export class AddStepTrackModalComponent {
} }
ngOnInit(): void { ngOnInit(): void {
this.filteredSteps = this.steps.filter(step => this.stepService.getStepsByProject(this.projectId)
!this.trackedSteps.some(trackedStep => trackedStep.id === step.id) .subscribe({
next: (data)=> {
);
console.log(data)
this.steps=data
console.log(this.steps)
this.filteredSteps = this.steps.filter(step =>
!this.trackedSteps.some(trackedStep => trackedStep.id === step.id)
);
}
})
} }
search = (text$: Observable<string>) => search = (text$: Observable<string>) =>
text$.pipe( text$.pipe(
map(term => term.length < 2 ? [] : map(term => term.length < 2 ? [] :
this.filteredSteps.filter(v => v.stepInfo.stepName.toLowerCase().includes(term.toLowerCase())).slice(0, 10)) this.filteredSteps.filter(v => v.stepInfo.stepName.toLowerCase().includes(term.toLowerCase())).slice(0, 10).map( e => e.stepInfo.stepName))
); );
onStepSelected(step: Step): void { onStepSelected(step: Step): void {
this.stepTrackForm.patchValue({ stepName: step.stepInfo.stepName });
this.stepTrackForm.patchValue({ stepName: step.stepInfo?.stepName });
//this.stepTrackForm.patchValue({id: step.id});
} }
onSubmit(): void { onSubmit(): void {
if (this.stepTrackForm.valid) { if (this.stepTrackForm.valid) {
const selectedStep = this.filteredSteps.find(step => step.stepInfo.stepName === this.stepTrackForm.value.stepName); debugger
const selectedStep = this.filteredSteps.find(step => step.stepInfo.stepName == this.stepTrackForm.value.stepName);
if (selectedStep) { if (selectedStep) {
const newStepTrack: AddStepTrackRequest = { const newStepTrack: AddStepTrackRequest = {
stepId: selectedStep.id, stepId: selectedStep.id,
trackId: this.trackId, trackId: this.trackId,
executionState: this.stepTrackForm.value.executionState, executionState: this.stepTrackForm.value.executionState,
trackDate: new Date(),
trackExecutionRatio: this.stepTrackForm.value.trackExecutionRatio, trackExecutionRatio: this.stepTrackForm.value.trackExecutionRatio,
}; };
this.addStepTrack.emit(newStepTrack);
this.closeModal(); this.closeModal();
this.addStepTrack.emit(newStepTrack);
} }
} }
} }
......
...@@ -3,6 +3,5 @@ export class AddStepTrackRequest { ...@@ -3,6 +3,5 @@ export class AddStepTrackRequest {
stepId: number; stepId: number;
trackId: number; trackId: number;
executionState: string; executionState: string;
trackDate: Date;
trackExecutionRatio: number; trackExecutionRatio: number;
} }
...@@ -64,8 +64,7 @@ ...@@ -64,8 +64,7 @@
<div class="tab-pane fade profile-edit pt-3 " id="profile-edit" role="tabpanel"> <div class="tab-pane fade profile-edit pt-3 " id="profile-edit" role="tabpanel">
<button class="btn btn-primary" (click)="showAddStepTrackModal()">متابعة مرحلة</button>
<hr>
<step-track *ngFor="let stepTrack of stepTracks" [stepTrack]="stepTrack" ></step-track> <step-track *ngFor="let stepTrack of stepTracks" [stepTrack]="stepTrack" ></step-track>
<div class="row" *ngIf="stepTracks.length ==0 " > <div class="row" *ngIf="stepTracks.length ==0 " >
لم تقم بمتابعة اية مراحل لم تقم بمتابعة اية مراحل
...@@ -98,14 +97,26 @@ ...@@ -98,14 +97,26 @@
</div> </div>
</div> </div>
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addStepTrackModal"> <button type="button" class="btn mr-4 ml-4 btn-primary" data-bs-toggle="modal" data-bs-target="#addStepTrackModal">
Add Step Track إضافة متابعة مرحلة
</button>
<button type="button" class="btn mr-4 ml-4 btn-primary" data-bs-toggle="modal" data-bs-target="#addEmployeeTrackModal">
إضافة متابعة مشارك
</button> </button>
<add-step-track-modal <add-step-track-modal
[steps]="steps"
[trackId]="trackId"
[projectId]="track.projectId"
[trackedSteps]="trackedSteps" [trackedSteps]="trackedSteps"
(addStepTrack)="handleAddStepTrack($event)"> (addStepTrack)="handleAddStepTrack($event)">
</add-step-track-modal> </add-step-track-modal>
<add-employee-track-modal
[trackId]="trackId"
[projectId]="track.projectId"
[trackedParticipants]="employeesTracks"
(addEmployeeTrack)="handleEmployeeTrack($event)">
</add-employee-track-modal>
</section> </section>
\ No newline at end of file
...@@ -10,6 +10,9 @@ import { AddStepTrackRequest } from '../../models/requests/AddStepTrackRequest'; ...@@ -10,6 +10,9 @@ import { AddStepTrackRequest } from '../../models/requests/AddStepTrackRequest';
import { error } from 'jquery'; import { error } from 'jquery';
import { StepService } from '../../../projects/services/step.service'; import { StepService } from '../../../projects/services/step.service';
import { forkJoin } from 'rxjs'; import { forkJoin } from 'rxjs';
import { AddEmployeeTrackRequest } from '../../models/requests/AddEmployeeTrackRequest';
import { ProjectService } from '../../../projects/services/project.service';
import { EmployeeParticipate } from '../../../employees/models/responses/employeeParticipate';
@Component({ @Component({
selector: 'track-details', selector: 'track-details',
...@@ -24,12 +27,14 @@ export class TrackDetailsComponent implements OnInit { ...@@ -24,12 +27,14 @@ export class TrackDetailsComponent implements OnInit {
employeesTracks : EmployeeTrack[] employeesTracks : EmployeeTrack[]
steps: Step[] = []; // Load steps from service or store steps: Step[] = []; // Load steps from service or store
trackedSteps: Step[] = []; // Load already tracked steps trackedSteps: Step[] = []; // Load already tracked steps
participants : EmployeeParticipate[]
constructor( constructor(
private toastr : ToastrService , private toastr : ToastrService ,
private route :ActivatedRoute, private route :ActivatedRoute,
private trackService : TrackService, private trackService : TrackService,
private stepService : StepService private stepService : StepService ,
private projectService :ProjectService
){} ){}
...@@ -51,12 +56,24 @@ export class TrackDetailsComponent implements OnInit { ...@@ -51,12 +56,24 @@ export class TrackDetailsComponent implements OnInit {
this.track = track; this.track = track;
this.stepTracks = stepTracks; this.stepTracks = stepTracks;
this.employeesTracks = employeesTracks; this.employeesTracks = employeesTracks;
this.loadParticipants();
this.loadSteps(); this.loadSteps();
}) })
} }
loadParticipants(){
this
.projectService
.getParticipants(this.track.projectId)
.subscribe({
next: (data)=>{
this.participants = data
}
});
}
loadSteps(){ loadSteps(){
this.stepService this.stepService
.getStepsByProject(this.track.projectId) .getStepsByProject(this.track.projectId)
...@@ -99,13 +116,13 @@ export class TrackDetailsComponent implements OnInit { ...@@ -99,13 +116,13 @@ export class TrackDetailsComponent implements OnInit {
handleAddStepTrack(stepTrackRequest: AddStepTrackRequest): void { handleAddStepTrack(stepTrackRequest: AddStepTrackRequest): void {
stepTrackRequest.trackDate=this.track.trackInfo.trackDate debugger
this.trackService.addStepTrack(stepTrackRequest).subscribe({ this.trackService.addStepTrack(stepTrackRequest).subscribe({
next : (data)=>{ next : (data)=>{
this.loadTheNewStep(data,stepTrackRequest); this.loadTheNewStep(data,stepTrackRequest);
this.toastr.success('تمت إضافة متالعة المرحلة ')
} }
, ,
...@@ -116,6 +133,9 @@ export class TrackDetailsComponent implements OnInit { ...@@ -116,6 +133,9 @@ export class TrackDetailsComponent implements OnInit {
}); });
} }
loadTheNewStep(stId :number,request :AddStepTrackRequest ){ loadTheNewStep(stId :number,request :AddStepTrackRequest ){
let s = this.steps.find(s => s.id == request.stepId ) let s = this.steps.find(s => s.id == request.stepId )
let st : StepTrack ={ let st : StepTrack ={
...@@ -143,4 +163,41 @@ export class TrackDetailsComponent implements OnInit { ...@@ -143,4 +163,41 @@ export class TrackDetailsComponent implements OnInit {
} }
handleEmployeeTrack(request: AddEmployeeTrackRequest): void {
debugger
this.trackService.addEmployeeTrack(request).subscribe({
next : (data)=>{
this.loadTheNewParticipant(data,request);
this.toastr.success('تمت إضافة متالعة المرحلة ')
}
,
error:(err)=>{
this.toastr.error('لقد حدث خطاء ما')
}
});
}
loadTheNewParticipant(empTrackId :number,request :AddEmployeeTrackRequest ){
let s = this.participants.find(s => s.employeeId == request.employeeId )
let st : EmployeeTrack ={
trackId:this.trackId,
trackInfo:this.track.trackInfo,
emloyeeId:request.employeeId,
employeeWork:request.employeeWork,
employeeWorkInfo:request.employeeWorkInfo,
employee:s!.employee,
notes:request.notes
}
this.employeesTracks.push(st)
this.participants=this.participants.filter(e => e.employeeId == s?.employeeId)
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment