Skip to content

Commit

Permalink
prevent multiple clicks on submit button
Browse files Browse the repository at this point in the history
  • Loading branch information
horatiorosa committed Jan 8, 2025
1 parent 33bc5aa commit 20c57fa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion client/app/components/projects/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@
</saveableProjectsNewForm.PageNav>
<Messages::Assistance class="large-margin-top" />
<saveableProjectsNewForm.ConfirmationModal @action={{component saveableProjectsNewForm.SubmitButton onClick=this.submitProject class="no-margin" }}
disabled={{or (not saveableProjectsNewForm.isSubmittable) this.submissionError}}
disabled={{or (not saveableProjectsNewForm.isSubmittable) this.submissionError this.isSubmitting}}
@continueButtonTitle="Continue Editing" data-test-confirm-submit-button={{true}}>
<h6>Confirm New Project Submission</h6>
{{#if this.submissionError}}
<div class="grid-x medium-padding-top medium-padding-bottom">
<p class="header-large medium-marin-top small-margin-bottom">Error while creating project. Lorem Ipsum.....</p>
</div>
{{else}}
<p class="header-large medium-margin-top small-margin-bottom">
Are you sure?
Expand Down
10 changes: 9 additions & 1 deletion client/app/components/projects/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export default class ProjectsNewFormComponent extends Component {
SubmittableProjectsNewForm,
};

@tracked submissionError = false;
@tracked
submissionError = false;

@tracked
isSubmitting = false;

requestCounter = 0;

Expand All @@ -33,6 +37,8 @@ export default class ProjectsNewFormComponent extends Component {
@action
async submitProject() {
this.submissionError = false;
if (this.isSubmitting) return;
this.isSubmitting = true;
const requestStartTime = Date.now();
this.requestCounter++;
console.log(`LOGGER: [Total Requests Made in the client controller] ${this.requestCounter}`);
Expand Down Expand Up @@ -141,6 +147,8 @@ export default class ProjectsNewFormComponent extends Component {
this.submissionError = true;
/* eslint-disable-next-line no-console */
console.error('Error while creating project');
} finally {
this.isSubmitting = false;
}
}
}
1 change: 0 additions & 1 deletion server/src/projects/projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export class ProjectsService {
try {
const requestStartTime = Date.now();


const data = {
dcp_projectname: attributes.dcp_projectname,
dcp_borough: attributes.dcp_borough,
Expand Down

0 comments on commit 20c57fa

Please sign in to comment.