Commit 7fc8a255 authored by Simone Vuotto's avatar Simone Vuotto

Add possibility to delete requirements

parent d27d12c4
......@@ -27,6 +27,7 @@
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/popper.js/dist/umd/popper.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js"
]
},
......@@ -139,4 +140,4 @@
"prefix": "app"
}
}
}
\ No newline at end of file
}
......@@ -13,7 +13,7 @@
<a class="nav-link active show" data-toggle="tab" href="#requirements">Requirements</a>
</li>
<li class="nav-item">
<a class="nav-link active show" data-toggle="tab" href="#tasks">Tasks</a>
<a class="nav-link" data-toggle="tab" href="#tasks">Tasks</a>
</li>
</ul>
......
......@@ -10,19 +10,27 @@
<div class="hidden"><input type="file" #fileInput (change)="fileChange($event)"/></div>
<div class="btn-group" role="group" aria-label="Basic example">
<button type="button" class="btn btn-secondary" (click)="disableSelected(false)"><i class="fa fa-check"></i>&nbsp;Enable</button>
<button type="button" class="btn btn-secondary" (click)="disableSelected(true)"><i class="fa fa-minus"></i>&nbsp;Disable</button>
<button type="button" class="btn btn-secondary" (click)="deleteSelected()"><i class="fa fa-trash"></i>&nbsp;Delete</button>
<button type="button" class="btn btn-secondary" (click)="disableSelected(false)"
[disabled]="selected.length == 0">
<i class="fa fa-check"></i>&nbsp;Enable
</button>
<button type="button" class="btn btn-secondary" (click)="disableSelected(true)"
[disabled]="selected.length == 0">
<i class="fa fa-minus"></i>&nbsp;Disable
</button>
<button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#deleteConfirmationModal"
[disabled]="selected.length == 0">
<i class="fa fa-trash"></i>&nbsp;Delete
</button>
</div>
<button type="button" class="btn btn-outline-primary" (click)="fileInput.click()"
[disabled]="uploadLoading">
<i class="fa fa-plus" aria-hidden="true" *ngIf="!uploadLoading"></i>
<i class='fa fa-spinner fa-spin' *ngIf="uploadLoading"></i>
&nbsp;Add Requirement
</button>
<a routerLink="/projects/{{projectId}}/addReq">
<button type="button" class="btn btn-outline-primary" [disabled]="uploadLoading">
<i class="fa fa-plus" aria-hidden="true"></i>
&nbsp;Add Requirement
</button>
</a>
<button type="button" class="btn btn-outline-primary" (click)="fileInput.click()"
[disabled]="uploadLoading">
......@@ -71,3 +79,24 @@
</ngx-datatable>
<app-requirement-details [req]="selectedRequirement" (update)="onChange($event)"></app-requirement-details>
<!-- Delete Confirmation Modal -->
<div class="modal fade" id="deleteConfirmationModal" tabindex="-1" role="dialog" aria-labelledby="deleteConfirmationModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Delete Confirmation</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Are you sure you want to delete {{ selected.length }} requirements?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal" (click)="deleteSelected()">Delete</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
......@@ -22,7 +22,7 @@ export class RequirementsTabComponent implements OnInit {
searchValue = '';
rows = [];
selected = [];
selected: Requirement[] = [];
@ViewChild(DatatableComponent) table: DatatableComponent;
......@@ -105,7 +105,26 @@ export class RequirementsTabComponent implements OnInit {
}
deleteSelected() {
this.uploadLoading = true;
const reqs = this.selected;
let loaded = 0;
reqs.forEach(req => {
this.requirementService.deleteRequirement(req.id).subscribe(
response => {
const index = this.requirements.findIndex(r => r.id === req.id);
if (index >= 0) {
this.requirements.splice(index, 1);
}
loaded++;
if (loaded === reqs.length) {
this.uploadLoading = false;
this.updateFilter(null);
}
},
error => {
this.alertService.error(error);
});
});
}
updateFilter(event) {
......
......@@ -24,6 +24,10 @@ export class RequirementService {
return this.http.put<Requirement>(this.requirementsUrl, req);
}
deleteRequirement(id: number): Observable<HttpResponse<any>> {
return this.http.delete(this.requirementsUrl + '/' + id, {observe: 'response'});
}
uploadFile(file: File, projectId: number): Observable<Requirement[]> {
const formData = new FormData();
formData.append('file', file, file.name);
......
......@@ -27,6 +27,10 @@ export class TaskService {
return this.http.get<Task>(this.tasksUrl(projectId, 'consistencyCheck'));
}
public performComputeMuc(projectId: number): Observable<Task> {
return this.http.get<Task>(this.tasksUrl(projectId, 'computeMUC'));
}
private tasksUrl(projectId: number, taskName = '') {
const url = 'api/projects/{pid}/tasks/' + taskName;
return url.replace('{pid}', projectId.toString());
......
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