Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: #177 fix projects creation
  • Loading branch information
macrisguncay committed Apr 24, 2020
commit cc517c9a65d9d698e7f92b6e02451488c7856537
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
></textarea>
<div class="form-group">
<select class="custom-select custom-select-sm mt-2" formControlName="project_type_id">
<option [value]="" disabled selected>Select project type</option>
<option value="" selected>Select project type</option>
<option *ngFor="let type of projectsTypes" [value]="type.id">{{ type.name }}</option>
</select>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class CreateProjectComponent implements OnInit, OnDestroy {
this.projectForm = this.formBuilder.group({
name: ['', Validators.required],
description: [''],
project_type_id: [''],
project_type_id: [null],
});
}

Expand All @@ -52,13 +52,17 @@ export class CreateProjectComponent implements OnInit, OnDestroy {
}

onSubmit(formData) {
if (formData.project_type_id === '') {
formData.project_type_id = null;
}
this.projectForm.reset();
if (this.projectToEdit) {
const projectData = { id: this.projectToEdit.id, ...formData };
this.store.dispatch(new actions.UpdateProject(projectData));
} else {
this.store.dispatch(new actions.CreateProject(formData));
}
this.resetValuesForm();
}

get name() {
Expand Down Expand Up @@ -86,4 +90,12 @@ export class CreateProjectComponent implements OnInit, OnDestroy {
cancelButton() {
this.store.dispatch(new actions.ResetProjectToEdit());
}

resetValuesForm() {
this.projectForm.setValue({
name: '',
description: '',
project_type_id: null,
});
}
}