Commit cef92378 authored by Simone Vuotto's avatar Simone Vuotto

Update project view

parent e2391727
......@@ -10,15 +10,15 @@
<i class='fa fa-spinner fa-spin' *ngIf="uploadLoading"></i>
&nbsp;Upload File
</button>
<button type="button" class="btn btn-primary pull-right btn-top">
<i class="fa fa-play" aria-hidden="true"></i>
&nbsp;Validate
</button>
<button type="button" class="btn btn-primary pull-right btn-top" [disabled]="translateLoading" (click)="getTranslation()">
<i class="fa fa-download" aria-hidden="true" *ngIf="!translateLoading"></i>
<i class='fa fa-spinner fa-spin' *ngIf="translateLoading"></i>
&nbsp;Translate
</button>
<button type="button" class="btn btn-primary pull-right btn-top" [disabled]="true">
<i class="fa fa-play" aria-hidden="true"></i>
&nbsp;Validate
</button>
</div>
</div>
......
......@@ -53,7 +53,7 @@ export class ProjectDetailsComponent implements OnInit {
this.requirementService.uploadFile(fileList[0], this.projectId).subscribe(
data => {
this.uploadLoading = false;
this.requirements = this.requirements.concat(data);
this.requirements = this.requirements.concat(data.map(req => new Requirement().clone(req)));
this.alertService.success('File uploaded correctly!');
},
error => {
......
......@@ -39,8 +39,10 @@
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary" data-dismiss="modal" [disabled]="!newProjectForm.valid" (click)="createProject()">Save</button>
<button type="reset" class="btn btn-secondary" data-dismiss="modal" (click)="reset()">Close</button>
<button type="submit" class="btn btn-primary" [disabled]="!newProjectForm.valid || loading" (click)="createProject()">
<i class="fa fa-spinner fa-spin" aria-hidden="true" *ngIf="loading">&nbsp;</i>Save
</button>
<button type="reset" class="btn btn-secondary" data-dismiss="modal" (click)="reset()" #closeBtn>Close</button>
</div>
</form>
</div>
......
import { Component, OnInit } from '@angular/core';
import { Component, ElementRef, EventEmitter, OnInit, Output, ViewChild } from '@angular/core';
import { Project, ProjectType } from '../models/project';
import { ProjectService } from '../services/project.service';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { AlertService } from '../alert/alert.service';
import { Requirement } from '../models/requirement';
@Component({
selector: 'app-project-dialog',
......@@ -16,6 +17,12 @@ export class ProjectDialogComponent implements OnInit {
project = new Project(null, '', '', null);
@Output() projectCreated = new EventEmitter<Project>();
@ViewChild('closeBtn') closeBtn: ElementRef;
loading = false;
constructor( private fb: FormBuilder,
private projectService: ProjectService,
private alertService: AlertService) {
......@@ -55,6 +62,7 @@ export class ProjectDialogComponent implements OnInit {
}
createProject() {
this.loading = true;
const formModel = this.newProjectForm.value;
this.project.name = formModel.name as string;
......@@ -65,12 +73,16 @@ export class ProjectDialogComponent implements OnInit {
response => {
if (response.status === 200) {
this.alertService.success('New Project created successfully');
this.projectCreated.emit(response.body);
} else {
this.alertService.error('Error creating the new project');
}
this.closeBtn.nativeElement.click();
this.loading = false;
},
error => {
this.alertService.error('Error creating the new project');
this.loading = false;
}
);
}
......
......@@ -29,7 +29,7 @@
</div>
<app-project-dialog></app-project-dialog>
<app-project-dialog (projectCreated)="addProject($event)"></app-project-dialog>
......@@ -26,4 +26,8 @@ export class ProjectsComponent implements OnInit {
});
}
addProject(project: Project) {
this.projects.push(project);
}
}
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