Commit 96ebd933 authored by hasan khaddour's avatar hasan khaddour

fix projecgt modals

parent ba87b117
...@@ -88,5 +88,4 @@ export class AuthenticationService { ...@@ -88,5 +88,4 @@ export class AuthenticationService {
} }
//#endregion Logout //#endregion Logout
} }
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { DataStorageService } from '../dataStorage/data-storage.service'; import { DataStorageService } from '../dataStorage/data-storage.service';
import { User } from '../../models/users/User'; import { User } from '../../models/users/User';
import { ROLES } from '../../constants/roles';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -43,4 +44,13 @@ export class UserService { ...@@ -43,4 +44,13 @@ export class UserService {
.length !=0; .length !=0;
} }
//#region authority
public isAuthorizedAsSeflOrDeputy( employeeId : number ){
return this.hasRole(ROLES.SCIENTIFIC_DEPUTY)|| this.getEmployeeId() == employeeId;
}
//#endregion authority
} }
<!-- edit-participant-modal.component.html -->
<div class="modal fade" id="editParticipantModal" tabindex="-1" aria-labelledby="editParticipantModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="editParticipantModalLabel">تعديل معلومات مشاركة </h5> <h5 class="modal-title" id="editParticipantModalLabel">تعديل معلومات مشاركة </h5>
<button type="button" class=" ml-4 mr-4 btn-close" data-bs-dismiss="modal" aria-label="Close"></button> <button type="button" class=" ml-4 mr-4 btn-close" (click)="closeModal()"></button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form [formGroup]="editParticipantForm" (ngSubmit)="onSubmit()"> <form [formGroup]="editParticipantForm" (ngSubmit)="onSubmit()">
...@@ -18,11 +14,8 @@ ...@@ -18,11 +14,8 @@
</div> </div>
<button type="submit" class="col-4 offset-2 btn btn-primary" [disabled]="!editParticipantForm.valid">حفظ</button> <button type="submit" class="col-4 offset-2 btn btn-primary" [disabled]="!editParticipantForm.valid">حفظ</button>
<button type="button" class="col-4 offset-2 btn btn-secondary" data-bs-dismiss="modal">إزالة</button> <button type="button" (click)="closeModal()">إلغاء</button>
</form> </form>
</div> </div>
</div>
</div>
</div>
\ No newline at end of file
...@@ -19,7 +19,7 @@ export class EditParticipantModalComponent { ...@@ -19,7 +19,7 @@ export class EditParticipantModalComponent {
constructor( constructor(
private fb: FormBuilder, private fb: FormBuilder,
private projectService: ProjectService, private projectService: ProjectService,
private activeModal : NgbModal private activeModal :NgbActiveModal
) { ) {
this.editParticipantForm = this.fb.group({ this.editParticipantForm = this.fb.group({
role: ['', Validators.required], role: ['', Validators.required],
...@@ -49,12 +49,13 @@ export class EditParticipantModalComponent { ...@@ -49,12 +49,13 @@ export class EditParticipantModalComponent {
.changeParticipation(request) .changeParticipation(request)
.subscribe(() => { .subscribe(() => {
this.participantEdited.emit(); this.participantEdited.emit();
this.closeModal(); this.activeModal.close(request);
}); });
} }
} }
closeModal() { closeModal() {
this.activeModal.dismissAll(); this.activeModal.close();
} }
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<button type="button" class="ml-4 mr-4 btn-close" data-bs-dismiss="modal" aria-label="Close"></button> <button type="button" class="ml-4 mr-4 btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p>هل أنت متأكد من أنك تريد إزالة السيد {{participant.employee.personalInfo | fullname}} من قائمة المشاركين في المشروع</p> <p class="text-center text-danger">هل أنت متأكد من أنك تريد إزالة السيد {{participant.employee.personalInfo | fullname}} من قائمة المشاركين في المشروع</p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">إلغاء</button> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">إلغاء</button>
......
...@@ -2,6 +2,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; ...@@ -2,6 +2,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
import { EmployeeParticipate } from '../../../../employees/models/responses/employeeParticipate'; import { EmployeeParticipate } from '../../../../employees/models/responses/employeeParticipate';
import { ProjectService } from '../../../services/project.service'; import { ProjectService } from '../../../services/project.service';
import { RemoveParticipantRequest } from '../../../models/requests/project-requests/RemoveParticipant'; import { RemoveParticipantRequest } from '../../../models/requests/project-requests/RemoveParticipant';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
@Component({ @Component({
selector: 'remove-participant-modal', selector: 'remove-participant-modal',
...@@ -12,7 +13,9 @@ export class RemoveParticipantModalComponent { ...@@ -12,7 +13,9 @@ export class RemoveParticipantModalComponent {
@Input() participant: EmployeeParticipate; @Input() participant: EmployeeParticipate;
@Output() participantRemoved = new EventEmitter<void>(); @Output() participantRemoved = new EventEmitter<void>();
constructor(private projectService: ProjectService) {} constructor(private projectService: ProjectService,
private activeModal : NgbActiveModal
) {}
onConfirmRemove() { onConfirmRemove() {
let request :RemoveParticipantRequest= { let request :RemoveParticipantRequest= {
...@@ -23,7 +26,7 @@ export class RemoveParticipantModalComponent { ...@@ -23,7 +26,7 @@ export class RemoveParticipantModalComponent {
this.projectService this.projectService
.removeParticipant(request) .removeParticipant(request)
.subscribe(() => { .subscribe(() => {
this.participantRemoved.emit(); this.activeModal.close(this.participant.employeeId);
}); });
} }
......
<p>remove-step-modal works!</p> <div class="modal-header">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<h5 class="modal-title" id="modalLabel">حذف مرحلة </h5>
</div>
<div class="modal-body">
<p
class="text-center text-danger p-10"
>هل أنت متأكد من أنك تريد حذف المرحلة {{ step.stepInfo.stepName }}?</p>
<button type="button" class="btn m-4 btn-danger" (click)="onConfirmRemove()">حذف</button>
<button type="button" class="btn m-4 btn-secondary" (click)="onClose()">إلغاء</button>
</div>
...@@ -3,6 +3,7 @@ import { Step } from '../../../models/responses/Step'; ...@@ -3,6 +3,7 @@ import { Step } from '../../../models/responses/Step';
import { ProjectService } from '../../../services/project.service'; import { ProjectService } from '../../../services/project.service';
import { StepService } from '../../../services/step.service'; import { StepService } from '../../../services/step.service';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
@Component({ @Component({
selector: 'remove-step-modal', selector: 'remove-step-modal',
...@@ -15,6 +16,7 @@ export class RemoveStepModalComponent { ...@@ -15,6 +16,7 @@ export class RemoveStepModalComponent {
constructor( constructor(
private stepService: StepService, private stepService: StepService,
private activeModal :NgbActiveModal,
private toastr : ToastrService) {} private toastr : ToastrService) {}
onConfirmRemove() { onConfirmRemove() {
...@@ -25,8 +27,8 @@ export class RemoveStepModalComponent { ...@@ -25,8 +27,8 @@ export class RemoveStepModalComponent {
.subscribe({ .subscribe({
next: ()=>{ next: ()=>{
this.stepRemoved.emit(); this.activeModal.close(this.step.id);
}, },
error: (err)=>{ error: (err)=>{
this this
...@@ -39,4 +41,8 @@ export class RemoveStepModalComponent { ...@@ -39,4 +41,8 @@ export class RemoveStepModalComponent {
} }
onClose(){
this.activeModal.close();
}
} }
...@@ -36,10 +36,10 @@ ...@@ -36,10 +36,10 @@
<div class="col-auto"> <div class="col-auto">
<button type="button" [routerLink]="['/tracks/history/step/',step.id]" class="btn mr-2 btn-sm btn-primary">استعراض تاريخ متابعتها </button> <button type="button" [routerLink]="['/tracks/history/step/',step.id]" class="btn mr-2 btn-sm btn-primary">استعراض تاريخ متابعتها </button>
<button type="button"(click)="onChangeWeight()" class="btn mr-2 btn-sm btn-secondary">تعديل الثقل</button> <button type="button" *ngIf="canSee" (click)="onChangeWeight()" class="btn mr-2 btn-sm btn-secondary">تعديل الثقل</button>
<button type="button" (click)="onEdit()" class="btn mr-2 btn-sm btn-secondary">تعديل المعلومات</button> <button type="button" *ngIf="canSee" (click)="onEdit()" class="btn mr-2 btn-sm btn-secondary">تعديل المعلومات</button>
<button type="button" (click)="onDelete()" class="btn mr2 btn-sm btn-danger">إزالة</button> <button type="button" *ngIf="canSee" (click)="onDelete()" class="btn mr2 btn-sm btn-danger">إزالة</button>
</div> </div>
</div> </div>
......
...@@ -9,6 +9,7 @@ import { Step } from '../../../models/responses/Step'; ...@@ -9,6 +9,7 @@ import { Step } from '../../../models/responses/Step';
export class StepRowItemComponent { export class StepRowItemComponent {
@Input() step :Step @Input() step :Step
@Input() canSee :boolean
@Output() delete = new EventEmitter<void>(); @Output() delete = new EventEmitter<void>();
@Output() edit = new EventEmitter<Step>(); @Output() edit = new EventEmitter<Step>();
@Output() changeWeight = new EventEmitter<Step>(); @Output() changeWeight = new EventEmitter<Step>();
......
...@@ -3,10 +3,11 @@ import { Project } from '../../models/responses/project'; ...@@ -3,10 +3,11 @@ import { Project } from '../../models/responses/project';
import { Employee } from '../../../employees/models/responses/employee'; import { Employee } from '../../../employees/models/responses/employee';
import { ParticipationChange } from '../../models/responses/participationChange'; import { ParticipationChange } from '../../models/responses/participationChange';
import { ProjectService } from '../../services/project.service'; import { ProjectService } from '../../services/project.service';
import { ActivatedRoute } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { EmployeesService } from '../../../employees/services/employees.service'; import { EmployeesService } from '../../../employees/services/employees.service';
import { EmployeeParticipate } from '../../../employees/models/responses/employeeParticipate'; import { EmployeeParticipate } from '../../../employees/models/responses/employeeParticipate';
import { UserService } from '../../../core/services/authentication/user.service';
@Component({ @Component({
selector: 'participant-changes', selector: 'participant-changes',
...@@ -25,6 +26,8 @@ export class ParticipantChangesComponent implements OnInit{ ...@@ -25,6 +26,8 @@ export class ParticipantChangesComponent implements OnInit{
private projectService :ProjectService, private projectService :ProjectService,
private employeeServie :EmployeesService, private employeeServie :EmployeesService,
private route :ActivatedRoute, private route :ActivatedRoute,
private userService : UserService,
private router :Router,
private toastr :ToastrService private toastr :ToastrService
){} ){}
...@@ -35,7 +38,7 @@ export class ParticipantChangesComponent implements OnInit{ ...@@ -35,7 +38,7 @@ export class ParticipantChangesComponent implements OnInit{
this this
.participantId = Number(this.route.snapshot.paramMap.get('participantId')); .participantId = Number(this.route.snapshot.paramMap.get('participantId'));
this this
.employeeServie .employeeServie
.getEmployeeById(this.participantId) .getEmployeeById(this.participantId)
...@@ -50,9 +53,24 @@ export class ParticipantChangesComponent implements OnInit{ ...@@ -50,9 +53,24 @@ export class ParticipantChangesComponent implements OnInit{
.getProjectById(this.projectId) .getProjectById(this.projectId)
.subscribe({ .subscribe({
next:(data)=>{ next:(data)=>{
this.project=data
this.currentParticipation=this.project.employeeParticipates.filter(e => e.employeeId == this.participantId)[0] if(this.userService.isAuthorizedAsSeflOrDeputy(this.participantId)||data.projectManagerId == this.userService.getEmployeeId()){
}
this.project=data
this
.toastr
.success('لقد تم تحميل تاريخ التبدلات بنجاح');
this.currentParticipation=this.project.employeeParticipates.filter(e => e.employeeId == this.participantId)[0]
}else {
this.toastr.error('ليس لديك صلاحيات الولوج إلى هذه الصفحة')
this.router.navigate(['/forbiden'])
}
}
}); });
...@@ -64,10 +82,6 @@ export class ParticipantChangesComponent implements OnInit{ ...@@ -64,10 +82,6 @@ export class ParticipantChangesComponent implements OnInit{
next: (data)=>{ next: (data)=>{
this this
.history=data.filter(e=> e.employeeId==this.participantId); .history=data.filter(e=> e.employeeId==this.participantId);
this
.toastr
.success('لقد تم تحميل تاريخ التبدلات بنجاح');
}, },
error:(err)=>{ error:(err)=>{
......
...@@ -37,16 +37,13 @@ ...@@ -37,16 +37,13 @@
</div> </div>
</div> </div>
<edit-participant-modal
[participant]="selectedParticipant" <!-- <remove-participant-modal *ngIf="selectedParticipant"
(participantEdited)="onParticipantUpdated()"
></edit-participant-modal>
<remove-participant-modal *ngIf="selectedParticipant"
[participant]="selectedParticipant" [participant]="selectedParticipant"
(participantRemoved)="onParticipantRemoved()" (participantRemoved)="onParticipantRemoved()"
> > -->
<!--
</remove-participant-modal> </remove-participant-modal> -->
<!-- <app-remove-participant-modal [participant]="selectedParticipant" (participantRemoved)="onParticipantRemoved()"></app-remove-participant-modal> --> <!-- <app-remove-participant-modal [participant]="selectedParticipant" (participantRemoved)="onParticipantRemoved()"></app-remove-participant-modal> -->
...@@ -80,8 +77,8 @@ ...@@ -80,8 +77,8 @@
<div class="col-10"> <div class="col-10">
<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" data-bs-toggle="modal" data-bs-target="#editParticipantModal" class="btn m-2 btn-sm btn-secondary">تعديل معلومات المشاركة</button> <button type="button" (click)="onParticipantUpdated()" class="btn m-2 btn-sm btn-secondary">تعديل معلومات المشاركة</button>
<button type="button" data-bs-toggle="modal" data-bs-target="#removeParticipantModal" class="btn m-2 btn-sm btn-danger">إزالة</button> <button type="button" (click)="openDeleteModal()" class="btn m-2 btn-sm btn-danger">إزالة</button>
<button type="button" [routerLink]="['/reports/contributions',selectedParticipant.projectId,'employee',selectedParticipant.employeeId]" class="btn btn-sm btn-secondary">المساهمات</button> <button type="button" [routerLink]="['/reports/contributions',selectedParticipant.projectId,'employee',selectedParticipant.employeeId]" class="btn btn-sm btn-secondary">المساهمات</button>
</div> </div>
......
...@@ -8,6 +8,9 @@ import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'; ...@@ -8,6 +8,9 @@ import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { AddParticipantModalComponent } from '../../components/modals/add-participant-modal/add-participant-modal.component'; import { AddParticipantModalComponent } from '../../components/modals/add-participant-modal/add-participant-modal.component';
import { ModalService } from '../../../core/services/modals/modal.service'; import { ModalService } from '../../../core/services/modals/modal.service';
import { NgModel } from '@angular/forms'; import { NgModel } from '@angular/forms';
import { RemoveParticipantModalComponent } from '../../components/modals/remove-participant-modal/remove-participant-modal.component';
import { EditParticipantModalComponent } from '../../components/modals/edit-participant-modal/edit-participant-modal.component';
import { ChangeEmployeeParticipationRequest } from '../../models/requests/project-requests/ChangeEmployeeParticipationRequest';
@Component({ @Component({
selector: 'participants-list', selector: 'participants-list',
...@@ -26,7 +29,8 @@ export class ParticipantsListComponent { ...@@ -26,7 +29,8 @@ export class ParticipantsListComponent {
private toastr : ToastrService, private toastr : ToastrService,
private route: ActivatedRoute, private route: ActivatedRoute,
private activeModal : NgbModal, private activeModal : NgbModal,
public router :Router public router :Router,
private modalService :NgbModal
) { ) {
...@@ -48,7 +52,7 @@ export class ParticipantsListComponent { ...@@ -48,7 +52,7 @@ export class ParticipantsListComponent {
} }
onParticipantUpdated(): void { onParticipantUpdated(): void {
this.activeModal.dismissAll();
this.loadParticipations(); this.loadParticipations();
} }
...@@ -79,6 +83,49 @@ export class ParticipantsListComponent { ...@@ -79,6 +83,49 @@ export class ParticipantsListComponent {
} }
openDeleteModal(): void {
const modalRef = this.modalService.open(RemoveParticipantModalComponent);
modalRef.componentInstance.participant = this.selectedParticipant;
modalRef.result.then((result) => {
if (result) {
// Add the new project to the list
this.isDetailMode=false ;
this.participants=this.participants.filter(w => w.employeeId == this.selectedParticipant.employeeId)
}
}, (reason) => {
});
}
openUpdateModal(): void {
const modalRef = this.modalService.open(EditParticipantModalComponent);
modalRef.componentInstance.participant = this.selectedParticipant;
modalRef.result.then((result : ChangeEmployeeParticipationRequest) => {
if (result ) {
let part= this.participants.find(w => w.employeeId == this.selectedParticipant.employeeId)
part!.partialTimeRatio=result.partialTimeRation;
part!.role=result.role;
}
}, (reason) => {
});
}
onDetailMode(participant: EmployeeParticipate) { onDetailMode(participant: EmployeeParticipate) {
this.selectedParticipant=participant ; this.selectedParticipant=participant ;
this.isDetailMode=true; this.isDetailMode=true;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<h2 class="h3 mb-0 page-title"> قائمة مراحل المشروع </h2> <h2 class="h3 mb-0 page-title"> قائمة مراحل المشروع </h2>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<button type="button" (click)="openAddModal()" class="btn btn-primary"><span class="fe fe-file-plus fe-12 mr-2"></span>إضافة مرحلة </button> <button type="button" *ngIf="canSee()" (click)="openAddModal()" class="btn btn-primary"><span class="fe fe-file-plus fe-12 mr-2"></span>إضافة مرحلة </button>
</div> </div>
</div> </div>
<hr> <hr>
...@@ -16,36 +16,22 @@ ...@@ -16,36 +16,22 @@
class=" offset-2" class=" offset-2"
*ngFor="let step of steps" *ngFor="let step of steps"
[step]="step" [step]="step"
(delete)="openModal('delete', step)" [canSee]="canSee()"
(delete)="openDelteModal(step)"
(changeWeight)="openChangeWeightModal(step)" (changeWeight)="openChangeWeightModal(step)"
(edit)="openEditModal(step)" (edit)="openEditModal(step)"
></step-row-item> ></step-row-item>
<div *ngIf="steps.length==0"> <div *ngIf="steps.length==0">
للأسف هذا المروع لايحوي على أية مراحل <p class="tect-center">
</div>
</div>
</div>
</section>
<strong>
<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> </strong>
<div class="modal-body"> </p>
<!-- Delete Confirmation --> </div>
<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>
</div> </div>
\ No newline at end of file </section>
...@@ -11,6 +11,7 @@ import { RemoveStepModalComponent } from '../../components/steps/remove-step-mod ...@@ -11,6 +11,7 @@ import { RemoveStepModalComponent } from '../../components/steps/remove-step-mod
import { EditStepModalComponent } from '../../components/step-modals/edit-step-modal/edit-step-modal.component'; import { EditStepModalComponent } from '../../components/step-modals/edit-step-modal/edit-step-modal.component';
import { EditWeightModalComponent } from '../../components/step-modals/edit-weight-modal/edit-weight-modal.component'; import { EditWeightModalComponent } from '../../components/step-modals/edit-weight-modal/edit-weight-modal.component';
import { ChangeStepInfoRequest } from '../../models/requests/step-requests/changeStepInfoRequest'; import { ChangeStepInfoRequest } from '../../models/requests/step-requests/changeStepInfoRequest';
import { Project } from '../../models/responses/project';
@Component({ @Component({
selector: 'step-list', selector: 'step-list',
templateUrl: './step-list.component.html', templateUrl: './step-list.component.html',
...@@ -18,6 +19,7 @@ import { ChangeStepInfoRequest } from '../../models/requests/step-requests/chang ...@@ -18,6 +19,7 @@ import { ChangeStepInfoRequest } from '../../models/requests/step-requests/chang
}) })
export class StepListComponent { export class StepListComponent {
steps : Step[] steps : Step[]
project : Project
modalMode: 'edit' | 'delete' = 'edit'; modalMode: 'edit' | 'delete' = 'edit';
modalTitle: string = ''; modalTitle: string = '';
selectedItem : Step; selectedItem : Step;
...@@ -28,6 +30,7 @@ export class StepListComponent { ...@@ -28,6 +30,7 @@ export class StepListComponent {
private toastr : ToastrService, private toastr : ToastrService,
private route: ActivatedRoute, private route: ActivatedRoute,
public router :Router, public router :Router,
private projectService : ProjectService,
private modalService: NgbModal private modalService: NgbModal
) { ) {
...@@ -40,9 +43,10 @@ export class StepListComponent { ...@@ -40,9 +43,10 @@ export class StepListComponent {
loadParticipations(): void{ loadParticipations(): void{
this.stepService.getStepsByProject(this.projectId).subscribe({ this.projectService.getProjectById(this.projectId).subscribe({
next: (data)=> { next: (data)=> {
this.steps= data this.steps= data.steps
this.project=data;
this.toastr.success("تم تحميل المراحل بنجاح"); this.toastr.success("تم تحميل المراحل بنجاح");
} }
, ,
...@@ -88,6 +92,7 @@ export class StepListComponent { ...@@ -88,6 +92,7 @@ export class StepListComponent {
}); });
} }
openEditModal(step : Step): void { openEditModal(step : Step): void {
const modalRef = this.modalService.open(EditStepModalComponent ,{size:'lg'}); const modalRef = this.modalService.open(EditStepModalComponent ,{size:'lg'});
...@@ -107,6 +112,26 @@ export class StepListComponent { ...@@ -107,6 +112,26 @@ export class StepListComponent {
}); });
} }
openDelteModal(step : Step): void {
const modalRef = this.modalService.open(RemoveStepModalComponent);
modalRef.componentInstance.step = step;
modalRef.result.then((result ) => {
if (result) {
// Add the new project to the list
this.delete(step.id)
}
}, (reason) => {
});
}
openModal(mode: 'edit' | 'delete', item: Step): void { openModal(mode: 'edit' | 'delete', item: Step): void {
this.modalMode = mode; this.modalMode = mode;
this.selectedItem = { ...item }; // Clone project to prevent direct mutation this.selectedItem = { ...item }; // Clone project to prevent direct mutation
...@@ -123,29 +148,11 @@ export class StepListComponent { ...@@ -123,29 +148,11 @@ export class StepListComponent {
} }
} }
delete(): void { delete(id :number ): void {
this.steps = this.steps.filter(p => p.id !== id);
this.stepService.deleteSep(this.selectedItem.id).subscribe({
next :()=>{
this.steps = this.steps.filter(p => p.id !== this.selectedItem.id);
this.toastr.success("تم الحذف بنجاح") this.toastr.success("تم الحذف بنجاح")
this.closeModal();
}
,
error:(err)=>{
this.toastr.error("لقد حدث خطاء ما ")
this.closeModal();
}
}
);
} }
...@@ -157,7 +164,7 @@ closeModal(): void { ...@@ -157,7 +164,7 @@ closeModal(): void {
} }
canSee(){ canSee(){
return this.project.currentState.toLocaleLowerCase()=='inplan'
} }
} }
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