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: TTL-985 add debouncing to clock in buttons
  • Loading branch information
mmaquina committed Sep 19, 2023
commit c8d3d686126042e48c46838750a1f39ae78ebae4
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
</fieldset>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Save</button>
<button type="submit" id=submitButton class="btn btn-primary">Save</button>
<button #closeModal type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,14 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
}

onSubmit() {

// Debounce submit (Save) button
const button = document.querySelector('#submitButton');
button.setAttribute('disabled', 'true');
setTimeout(() => {
button.removeAttribute('disabled');
}, 3000);

const emptyValue = '';
const { project_name, uri, description } = this.entryForm.value;
const areEmptyValues = [uri, description].every(item => item === emptyValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,26 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
}

clockIn(selectedProject, customerName, name) {

// Debounce 'Clock In' buttons
const buttons = document.getElementsByClassName('btn btn-sm btn-primary btn-select');
for (const button of buttons) {
button.setAttribute('disabled', 'true');
}
setTimeout(() => {
for (const button of buttons) {
button.removeAttribute('disabled');
}
}, 3000);

const entry = {
project_id: selectedProject,
start_date: new Date().toISOString(),
timezone_offset: new Date().getTimezoneOffset(),
technologies: [],
activity_id: head(this.activities).id,
};

this.store.dispatch(new entryActions.ClockIn(entry));
this.projectsForm.setValue({ project_id: `${customerName} - ${name}` });
setTimeout(() => {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
],
"lib": [
"es2018",
"dom"
"dom",
"dom.Iterable"
]
},
"angularCompilerOptions": {
Expand Down