Skip to content
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

fix: button disabled while running request #666

Merged
merged 2 commits into from
Sep 1, 2022
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
11 changes: 10 additions & 1 deletion src/app/data/data.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,20 @@
{{ area['AREA'] }}
</option>
</select>

<!--
Here we disable the button in 2 cases:

1. Value from the dropdown is not selected
2. Request is sent, and button disabled until it is finished

To only disable button when request is running:
[disabled]="springsLoading"
-->
<button
(click)="submitData()"
class="btn btn-primary"
[disabled]="!selectedArea"
[disabled]="!selectedArea || springsLoading"
allanbowe marked this conversation as resolved.
Show resolved Hide resolved
>
SUBMIT
</button>
Expand Down
4 changes: 2 additions & 2 deletions src/app/data/data.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ export class DataComponent implements OnInit {
}

public submitData() {
this.springsLoading = true
this.springsLoading = true //Request started we set variable to `true`
let data = { areas: [{ area: this.selectedArea }] }

this.sasService.request('common/getdata', data).then((res: any) => {
this.springs = res['springs']
this.springsLoading = false
this.springsLoading = false // Request is finished, success or fail anyway we set variable to false

if (!res || !res['springs'] || res['spring']?.length < 1) {
this.noData = true
Expand Down