Skip to content

Commit 14bdb1b

Browse files
authored
fix: TTL-985 add debouncing to clock in buttons (#1006)
1 parent 984815b commit 14bdb1b

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

src/app/modules/shared/components/details-fields/details-fields.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
</fieldset>
152152
</div>
153153
<div class="modal-footer">
154-
<button type="submit" class="btn btn-primary">Save</button>
154+
<button type="submit" id=submitButton class="btn btn-primary">Save</button>
155155
<button #closeModal type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
156156
</div>
157157
</form>

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,14 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
333333
}
334334

335335
onSubmit() {
336+
337+
// Debounce submit (Save) button
338+
const button = document.querySelector('#submitButton');
339+
button.setAttribute('disabled', 'true');
340+
setTimeout(() => {
341+
button.removeAttribute('disabled');
342+
}, 3000);
343+
336344
const emptyValue = '';
337345
const { project_name, uri, description } = this.entryForm.value;
338346
const areEmptyValues = [uri, description].every(item => item === emptyValue);

src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,26 @@ export class ProjectListHoverComponent implements OnInit, OnDestroy {
106106
}
107107

108108
clockIn(selectedProject, customerName, name) {
109+
110+
// Debounce 'Clock In' buttons
111+
const buttons = document.getElementsByClassName('btn btn-sm btn-primary btn-select');
112+
for (const button of buttons) {
113+
button.setAttribute('disabled', 'true');
114+
}
115+
setTimeout(() => {
116+
for (const button of buttons) {
117+
button.removeAttribute('disabled');
118+
}
119+
}, 3000);
120+
109121
const entry = {
110122
project_id: selectedProject,
111123
start_date: new Date().toISOString(),
112124
timezone_offset: new Date().getTimezoneOffset(),
113125
technologies: [],
114126
activity_id: head(this.activities).id,
115127
};
128+
116129
this.store.dispatch(new entryActions.ClockIn(entry));
117130
this.projectsForm.setValue({ project_id: `${customerName} - ${name}` });
118131
setTimeout(() => {

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"lib": [
1919
"es2018",
20-
"dom"
20+
"dom",
21+
"dom.Iterable"
2122
]
2223
},
2324
"angularCompilerOptions": {

0 commit comments

Comments
 (0)