-
Notifications
You must be signed in to change notification settings - Fork 1
fix: TT-23 Clear form when adding an entry (Time Entries) #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ import { SaveEntryEvent } from './save-entry-event'; | |
import { ProjectSelectedEvent } from './project-selected-event'; | ||
import { get } from 'lodash'; | ||
import { DATE_FORMAT } from 'src/environments/environment'; | ||
import { TechnologiesComponent } from '../technologies/technologies.component'; | ||
|
||
type Merged = TechnologyState & ProjectState & ActivityState & EntryState; | ||
@Component({ | ||
|
@@ -33,6 +34,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { | |
@Output() saveEntry = new EventEmitter<SaveEntryEvent>(); | ||
@Output() projectSelected = new EventEmitter<ProjectSelectedEvent>(); | ||
@ViewChild('closeModal') closeModal: ElementRef; | ||
@ViewChild('technologies', { static: true }) technologies: TechnologiesComponent; | ||
entryForm: FormGroup; | ||
selectedTechnologies: string[] = []; | ||
isLoading = false; | ||
|
@@ -151,11 +153,14 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { | |
} | ||
} | ||
|
||
cleanForm() { | ||
cleanForm(skipProject: boolean = false): void { | ||
this.selectedTechnologies = []; | ||
this.entryForm.setValue({ | ||
project_name: '', | ||
project_id: '', | ||
this.technologies.query = ''; | ||
const projectNameField = this.project_name.value; | ||
const projectName = get(projectNameField, 'search_field', projectNameField); | ||
this.entryForm.reset({ | ||
project_name: skipProject ? projectName : '', | ||
project_id: skipProject ? this.project_id.value : '', | ||
activity_id: '', | ||
description: '', | ||
start_date: formatDate(new Date(), DATE_FORMAT, 'en'), | ||
|
@@ -167,6 +172,10 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { | |
}); | ||
} | ||
|
||
cleanFormWithSkipProject(): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename this function to cleanFieldsForm. |
||
this.cleanForm(true); | ||
} | ||
|
||
onTechnologiesUpdated($event: string[]) { | ||
this.selectedTechnologies = $event; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,13 +64,17 @@ | |
<div class="modal-content" cdkDrag (cdkDragEnded)="resetDraggablePosition($event)"> | ||
<div class="modal-header" cdkDragHandle> | ||
<h5 class="modal-title">{{ entryId ? 'Edit Entry' : 'New Entry' }}</h5> | ||
<button type="button" class="btn" (click)="detailsFields.cleanFormWithSkipProject()"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How work with #Id detailsFields? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the |
||
<i class="fa fa-undo" aria-hidden="true"></i> | ||
</button> | ||
</div> | ||
<div class="modal-body"> | ||
<app-details-fields | ||
[entryToEdit]="entry" | ||
(saveEntry)="saveEntry($event)" | ||
(projectSelected)="projectSelected($event)" | ||
[canMarkEntryAsWIP]='canMarkEntryAsWIP' | ||
#detailsFields | ||
> | ||
</app-details-fields> | ||
</div> | ||
|
Uh oh!
There was an error while loading. Please reload this page.