Skip to content

Commit cc517c9

Browse files
committed
fix: #177 fix projects creation
1 parent 966a212 commit cc517c9

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/app/modules/customer-management/components/projects/components/create-project/create-project.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
></textarea>
2020
<div class="form-group">
2121
<select class="custom-select custom-select-sm mt-2" formControlName="project_type_id">
22-
<option [value]="" disabled selected>Select project type</option>
22+
<option value="" selected>Select project type</option>
2323
<option *ngFor="let type of projectsTypes" [value]="type.id">{{ type.name }}</option>
2424
</select>
2525
</div>

src/app/modules/customer-management/components/projects/components/create-project/create-project.component.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class CreateProjectComponent implements OnInit, OnDestroy {
2929
this.projectForm = this.formBuilder.group({
3030
name: ['', Validators.required],
3131
description: [''],
32-
project_type_id: [''],
32+
project_type_id: [null],
3333
});
3434
}
3535

@@ -52,13 +52,17 @@ export class CreateProjectComponent implements OnInit, OnDestroy {
5252
}
5353

5454
onSubmit(formData) {
55+
if (formData.project_type_id === '') {
56+
formData.project_type_id = null;
57+
}
5558
this.projectForm.reset();
5659
if (this.projectToEdit) {
5760
const projectData = { id: this.projectToEdit.id, ...formData };
5861
this.store.dispatch(new actions.UpdateProject(projectData));
5962
} else {
6063
this.store.dispatch(new actions.CreateProject(formData));
6164
}
65+
this.resetValuesForm();
6266
}
6367

6468
get name() {
@@ -86,4 +90,12 @@ export class CreateProjectComponent implements OnInit, OnDestroy {
8690
cancelButton() {
8791
this.store.dispatch(new actions.ResetProjectToEdit());
8892
}
93+
94+
resetValuesForm() {
95+
this.projectForm.setValue({
96+
name: '',
97+
description: '',
98+
project_type_id: null,
99+
});
100+
}
89101
}

0 commit comments

Comments
 (0)